cvQueryFrame returns rotated image

asked 2016-12-01 18:36:57 -0500

coredump gravatar image

I am using a MacBook Pro OS X version 10.12.1 with an external USB Web Camera. If I look at an image in photo booth with the external web camera the image is correct. However when I capture frames from the same web cam and display it, the image shows up rotated 90 degrees clockwise. What am I doing wrong ?

Here is the code :

CvCapture *capture = 0;
capture = cvCaptureFromCAM(1); // 1 = web cam , -1 = autodetect , 0 = default
if (!capture)
{
    fprintf(stderr, "!!! Cannot open initialize webcam!\n" );
    return;
}

// Create a window for the video
cvNamedWindow("Frame Captured", CV_WINDOW_AUTOSIZE);

IplImage* frame = 0;
char key = 0;
while (key != 27) // ESC
{
    frame = cvQueryFrame(capture);
    if(!frame)
    {
        fprintf( stderr, "!!! cvQueryFrame failed!\n" );
        break;
    }

    // Display frame
    cvShowImage("Frame Captured", frame);

    // Exit when user press ESC
    key = cvWaitKey(10);
}

// Free memory
cvDestroyWindow("result");
cvReleaseCapture(&capture);

}

edit retag flag offensive close merge delete

Comments

can you try to get rid of that outdated c-api code first ?

berak gravatar imageberak ( 2016-12-01 22:20:02 -0500 )edit

Still has the same problem

Mat frame, gray;
VideoCapture video(1); // 1 = web cam , -1 = autodetect , 0 = default

if(video.isOpened())
{
    int key = 0;
    do
    {
        video >> frame;
        if(frame.empty())
        {
            break;
        }

        imshow("Frame Captured", frame);

        cvtColor(frame, gray, CV_BGR2GRAY);

        (*pattern_cb)(gray);

        key = waitKey(10);
    } while((char)key != 27); // press ESC to exit
}
coredump gravatar imagecoredump ( 2016-12-02 17:32:15 -0500 )edit