[英]Load Image OpenCV (JavaCV) from byte[] not a file
I have image data coming in from over a socket connection as a byte[]. 我有图像数据从套接字连接作为byte []进入。 All examples I have seen using cvLoadImage()
is passed a file name. 我见过的所有使用cvLoadImage()
例子都是传递一个文件名。 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? 对于需要发生的事情,这似乎有很多开销,是否可以从byte []数据加载图像?
假设数据以某种标准格式(如JPG或PNG)进行编码,并假设您使用的是JavaCV,对于字节数组b,这也适用:
IplImage image = cvDecodeImage(cvMat(1, b.length, CV_8UC1, new BytePointer(b)));
最后简单的解决方案,您可以使用以下方法从BufferedImage创建一个Image来解决我的问题:
IplImage src = IplImage.createFrom(buffered);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.