Loading image from memory

810 views
Skip to first unread message

Øyvind

unread,
Mar 2, 2011, 10:03:26 AM3/2/11
to javacv
Hi

I have a .jpg contained in a byte-array (byte[] b) and want to
represent it as a IplImage, but I can't find any examples on how to do
it. Is it possible? The images are received over the wire, and I'm
currently storing them on disk before loading them into memory again
with cvLoadImage(). Expensive as that is, I'm looking for a better
way.

Sorry if this question has been answered before - but if it has, can
you please point me in the right direction?

Thanks.

/Øyvind

Samuel Audet

unread,
Mar 2, 2011, 10:19:59 PM3/2/11
to jav...@googlegroups.com
Hello,

I did not test it, but cvDecodeImage() should work. Something like:

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

Samuel

Øyvind

unread,
Mar 3, 2011, 10:25:02 AM3/3/11
to javacv
Excellent. It works as expected. Thank you!

/Øyvind
Reply all
Reply to author
Forward
0 new messages