sorry if I am asking a silly question, I am trying to learn openCV using Java build. In opencv samples i found there is method imshow in c++ or showImage in python, but i search in opencv Java API, i cannot found imshow method.
What is the equal method of imshow() and waitKey() in opencv with Java build?
public static void showResult(Mat img) { Imgproc.resize(img, img, new Size(640, 480)); MatOfByte matOfByte = new MatOfByte(); Highgui.imencode(".jpg", img, matOfByte); byte[] byteArray = matOfByte.toArray(); BufferedImage bufImage = null; try { InputStream in = new ByteArrayInputStream(byteArray); bufImage = ImageIO.read(in); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(DISPOSE_ON_CLOSE); frame.getContentPane().add(new JLabel(new ImageIcon(bufImage))); frame.pack(); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } }
There is no Java highgui wrapper yet (link). You should use swing or swt to show image. See: Opencv java - Load image to GUI
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With