Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Change videoCapture format to MJPEG

Hi there,

I would like to get frames from my camera in the MJPEG format. I know for sure that my camera is able to use the MJPEG but when I try:

webcam.set(CV_CAP_PROP_FOURCC, CV_FOURCC('M', 'J', 'P', 'G'));

I get:

HIGHGUI ERROR: V4L: Property <unknown property="" string="">(6) not supported by device

Can you help?

Thanks!

Here is my code:

#include "opencv2/opencv.hpp"
#include <iostream>
#include <sstream>

using namespace std;
using namespace cv;

int main() {
    VideoCapture webcam;
    webcam.open(0);
    webcam.set(CV_CAP_PROP_FOURCC, CV_FOURCC('M', 'J', 'P', 'G'));
    webcam.set(CV_CAP_PROP_FRAME_WIDTH, 1920);
    webcam.set(CV_CAP_PROP_FRAME_HEIGHT, 1080);

    Mat frame;
    webcam >> frame;         //get a new frame from camera
    imwrite("image.jpg", frame);
    return 0;
}