Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

png Saving with a video camera

Hi,

I'm currently working on a video acquisition project in which I have to save frames from a video camera. My software works when I save frames in bmp format but so as to use less space on the hard drive I would like to save them in png format. But when I change the format my application doesn't work anymore (xxx.exe encountered a problem and needs to close). Then I reduced the code to its minimum to save only one image from the video camera (see code below) and I don't understand why it works perfectly in bmp and bugs in png :

#include "stdafx.h"
#include "cv.h"
#include "highgui.h"

using namespace std;
using namespace cv;

int main()
{
    VideoCapture cap(0);
    if(!cap.isOpened())
        return -1;

    Mat frame;
    cap >> frame;
    // Mat frameC;
    // frame.convertTo(frameC,CV_16UC3);
    imwrite("C:\\Frames\\frame.png",frame);

    return 0;
}

It also doesn't work in jpg format. I'm working with Visual Studio 2005 on Windows XP and OpenCV2.1. I tried to convert the image before saving it, but no change (comments in the code) And if I just open and save a png image (without using the video camera) then it works.

Debugging indicates that the problem is in malloc.c (l. 163) :

res = _heap_alloc(size);

And the error is "Unhandled exception at 0x70100fcd in TestOpenCV.exe: 0xC0000005: Access violation reading location 0x00000000" I don't know what is "size" in this function but its type is size_t and its value 32. Then the program stops with the code -1073741819.

I've no idea how to fix this problem or even if it's possible. Maybe the problem comes from the camera or the acquisition card (Intensity Pro from BlackMagicDesign). Any ideas?

Your help or advices are welcome, I'm really stuck with this issue.

Thanks a lot.

Lucas