Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

no, you're NOT using opencv's C++ api, but the deprecated C-api (thus the warning). you can no longer use IplImage and the like with current opencv (and 3.3.0 is quite outdated, too !)

again, the main problem is, that the code you are trying to use is from opencv 1.0, and cannot be maintained in the future.

please rather try like this:

#include "opencv2/opencv.hpp" // opencv2 headers !
using namespace cv;           // c++ namespaces !

#include <iostream>
using namespace std;

int main()
{
    VideoCapture cap;         // c++ classes !
    cap.open(0);
    if (! cap.isOpened())     // you have to CHECK this !
    {
        cout << "could not open the VideoCapture !" << endl;
        return -1;
    }
    while(true)
    {
        Mat frame;
        bool ok = cap.read(frame);
        if (! ok)             // also, mandatory CHECK !
             break; 
        imshow("ocv",frame);
        int k = waitKey(10);
        if (k==27) break;     // esc. pressed
    }
    return 0;
}

please also take a look at the tutorials / docs

no, you're NOT using opencv's C++ api, but the deprecated C-api (thus the warning). you can no longer use IplImage and the like with current opencv (and 3.3.0 is quite outdated, too !)opencv

again, the main problem is, that the code you are trying to use is from opencv 1.0, and cannot be maintained in the future.

please rather try like this:

#include "opencv2/opencv.hpp" // opencv2 headers !
using namespace cv;           // c++ namespaces !

#include <iostream>
using namespace std;

int main()
{
    VideoCapture cap;         // c++ classes !
    cap.open(0);
    if (! cap.isOpened())     // you have to CHECK this !
    {
        cout << "could not open the VideoCapture !" << endl;
        return -1;
    }
    while(true)
    {
        Mat frame;
        bool ok = cap.read(frame);
        if (! ok)             // also, mandatory CHECK !
             break; 
        imshow("ocv",frame);
        int k = waitKey(10);
        if (k==27) break;     // esc. pressed
    }
    return 0;
}

please also take a look at the tutorials / docs