相机标定ArUco和ChArUco
原文来源 opencv http://docs.opencv.org/master/da/d13/tutorial_aruco_calibration.html
ArUco模块也可以用来相机标定。 相机标定是获得相机固有参数和失真系数。 这个参数保持不变,除非相机光学修改,因此相机相机标定只需要做一次。
相机校正通常是执行使用OpenCV calibrateCamera()
函数。 这个函数需要一些环境点之间的对应关系和摄像机的投影图像从不同的观点。 一般来说,这些通讯从角落获得棋盘模式。 看到 calibrateCamera()
函数的OpenCV相机标定教程文档或更详细的信息。
使用ArUco模块、相机标定可以执行基于ArUco标记角落或ChArUco角落。 相机标定使用ArUco比使用传统的棋盘模式更多才多艺,因为它允许遮挡或部分视图。
因为它可以表示,相机标定可以同时使用,标志的角落或ChArUco角落。 然而,强烈建议使用ChArUco角落方法自角落提供更准确的标记相比,角。 相机标定用标准板只能从事那些场景ChArUco(标识)板不能雇用的任何限制。
相机标定与ChArUco(标识)板
使用ChArUco相机标定板,需要从不同角度检测板,以同样的方式,相机标定并与传统的棋盘格。 然而,由于使用ChArUco的好处,允许遮挡和局部视图,而不是所有的角落需要显示在所有的观点。
ChArUco相机标定的观点
相机标定的函数 calibrateCameraCharuco()
。 例子:
cv::Ptr<aruco::CharucoBoard> board = ... // create charuco board
cv::Size imgSize = ... // camera image size
std::vector<std::vector<cv::Point2f>> allCharucoCorners;
std::vector<std::vector<int>> allCharucoIds;
// Detect charuco board from several viewpoints and fill allCharucoCorners and allCharucoIds
...
...
// After capturing in several viewpoints, start calibration
cv::Mat cameraMatrix, distCoeffs;
std::vector<cv::Mat> rvecs, tvecs;
int calibrationFlags = ... // Set calibration flags (same than in calibrateCamera() function)
double repError = cv::aruco::calibrateCameraCharuco(allCharucoCorners, allCharucoIds, board, imgSize, cameraMatrix, distCoeffs, rvecs, tvecs, calibrationFlags);
ChArUco角落和ChArUco标识符捕捉到每个观点都存储在向量 allCharucoCorners
和 allCharucoIds
,每一个元素的观点。
的 calibrateCameraCharuco()
函数将填补 cameraMatrix
和 distCoeffs
数组形式的摄像机标定参数。 它将返回摄像机标定的映射误差。 元素 rvecs
和 tvecs
充满相机的姿势估计(关于ChArUco(标识)板)的观测角度。
最后, calibrationFlags
相机标定参数确定的一些选项。 它的格式是相当于OpenCV的旗帜参数
{allCornersConcatenated```}
The rest of parameters are the same than in ```calibrateCameraCharuco()```, except the board layout object which does not need to be a ```CharucoBoard``` object, it can be
any ```Board``` object.
A full working example is included in the ```calibrate_camera.cpp``` inside the module samples folder.
Note: The samples now take input via commandline via the [OpenCV Commandline Parser](http://docs.opencv.org/trunk/d0/d2e/classcv_1_1CommandLineParser.html#gsc.tab=0). For this file the example parameters will look like
``` c++
"_path_/calib.txt" -w=5 -h=7 -l=100 -s=10 -d=10
相机标定与ArUc(标识)板
已经声明,建议使用ChAruco电路板代替ArUco相机校正,因为比标记角落ChAruco角落更准确。 然而,在一些特殊情况下,必须要求使用基于ArUco相机标定板。 在这些情况下, calibrateCameraAruco()
提供的函数。 与前面的情况下,它需要从不同的视点ArUco板的检测。
ArUco相机标定的观点
的例子 calibrateCameraAruco()
使用:
cv::Ptr<aruco::Board> board = ... // create aruco board
cv::Size imgSize = ... // camera image size
std::vector<std::vector<cv::Point2f>> allCornersConcatenated;
std::vector<int> allIdsConcatenated;
std::vector<int> markerCounterPerFrame;
// Detect aruco board from several viewpoints and fill allCornersConcatenated, allIdsConcatenated and markerCounterPerFrame
...
...
// After capturing in several viewpoints, start calibration
cv::Mat cameraMatrix, distCoeffs;
std::vector<cv::Mat> rvecs, tvecs;
int calibrationFlags = ... // Set calibration flags (same than in calibrateCamera() function)
double repError = cv::aruco::calibrateCameraAruco(allCornersConcatenated, allIdsConcatenated, markerCounterPerFrame, board, imgSize, cameraMatrix, distCoeffs, rvecs, tvecs, calibrationFlags);
在这种情况下,相反 calibrateCameraCharuco()
函数,每个角度的检测标记连接在数组 allCornersConcatenated
和
{allCornersConcatenated```}
The rest of parameters are the same than in ```calibrateCameraCharuco()```, except the board layout object which does not need to be a ```CharucoBoard``` object, it can be
any ```Board``` object.
A full working example is included in the ```calibrate_camera.cpp``` inside the module samples folder.
Note: The samples now take input via commandline via the [OpenCV Commandline Parser](http://docs.opencv.org/trunk/d0/d2e/classcv_1_1CommandLineParser.html#gsc.tab=0). For this file the example parameters will look like
``` c++
"_path_/calib.txt" -w=5 -h=7 -l=100 -s=10 -d=10