Quantcast
Channel: OpenCV Q&A Forum - Latest question feed
Viewing all articles
Browse latest Browse all 19555

How to read pixel every frame?

$
0
0
**Hello!** I using *Opencv 2.3.1* and *cimg*! I need to read every frame with IP camera and record it into the BMP file. I have the following code: Mat frame; VideoCapture cam("rtsp://admin:admin@192.168.2.228/defaultPrimary?streamType=u"); while(true) { if (!cam.read(frame)) continue; count++; cimg_library::CImg* m_frameData = new cimg_library::CImg(1920, 1080, 1 , 3); if (frame.data) { cvtColor(frame, frameRGB, CV_BGR2RGB); uchar* pixelsRGB = frameRGB.data; for (unsigned int x = 0; x < frame.rows; x++) { for (unsigned int y = 0; y < frame.cols; y++) { m_frameData->atXYZC(x,y,0,0) = (int) pixelsRGB[ y + x]; m_frameData->atXYZC(x,y,0,1) = (int)pixelsRGB [ y + x + 1]; m_frameData->atXYZC(x,y,0,2) = (int) pixelsRGB[ y + x + 2]; } } std::string fileWrite = "C:\\Temp\\out" +count+ ".bmp"; m_frameData->save_bmp(fileWrite.c_str()); delete m_frameData; } **When I open the BMP file I get**: ![image description](/upfiles/14355640437995542.bmp) **But it should be this:** ![image description](/upfiles/1435564331679486.bmp) Please help me! Thanks.

Viewing all articles
Browse latest Browse all 19555

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>