Improving Speed of Histogram Back Projection
I am currently using OpenCV's built-in patch-based histogram back projection (cv::calcBackProjectPatch()
) to identify regions of a target material in an image. With an image resolution of 640 x 480 and a window size of 10 x 10, processing a single image requires ~1200 ms. While the results are great, this far too slow for a real-time application (which should have a processing time of no more than ~100 ms).
I have already tried reducing the window size and switching from CV_COMP_CORREL
to CV_COMP_INTERSECT
to speed up the processing, but have not seen any appreciable speed up. This may be explained by the OpenCV documentation (emphasis mine):
Each new image is measured and then converted into an image image array over a chosen ROI. Histograms are taken from this image image in an area covered by a “patch” with an anchor at center as shown in the picture below. 开发者_如何学JAVA The histogram is normalized using the parameter norm_factor so that it may be compared with hist. The calculated histogram is compared to the model histogram; hist uses The function cvCompareHist() with the comparison method=
method
). The resulting output is placed at the location corresponding to the patch anchor in the probability image dst. This process is repeated as the patch is slid over the ROI. Iterative histogram update by subtracting trailing pixels covered by the patch and adding newly covered pixels to the histogram can save a lot of operations, though it is not implemented yet.
This leaves me with a few questions:
- Is there another library that supports iterative histogram updates?
- How significant of a speed-up should I expect from using an iterative update?
- Are there any other techniques for speeding up this type of operation?
As mentioned in OpenCV Integral Histograms will definitely improve speed.
Please take a look at a sample implementation in the following link http://smsoftdev-solutions.blogspot.com/2009/08/integral-histogram-for-fast-calculation.html
精彩评论