Question

I am using Canny Detection on a streaming image from a robot's camera (looking for circles). To get the maximum contrast between edges, I split the rgb image into the separate channels, perform Canny on each one, then bitwise or the edges together into a merged image. When used on a simple image, my fps is relatively unaffected at 30 fps. When a more complicated image is seen by the camera, the fps drops to 24 fps. Is this normal? If so, is there anyway that I can speed this up so that I can continue to run at a constant frame rate?

Here's the code that I'm using:

vector<Mat> rgb;
split(src, rgb);

Canny( rgb[0], rgb[0], cannyThreshold, cannyThreshold2, 3);
Canny( rgb[1], rgb[1], cannyThreshold, cannyThreshold2, 3 );
Canny( rgb[2], rgb[2], cannyThreshold, cannyThreshold2, 3 );

Mat mergedImage;
bitwise_or(rgb[0], rgb[1], mergedImage);
bitwise_or(mergedImage, rgb[2], mergedImage);
Was it helpful?

Solution

That behavior is expected, indeed.

There are 3 ways to speed things up:

  • OpenCV can benefit from an Intel processor, if you have one you can install Intel IPP. You might have to compile OpenCV on your own to enable this feature.

  • Use OpenCV's GPU module. The method gpu::Canny() provides an implementation of Canny that runs on the GPU. OpenCV can run certain algorithms on the GPU if your video card supports CUDA or OpenCL. You might have to compile OpenCV on your own to enable this feature.

  • Investigate a different approach: sometimes a different set of algorithms can achieve the same result in a smaller amount of time. I talked briefly about this on your other question.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top