JeVoisBase  1.22
JeVois Smart Embedded Machine Vision Toolkit Base Modules
Share this page:
Loading...
Searching...
No Matches
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.
 
void postUninit () override
 
 ~ARtoolkit ()
 Destructor.
 
void detectMarkers (jevois::RawImage const &image)
 Detect markers in an image.
 
void detectMarkers (cv::Mat const &image)
 Detect markers in an image.
 
void drawDetections (jevois::RawImage &outimg, int txtx=-1, int txty=-1)
 Draw any markers previously detected by detectMarkers()
 
void drawDetections (jevois::GUIhelper &helper)
 Draw any markers previously detected by detectMarkers() using ImGui.
 
void sendSerial (jevois::StdModule *mod)
 Send serial messages about detections.
 
- 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
 
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, bool doit)
 
void freezeAllParams (bool doit)
 
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, bool throw_if_not_found=true)
 
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
 
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, bool doit)
 
void freezeAllParams (bool doit)
 
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, bool throw_if_not_found=true)
 
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.
 

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.
 
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 Symbols

(Note that these are not member symbols.)

 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.
 
 JEVOIS_DECLARE_PARAMETER (contpose, bool, "Use continuous pose estimation in good quality video", true, ParamCateg)
 Parameter.
 
 JEVOIS_DECLARE_PARAMETER (msg3d, bool, "Send 3D serial messages if true, otherwise 2D", false, ParamCateg)
 Parameter.
 
 JEVOIS_DEFINE_ENUM_CLASS (Dict,(AR_MATRIX_CODE_3x3)(AR_MATRIX_CODE_3x3_HAMMING63)(AR_MATRIX_CODE_3x3_PARITY65))
 Enum for parameter.
 
 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.
 
 JEVOIS_DECLARE_PARAMETER (dictionary, Dict, "Symbol dictionary to use", Dict::AR_MATRIX_CODE_3x3_PARITY65, Dict_Values, ParamCateg)
 Parameter.
 

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 82 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(), 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(), LFATAL, and manualinit().

◆ drawDetections() [1/2]

void ARtoolkit::drawDetections ( jevois::GUIhelper helper)

Draw any markers previously detected by detectMarkers() using ImGui.

Detections are drawn to scale on the last image drawn by the helper.

Definition at line 261 of file ARtoolkit.C.

References jevois::GUIhelper::drawCircle(), jevois::GUIhelper::drawPoly(), jevois::GUIhelper::drawText(), jevois::GUIhelper::itext(), and itsResults.

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

◆ drawDetections() [2/2]

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, jevois::yuyv::LightPink, jevois::yuyv::White, and jevois::rawimage::writeText().

Referenced by FirstPython.FirstPython::process(), and PythonObject6D.PythonObject6D::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, and newMarkers().

Referenced by detectMarkers(), and 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.

◆ postUninit()

void ARtoolkit::postUninit ( )
overridevirtual

Reimplemented from jevois::Component.

Definition at line 36 of file ARtoolkit.C.

References ar3DHandle, arHandle, arPattHandle, deleteMarkers(), gCparamLT, markersSquare, and markersSquareCount.

◆ 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(), and jevois::StdModule::sendSerialStd3D().

Friends And Related Symbol 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.

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(), 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(), 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: