Pixhawk 开发笔记
定点降落方案
- 颜色识别
- 优点:简单、实时性好
- 缺点:容易受光照干扰
- 形状检测
- 缺点:识别成功率低,运算量大
- AprilTag/ArUco
- 优点:运行稳定,实时性好
ArUco姿态估计实践
以下实验采用Aruco Library库。
第一步:标定
至少采集 15 张图。标定所需的图:
运行指令:
aruco_calibration_fromimages mycalibrationfile.yml pathToDirWithImage -size 0.03
执行完后生成相机的内参文件 aruco_calibration_grid_board_a4.yml
%YAML:1.0
---
image_width: 1280
image_height: 720
camera_matrix: !!opencv-matrix
rows: 3
cols: 3
dt: d
data: [ 1.3293642549176379e+03, 0., 6.5434138777781050e+02, 0.,
1.3408271477588517e+03, 3.8195972804132447e+02, 0., 0., 1. ]
distortion_coefficients: !!opencv-matrix
rows: 1
cols: 5
dt: d
data: [ -8.8053880180133173e-02, 2.4600465942662324e+00,
4.4439378615367849e-03, -3.3176117502153640e-03,
-1.0540748855593554e+01 ]
第二步:估计
执行命令:
./utils/aruco_pose ../utils_calibration/aruco_calibration_grid_board_a4.yml
参考程序:
#include <opencv2/highgui.hpp>
#include "aruco.h"
using namespace std;
int main(int argc,char **argv)
{
aruco::CameraParameters camera;
camera.readFromXMLFile(argv[1]);
aruco::MarkerDetector Detector;
Detector.setDictionary("ARUCO_MIP_36h12");
cv::namedWindow( "ArUco-Pose-Estimation", cv::WINDOW_AUTOSIZE );
cv::VideoCapture cap;
cap.open(0); // open the first camera
if( !cap.isOpened() )
{ // check if we succeeded
std::cerr << "Couldn't open capture." << std::endl;
return -1;
}
cv::Mat im;
for (;;)
{
cap >> im;
if ( im.empty() )
break; // Ran out of film
auto markers=Detector.detect(im,camera,0.04);//0.102 is the marker size
for ( auto m:markers )
{
aruco::CvDrawingUtils::draw3dAxis(im,m,camera);
// cout<<m.Rvec<<" "<<m.Tvec<<endl;
// 实时输出位置坐标 XYZ:
cout<<m.Tvec<<endl;
}
cv::imshow("ArUco-Pose-Estimation",im);
if ( (char) cv::waitKey(33) >= 0 )
break;
}
}
实验结果截图:
注意:Debug 和 Release 模式的区别
全局快门相机
虽然使用普通相机的定位周期 <20ms,但是快速移动相机时容易出现无法识别 ArUco 的情况。下一步考虑采用全局快门相机,比如 MT9V034。
[TODO…]