Web cam and prosilica camera did not work.

asked 2014-02-07 10:36:56 -0500

updated 2014-02-07 10:52:40 -0500

Hello, I installed vimbaviewer on windows 7. Then, I installed opencv 2.4.8. I build it using cmake with With_PVAPI and WITH_QT. I am using QT 5.2.0 with mingw32. At this stade the webcam is running correctly but the prosilica camera did not work.

After that I found the link link. So I nstalled the SDK AVT for windows and I rebuild it with With_PVAPI and WITH_QT. At this phase, the webcam did not work and also the prosilica camera always did not work. SEE my code to get video:

#include "opencv2/highgui/highgui.hpp"
#include <iostream>
using namespace cv;
using namespace std;
int main()
{
    cout<<"Start"<<endl;
    VideoCapture cap(0); // open the video camera no. 0
    //VideoCapture cap(CV_CAP_PVAPI); // open the video camera prosilica
     cout<<"end"<<endl;

    if (!cap.isOpened())  // if not success, exit program
    {
cout << "Cannot open the video cam" << endl;
        return -1;
    }

   double dWidth = cap.get(CV_CAP_PROP_FRAME_WIDTH); //get the width of frames of the video
   double dHeight = cap.get(CV_CAP_PROP_FRAME_HEIGHT); //get the height of frames of the video

    cout << "Frame size : " << dWidth << " x " << dHeight << endl;

    namedWindow("MyVideo",CV_WINDOW_AUTOSIZE); //create a window called "MyVideo"

    while (1)
    {
        Mat frame;

        bool bSuccess = cap.read(frame); // read a new frame from video

if (!bSuccess) //if not success, break loop
{
cout << "Cannot read a frame from video stream" << endl;
break;
}

        imshow("MyVideo", frame); //show the frame in "MyVideo" window

        if (waitKey(30) == 27) //wait for 'esc' key press for 30ms. If 'esc' key is pressed, break loop
{
cout << "esc key is pressed by user" << endl;
break;
}
    }
    return 0;

}

When I execute this code, It seems that exit directly without any error, I did not execute the code. In fact , I get this window:

image description

Thanks for help me

edit retag flag offensive close merge delete

Comments

I get the solution

phdstudent2012 gravatar imagephdstudent2012 ( 2014-02-07 14:58:52 -0500 )edit