Im having a bit of a slow start with openCV and have had some difficulties setting it up and integrating with Qt but am finally in the clear . I would like to know how to detect face in openCV using the code as per provided below; I have been trying to integrate other code and create my own with no prevail not really sure what I'm doing wrong can someone point me in the right direction? here is my code; this code open the camera only and captures frames.
#include "mainwindow.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace cv;
using namespace std;
class openCam{
public:
void initiateCamera(){
VideoCapture capture(0);
if (!capture.isOpened()){
std::cout << "Could not open VideoCapture" << std::endl;
}
Mat imgRead;
for (;;){
// capture a frame
capture >> imgRead;
imshow("Cam Interface", imgRead);
// close if key pressed
if(waitKey(27) > 0)
break;
}
capture.release();
destroyAllWindows();
}
};
// ************************************************************** MAIN
int main(int argc, char *argv[]){
QApplication a(argc, argv);
MainWindow w;
// cam code
try{
openCam cam;
cam.initiateCamera();
}catch(Exception ex){
cout << "Unable to initiate camera" << std::endl;
}
w.show();
return a.exec();
}
↧