Quantcast
Channel: OpenCV Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 41027

Identify Pepperoni Slice: Houghs Circles is Slow

$
0
0
Hello I am making a simple fun project that identifies how many pepperoni pieces/slices are on a pizza. The algorithm to count the no. of pepperoni slices is based off [this example](http://docs.opencv.org/2.4/doc/tutorials/imgproc/imgtrans/hough_circle/hough_circle.html) and is as follows: - For each video frame: - Convert to gray scale - Apply Gaussian Blur to reduce noise - Use Hough's Circle to identify all pepperoni slices and the pizza itself - If a circle sits inside another circle (pizza): then its a pepperoni slice Example of the frame input: ![image description](/upfiles/1449283548208819.jpg) The execution of the program is incredibly slow (as in 1 frame per second) and the algorithm is very hit and miss. Can you provide advice on why its slow, how I can achieve any speed increases and improve/alternative algorithms? Should I identify slices by their colour instead? VideoCapture gCapture.open(VIDEO_SAMPLE_PATH); while (true) { if (!gCapture.read(gCameraFeed)) return -1; vector circles; IdentifyCircles(gCameraFeed, circles); DrawPepperoni(gCameraFeed, circles); imshow(MAIN_WND_TITLE, gCameraFeed); // Exit on escape key down int c = waitKey(30); if ((char)c == 27) break; } int IdentifyCircles(const Mat& frame, vector& circles) { // Post: Use Hough Circles algorithm to identify all circles in frame Mat grayScaleFrame; circles.clear(); cvtColor(frame, grayScaleFrame, CV_BGR2GRAY); GaussianBlur(grayScaleFrame, grayScaleFrame, Size(9, 9), 2, 2); HoughCircles(grayScaleFrame, circles, CV_HOUGH_GRADIENT, 1, grayScaleFrame.rows/8, 50, 50, 0, 0); putText(gCameraFeed, "Circles Identified: " + to_string(circles.size()), Point(20, 50), 1, 2, Scalar::all(200), 1, 8); return 1; }

Viewing all articles
Browse latest Browse all 41027

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>