31 #include <opencv2/highgui/highgui.hpp> 32 #include <opencv2/imgproc/imgproc.hpp> 33 #include <opencv2/calib3d/calib3d.hpp> 37 using namespace aruco;
52 void getMarker2d_3d(vector<cv::Point2f> &p2d, vector<cv::Point3f> &p3d,
const vector< Marker >&markers_detected,
const MarkerMap &bc){
56 for(
size_t i=0;i<markers_detected.size();i++){
59 for(
size_t j=0;j<bc.size() &&fidx==-1;j++)
60 if (bc[j].
id==markers_detected[i].
id ) fidx=j;
63 p2d.push_back(markers_detected[i][j]);
64 p3d.push_back(bc[fidx][j]);
68 cout<<
"points added"<<endl;
78 for(
int i=2;i<argc;i++){
79 if (
string(argv[i])==
"-size" ){
83 if (
string(argv[i])==
"-m" ){
96 int main(
int argc,
char **argv) {
100 cerr <<
"Usage: out_camera_calibration.yml [options] image1 image2 ... " << endl;
101 cerr<<
"options:"<<endl;
102 cerr<<
"-size maker_size : Size of the markers in meters. "<<endl;
103 cerr<<
"-m markersetconfig.yml : By default, the one in utils is assumed. Otherwise, set the file here "<<endl;
117 cerr<<
"Need to specify the length of the board with -size"<<endl;
122 vector<string> images;
123 for(
int i=firstImageIdx;i<argc;i++)images.push_back(argv[i]);
139 cv::Size imageSize(-1,-1);
142 cout<<
"reading "<<images[currImage]<<endl;
145 if (imageSize!=cv::Size(-1,-1) && imageSize!=
TheInputImage.size()){
146 cerr<<
"Input image sizes must be equal"<<endl;exit(0);
152 vector<int> markers_from_set=TheMarkerMapConfig.
getIndices(detected_markers);
154 for(
auto idx:markers_from_set) detected_markers[idx].draw(
TheInputImageCopy, Scalar(0, 0, 255), 1);
162 vector<cv::Point2f> p2d;
163 vector<cv::Point3f> p3d;
176 else cerr<<
"Could not read image "<<images[currImage]<<endl;
177 }
while (++currImage<
int(images.size()));
179 cout<<
"Starting calibration"<<endl;
180 vector<cv::Mat> vr,vt;
184 cerr<<
"repj error="<<err<<endl;
188 }
catch (std::exception &ex)
191 cout <<
"Exception :" << ex.what() << endl;
vector< vector< cv::Point2f > > calib_p2d
aruco::CameraParameters camp
void saveToFile(string path, bool inXML=true)
bool isExpressedInMeters() const
unsigned int default_a4_board_size
vector< vector< cv::Point3f > > calib_p3d
void setDictionary(std::string dict_type, float error_correction_rate=0)
std::vector< aruco::Marker > detect(const cv::Mat &input)
void readFromFile(string sfile)
unsigned char default_a4_board[]
MarkerMap TheMarkerMapConfig
string TheMarkerMapConfigFile
MarkerMap convertToMeters(float markerSize)
CameraParameters TheCameraParameters
Main class for marker detection.
Parameters of the camera.
int parseInput(int argc, char **argv)
std::string getDictionary() const
int main(int argc, char **argv)
string TheOutCameraParams
void fromStream(std::istream &str)
double _thresParam1_range
MarkerDetector TheMarkerDetector
std::vector< int > getIndices(vector< aruco::Marker > &markers)
void getMarker2d_3d(vector< cv::Point2f > &p2d, vector< cv::Point3f > &p3d, const vector< Marker > &markers_detected, const MarkerMap &bc)
CornerRefinementMethod _cornerMethod
This class defines a set of markers whose locations are attached to a common reference system...