I am reading a picture and filtering out the colors and this is the result I get in the following images. The code is from the example folder in the opencv
module.
I am trying to feed the picture back to an A.R Drone 2.0
and have the drone follow the color white. How would I do the second part?
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');
});
Since your drone can move in 3D-space, I will suggest some pseudo-code steps in the 2D realm to get you started with a simple line follower. Then you can extrapolate to 3D and add more degrees of freedom to meet your needs.
From here, you can do several other basic things to control the motion of your drone: