25 #include <Eigen/StdVector> 32 MultiMarkerInitializer::MultiMarkerInitializer(std::vector<int>& indices,
int _filter_buffer_min,
int _filter_buffer_max)
33 :
MultiMarker(indices), filter_buffer_min(_filter_buffer_min) {
37 for (
size_t i=0; i<indices.size()*4*3; i++) {
46 vector<MarkerMeasurement, Eigen::aligned_allocator<MarkerMeasurement> > new_measurements;
50 if (index == -1)
continue;
56 new_measurements.push_back(m);
63 int id = marker->
GetId();
70 CvPoint3D64f corners[4];
72 for(
size_t j = 0; j < 4; ++j) {
95 for (
bool found_new =
true; found_new; ) {
99 vector<MarkerMeasurement, Eigen::aligned_allocator<MarkerMeasurement> > &markers = *mi;
103 double err =
_GetPose(m_begin, m_end, cam, pose, NULL);
121 bool found_new =
false;
122 for (vector<
MarkerMeasurement, Eigen::aligned_allocator<MarkerMeasurement> >::iterator i = markers.begin(); i != markers.end(); ++i) {
124 int id = marker.
GetId();
128 double cam_posed[16];
129 double mar_posed[16];
130 CvMat cam_mat = cvMat(4, 4, CV_64F, cam_posed);
131 CvMat mar_mat = cvMat(4, 4, CV_64F, mar_posed);
134 cvInvert(&cam_mat, &cam_mat);
135 cvMatMul(&cam_mat, &mar_mat, &mar_mat);
138 CvPoint3D64f corners[4];
140 for(
size_t j = 0; j < 4; ++j) {
void PointCloudCorners3d(double edge_length, Pose &pose, CvPoint3D64f corners[4])
Calculates 3D coordinates of marker corners relative to given pose (camera).
void SetMatrix(const CvMat *mat)
std::vector< PointDouble > marker_corners_img
Marker corners in image coordinates.
unsigned long GetId() const
Get id for this marker This is used e.g. in MarkerDetector to associate a marker id with an appropria...
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...
std::vector< int > marker_status
bool updateMarkerPoses(std::vector< MarkerMeasurement, Eigen::aligned_allocator< MarkerMeasurement > > &markers, const Pose &pose)
Base class for using MultiMarker.
TFSIMD_FORCE_INLINE const tfScalar & y() const
std::map< int, CvPoint3D64f > pointcloud
int get_id_index(int id, bool add_if_missing=false)
std::vector< int > marker_indices
Simple Camera class for calculating distortions, orientation or projections with pre-calibrated camer...
virtual void reset()
Reset the filter state.
std::vector< std::vector< MarkerMeasurement, Eigen::aligned_allocator< MarkerMeasurement > > >::iterator MeasurementIterator
int pointcloud_index(int marker_id, int marker_corner, bool add_if_missing=false)
Pose pose
The current marker Pose.
std::vector< bool > marker_detected
Pose representation derived from the Rotation class
TFSIMD_FORCE_INLINE const tfScalar & x() const
void SetId(unsigned long _id)
Basic 2D Marker functionality.
MarkerMeasurement that holds the maker id.
std::vector< std::vector< MarkerMeasurement, Eigen::aligned_allocator< MarkerMeasurement > > > measurements
void PointCloudReset()
Reserts the 3D point cloud of the markers.
TFSIMD_FORCE_INLINE const tfScalar & z() const
Iterator type for traversing templated Marker vector without the template.
double GetMarkerEdgeLength() const
Get edge length (to support different size markers.
void MeasurementsAdd(MarkerIterator &begin, MarkerIterator &end)
void GetMatrix(CvMat *mat) const
This file implements a initialization algorithm to create a multi-marker field configuration.
FilterMedian * pointcloud_filtered
Iterator implementation for traversing templated Marker vector without the template.
void SetMarkerSize(double _edge_length=0, int _res=0, double _margin=0)
Method for resizing the marker dimensions.
double _GetPose(MarkerIterator &begin, MarkerIterator &end, Camera *cam, Pose &pose, IplImage *image)
int Initialize(Camera *cam)
virtual MarkerIterator & reset()=0