Face Detection Error OpenCV 3.1.0

asked 2016-06-19 10:07:33 -0500

trav gravatar image

updated 2016-06-19 10:08:41 -0500

I am trying to get started in opneCv and get learning but am running into problems in regards to face detection the code I have should detect faces I believe my linkages are fine can someone please help me understand what I'm doing wrong? full code in both main.cpp and project.pro file is provided below

App Output:

starting /Users/admin/Desktop/build-Origin-Desktop_Qt_5_6_0_clang_64bit-Debug/Origin.app/Contents/MacOS/Origin... OpenCV Error: Assertion failed (!empty()) in detectMultiScale, file /Users/admin/Desktop/opencv-3.1.0/modules/objdetect/src/cascadedetect.cpp, line 1639 Cleaned up camera. Unable to initiate camera /Users/admin/Desktop/build-Origin-Desktop_Qt_5_6_0_clang_64bit-Debug/Origin.app/Contents/MacOS/Origin exited with code 0

Compile Output:

10:46:41: Running steps for project Origin... 10:46:41: Configuration unchanged, skipping qmake step. 10:46:41: Starting: "/usr/bin/make" /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -c -pipe -stdlib=libc++ -g -std=gnu++11 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -mmacosx-version-min=10.7 -Wall -W -fPIC -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../Origin -I. -I/usr/local/include -I../../Qt/5.6/clang_64/lib/QtWidgets.framework/Headers -I../../Qt/5.6/clang_64/lib/QtGui.framework/Headers -I../../Qt/5.6/clang_64/lib/QtCore.framework/Headers -I. -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/AGL.framework/Headers -I. -I../../Qt/5.6/clang_64/mkspecs/macx-clang -F/Users/admin/Qt/5.6/clang_64/lib -o main.o ../Origin/main.cpp /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -headerpad_max_install_names -stdlib=libc++ -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -mmacosx-version-min=10.7 -Wl,-rpath,/Users/travishaycock/Qt/5.6/clang_64/lib -o Origin.app/Contents/MacOS/Origin main.o mainwindow.o moc_mainwindow.o -F/Users/admin/Qt/5.6/clang_64/lib -L/usr/local/lib -lopencv_core -lopencv_highgui -lopencv_videoio -lopencv_imgproc -lopencv_objdetect -framework QtWidgets -framework QtGui -framework QtCore -framework OpenGL -framework AGL 10:46:43: The process "/usr/bin/make" exited normally. 10:46:43: Elapsed time: 00:02.

Main.cpp File

  #include "mainwindow.h"
#include <QApplication>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/videoio/videoio.hpp>
#include<opencv2/objdetect/objdetect.hpp>
#include<opencv2/imgproc/imgproc.hpp>
#include<vector>
#include<string>

#include <iostream>
#include<stdio.h>

using namespace cv;
using namespace std;





CascadeClassifier face_cascade, eyes_cascade;
String window_name = "Face Detection";

/**
 * Detects faces 
 */
void detectFaces(Mat frame) {

  std::vector<Rect> faces;
  Mat frame_gray;
  cvtColor(frame, frame_gray, COLOR_BGR2GRAY);  // Convert to gray scale
  equalizeHist(frame_gray, frame_gray);         // Equalize histogram

  // Detect faces
  face_cascade.detectMultiScale(frame_gray, faces, 1.1, 3,
                0|CASCADE_SCALE_IMAGE, Size(30, 30));

  // Iterate over all of the faces
  for(size_t i = 0; i < faces.size(); i++) {

    // Find center of faces
    Point center(faces[i].x + faces[i].width/2, faces[i].y + faces[i].height ...
(more)
edit retag flag offensive close merge delete

Comments

imho, you're asking the wrong question.

it rather looks, you have a problem using your webcam, and it's not about face (or object) detection.

berak gravatar imageberak ( 2016-06-20 06:50:07 -0500 )edit