2

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.

SDG
  • 2,260
  • 8
  • 35
  • 77
  • http://stackoverflow.com/questions/3431434/video-stabilization-with-opencv This should work http://stackoverflow.com/a/3511233/4021785 – Mahesh Attarde Jan 31 '17 at 12:18
  • @MaheshAttarde This relates to video stabilisation, while, relevant, does not help me too much. Because, by definition, the moving camera and respective objects is useful for me, as I use it to stabilise the drone. SIFT and SURF, while brilliant and efficient suggestions, will be a bit too taxing on the drone in the long run. – SDG Jan 31 '17 at 12:27
  • If I may you should certainly consider improving lens with some sort of image stabilization: https://en.wikipedia.org/wiki/Image_stabilization You're going to find yourself spending a tremendous amount of time compensating otherwise. – Jonathan Mee Jan 31 '17 at 12:29
  • @JonathanMee Yeah, that's actually a wonderful tip. I'll actually work on implementing this immediately. But I do predict that, it won't completely reduce the amount of noise, that will help me with stable detection of objects – SDG Jan 31 '17 at 12:33
  • @SharanDuggirala You're correct. You'll still need to do stabilization in software. But I wouldn't be surprised to see it solve your 20% of frames that don't detect the circle, which allows you to choose a far more dependable and reliable algorithm. – Jonathan Mee Jan 31 '17 at 12:36
  • @JonathanMee Yeah, I'll definitely implement it right now and see if it works. In which case, I will accept either yours or Mahesh Attarde's answer. But I am also very interested in frame averaging of object detection using OpenCV (and possibly even research into it). – SDG Jan 31 '17 at 12:40

0 Answers0