本文整理匯總了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()));
}