为opencv设置相机框架大小没有响应

时间:2017-06-23 13:00:37

标签: c++ xcode opencv

我使用以下代码在我的Mac中打开网络摄像头。

#define CAMERA_OUTPUT_WINDOW_NAME "camera"

int main(int argc, char **argv)
{
    CvCapture *camCapture;
    int ret = 0;

    if (!(camCapture = cvCaptureFromCAM(CV_CAP_ANY))) {
        cout << "Failed to capture from camera" << endl;

        ret = 1;

        goto exitCameraOpenFailed;
    }

    cout << "Camera opened successfully" << endl;

    cvNamedWindow(CAMERA_OUTPUT_WINDOW_NAME, CV_WINDOW_AUTOSIZE);

    IplImage *cameraFrame;
    cvSetCaptureProperty( camCapture, CV_CAP_PROP_FRAME_WIDTH, 640 );

    cvSetCaptureProperty( camCapture, CV_CAP_PROP_FRAME_HEIGHT, 480 );

    while (true) {
        if ((cameraFrame = cvQueryFrame(camCapture))) {
            cvShowImage(CAMERA_OUTPUT_WINDOW_NAME, cameraFrame);
        }

        if (cvWaitKey(60) != -1) {
            cout << "Input" << endl;
            break;
        }
    }

    cout << "Done" << endl;

    cvReleaseCapture(&camCapture);
    cvDestroyWindow(CAMERA_OUTPUT_WINDOW_NAME);
exitCameraOpenFailed:
    return ret;
}

但输出窗口帧分辨率太小。虽然我已将其大小设置为640x480,但只有输出框的工具栏可见而不是实际框架。 我怎样才能解决这个问题?

我尝试将window_cocoa.mm文件转换为

@implementation CVView
@synthesize image = _image;

但它对最终结果没有影响

0 个答案:

没有答案