opencv 2.4.8 microsoft surface pro 2 camera

asked 2014-02-24 06:17:13 -0500

makys gravatar image

updated 2014-02-24 06:18:23 -0500

berak gravatar image

I built opencv 2.4.8 x86 using visual studio express 2012, with media foundation support, and then wrote a simple program to test camera, all things done on Microsoft surface pro 2.

Problem 1, image shown in window is upside down

problem 2, setting image width and height not work

code is pasted here, and thank you for help!

#include <iostream>
#include <opencv2\opencv.hpp>

bool quitNow=false;

void mouseCallBackFunc(int event, int x, int y, int flags, void* userdata){
    if (event==CV_EVENT_LBUTTONDBLCLK) quitNow=true;
}

int main()
{
    int key;
    std::string winName="show cam";
    cv::namedWindow(winName,1);
    cv::setMouseCallback(winName,mouseCallBackFunc);
    cv::Mat img;
cv::VideoCapture vc(1);
if (vc.isOpened()){
    std::cout<<"cam open good\n";
}else{
    std::cout<<"cam open bad\n";
    vc.release();
    return 2;
}
if (!vc.set(CV_CAP_PROP_FRAME_HEIGHT,720)) return 3;
if (!vc.set(CV_CAP_PROP_FRAME_HEIGHT,1280)) return 4;

vc>>img;
std::cout<<std::endl<<"size is "<<img.size()<<std::endl;

do
{
    vc>>img;
    if(img.empty()) return 9;
    cv::imshow(winName,img);
    key=cv::waitKey(10) & 0xff;
} while (!quitNow);
return 0;
}
edit retag flag offensive close merge delete