Ask Your Question
1

file loaded from std::ifstream to opencv image

asked 2015-03-30 22:37:29 -0500

deshan gravatar image

updated 2020-11-30 03:09:54 -0500

Hi all,

I have a image file as a byte buffer loaded using a Input stream as below.

std::ifstream is("image.jpg", std::ifstream::binary);
char * buffer; // image.jpg store in this buffer

Now has some difficulties for me to convert this one into a opencv image. Unfortunately I cannot use cvLoadImage function. I tried below but failed.

 cv::Mat mat= cv::Mat(imageHeight, imageWidth, CV_8UC3, buffer);

Getting an error when I want to display it.

cv::imshow("Img", mat);

Please help. Thanks

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
3

answered 2015-03-31 01:58:30 -0500

berak gravatar image

you will have to decode that buffer first , to get a cv::Mat.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-03-30 22:37:29 -0500

Seen: 1,321 times

Last updated: Mar 30 '15