Skip to content

Commit

Permalink
Update OpenCVHelp.java
Browse files Browse the repository at this point in the history
  • Loading branch information
mcm001 committed Jan 1, 2024
1 parent 6d31b1d commit 53514a2
Showing 1 changed file with 0 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -572,25 +572,4 @@ public static PNPResult solvePNP_SQPNP(
return new PNPResult();
}
}

/**
* Convert a image to a BufferedImage
*
* @param input input Mat as bgr/8uc3
* @return The same data but as a BufferedImage
*/
public static Optional<BufferedImage> matToImage(Mat bgr) {
MatOfByte outputBuffer = new MatOfByte();
Imgcodecs.imencode(".jpg", bgr, outputBuffer);
byte ba[] = outputBuffer.toArray();

BufferedImage bi;
try {
bi = ImageIO.read(new ByteArrayInputStream(ba));
return Optional.of(bi);
} catch (IOException e) {
e.printStackTrace();
return Optional.empty();
}
}
}

0 comments on commit 53514a2

Please sign in to comment.