JeVoisBase  1.20
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< 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
 
Engineengine () const
 
bool initialized () const
 
const std::string & className () const
 
const std::string & 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)
 
virtual void paramInfo (std::shared_ptr< UserInterface > s, std::map< std::string, std::string > &categs, bool skipFrozen, std::string const &cname="", std::string const &pfx="")
 
void foreachParam (std::function< void(std::string const &compname, ParameterBase *p)> func, std::string const &cname="")
 
std::shared_ptr< DynamicParameter< T > > addDynamicParameter (std::string const &name, std::string const &description, T const &defaultValue, ParameterCategory const &category)
 
std::shared_ptr< DynamicParameter< T > > addDynamicParameter (std::string const &name, std::string const &description, T const &defaultValue, ValidValuesSpec< T > const &validValuesSpec, ParameterCategory const &category)
 
void setDynamicParameterCallback (std::string const &name, std::function< void(T const &)> cb, bool callnow=true)
 
void removeDynamicParameter (std::string const &name)
 
void setPath (std::string const &path)
 
std::filesystem::path absolutePath (std::filesystem::path 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
 
Engineengine () const
 
bool initialized () const
 
const std::string & className () const
 
const std::string & 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)
 
virtual void paramInfo (std::shared_ptr< UserInterface > s, std::map< std::string, std::string > &categs, bool skipFrozen, std::string const &cname="", std::string const &pfx="")
 
void foreachParam (std::function< void(std::string const &compname, ParameterBase *p)> func, std::string const &cname="")
 
std::shared_ptr< DynamicParameter< T > > addDynamicParameter (std::string const &name, std::string const &description, T const &defaultValue, ParameterCategory const &category)
 
std::shared_ptr< DynamicParameter< T > > addDynamicParameter (std::string const &name, std::string const &description, T const &defaultValue, ValidValuesSpec< T > const &validValuesSpec, ParameterCategory const &category)
 
void setDynamicParameterCallback (std::string const &name, std::function< void(T const &)> cb, bool callnow=true)
 
void removeDynamicParameter (std::string const &name)
 
void setPath (std::string const &path)
 
std::filesystem::path absolutePath (std::filesystem::path 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 .dat 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 (if relative stem) or " "from the specified absolute location (if absolute stem).", JEVOIS_SHARE_PATH "/camera/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, DictThreshMode_Values, ParamCateg)
 Parameter. More...
 
 JEVOIS_DECLARE_PARAMETER (dictionary, Dict, "Symbol dictionary to use", Dict::AR_MATRIX_CODE_3x3_PARITY65, Dict_Values, 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 25 of file ARtoolkit.C.

Member Function Documentation

◆ detectInternal()

void ARtoolkit::detectInternal ( unsigned char const *  data)
protected

◆ detectMarkers() [1/2]

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

Detect markers in an image.

Definition at line 151 of file ARtoolkit.C.

References arHandle, detectInternal(), demo::image, LFATAL, and manualinit().

◆ detectMarkers() [2/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 130 of file ARtoolkit.C.

References arHandle, detectInternal(), demo::image, 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 237 of file ARtoolkit.C.

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

Referenced by PythonObject6D.PythonObject6D::process(), and FirstPython.FirstPython::process().

◆ 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 58 of file ARtoolkit.C.

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

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 29 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 281 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 .dat 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(if relative stem) or " "from the specified absolute location(if absolute stem)."  ,
JEVOIS_SHARE_PATH "/camera/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 ( dictionary  ,
Dict  ,
"Symbol dictionary to use"  ,
Dict::AR_MATRIX_CODE_3x3_PARITY65  ,
Dict_Values  ,
ParamCateg   
)
related

Parameter.

◆ JEVOIS_DECLARE_PARAMETER() [4/5]

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

Parameter.

◆ JEVOIS_DECLARE_PARAMETER() [5/5]

JEVOIS_DECLARE_PARAMETER ( threshmode  ,
DictThreshMode  ,
"Dictionary threshold mode to  use,
affects " "robustness to varying lighting conditions"  ,
DictThreshMode::AR_LABELING_THRESH_MODE_AUTO_OTSU  ,
DictThreshMode_Values  ,
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 154 of file ARtoolkit.H.

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

◆ arHandle

ARHandle* ARtoolkit::arHandle = nullptr
protected

Definition at line 151 of file ARtoolkit.H.

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

◆ arPattHandle

ARPattHandle* ARtoolkit::arPattHandle
protected

Definition at line 152 of file ARtoolkit.H.

Referenced by manualinit(), and postUninit().

◆ gARPattDetectionMode

int ARtoolkit::gARPattDetectionMode
protected

Definition at line 153 of file ARtoolkit.H.

Referenced by manualinit().

◆ gCparamLT

ARParamLT* ARtoolkit::gCparamLT = nullptr
protected

Definition at line 155 of file ARtoolkit.H.

Referenced by manualinit(), and postUninit().

◆ itsH

unsigned int ARtoolkit::itsH
protected

Definition at line 158 of file ARtoolkit.H.

Referenced by manualinit(), and sendSerial().

◆ itsResults

std::vector<arresults> ARtoolkit::itsResults

Results of the last detection round.

Definition at line 139 of file ARtoolkit.H.

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

◆ itsW

unsigned int ARtoolkit::itsW
protected

Definition at line 158 of file ARtoolkit.H.

Referenced by manualinit(), and sendSerial().

◆ markersSquare

ARMarkerSquare* ARtoolkit::markersSquare = nullptr
protected

Definition at line 156 of file ARtoolkit.H.

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

◆ markersSquareCount

int ARtoolkit::markersSquareCount = 0
protected

Definition at line 157 of file ARtoolkit.H.

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


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