Face Detection/ Recognition [OpenCV 3.1.0 With Qt]

asked 2016-06-08 14:50:59 -0500

trav gravatar image

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 <QApplication>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/videoio/videoio.hpp>
#include <iostream>
using namespace cv;
using namespace std;

class openCam{


 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)




// ************************************************************** MAIN

int main(int argc, char *argv[]){
    QApplication a(argc, argv);
    MainWindow w;
 // cam code
  openCam cam;

}catch(Exception ex){
cout << "Unable to initiate camera" << std::endl;

return a.exec();
edit retag flag offensive close merge delete


are there any errors ? i cannot see the problem ?

berak gravatar imageberak ( 2016-06-08 23:30:57 -0500 )edit


Errors in this code? No; This code works I'm asking how to implement this to detect faces.. the code to detect faces is absent and am requesting if someone knows how to combine this code and the code that detects faces... this code only opens local camera on a machine , thanks

trav gravatar imagetrav ( 2016-06-09 15:25:58 -0500 )edit