Download OpenCV image (JavaCV) from byte [] not file

I have image data coming in through a socket connection as a byte []. All the examples I saw using cvLoadImage() pass the file name. Should I save each image to a file and reopen it for processing? This seems to have a lot of overhead for what should happen, is it possible to load an image from bytes [] of data?

+4
source share
2 answers

A simple solution at the end, you can use the following method to create an image from BufferedImage, which solved my problem:

 IplImage src = IplImage.createFrom(buffered); 
+1
source

Assuming the data is encoded in some standard format such as JPG or PNG, and if you use JavaCV for byte array b, this also works:

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

+2
source

Source: https://habr.com/ru/post/1396074/


All Articles