42 #include <opencv2/imgproc.hpp>
55 void VisualizeMarkerPose(cv::Mat & image,
57 double visualize2d_points[12][2],
58 const cv::Scalar color = CV_RGB(255, 0, 0))
const;
59 virtual void VisualizeMarkerContent(cv::Mat &image,
61 double datatext_point[2],
62 double content_point[2])
const;
63 virtual void VisualizeMarkerError(cv::Mat &image,
Camera *cam,
double errortext_point[2])
const;
64 bool UpdateContentBasic(std::vector<PointDouble> &_marker_corners_img,
84 int * orientation)
const;
97 bool update_pose =
true);
108 return marker_content;
118 void Visualize(cv::Mat &image,
Camera *cam,
const cv::Scalar color = CV_RGB(255, 0, 0))
const;
120 void SetMarkerSize(
double _edge_length = 0,
int _res = 0,
double _margin = 0);
134 Marker(
double _edge_length = 0,
int _res = 0,
double _margin = 0);
142 virtual unsigned long
147 virtual void SetId(
unsigned long _id){};
181 GetError(
int errors = (MARGIN_ERROR | DECODE_ERROR))
const
185 if (errors & MARGIN_ERROR) {
186 error += margin_error;
189 if (errors & DECODE_ERROR) {
190 error += decode_error;
193 if (errors & TRACK_ERROR) {
194 error += track_error;
197 return error / count;
203 if (error_type == MARGIN_ERROR)
204 margin_error = value;
205 else if (error_type == DECODE_ERROR)
206 decode_error = value;
207 else if (error_type == TRACK_ERROR)
210 static const int MARGIN_ERROR = 1;
211 static const int DECODE_ERROR = 2;
212 static const int TRACK_ERROR = 4;
221 cv::Mat marker_content;
234 #ifdef VISUALIZE_MARKER_POINTS
235 std::vector<PointDouble> marker_allpoints_img;
248 std::cout <<
"MarkerArtoolkit::default_res" << std::endl;
262 :
Marker(_edge_length, (_res ? _res : 3), (_margin ? _margin : 1.5))
272 SetId(
unsigned long _id)
288 virtual void VisualizeMarkerContent(cv::Mat &image,
290 double datatext_point[2],
291 double content_point[2])
const;
292 void DecodeOrientation(
int *error,
int *total,
int *orientation);
293 int DecodeCode(
int orientation,
297 unsigned char *content_type);
298 void Read6bitStr(
BitsetExt *bs,
char *s,
size_t s_max_len);
300 int UsableDataBits(
int marker_res,
int hamming);
306 static const int MAX_MARKER_STRING_LEN = 2048;
307 enum MarkerContentType {
308 MARKER_CONTENT_TYPE_NUMBER,
309 MARKER_CONTENT_TYPE_STRING,
310 MARKER_CONTENT_TYPE_FILE,
311 MARKER_CONTENT_TYPE_HTTP
313 unsigned char content_type;
318 char str[MAX_MARKER_STRING_LEN];
326 MarkerData(
double _edge_length = 0,
int _res = 0,
double _margin = 0)
327 :
Marker(_edge_length, _res, (_margin ? _margin : 2))
358 bool force_strong_hamming =
false,
359 bool verbose =
false);
364 class ALVAR_EXPORT
MarkerIterator :
public std::iterator<std::forward_iterator_tag, Marker *>
370 virtual const Marker * operator*() = 0;
371 virtual const Marker * operator->() = 0;
381 template <
typename T>
406 return (_i == pother->_i);
413 return (_i != pother->_i);
443 typename std::vector<T>::const_iterator _begin;
444 typename std::vector<T>::const_iterator _i;
This file defines library export definitions, version numbers and build information.
This file implements bit set handling.
This file implements a camera used for projecting points and computing homographies.
This file implements a pose.
This file implements generic utility functions and a serialization interface.
An extended Bitset ( BitsetExt ) for handling e.g. Hamming encoding/decoding.
Simple Camera class for calculating distortions, orientation or projections with pre-calibrated camer...
MarkerData contains matrix of Hamming encoded data.
MarkerData(double _edge_length=0, int _res=0, double _margin=0)
Default constructor.
void SetId(unsigned long _id)
Set the ID.
bool DecodeContent(int *orientation)
DecodeContent should be called after UpdateContent to fill content_type, decode_error and data
virtual bool UpdateContent(std::vector< Point< cv::Point2d >> &_marker_corners_img, cv::Mat &gray, Camera *cam, int frame_no=0)
Updates the marker_content from the image using Homography Compared to the basic implementation in Ma...
unsigned long GetId() const
Get ID for recognizing this marker.
void SetContent(MarkerContentType content_type, unsigned long id, const char *str, bool force_strong_hamming=false, bool verbose=false)
Updates the marker_content by "encoding" the given parameters.
Basic 2D Marker functionality.
std::vector< PointDouble > marker_corners
Marker corners in marker coordinates.
Marker(double _edge_length=0, int _res=0, double _margin=0)
Default constructor.
virtual unsigned long GetId() const
Get id for this marker This is used e.g. in MarkerDetector to associate a marker id with an appropria...
void ScaleMarkerToImage(cv::Mat &image) const
Draw the marker filling the ROI in the given image.
virtual bool UpdateContent(std::vector< Point< cv::Point2d >> &_marker_corners_img, cv::Mat &gray, Camera *cam, int frame_no=0)
Updates the marker_content from the image using Homography.
void SaveMarkerImage(const char *filename, int save_res=0) const
Saves the marker as an image.
void SetMarkerSize(double _edge_length=0, int _res=0, double _margin=0)
Method for resizing the marker dimensions
std::vector< PointDouble > marker_margin_b
Samples to be used in figuring out min/max for thresholding.
cv::Mat GetContent() const
Returns the content as a matrix.
std::vector< PointDouble > marker_corners_img
Marker corners in image coordinates.
Marker(const Marker &m)
Copy constructor
Pose pose
The current marker Pose.
void UpdatePose(std::vector< Point< cv::Point2d >> &_marker_corners_img, Camera *cam, int orientation, int frame_no=0, bool update_pose=true)
Updates the markers pose estimation.
void SetError(int error_type, double value)
Set the marker error estimate.
void Visualize(cv::Mat &image, Camera *cam, const cv::Scalar color=CV_RGB(255, 0, 0)) const
Visualize the marker.
std::vector< PointDouble > marker_margin_w
Samples to be used in figuring out min/max for thresholding.
void CompareCorners(std::vector< Point< cv::Point2d >> &_marker_corners_img, int *orientation, double *error)
Compares the marker corners with the previous match.
double GetMarkerEdgeLength() const
Get edge length (to support different size markers.
double GetError(int errors=(MARGIN_ERROR|DECODE_ERROR)) const
Get marker detection error estimate.
void CompareContent(std::vector< PointDouble > &_marker_corners_img, cv::Mat &gray, Camera *cam, int *orientation) const
Compares the marker corners with the previous match.
std::vector< PointDouble > marker_points
Marker color points in marker coordinates.
virtual bool DecodeContent(int *orientation)
Decodes the marker content. Please call UpdateContent before this. This virtual method is meant to be...
Iterator type for traversing templated Marker vector without the template.
Iterator implementation for traversing templated Marker vector without the template.
Pose representation derived from the Rotation class