This project is about achieving a 10x performance improvement on our target detection code when running on an Arm A9 1GHz processor.
We've designed a visual target (see attached), and written code to find the 4 corners of the outer square using the open source library OpenCV.
This code runs really slowly on our drone (3DR Solo), with a 1GHz Arm A9 chip from 2008. (The code runs on any OS though, we develop on OSX). This project is about finding a way to detect the target's 4 corners 10x faster on the drone.
Background: Once our code finds the corners, it then uses the corners to do POSE detection, do determine the drone's 3d location and orientation relative to the target.
I can share the Python code we use that detects the target (its mostly calls to OpenCV), its something like:
1. Make image grayscale
2. cv2.GaussianBlur(gray, (3, 3), 0)
3. edged = cv2.Canny(gray, 25, 100)
4. kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (7, 7))
5. img_search = cv2.morphologyEx(edged, cv2.MORPH_CLOSE, kernel)
6. contours, hierarchies = cv2.findContours(img_search, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE, offset=offset)
Then we loop through the contours and apply a few checks to find our target contours.
Step #3 is often the slowest.
Optimizations we've already implemented:
- resize image smaller before looking for target
- cropping image based on where we think the target is
1. Code needs to run/compile on the 3DR Solo
- If coding in C, need to provide assistance to get it compiled for solo
2. Ideally no changes to the target, but, we're open to suggestions if they will help perf
3. Performance improvements need to work in both positive and negative cases
3. No reduction in accuracy of detection
1. Recompile openCV more aggressively for the A9? (wild guess, might not help)
2. Write replacements for the methods we call in OpenCV (our python code doesn't change much)
3. Step back, consider alternate approach for detection, and write faster algorithm