**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**:

**But it should be this:** 
Please help me! Thanks.
↧