31 #include <opencv2/core/core.hpp> 32 #include <opencv2/highgui/highgui.hpp> 37 using namespace aruco;
44 int main(
int argc,
char **argv) {
47 cerr <<
"Usage: (in_image|video.avi) markerSetConfig.yml [cameraParams.yml] [markerSize] [outImage]" << endl;
52 VideoCapture vreader(argv[1]);
53 if (!vreader.isOpened())
throw std::runtime_error(
"Could not open input");
66 CamParam.
resize(InImage.size());
69 float MarkerSize = -1;
70 if (argc >= 5) MarkerSize = atof(argv[4]);
82 vector< Marker > Markers=MDetector.
detect(InImage);
85 vector<int> markers_from_set=TheMarkerMapConfig.
getIndices(Markers);
86 for(
auto idx:markers_from_set) Markers[idx].draw(InImage, Scalar(0, 0, 255), 2);
92 MSPoseTracker.
setParams(CamParam,TheMarkerMapConfig);
97 cv::imshow(
"in", InImage);
98 while (
char(cv::waitKey(0))!=27) ;
100 if (argc >= 6) cv::imwrite(argv[5], InImage);
102 }
catch (std::exception &ex)
105 cout <<
"Exception :" << ex.what() << endl;
const cv::Mat getTvec() const
void resize(cv::Size size)
bool isExpressedInPixels() const
bool isExpressedInMeters() const
const cv::Mat getRvec() const
void setDictionary(std::string dict_type, float error_correction_rate=0)
std::vector< aruco::Marker > detect(const cv::Mat &input)
void readFromFile(string sfile)
static void draw3dAxis(cv::Mat &Image, const CameraParameters &CP, const cv::Mat &Rvec, const cv::Mat &Tvec, float axis_size)
bool estimatePose(const vector< Marker > &v_m)
void readFromXMLFile(string filePath)
void setParams(const CameraParameters &cam_params, const MarkerMap &msconf, float markerSize=-1)
MarkerMap TheMarkerMapConfig
MarkerMap convertToMeters(float markerSize)
Main class for marker detection.
Parameters of the camera.
std::string getDictionary() const
std::vector< int > getIndices(vector< aruco::Marker > &markers)
This class defines a set of markers whose locations are attached to a common reference system...
int main(int argc, char **argv)