Visual Servoing Platform
version 3.7.0
Toggle main menu visibility
Loading...
Searching...
No Matches
vpDetectorAprilTag.h
1
/*
2
* ViSP, open source Visual Servoing Platform software.
3
* Copyright (C) 2005 - 2025 by Inria. All rights reserved.
4
*
5
* This software is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
9
* See the file LICENSE.txt at the root directory of this source
10
* distribution for additional information about the GNU GPL.
11
*
12
* For using ViSP with software that can not be combined with the GNU
13
* GPL, please contact Inria about acquiring a ViSP Professional
14
* Edition License.
15
*
16
* See https://visp.inria.fr for more information.
17
*
18
* This software was developed at:
19
* Inria Rennes - Bretagne Atlantique
20
* Campus Universitaire de Beaulieu
21
* 35042 Rennes Cedex
22
* France
23
*
24
* If you have questions regarding the use of this file, please contact
25
* Inria at visp@inria.fr
26
*
27
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29
*
30
* Description:
31
* Base class for AprilTag detection.
32
*/
33
#ifndef VP_DETECTOR_APRILTAG_H
34
#define VP_DETECTOR_APRILTAG_H
35
36
#include <map>
37
38
#include <visp3/core/vpConfig.h>
39
40
#ifdef VISP_HAVE_APRILTAG
41
#include <visp3/core/vpCameraParameters.h>
42
#include <visp3/core/vpColor.h>
43
#include <visp3/core/vpHomogeneousMatrix.h>
44
#include <visp3/core/vpImage.h>
45
#include <visp3/detection/vpDetectorBase.h>
46
47
BEGIN_VISP_NAMESPACE
261
class
VISP_EXPORT
vpDetectorAprilTag
:
public
vpDetectorBase
262
{
263
public
:
264
enum
vpAprilTagFamily
265
{
266
TAG_36h11
,
267
TAG_36h10
,
268
TAG_36ARTOOLKIT
,
269
TAG_25h9
,
270
TAG_25h7
,
271
TAG_16h5
,
272
TAG_CIRCLE21h7
,
273
TAG_CIRCLE49h12
,
274
TAG_CUSTOM48h12
,
275
TAG_STANDARD41h12
,
276
TAG_STANDARD52h13
,
277
TAG_ARUCO_4x4_50
,
281
TAG_ARUCO_4x4_100
,
285
TAG_ARUCO_4x4_250
,
289
TAG_ARUCO_4x4_1000
,
293
TAG_ARUCO_5x5_50
,
297
TAG_ARUCO_5x5_100
,
301
TAG_ARUCO_5x5_250
,
305
TAG_ARUCO_5x5_1000
,
309
TAG_ARUCO_6x6_50
,
313
TAG_ARUCO_6x6_100
,
317
TAG_ARUCO_6x6_250
,
321
TAG_ARUCO_6x6_1000
,
325
TAG_ARUCO_7x7_50
,
329
TAG_ARUCO_7x7_100
,
333
TAG_ARUCO_7x7_250
,
337
TAG_ARUCO_7x7_1000
,
341
TAG_ARUCO_MIP_36h12
344
};
345
346
enum
vpPoseEstimationMethod
347
{
348
HOMOGRAPHY
,
349
HOMOGRAPHY_VIRTUAL_VS
,
351
DEMENTHON_VIRTUAL_VS
,
353
LAGRANGE_VIRTUAL_VS
,
355
BEST_RESIDUAL_VIRTUAL_VS
,
358
HOMOGRAPHY_ORTHOGONAL_ITERATION
359
};
360
361
vpDetectorAprilTag
(
const
vpAprilTagFamily &tagFamily = TAG_36h11,
362
const
vpPoseEstimationMethod &poseEstimationMethod = HOMOGRAPHY_VIRTUAL_VS);
363
vpDetectorAprilTag
(
const
vpDetectorAprilTag
&o);
364
vpDetectorAprilTag
&operator=(
vpDetectorAprilTag
o);
365
virtual
~vpDetectorAprilTag
() VP_OVERRIDE;
366
bool
detect(const
vpImage
<
unsigned
char
> &I) VP_OVERRIDE;
367
368
bool
detect(const
vpImage
<
unsigned
char
> &I,
double
tagSize, const
vpCameraParameters
&cam,
369
std::vector<
vpHomogeneousMatrix
> &cMo_vec, std::vector<
vpHomogeneousMatrix
> *cMo_vec2 =
nullptr
,
370
std::vector<
double
> *projErrors =
nullptr
, std::vector<
double
> *projErrors2 =
nullptr
);
371
372
void
displayFrames(const
vpImage
<
unsigned
char
> &I, const std::vector<
vpHomogeneousMatrix
> &cMo_vec,
373
const
vpCameraParameters
&cam,
double
size, const
vpColor
&color,
unsigned
int
thickness = 1) const;
374
void
displayFrames(const
vpImage
<
vpRGBa
> &I, const std::vector<
vpHomogeneousMatrix
> &cMo_vec,
375
const
vpCameraParameters
&cam,
double
size, const
vpColor
&color,
unsigned
int
thickness = 1) const;
376
377
void
displayTags(const
vpImage
<
unsigned
char
> &I, const std::vector<std::vector<
vpImagePoint
> > &tagsCorners,
378
const
vpColor
&color =
vpColor
::none,
unsigned
int
thickness = 1) const;
379
void
displayTags(const
vpImage
<
vpRGBa
> &I, const std::vector<std::vector<
vpImagePoint
> > &tagsCorners,
380
const
vpColor
&color =
vpColor
::none,
unsigned
int
thickness = 1) const;
381
382
float
getAprilTagDecisionMarginThreshold() const;
383
int
getAprilTagHammingDistanceThreshold() const;
384
bool
getPose(
size_t
tagIndex,
double
tagSize, const
vpCameraParameters
&cam,
vpHomogeneousMatrix
&cMo,
385
vpHomogeneousMatrix
*cMo2 =
nullptr
,
double
*projError =
nullptr
,
double
*projError2 =
nullptr
);
386
390
inline
vpPoseEstimationMethod
getPoseEstimationMethod
()
const
{
return
m_poseEstimationMethod
; }
391
392
bool
getTagImage(
vpImage<unsigned char>
&I,
int
id
);
393
std::vector<std::vector<vpImagePoint> > getTagsCorners()
const
;
394
std::vector<float> getTagsDecisionMargin()
const
;
395
std::vector<int> getTagsHammingDistance()
const
;
396
std::vector<int> getTagsId()
const
;
397
std::vector<std::vector<vpPoint> > getTagsPoints3D(
const
std::vector<int> &tagsId,
398
const
std::map<int, double> &tagsSize)
const
;
399
400
bool
isZAlignedWithCameraAxis()
const
;
401
402
void
setAprilTagDebugOption(
bool
flag);
403
void
setAprilTagDecisionMarginThreshold(
float
decisionMarginThreshold);
404
void
setAprilTagDecodeSharpening(
double
decodeSharpening);
405
void
setAprilTagFamily(
const
vpAprilTagFamily &tagFamily);
406
void
setAprilTagHammingDistanceThreshold(
int
hammingDistanceThreshold);
407
void
setAprilTagNbThreads(
int
nThreads);
408
void
setAprilTagPoseEstimationMethod(
const
vpPoseEstimationMethod &poseEstimationMethod);
409
void
setAprilTagQuadDecimate(
float
quadDecimate);
410
void
setAprilTagQuadSigma(
float
quadSigma);
411
void
setAprilTagRefineEdges(
bool
refineEdges);
412
413
416
inline
void
setDisplayTag
(
bool
display,
const
vpColor
&color =
vpColor::none
,
unsigned
int
thickness = 2)
417
{
418
m_displayTag
= display;
419
m_displayTagColor
= color;
420
m_displayTagThickness
= thickness;
421
}
422
423
inline
friend
void
swap
(
vpDetectorAprilTag
&o1,
vpDetectorAprilTag
&o2)
424
{
425
using
std::swap;
426
swap
(o1.m_impl, o2.m_impl);
427
}
428
429
void
setZAlignedWithCameraAxis(
bool
zAlignedWithCameraFrame);
430
431
#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS)
436
VP_DEPRECATED void setAprilTagRefinePose(bool refinePose);
437
VP_DEPRECATED
void
setAprilTagRefineDecode(
bool
refineDecode);
439
#endif
440
441
protected
:
442
bool
m_displayTag
;
443
vpColor
m_displayTagColor
;
444
unsigned
int
m_displayTagThickness
;
445
vpPoseEstimationMethod
m_poseEstimationMethod
;
446
vpAprilTagFamily
m_tagFamily
;
447
448
private
:
449
vpCameraParameters
m_defaultCam;
450
451
// PIMPL idiom
452
class
Impl;
453
Impl *m_impl;
454
};
455
456
inline
std::ostream &operator<<(std::ostream &os,
const
vpDetectorAprilTag::vpPoseEstimationMethod
&method)
457
{
458
switch
(method) {
459
case
vpDetectorAprilTag::HOMOGRAPHY
:
460
os <<
"HOMOGRAPHY"
;
461
break
;
462
463
case
vpDetectorAprilTag::HOMOGRAPHY_VIRTUAL_VS
:
464
os <<
"HOMOGRAPHY_VIRTUAL_VS"
;
465
break
;
466
467
case
vpDetectorAprilTag::DEMENTHON_VIRTUAL_VS
:
468
os <<
"DEMENTHON_VIRTUAL_VS"
;
469
break
;
470
471
case
vpDetectorAprilTag::LAGRANGE_VIRTUAL_VS
:
472
os <<
"LAGRANGE_VIRTUAL_VS"
;
473
break
;
474
475
case
vpDetectorAprilTag::BEST_RESIDUAL_VIRTUAL_VS
:
476
os <<
"BEST_RESIDUAL_VIRTUAL_VS"
;
477
break
;
478
479
case
vpDetectorAprilTag::HOMOGRAPHY_ORTHOGONAL_ITERATION
:
480
os <<
"HOMOGRAPHY_ORTHOGONAL_ITERATION"
;
481
break
;
482
483
default
:
484
os <<
"ERROR_UNKNOWN_POSE_METHOD!"
;
485
break
;
486
}
487
488
return
os;
489
}
490
491
inline
std::ostream &operator<<(std::ostream &os,
const
vpDetectorAprilTag::vpAprilTagFamily
&tagFamily)
492
{
493
switch
(tagFamily) {
494
case
vpDetectorAprilTag::TAG_36h11
:
495
os <<
"36h11"
;
496
break
;
497
498
case
vpDetectorAprilTag::TAG_36h10
:
499
os <<
"36h10"
;
500
break
;
501
502
case
vpDetectorAprilTag::TAG_36ARTOOLKIT
:
503
os <<
"36artoolkit"
;
504
break
;
505
506
case
vpDetectorAprilTag::TAG_25h9
:
507
os <<
"25h9"
;
508
break
;
509
510
case
vpDetectorAprilTag::TAG_25h7
:
511
os <<
"25h7"
;
512
break
;
513
514
case
vpDetectorAprilTag::TAG_16h5
:
515
os <<
"16h5"
;
516
break
;
517
518
case
vpDetectorAprilTag::TAG_CIRCLE21h7
:
519
os <<
"CIRCLE21h7"
;
520
break
;
521
522
case
vpDetectorAprilTag::TAG_CIRCLE49h12
:
523
os <<
"CIRCLE49h12"
;
524
break
;
525
526
case
vpDetectorAprilTag::TAG_CUSTOM48h12
:
527
os <<
"CUSTOM48h12"
;
528
break
;
529
530
case
vpDetectorAprilTag::TAG_STANDARD52h13
:
531
os <<
"STANDARD52h13"
;
532
break
;
533
534
case
vpDetectorAprilTag::TAG_STANDARD41h12
:
535
os <<
"STANDARD41h12"
;
536
break
;
537
538
case
vpDetectorAprilTag::TAG_ARUCO_4x4_50
:
539
os <<
"TAG_ARUCO_4x4_50"
;
540
break
;
541
542
case
vpDetectorAprilTag::TAG_ARUCO_4x4_100
:
543
os <<
"TAG_ARUCO_4x4_100"
;
544
break
;
545
546
case
vpDetectorAprilTag::TAG_ARUCO_4x4_250
:
547
os <<
"TAG_ARUCO_4x4_250"
;
548
break
;
549
550
case
vpDetectorAprilTag::TAG_ARUCO_4x4_1000
:
551
os <<
"TAG_ARUCO_4x4_1000"
;
552
break
;
553
554
case
vpDetectorAprilTag::TAG_ARUCO_5x5_50
:
555
os <<
"TAG_ARUCO_5x5_50"
;
556
break
;
557
558
case
vpDetectorAprilTag::TAG_ARUCO_5x5_100
:
559
os <<
"TAG_ARUCO_5x5_100"
;
560
break
;
561
562
case
vpDetectorAprilTag::TAG_ARUCO_5x5_250
:
563
os <<
"TAG_ARUCO_5x5_250"
;
564
break
;
565
566
case
vpDetectorAprilTag::TAG_ARUCO_5x5_1000
:
567
os <<
"TAG_ARUCO_5x5_1000"
;
568
break
;
569
570
case
vpDetectorAprilTag::TAG_ARUCO_6x6_50
:
571
os <<
"TAG_ARUCO_6x6_50"
;
572
break
;
573
574
case
vpDetectorAprilTag::TAG_ARUCO_6x6_100
:
575
os <<
"TAG_ARUCO_6x6_100"
;
576
break
;
577
578
case
vpDetectorAprilTag::TAG_ARUCO_6x6_250
:
579
os <<
"TAG_ARUCO_6x6_250"
;
580
break
;
581
582
case
vpDetectorAprilTag::TAG_ARUCO_6x6_1000
:
583
os <<
"TAG_ARUCO_6x6_1000"
;
584
break
;
585
586
case
vpDetectorAprilTag::TAG_ARUCO_7x7_50
:
587
os <<
"TAG_ARUCO_7x7_50"
;
588
break
;
589
590
case
vpDetectorAprilTag::TAG_ARUCO_7x7_100
:
591
os <<
"TAG_ARUCO_7x7_100"
;
592
break
;
593
594
case
vpDetectorAprilTag::TAG_ARUCO_7x7_250
:
595
os <<
"TAG_ARUCO_7x7_250"
;
596
break
;
597
598
case
vpDetectorAprilTag::TAG_ARUCO_7x7_1000
:
599
os <<
"TAG_ARUCO_7x7_1000"
;
600
break
;
601
602
case
vpDetectorAprilTag::TAG_ARUCO_MIP_36h12
:
603
os <<
"TAG_ARUCO_MIP_36h12"
;
604
break
;
605
606
default
:
607
os <<
"UNKNOWN"
;
608
break
;
609
}
610
611
return
os;
612
}
613
614
END_VISP_NAMESPACE
615
616
#endif
617
#endif
vpCameraParameters
Generic class defining intrinsic camera parameters.
Definition
vpCameraParameters.h:311
vpColor
Class to define RGB colors available for display functionalities.
Definition
vpColor.h:157
vpColor::none
static const vpColor none
Definition
vpColor.h:210
vpDetectorAprilTag
Definition
vpDetectorAprilTag.h:262
vpDetectorAprilTag::vpPoseEstimationMethod
vpPoseEstimationMethod
Definition
vpDetectorAprilTag.h:347
vpDetectorAprilTag::LAGRANGE_VIRTUAL_VS
@ LAGRANGE_VIRTUAL_VS
Definition
vpDetectorAprilTag.h:353
vpDetectorAprilTag::DEMENTHON_VIRTUAL_VS
@ DEMENTHON_VIRTUAL_VS
Definition
vpDetectorAprilTag.h:351
vpDetectorAprilTag::HOMOGRAPHY_VIRTUAL_VS
@ HOMOGRAPHY_VIRTUAL_VS
Definition
vpDetectorAprilTag.h:349
vpDetectorAprilTag::BEST_RESIDUAL_VIRTUAL_VS
@ BEST_RESIDUAL_VIRTUAL_VS
Definition
vpDetectorAprilTag.h:355
vpDetectorAprilTag::HOMOGRAPHY
@ HOMOGRAPHY
Definition
vpDetectorAprilTag.h:348
vpDetectorAprilTag::HOMOGRAPHY_ORTHOGONAL_ITERATION
@ HOMOGRAPHY_ORTHOGONAL_ITERATION
Definition
vpDetectorAprilTag.h:358
vpDetectorAprilTag::setDisplayTag
void setDisplayTag(bool display, const vpColor &color=vpColor::none, unsigned int thickness=2)
Definition
vpDetectorAprilTag.h:416
vpDetectorAprilTag::m_displayTag
bool m_displayTag
Definition
vpDetectorAprilTag.h:442
vpDetectorAprilTag::swap
friend void swap(vpDetectorAprilTag &o1, vpDetectorAprilTag &o2)
Definition
vpDetectorAprilTag.h:423
vpDetectorAprilTag::getPoseEstimationMethod
vpPoseEstimationMethod getPoseEstimationMethod() const
Definition
vpDetectorAprilTag.h:390
vpDetectorAprilTag::vpDetectorAprilTag
vpDetectorAprilTag(const vpAprilTagFamily &tagFamily=TAG_36h11, const vpPoseEstimationMethod &poseEstimationMethod=HOMOGRAPHY_VIRTUAL_VS)
Definition
vpDetectorAprilTag.cpp:1169
vpDetectorAprilTag::m_displayTagThickness
unsigned int m_displayTagThickness
Definition
vpDetectorAprilTag.h:444
vpDetectorAprilTag::m_tagFamily
vpAprilTagFamily m_tagFamily
Definition
vpDetectorAprilTag.h:446
vpDetectorAprilTag::m_poseEstimationMethod
vpPoseEstimationMethod m_poseEstimationMethod
Definition
vpDetectorAprilTag.h:445
vpDetectorAprilTag::vpAprilTagFamily
vpAprilTagFamily
Definition
vpDetectorAprilTag.h:265
vpDetectorAprilTag::TAG_ARUCO_4x4_250
@ TAG_ARUCO_4x4_250
Definition
vpDetectorAprilTag.h:285
vpDetectorAprilTag::TAG_ARUCO_6x6_50
@ TAG_ARUCO_6x6_50
Definition
vpDetectorAprilTag.h:309
vpDetectorAprilTag::TAG_ARUCO_7x7_1000
@ TAG_ARUCO_7x7_1000
Definition
vpDetectorAprilTag.h:337
vpDetectorAprilTag::TAG_ARUCO_5x5_50
@ TAG_ARUCO_5x5_50
Definition
vpDetectorAprilTag.h:293
vpDetectorAprilTag::TAG_ARUCO_5x5_1000
@ TAG_ARUCO_5x5_1000
Definition
vpDetectorAprilTag.h:305
vpDetectorAprilTag::TAG_CIRCLE21h7
@ TAG_CIRCLE21h7
AprilTag Circle21h7 pattern.
Definition
vpDetectorAprilTag.h:272
vpDetectorAprilTag::TAG_ARUCO_6x6_250
@ TAG_ARUCO_6x6_250
Definition
vpDetectorAprilTag.h:317
vpDetectorAprilTag::TAG_25h7
@ TAG_25h7
DEPRECATED AND POOR DETECTION PERFORMANCE.
Definition
vpDetectorAprilTag.h:270
vpDetectorAprilTag::TAG_ARUCO_MIP_36h12
@ TAG_ARUCO_MIP_36h12
Definition
vpDetectorAprilTag.h:341
vpDetectorAprilTag::TAG_36ARTOOLKIT
@ TAG_36ARTOOLKIT
DEPRECATED AND WILL NOT DETECT ARTOOLKIT TAGS.
Definition
vpDetectorAprilTag.h:268
vpDetectorAprilTag::TAG_ARUCO_4x4_100
@ TAG_ARUCO_4x4_100
Definition
vpDetectorAprilTag.h:281
vpDetectorAprilTag::TAG_ARUCO_5x5_250
@ TAG_ARUCO_5x5_250
Definition
vpDetectorAprilTag.h:301
vpDetectorAprilTag::TAG_25h9
@ TAG_25h9
AprilTag 25h9 pattern.
Definition
vpDetectorAprilTag.h:269
vpDetectorAprilTag::TAG_ARUCO_7x7_250
@ TAG_ARUCO_7x7_250
Definition
vpDetectorAprilTag.h:333
vpDetectorAprilTag::TAG_ARUCO_7x7_100
@ TAG_ARUCO_7x7_100
Definition
vpDetectorAprilTag.h:329
vpDetectorAprilTag::TAG_CUSTOM48h12
@ TAG_CUSTOM48h12
AprilTag Custom48h12 pattern.
Definition
vpDetectorAprilTag.h:274
vpDetectorAprilTag::TAG_ARUCO_4x4_1000
@ TAG_ARUCO_4x4_1000
Definition
vpDetectorAprilTag.h:289
vpDetectorAprilTag::TAG_ARUCO_7x7_50
@ TAG_ARUCO_7x7_50
Definition
vpDetectorAprilTag.h:325
vpDetectorAprilTag::TAG_36h11
@ TAG_36h11
AprilTag 36h11 pattern (recommended).
Definition
vpDetectorAprilTag.h:266
vpDetectorAprilTag::TAG_ARUCO_5x5_100
@ TAG_ARUCO_5x5_100
Definition
vpDetectorAprilTag.h:297
vpDetectorAprilTag::TAG_ARUCO_6x6_100
@ TAG_ARUCO_6x6_100
Definition
vpDetectorAprilTag.h:313
vpDetectorAprilTag::TAG_36h10
@ TAG_36h10
DEPRECATED.
Definition
vpDetectorAprilTag.h:267
vpDetectorAprilTag::TAG_STANDARD52h13
@ TAG_STANDARD52h13
AprilTag Standard52h13 pattern.
Definition
vpDetectorAprilTag.h:276
vpDetectorAprilTag::TAG_ARUCO_6x6_1000
@ TAG_ARUCO_6x6_1000
Definition
vpDetectorAprilTag.h:321
vpDetectorAprilTag::TAG_ARUCO_4x4_50
@ TAG_ARUCO_4x4_50
Definition
vpDetectorAprilTag.h:277
vpDetectorAprilTag::TAG_16h5
@ TAG_16h5
AprilTag 16h5 pattern.
Definition
vpDetectorAprilTag.h:271
vpDetectorAprilTag::TAG_STANDARD41h12
@ TAG_STANDARD41h12
AprilTag Standard41h12 pattern.
Definition
vpDetectorAprilTag.h:275
vpDetectorAprilTag::TAG_CIRCLE49h12
@ TAG_CIRCLE49h12
AprilTag Circle49h12 pattern.
Definition
vpDetectorAprilTag.h:273
vpDetectorAprilTag::m_displayTagColor
vpColor m_displayTagColor
Definition
vpDetectorAprilTag.h:443
vpDetectorBase::vpDetectorBase
vpDetectorBase()
Definition
vpDetectorBase.cpp:41
vpHomogeneousMatrix
Implementation of an homogeneous matrix and operations on such kind of matrices.
Definition
vpHomogeneousMatrix.h:221
vpImagePoint
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition
vpImagePoint.h:82
vpImage
Definition of the vpImage class member functions.
Definition
vpImage.h:131
vpRGBa
Definition
vpRGBa.h:74
BEGIN_VISP_NAMESPACE
Definition
vpMbtDistanceCircle.cpp:55
modules
detection
include
visp3
detection
vpDetectorAprilTag.h
Generated by
1.17.0