1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- #include "mainwindow.h"
- #include <QApplication>
- #include <opencv2/core/core.hpp>
- #include <opencv2/highgui/highgui.hpp>
- #include <opencv2/videoio/videoio.hpp>
- #include <QDebug>
- int main(int argc, char *argv[])
- {
- QApplication a(argc, argv);
- //jMainWindow w;
- //w.show();
- cv::Mat frame;
- //--- INITIALIZE VIDEOCAPTURE
- cv::VideoCapture cap;
- // open the default camera using default API
- // cap.open(0);
- // OR advance usage: select any API backend
- int deviceID = 0; // 0 = open default camera
- int apiID = cv::CAP_ANY; // 0 = autodetect default API
- // open selected camera using selected API
- cap.open(deviceID, apiID);
- // check if we succeeded
- if (!cap.isOpened()) {
- qDebug() << "ERROR! Unable to open camera";
- return a.exec();
- }
- qDebug() << "Camera Open !";
- //--- GRAB AND WRITE LOOP
- qDebug() << "Start grabbing";
- qDebug() << "Press any key to terminate";
- //for (;;)
- //{
- // wait for a new frame from camera and store it into 'frame'
- cap.read(frame);
- // check if we succeeded
- if (frame.empty()) {
- qDebug() << "ERROR! blank frame grabbed\n";
- //break;
- }
- else {
- // show live and wait for a key with timeout long enough to show images
- imshow("Live", frame);
- // if (cv::waitKey(5) > = 0)
- //b break;
- qDebug() << "FLUX !!\n";
- }
- // }
- // the camera will be deinitialized automatically in VideoCapture destructor
- return a.exec();
- }
|