Ask Your Question
0

Is there any way to decrease CPU usage of feature detector?

asked 2016-03-10 03:17:49 -0600

Oguzhan gravatar image

updated 2016-03-10 03:38:44 -0600

berak gravatar image

Hi everbody,

The feature detector,in OpenCV c++, launches 14 threads and makes heavy usage of CPU (more than 50%). Is there any way to decrease this usage.

Simple code:

cv::Mat grayImage= cv::imread("image.bmp",CV_LOAD_IMAGE_GRAYSCALE);

cv::FeatureDetector *detector;

detector = new cv::SURF(300, 1);

cv::initModule_nonfree();

std::vector<cv::KeyPoint> keyPoints;

detector->detect(grayImage, keyPoints);

enviroınment: Intel i7 3770K , 8GB RAM, Windows 8.1 Pro Visual studio 2013 Pro

edit retag flag offensive close merge delete

2 answers

Sort by » oldest newest most voted
1

answered 2020-10-13 07:31:30 -0600

batug gravatar image

try using cv::setNumThreads(int); OpenCV library beware that it spawns multiple threads for image processing internally. So, setting the number of threads to be spawned by OpenCV could be a good choice.

edit flag offensive delete link more
0

answered 2016-03-10 04:03:53 -0600

Try this:

#include <tbb\task_scheduler_init.h>

tbb::task_scheduler_init init(1);
edit flag offensive delete link more

Comments

Thank you for your answer. However, It couldn't solve. Actually even if it could solve, it is not appropriate for my project. Let me give you the big picture: I am trying to implement a project in a pipes & filters fashion using tbb library. The feature detection is one of the filters. Since openCV's feature detection occupies more than 50% of CPU resources, I could not run more than two filter in parallel which is the main ideo of pipes&filters design. This destroys the performance of my pipeline. Any other recommendation on that?

Oguzhan gravatar imageOguzhan ( 2016-03-10 10:18:25 -0600 )edit
1

Have you tried cv::setNumThreads ?

Eduardo gravatar imageEduardo ( 2016-03-11 08:08:23 -0600 )edit

That works. Thank you.

Oguzhan gravatar imageOguzhan ( 2016-03-11 08:24:42 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2016-03-10 03:17:49 -0600

Seen: 2,115 times

Last updated: Mar 10 '16