本文整理汇总了Java中org.opencv.core.MatOfByte.toArray方法的典型用法代码示例。如果您正苦于以下问题:Java MatOfByte.toArray方法的具体用法?Java MatOfByte.toArray怎么用?Java MatOfByte.toArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opencv.core.MatOfByte
的用法示例。
在下文中一共展示了MatOfByte.toArray方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showResult
import org.opencv.core.MatOfByte; //导入方法依赖的package包/类
public void showResult(Mat img) {
Imgproc.resize(img, img, new Size(640, 480));
MatOfByte matOfByte = new MatOfByte();
Imgcodecs.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.getContentPane().add(new JLabel(new ImageIcon(bufImage)));
frame.pack();
frame.setVisible(true);
} catch (IOException | HeadlessException e) {
e.printStackTrace();
}
}
示例2: mat2Image
import org.opencv.core.MatOfByte; //导入方法依赖的package包/类
/**
* Convert a Mat object (OpenCV) in the corresponding Image for JavaFX
*
* @param frame
* the {@link Mat} representing the current frame
* @return the {@link Image} to show
*/
private Image mat2Image(Mat frame)
{
// create a temporary buffer
MatOfByte buffer = new MatOfByte();
// encode the frame in the buffer, according to the PNG format
Imgcodecs.imencode(".png", frame, buffer);
// build and return an Image created from the image encoded in the
// buffer
return new Image(new ByteArrayInputStream(buffer.toArray()));
}
示例3: cvMat2FxImage
import org.opencv.core.MatOfByte; //导入方法依赖的package包/类
public static Image cvMat2FxImage(Mat mat){
MatOfByte buffer = new MatOfByte();
Imgcodecs.imencode(".png", mat, buffer);
return new Image(new ByteArrayInputStream(buffer.toArray()));
}