简体   繁体   中英

Load Image OpenCV (JavaCV) from byte[] not a file

I have image data coming in from over a socket connection as a byte[]. All examples I have seen using cvLoadImage() is passed a file name. Do I have to save every image to file and re-open it to do the processing? This seems to have a lot of overhead for what needs to happen, is it possible to load the image from the byte[] data?

假设数据以某种标准格式(如JPG或PNG)进行编码,并假设您使用的是JavaCV,对于字节数组b,这也适用:

IplImage image = cvDecodeImage(cvMat(1, b.length, CV_8UC1, new BytePointer(b)));

最后简单的解决方案,您可以使用以下方法从BufferedImage创建一个Image来解决我的问题:

IplImage src = IplImage.createFrom(buffered);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM