c ++ y openCV con windows8: la clase VideoWriter no se abre

I am trying to record a video using openCV's class VideoWriter.

Usando la siguiente función,

void addFrameToVideo(Mat& frame)
{
    if(_vid.open("test.avi", CV_FOURCC('M','J','P','G'), 30, frame.size(), 1))
        cout << "here" << endl;

    _vid.write(frame);
}

_vid is a variable of type VideoWriter and I can imshow frame with no problems.

The if condition never verifies, since the program never outputs "here". However, this code actually creates a "test.avi" file in the directory, but it remains empty. I've tried several different compression methods with no success.

¿Alguna idea?

preguntado el 13 de septiembre de 13 a las 10:09

1 Respuestas

It is possible that the codec could not be found in your system. You should try using different codecs. Alternatively, you can pass the value -1 instead of CV_FOURCC() and a window will pop up at runtime that contains all the codec installed on your system and ask you to select the one to use (this only works on Windows).

Respondido el 30 de Septiembre de 13 a las 17:09

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.