Drone Line Follower
Hello everyone, I am working a project where I want to follow a straight line to clean gutters. I read up on opencv
for image processing. This is my thought process:
- Perform
Erosion/Dilation
Operations on your image to get rid of extra space, if necessary. - Call
cv::findContours()
to get a trace around the edges of the white regions in your image. - Sort your found contours by pixel area to find the contour you want to follow.
- follow the largest pixel area. Try using the contour moments.
- Fit a line to the contour using
cv::fitline()
or your own approach. - Take the angle of the line and map it to your drone controller to adjust the yaw.
Set a contour pixel mass threshold. If the contour area > threshold, move up. Look at the shape of the threshold area. If it is more like a trapezoid than a rectangle, you can adjust your roll/pitch.
My problem is how do I feed images to the drone, for the drone to detect the gutter and follow a straight line. How do I code the movements? Also what streaming service will recognize opencv
. The code I have is node.js
because I am not sure how to use the C++ / Python Version of OpenCV
. But i want to use the c++ version because there are more capabilities.
var cv = require('C:/users/danny/codes/node_modules/opencv/lib/opencv');
// (B)lue, (G)reen, (R)ed
var lower_threshold = [220, 220, 220];
var upper_threshold = [255, 255, 255];
//var lower_threshold = [46, 57, 83];
//var upper_threshold = [80, 96, 115];
cv.readImage('C:/users/danny/codes/node_modules/opencv/examples/files/gutter.jpg',
function(err, im) {
if (err) throw err;
if (im.width() < 1 || im.height() < 1) throw new Error('Image has no size');
im.inRange(lower_threshold, upper_threshold);
im.save('C://users/danny/codes/coin_detected.jpg');
console.log('Image saved to C://users/danny/codes/coin_detected.jpg');
});
What operating system are you using? It looks like you're using Windows.
yes windows