how to load a matrix of channel Y or list of matrices?

asked 2015-05-30 05:12:07 -0600

Hi, yhea, I am a newbie moving first steps in OpenCV. I have an app that captures photographs from a camera and save them in a file with the following format 1 byte for the photograph sequence 1024*768 bytes for channel Y (of course 1 byte e per pixel)

up to 256 photos per file

I was wondering if: 1) easy way, can I load it as it is and navigate the frames? 2) I can split the file in single file per frame but then, can I load the stream of bytes and use it as an image without converting it to a fomat jpg or bmp or whatever?

My biggest concern is not much the file format but the fact I need to load the single image without passing to a "real" image format.

Do you think I have to write my on interface to load such data or OpenCV has already something that I can use?

Thx gys!

edit retag flag offensive close merge delete

Comments

once you got the pixels (of a single,grayscale frame) in memory, you can easily construct a cv::Mat from that:

unsigned char *pixels = ...
Mat img(h, w, CV_8U, pixels);
berak gravatar imageberak ( 2015-05-30 06:40:45 -0600 )edit

berak, thanks a lot!

nicolad gravatar imagenicolad ( 2015-05-30 11:47:20 -0600 )edit