samedi 2 juillet 2016

Perfomance Issues while capturing and processing a video

I'm currently working on a project where I need to display a processed live video capture. Therefore, I'm using something similar to this:

cv::VideoCapture cap(0); 
if (!cap.isOpened()) 
    return -1;

cap.set(CV_CAP_PROP_FRAME_WIDTH, 1280);
cap.set(CV_CAP_PROP_FRAME_HEIGHT, 720);

cv::namedWindow("Current Capture");
for (;;)
{
    cv::Mat frame;
    cap >> frame;       
    cv::Mat mirrored;
    cv::flip(frame, mirrored, 1);
    cv::imshow("Current Capture", process_image(mirrored));

    if (cv::waitKey(30) >= 0) break;
}

The problem I have is, that process_image, which perfomes a circle detection in the image, needs some time to finish and causes the displaying to be rather a slideshow then a video.

My Question is: How can I speed up the processing without manipulating the process_image function?

I thought about performing the image processing in another thread, but I'm not really sure how to start. Do you have any other idea than this?

PS.: I'm not expecting you to write code for me, I only need a point to start from ;)

Aucun commentaire:

Enregistrer un commentaire