JeVoisBase  1.6
JeVois Smart Embedded Machine Vision Toolkit Base Modules
Share this page:
ARtoolkit Class Reference

Augmented reality markers using ARtoolkit. More...

#include <jevoisbase/Components/ARtoolkit/ARtoolkit.H>

Inheritance diagram for ARtoolkit:
Collaboration diagram for ARtoolkit:

Classes

struct  arresults
 

Public Member Functions

void postInit () override
 Core initialization. More...
 
void postUninit () override
 
 ~ARtoolkit ()
 Destructor. More...
 
void detectMarkers (jevois::RawImage const &image)
 Detect markers in an image. More...
 
void detectMarkers (cv::Mat const &image)
 Detect markers in an image. More...
 
void drawDetections (jevois::RawImage &outimg, int txtx=-1, int txty=-1)
 Draw any markers previously detected by detectMarkers() More...
 
void sendSerial (jevois::StdModule *mod)
 Send serial messages about detections. More...
 
- Public Member Functions inherited from jevois::Component
 Component (std::string const &instance)
 
virtual ~Component ()
 
std::shared_ptr< ComponentgetSubComponent (std::string const &instance) const
 
std::shared_ptr< Comp > addSubComponent (std::string const &instance, Args &&...args)
 
void removeSubComponent (std::shared_ptr< Comp > &component)
 
void removeSubComponent (std::string const &instance, bool warnIfNotFound=true)
 
std::shared_ptr< Comp > getSubComponent (std::string const &instance) const
 
bool isTopLevel () const
 
bool initialized () const
 
std::string const & className () const
 
std::string const & instanceName () const
 
std::vector< std::string > setParamVal (std::string const &paramdescriptor, T const &val)
 
void setParamValUnique (std::string const &paramdescriptor, T const &val)
 
std::vector< std::pair< std::string, T > > getParamVal (std::string const &paramdescriptor) const
 
getParamValUnique (std::string const &paramdescriptor) const
 
std::vector< std::string > setParamString (std::string const &paramdescriptor, std::string const &val)
 
void setParamStringUnique (std::string const &paramdescriptor, std::string const &val)
 
std::vector< std::pair< std::string, std::string > > getParamString (std::string const &paramdescriptor) const
 
std::string getParamStringUnique (std::string const &paramdescriptor) const
 
void freezeParam (std::string const &paramdescriptor)
 
void unFreezeParam (std::string const &paramdescriptor)
 
void freezeAllParams ()
 
void unFreezeAllParams ()
 
std::string descriptor () const
 
void setParamsFromFile (std::string const &filename)
 
std::istream & setParamsFromStream (std::istream &is, std::string const &absfile)
 
void setPath (std::string const &path)
 
std::string absolutePath (std::string const &path="")
 
std::shared_ptr< Comp > addSubComponent (std::string const &instance, Args &&...args)
 
void removeSubComponent (std::shared_ptr< Comp > &component)
 
void removeSubComponent (std::string const &instance, bool warnIfNotFound=true)
 
std::shared_ptr< Comp > getSubComponent (std::string const &instance) const
 
bool isTopLevel () const
 
bool initialized () const
 
std::string const & className () const
 
std::string const & instanceName () const
 
std::vector< std::string > setParamVal (std::string const &paramdescriptor, T const &val)
 
void setParamValUnique (std::string const &paramdescriptor, T const &val)
 
std::vector< std::pair< std::string, T > > getParamVal (std::string const &paramdescriptor) const
 
getParamValUnique (std::string const &paramdescriptor) const
 
std::vector< std::string > setParamString (std::string const &paramdescriptor, std::string const &val)
 
void setParamStringUnique (std::string const &paramdescriptor, std::string const &val)
 
std::vector< std::pair< std::string, std::string > > getParamString (std::string const &paramdescriptor) const
 
std::string getParamStringUnique (std::string const &paramdescriptor) const
 
void freezeParam (std::string const &paramdescriptor)
 
void unFreezeParam (std::string const &paramdescriptor)
 
void freezeAllParams ()
 
void unFreezeAllParams ()
 
std::string descriptor () const
 
void setParamsFromFile (std::string const &filename)
 
std::istream & setParamsFromStream (std::istream &is, std::string const &absfile)
 
void setPath (std::string const &path)
 
std::string absolutePath (std::string const &path="")
 
- Public Member Functions inherited from jevois::ParameterRegistry
virtual ~ParameterRegistry ()
 

Public Attributes

std::vector< arresultsitsResults
 Results of the last detection round. More...
 

Protected Member Functions

void manualinit (int w, int h, AR_PIXEL_FORMAT pixformat)
 Manual initialization which should be run on first frame once its size is known. More...
 
void detectInternal (unsigned char const *data)
 
- Protected Member Functions inherited from jevois::Component
virtual void preInit ()
 
virtual void preUninit ()
 
virtual void preInit ()
 
virtual void preUninit ()
 
- Protected Member Functions inherited from jevois::ParameterRegistry
void addParameter (ParameterBase *const param)
 
void removeParameter (ParameterBase *const param)
 
void callbackInitCall ()
 

Protected Attributes

ARHandle * arHandle = nullptr
 
ARPattHandle * arPattHandle
 
int gARPattDetectionMode
 
AR3DHandle * ar3DHandle
 
ARParamLT * gCparamLT = nullptr
 
ARMarkerSquaremarkersSquare = nullptr
 
int markersSquareCount = 0
 
unsigned int itsW
 
unsigned int itsH
 

Related Functions

(Note that these are not member functions.)

 JEVOIS_DECLARE_PARAMETER (camparams, std::string, "File stem of camera parameters, or empty. Camera resolution " "will be appended, as well as a .cfg extension. For example, specifying 'camera_para' " "here and running the camera sensor at 320x240 will attempt to load " "camera_para320x240.dat from within the module's directory.", "camera_para", ParamCateg)
 Parameter. More...
 
 JEVOIS_DECLARE_PARAMETER (contpose, bool, "Use continuous pose estimation in good quality video", true, ParamCateg)
 Parameter. More...
 
 JEVOIS_DECLARE_PARAMETER (msg3d, bool, "Send 3D serial messages if true, otherwise 2D", false, ParamCateg)
 Parameter. More...
 
 JEVOIS_DEFINE_ENUM_CLASS (Dict,(AR_MATRIX_CODE_3x3)(AR_MATRIX_CODE_3x3_HAMMING63)(AR_MATRIX_CODE_3x3_PARITY65))
 Enum for parameter. More...
 
 JEVOIS_DECLARE_PARAMETER (threshmode, DictThreshMode, "Dictionary threshold mode to use, affects " "robustness to varying lighting conditions", DictThreshMode::AR_LABELING_THRESH_MODE_AUTO_OTSU, ParamCateg)
 Parameter. More...
 
 JEVOIS_DECLARE_PARAMETER (dictionary, Dict, "Symbol dictionary to use", Dict::AR_MATRIX_CODE_3x3_PARITY65, ParamCateg)
 Parameter. More...
 

Detailed Description

Augmented reality markers using ARtoolkit.

Detect and decode patterns known as ARtoolkit markers, which are small 2D barcodes often used in augmented reality and robotics.

Definition at line 87 of file ARtoolkit.H.

Constructor & Destructor Documentation

◆ ~ARtoolkit()

ARtoolkit::~ARtoolkit ( )

Destructor.

Definition at line 23 of file ARtoolkit.C.

Member Function Documentation

◆ detectInternal()

◆ detectMarkers() [1/2]

void ARtoolkit::detectMarkers ( jevois::RawImage const &  image)

Detect markers in an image.

Probably the fastest if you have not already converted your input image to cv::Mat

Definition at line 129 of file ARtoolkit.C.

References arHandle, detectInternal(), jevois::RawImage::fmt, jevois::RawImage::height, LFATAL, manualinit(), jevois::RawImage::pixels(), and jevois::RawImage::width.

◆ detectMarkers() [2/2]

void ARtoolkit::detectMarkers ( cv::Mat const &  image)

Detect markers in an image.

Definition at line 150 of file ARtoolkit.C.

References arHandle, detectInternal(), LFATAL, and manualinit().

◆ drawDetections()

void ARtoolkit::drawDetections ( jevois::RawImage outimg,
int  txtx = -1,
int  txty = -1 
)

Draw any markers previously detected by detectMarkers()

If txtx,txty are positive, also print a text string there

Definition at line 236 of file ARtoolkit.C.

References jevois::rawimage::drawCircle(), jevois::rawimage::drawLine(), itsResults, to_string(), and jevois::rawimage::writeText().

◆ manualinit()

void ARtoolkit::manualinit ( int  w,
int  h,
AR_PIXEL_FORMAT  pixformat 
)
protected

Manual initialization which should be run on first frame once its size is known.

pixformat should be AR_PIXEL_FORMAT_BGR, AR_PIXEL_FORMAT_RGB_565, etc

Definition at line 57 of file ARtoolkit.C.

References jevois::Component::absolutePath(), ar3DHandle, arHandle, arPattHandle, gARPattDetectionMode, gCparamLT, itsH, itsW, LFATAL, markersSquare, markersSquareCount, newMarkers(), and to_string().

Referenced by detectMarkers().

◆ postInit()

void ARtoolkit::postInit ( )
overridevirtual

Core initialization.

Note that initialization is only partial and will complete once the frame size and format is known at the first call to detectMarkers()

Reimplemented from jevois::Component.

Definition at line 27 of file ARtoolkit.C.

References freeze().

◆ postUninit()

void ARtoolkit::postUninit ( )
overridevirtual

◆ sendSerial()

void ARtoolkit::sendSerial ( jevois::StdModule mod)

Send serial messages about detections.

The module given should be the owner of this component, we will use it to actually send each serial message using some variant of jevois::Module::sendSetial().

Definition at line 259 of file ARtoolkit.C.

References itsH, itsResults, itsW, jevois::StdModule::sendSerialContour2D(), jevois::StdModule::sendSerialStd3D(), and to_string().

Friends And Related Function Documentation

◆ JEVOIS_DECLARE_PARAMETER() [1/5]

JEVOIS_DECLARE_PARAMETER ( camparams  ,
std::string  ,
"File stem of camera  parameters,
or empty. Camera resolution " "will be  appended,
as well as a .cfg extension. For  example,
specifying 'camera_para' " "here and running the camera sensor at 320x240 will attempt to load " "camera_para320x240.dat from within the module 's directory."  ,
"camera_para"  ,
ParamCateg   
)
related

Parameter.

◆ JEVOIS_DECLARE_PARAMETER() [2/5]

JEVOIS_DECLARE_PARAMETER ( contpose  ,
bool  ,
"Use continuous pose estimation in good quality video"  ,
true  ,
ParamCateg   
)
related

Parameter.

◆ JEVOIS_DECLARE_PARAMETER() [3/5]

JEVOIS_DECLARE_PARAMETER ( msg3d  ,
bool  ,
"Send 3D serial messages if  true,
otherwise 2D"  ,
false  ,
ParamCateg   
)
related

Parameter.

◆ JEVOIS_DECLARE_PARAMETER() [4/5]

JEVOIS_DECLARE_PARAMETER ( threshmode  ,
DictThreshMode  ,
"Dictionary threshold mode to  use,
affects " "robustness to varying lighting conditions"  ,
DictThreshMode::AR_LABELING_THRESH_MODE_AUTO_OTSU  ,
ParamCateg   
)
related

Parameter.

◆ JEVOIS_DECLARE_PARAMETER() [5/5]

JEVOIS_DECLARE_PARAMETER ( dictionary  ,
Dict  ,
"Symbol dictionary to use"  ,
Dict::AR_MATRIX_CODE_3x3_PARITY65  ,
ParamCateg   
)
related

Parameter.

◆ JEVOIS_DEFINE_ENUM_CLASS()

JEVOIS_DEFINE_ENUM_CLASS ( Dict  ,
(AR_MATRIX_CODE_3x3)(AR_MATRIX_CODE_3x3_HAMMING63)(AR_MATRIX_CODE_3x3_PARITY65)   
)
related

Enum for parameter.

dictionary to use according to the ARtoolkit AR_MATRIX_CODE_3x3 support 64 markers AR_MATRIX_CODE_3x3_HAMMING63 support 7 markers AR_MATRIX_CODE_3x3_PARITY65 support 32 markers the smaller the # of marker => larger distance between markers => better performance

Member Data Documentation

◆ ar3DHandle

AR3DHandle* ARtoolkit::ar3DHandle
protected

Definition at line 149 of file ARtoolkit.H.

Referenced by detectInternal(), manualinit(), and postUninit().

◆ arHandle

ARHandle* ARtoolkit::arHandle = nullptr
protected

Definition at line 146 of file ARtoolkit.H.

Referenced by detectInternal(), detectMarkers(), manualinit(), and postUninit().

◆ arPattHandle

ARPattHandle* ARtoolkit::arPattHandle
protected

Definition at line 147 of file ARtoolkit.H.

Referenced by manualinit(), and postUninit().

◆ gARPattDetectionMode

int ARtoolkit::gARPattDetectionMode
protected

Definition at line 148 of file ARtoolkit.H.

Referenced by manualinit().

◆ gCparamLT

ARParamLT* ARtoolkit::gCparamLT = nullptr
protected

Definition at line 150 of file ARtoolkit.H.

Referenced by manualinit(), and postUninit().

◆ itsH

unsigned int ARtoolkit::itsH
protected

Definition at line 153 of file ARtoolkit.H.

Referenced by manualinit(), and sendSerial().

◆ itsResults

std::vector<arresults> ARtoolkit::itsResults

Results of the last detection round.

Definition at line 134 of file ARtoolkit.H.

Referenced by detectInternal(), drawDetections(), and sendSerial().

◆ itsW

unsigned int ARtoolkit::itsW
protected

Definition at line 153 of file ARtoolkit.H.

Referenced by manualinit(), and sendSerial().

◆ markersSquare

ARMarkerSquare* ARtoolkit::markersSquare = nullptr
protected

Definition at line 151 of file ARtoolkit.H.

Referenced by detectInternal(), manualinit(), and postUninit().

◆ markersSquareCount

int ARtoolkit::markersSquareCount = 0
protected

Definition at line 152 of file ARtoolkit.H.

Referenced by detectInternal(), manualinit(), and postUninit().


The documentation for this class was generated from the following files: