Go to the documentation of this file.
31 #include "opencv2/opencv.hpp"
50 int main(
int argc,
char *argv[])
66 printf(
"Usage: %s [options]\n", argv[0]);
71 cout <<
"Enabling video capture" << endl;
78 if (!cap.isOpened()) {
79 cerr <<
"Couldn't open video capture device" << endl;
86 if (!strcmp(famname,
"tag36h11")) {
88 }
else if (!strcmp(famname,
"tag25h9")) {
90 }
else if (!strcmp(famname,
"tag16h5")) {
92 }
else if (!strcmp(famname,
"tagCircle21h7")) {
94 }
else if (!strcmp(famname,
"tagCircle49h12")) {
96 }
else if (!strcmp(famname,
"tagStandard41h12")) {
98 }
else if (!strcmp(famname,
"tagStandard52h13")) {
100 }
else if (!strcmp(famname,
"tagCustom48h12")) {
103 printf(
"Unrecognized tag family name. Use e.g. \"tag36h11\".\n");
111 if (errno == ENOMEM) {
112 printf(
"Unable to add family to detector due to insufficient memory to allocate the tag-family decoder with the default maximum hamming value of 2. Try choosing an alternative tag family.\n");
123 cout <<
"Detector " << famname <<
" initialized in "
124 << std::fixed << std::setprecision(3) << meter.getTimeSec() <<
" seconds" << endl;
125 #if CV_MAJOR_VERSION > 3
126 cout <<
" " << cap.get(CAP_PROP_FRAME_WIDTH ) <<
"x" <<
127 cap.get(CAP_PROP_FRAME_HEIGHT ) <<
" @" <<
128 cap.get(CAP_PROP_FPS) <<
"FPS" << endl;
130 cout <<
" " << cap.get(CV_CAP_PROP_FRAME_WIDTH ) <<
"x" <<
131 cap.get(CV_CAP_PROP_FRAME_HEIGHT ) <<
" @" <<
132 cap.get(CV_CAP_PROP_FPS) <<
"FPS" << endl;
140 cvtColor(frame, gray, COLOR_BGR2GRAY);
143 image_u8_t im = {gray.cols, gray.rows, gray.cols, gray.data};
147 if (errno == EAGAIN) {
148 printf(
"Unable to create the %d threads requested.\n",td->
nthreads);
153 for (
int i = 0; i <
zarray_size(detections); i++) {
156 line(frame, Point(det->
p[0][0], det->
p[0][1]),
157 Point(det->
p[1][0], det->
p[1][1]),
158 Scalar(0, 0xff, 0), 2);
159 line(frame, Point(det->
p[0][0], det->
p[0][1]),
160 Point(det->
p[3][0], det->
p[3][1]),
161 Scalar(0, 0, 0xff), 2);
162 line(frame, Point(det->
p[1][0], det->
p[1][1]),
163 Point(det->
p[2][0], det->
p[2][1]),
164 Scalar(0xff, 0, 0), 2);
165 line(frame, Point(det->
p[2][0], det->
p[2][1]),
166 Point(det->
p[3][0], det->
p[3][1]),
167 Scalar(0xff, 0, 0), 2);
171 String text = ss.str();
172 int fontface = FONT_HERSHEY_SCRIPT_SIMPLEX;
173 double fontscale = 1.0;
175 Size textsize = getTextSize(text, fontface, fontscale, 2,
177 putText(frame, text, Point(det->
c[0]-textsize.width/2,
178 det->
c[1]+textsize.height/2),
179 fontface, fontscale, Scalar(0xff, 0x99, 0), 2);
183 imshow(
"Tag Detections", frame);
184 if (waitKey(30) >= 0)
190 if (!strcmp(famname,
"tag36h11")) {
192 }
else if (!strcmp(famname,
"tag25h9")) {
194 }
else if (!strcmp(famname,
"tag16h5")) {
196 }
else if (!strcmp(famname,
"tagCircle21h7")) {
198 }
else if (!strcmp(famname,
"tagCircle49h12")) {
200 }
else if (!strcmp(famname,
"tagStandard41h12")) {
202 }
else if (!strcmp(famname,
"tagStandard52h13")) {
204 }
else if (!strcmp(famname,
"tagCustom48h12")) {
void getopt_destroy(getopt_t *gopt)
int getopt_parse(getopt_t *gopt, int argc, char *argv[], int showErrors)
int getopt_get_int(getopt_t *getopt, const char *lname)
void tag36h11_destroy(apriltag_family_t *tf)
void tag16h5_destroy(apriltag_family_t *tf)
apriltag_family_t * tagCustom48h12_create()
getopt_t * getopt_create()
void getopt_add_bool(getopt_t *gopt, char sopt, const char *lname, int def, const char *help)
zarray_t * apriltag_detector_detect(apriltag_detector_t *td, image_u8_t *im_orig)
void getopt_add_string(getopt_t *gopt, char sopt, const char *lname, const char *def, const char *help)
void getopt_do_usage(getopt_t *gopt)
static int zarray_size(const zarray_t *za)
apriltag_family_t * tag25h9_create()
void getopt_add_double(getopt_t *gopt, char sopt, const char *lname, const char *def, const char *help)
apriltag_family_t * tag16h5_create()
void tagCircle49h12_destroy(apriltag_family_t *tf)
apriltag_family_t * tagCircle21h7_create()
const char * getopt_get_string(getopt_t *gopt, const char *lname)
apriltag_detector_t * apriltag_detector_create()
double getopt_get_double(getopt_t *getopt, const char *lname)
void apriltag_detections_destroy(zarray_t *detections)
void tagCircle21h7_destroy(apriltag_family_t *tf)
void tagCustom48h12_destroy(apriltag_family_t *tf)
void apriltag_detector_destroy(apriltag_detector_t *td)
void tag25h9_destroy(apriltag_family_t *tf)
static void apriltag_detector_add_family(apriltag_detector_t *td, apriltag_family_t *fam)
apriltag_family_t * tagCircle49h12_create()
static void zarray_get(const zarray_t *za, int idx, void *p)
void getopt_add_int(getopt_t *gopt, char sopt, const char *lname, const char *def, const char *help)
int main(int argc, char *argv[])
apriltag_family_t * tag36h11_create()
int getopt_get_bool(getopt_t *getopt, const char *lname)
apriltag
Author(s): Edwin Olson
, Max Krogius
autogenerated on Sun Apr 20 2025 02:08:19