Reputation: 501
my attempt to move a few steps inside dlib came to an abrupt halt while trying to replicate some parts of this code http://dlib.net/face_landmark_detection_ex.cpp.html
This is what I've got so far
// video and image capturing
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/video.hpp"
//Dlib libraries
#include "dlib/image_processing/frontal_face_detector.h"
#include "dlib/image_processing/render_face_detections.h"
#include "dlib/image_processing.h"
#include "dlib/gui_widgets.h"
#include "dlib/image_io.h"
#include <iostream>
using namespace dlib;
using namespace cv;
using namespace std;
int main()
{
frontal_face_detector detector = get_frontal_face_detector();
shape_predictor sp;
array2d<rgb_pixel> img;
VideoCapture cap("/home/francesco/Downloads/05-1.avi");
if (!cap.isOpened())
{
cout << "Cannot open the video file. \n";
return -1;
}
double fps = cap.get(CV_CAP_PROP_FPS); //get the frames per second
namedWindow("UNLTD", CV_WINDOW_AUTOSIZE);
//For future: WINDOW_OPENGL instead of WINDOW_AUTOSIZE;
while(1)
{
Mat frame;
//Mat is basic image container, frame is an object of Mat.
std::vector<rectangle> dets = detector(img);
if (!cap.read(frame))
//read() decodes and capture the next frame, if it fails, break
{
cout << "Failed to read the video. \n";
break;
}
imshow("UNLTD", frame);
if(waitKey(30) == 27) //ESCAPE
{
break;
}
}
return 0;
}
For now, all I'm expecting the software to do is to play the video without returning errors but unfortunately I'm getting this
error: template argument 1 is invalid
error: template argument 2 is invalid
error: cannot convert 'std::vector<dlib::rectangle>' to 'int' in initialization
referring to the line
std::vector<rectangle> dets = detector(img);
which I copied/pasted from the example provided in the official dlib.net website.
Build log:
g++ -Wall -fexceptions -g -std=c++11 -I../../../../opt/opencv/include/opencv -I../../../../opt/opencv/include/opencv2 -c /home/francesco/dlib/OpenCV_videoPlayer_v01/main.cpp -o obj/Debug/main.o
/home/francesco/dlib/OpenCV_videoPlayer_v01/main.cpp: In function ‘int main()’:
/home/francesco/dlib/OpenCV_videoPlayer_v01/main.cpp:46:30: error: template argument 1 is invalid
std::vector<rectangle> dets = detector(img);
^
/home/francesco/dlib/OpenCV_videoPlayer_v01/main.cpp:46:30: error: template argument 2 is invalid
/home/francesco/dlib/OpenCV_videoPlayer_v01/main.cpp:46:51: error: cannot convert ‘std::vector<dlib::rectangle>’ to ‘int’ in initialization
std::vector<rectangle> dets = detector(img);
^
The full code is available here http://dlib.net/face_landmark_detection_ex.cpp.html
any idea?
Upvotes: 0
Views: 1000
Reputation: 23497
My best guess is that the problem is with the rectangle
identifier, which, as I look at documentations, is defined both in cv
and dlib
namespaces. using namespace ...
is generally not a good idea for multiple namespaces. Try to remove using namespace cv
and prefix all identifiers from cv
namespace accordingly.
Upvotes: 3