Background
I am currently trying to build an autonomous drone using ROS on my Rapsberry Pi which is running an Ubuntu MATE 16.04 LTS. Solving the Computer Vision problem of recognising red circles as of now. Since by nature, the drone is not stable (as there is an internal PID controller stabilising the drone) and due to lighting conditions, the drone often detects the same circle but in a very unstable way. About 80% of the frames detect the circle, while the other 20% do not at all. This is also inversely true where the drone does detect random noisy circles 20% of the time and not rest of the 80%.
Objective
I want to know if there is a good way to average the frames that I have right now. This way, I can get rid of the false positives and false negatives altogether.
Relevant Code
cv::medianBlur(intr_ptr, intr_ptr, 7);
strel_size.width = 3;
strel_size.height = 3;
cv::Mat strel = cv::getStructuringElement(cv::MORPH_ELLIPSE,
strel_size);
cv::morphologyEx(img_bin, intr_ptr, cv::MORPH_OPEN, strel,
cv::Point(-1,-1), 3);
cv::bitwise_not(intr_ptr,intr_ptr);
cv::GaussianBlur(intr_ptr, intr_ptr, cv::Size(7,7), 2, 2);
cv::vector<cv::Vec3f> circles;
cv::HoughCircles(intr_ptr, circles, CV_HOUGH_GRADIENT, 1, 70,
140, 15, 10, 40);
As you can see, I am performing a medianBlur
, an open morphological operation and a GaussianBlur
to get rid of the noise. However this is not enough.