chili-epfl / attention-tracker

136 stars 97 forks source link

Delay cv::VideoCapture and 500ms per frame #10

Closed patriciastar closed 8 years ago

patriciastar commented 8 years ago

Hey, I'm using your code in my eclipse project (Ubuntu 64-bit) and I'm having two problems: 1) a delay of 3 seconds using the VideoCapture 2) an average speed of 500ms per frame instead of about 1ms (I added the flags -mavx and -msse4 under Project > Properties > C/C++ Build > Settings then on the Tool Settings tab GCC C++ Compiler > Miscellaneous and under Window > Preferences > C/C++ > Build > Settings on the Discovery tab chose CDT GCC Built-in Compiler Settings and add the flags to Command to get compiler specs) I also built in Release mode.

Do you have any idea how I can fix this? Here's the main part of my code (there is of cause a "<" in the includes in my code):

include dlib/image_processing/render_face_detections.h>

include dlib/gui_widgets.h>

include iostream>

include string>

include cmath>

include "head-pose-estimation/headposeestimation.h"

using namespace std;

int main(int argc, char\ argv) {

auto estimator = HeadPoseEstimation();

dlib::image_window win;

std::string shapePredictor = argv[1];

estimator.initialize(shapePredictor);

cv::VideoCapture cap(0);

while(!win.is_closed()){

    cap >> estimator.matImage; //cv::Mat matImage
    dlib::cv_image<dlib::bgr_pixel> cvImage(estimator.matImage);

    auto t_start = cv::getTickCount();
    estimator.findLandmarks(cvImage);
    auto t_end = cv::getTickCount();
    cout << "Processing time for this frame: " << (t_end-t_start) / cv::getTickFrequency() * 1000. << "ms" << endl;

    win.clear_overlay();
    win.set_image(cvImage);

    win.add_overlay(render_face_detections(estimator.shapes));
}

}`

Thanks in advance. Patricia

nitheeshas commented 8 years ago

Why would you want to run this inside Eclipse when you can simply use cmake and run it from the executable?

patriciastar commented 8 years ago

Because this is only a part of a huge project I created using eclipse. I'm not used to cmake and I don't like cmake. Anyway I solved the problem by myself -> because of earlier tests, the flag ENABLE_ASSERTS had been set, removed it and speed is fine.