Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Equivalent method for imshow in opencv Java build

Tags:

java

opencv

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?

like image 542
Orochi Avatar asked May 11 '13 07:05

Orochi


2 Answers

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();     } } 
like image 178
Mar Avatar answered Sep 19 '22 15:09

Mar


There is no Java highgui wrapper yet (link). You should use swing or swt to show image. See: Opencv java - Load image to GUI

like image 45
ArtemStorozhuk Avatar answered Sep 20 '22 15:09

ArtemStorozhuk