我正在阅读一张图片并过滤掉颜色,这是我在下面的图像中得到的结果。该代码来自
opencv
模块中的示例文件夹。
我正在尝试将图片反馈给
A.R Drone 2.0
,并让无人机跟随白色。我该如何做第二部分?
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');
});
由于您的无人机可以在 3D 空间中移动,我将建议 2D 领域中的一些伪代码步骤,以帮助您开始使用简单的巡线器。然后您可以推断到 3D 并添加更多自由度来满足您的需求。
从这里,您可以执行其他几项基本操作来控制无人机的运动: