22     static bool init=
true;
    24         cout<<
"Using manual multimarker approach with MultiMarkerInitializer & MultiMarkerBundle."<<endl;
    25         cout<<
"Use 'p' for taking keyframes and 'o' for optimizing."<<endl;
    27         vector<int> id_vector;
    29             id_vector.push_back(i);
    42                 error = multi_marker_init->
Update(marker_detector.
markers, cam, pose, image);
    44                 error = multi_marker_init->
Update(marker_detector.
markers, cam, pose);
    49                 error = multi_marker_bundle->
Update(marker_detector.
markers, cam, pose, image);
    51                 error = multi_marker_bundle->
Update(marker_detector.
markers, cam, pose);
    52             if ((multi_marker_bundle->
SetTrackMarkers(marker_detector, cam, pose, image) > 0) &&
    56                     error = multi_marker_bundle->
Update(marker_detector.
markers, cam, pose, image);
    58                     error = multi_marker_bundle->
Update(marker_detector.
markers, cam, pose);
    64         if (marker_detector.
markers->size() >= 2) {
    65             cout<<
"Adding measurement..."<<endl;
    72         cout<<
"Initializing..."<<endl;
    74             cout<<
"Initialization failed, add some more measurements."<<endl;
    78             multi_marker_bundle->
Reset();
    84                 const std::vector<MultiMarkerInitializer::MarkerMeasurement> markers 
    90             cout<<
"Optimizing..."<<endl;
    91             if (multi_marker_bundle->
Optimize(cam, 0.01, 20)) {
    92                 cout<<
"Optimizing done"<<endl;
    96                 cout<<
"Optimizing FAILED!"<<endl;
   108     bool flip_image = (image->origin?
true:
false);
   111         image->origin = !image->origin;
   114     static bool init = 
true;
   128             cam.
SetRes(image->width, image->height);
   129             cout<<
" [Fail]"<<endl;
   141     if ((error >= 0) && (error < 5))
   145     foo.
Visualize(image, &cam, CV_RGB(0,0,255));
   149         image->origin = !image->origin;
   155     static bool fixed = 
false;
   159         cout<<
"Reseting multi marker"<<endl;
   160             multi_marker_init->
Reset();
   162             multi_marker_bundle->
Reset();
   176             cout<<
"Multi marker loaded"<<endl;
   181             cout<<
"Cannot load multi marker"<<endl;
   186             cout<<
"Multi marker saved"<<endl;
   188             cout<<
"Cannot save multi marker"<<endl;
   203 int main(
int argc, 
char *argv[])
   208         filename = filename.substr(filename.find_last_of(
'\\') + 1);
   209         std::cout << 
"SampleMultiMarkerBundle" << std::endl;
   210         std::cout << 
"=======================" << std::endl;
   211         std::cout << std::endl;
   212         std::cout << 
"Description:" << std::endl;
   213         std::cout << 
"  This is an example of how to use the 'MultiMarkerBundle' class to" << std::endl;
   214         std::cout << 
"  automatically deduce and optimize 'MultiMarker' setups." << std::endl;
   215         std::cout << std::endl;
   216         std::cout << 
"Usage:" << std::endl;
   217         std::cout << 
"  " << filename << 
" [device]" << std::endl;
   218         std::cout << std::endl;
   219         std::cout << 
"    device    integer selecting device from enumeration list (default 0)" << std::endl;
   220         std::cout << 
"              highgui capture devices are prefered" << std::endl;
   221         std::cout << std::endl;
   222         std::cout << 
"Keyboard Shortcuts:" << std::endl;
   223         std::cout << 
"  l: load marker configuration from mmarker.txt" << std::endl;
   224         std::cout << 
"  s: save marker configuration to mmarker.txt" << std::endl;
   225         std::cout << 
"  r: reset marker configuration" << std::endl;
   226         std::cout << 
"  p: add measurement" << std::endl;
   227         std::cout << 
"  o: optimize bundle" << std::endl;
   228         std::cout << 
"  q: quit" << std::endl;
   229         std::cout << std::endl;
   237         if (plugins.size() < 1) {
   238             std::cout << 
"Could not find any capture plugins." << std::endl;
   243         std::cout << 
"Available Plugins: ";
   245         std::cout << std::endl;
   249         if (devices.size() < 1) {
   250             std::cout << 
"Could not find any capture devices." << std::endl;
   257             selectedDevice = atoi(argv[1]);
   259         if (selectedDevice >= (
int)devices.size()) {
   264         std::cout << 
"Enumerated Capture Devices:" << std::endl;
   266         std::cout << std::endl;
   270         std::string uniqueName = devices[selectedDevice].uniqueName();
   275             std::stringstream settingsFilename;
   276             settingsFilename << 
"camera_settings_" << uniqueName << 
".xml";
   283                 std::cout << 
"Loading settings: " << settingsFilename.str() << std::endl;
   286             std::stringstream title;
   292                 std::cout << 
"Saving settings: " << settingsFilename.str() << std::endl;
   301             std::cout << 
"Could not initialize the selected capture backend." << std::endl;
   306     catch (
const std::exception &e) {
   307         std::cout << 
"Exception: " << e.what() << endl;
   310         std::cout << 
"Exception: unknown" << std::endl;
 double getMeasurementPose(int measurement, Camera *cam, Pose &pose)
static CvTestbed & Instance()
The one and only instance of CvTestbed is accessed using CvTestbed::Instance() 
Capture * createCapture(const CaptureDevice captureDevice)
Create Capture class. Transfers onwership to the caller. 
virtual void Reset()
Resets the multi marker. 
virtual void stop()=0
Stops the camera capture. 
void MeasurementsAdd(const std::vector< M, Eigen::aligned_allocator< M > > *markers, const Pose &camera_pose)
Adds new measurements that are used in bundle adjustment. 
virtual bool start()=0
Starts the camera capture. 
void SetMarkerSize(double _edge_length=1, int _res=5, double _margin=2)
CaptureDevice captureDevice()
The camera information associated to this capture object. 
void SetVideoCallback(void(*_videocallback)(IplImage *image))
Set the videocallback function that will be called for every frame. 
void Visualize(IplImage *image, Camera *cam, CvScalar color=CV_RGB(255, 0, 0)) const 
Visualize the marker. 
static CaptureFactory * instance()
The singleton instance of CaptureFactory. 
This file implements a generic marker detector. 
void SetRes(int _x_res, int _y_res)
If we have no calibration file we can still adjust the default calibration to current resolution...
bool Optimize(Camera *_cam, double stop, int max_iter, Optimization::OptimizeMethod method=Optimization::TUKEY_LM)
Runs the bundle adjustment optimization. 
Initializes multi marker by estimating their relative positions from one or more images. 
std::vector< CaptureDevice > CaptureDeviceVector
Vector of CaptureDevices. 
int DetectAdditional(IplImage *image, Camera *cam, bool visualize=false, double max_track_error=0.2)
Simple Camera class for calculating distortions, orientation or projections with pre-calibrated camer...
std::string captureType() const 
The type of capture backend. 
bool StartVideo(Capture *_cap, const char *_wintitle=0)
Start video input from given capture device. 
bool SetCalib(const char *calibfile, int _x_res, int _y_res, FILE_FORMAT format=FILE_FORMAT_DEFAULT)
Set the calibration file and the current resolution for which the calibration is adjusted to...
std::vector< M, Eigen::aligned_allocator< M > > * markers
std::vector< std::string > CapturePluginVector
Vector of strings. 
void outputEnumeratedPlugins(CaptureFactory::CapturePluginVector &plugins)
MarkerDetector for detecting markers of type M 
void SetKeyCallback(int(*_keycallback)(int key))
Sets the keyboard callback function that will be called when keyboard is pressed. ...
Pose pose
The current marker Pose. 
MarkerDetector< MarkerData > marker_detector
std::stringstream calibrationFilename
CaptureDeviceVector enumerateDevices(const std::string &captureType="")
Enumerate capture devices currently available. 
Multi marker that uses bundle adjustment to refine the 3D positions of the markers (point cloud)...
void PointCloudCopy(const MultiMarker *m)
Copies the 3D point cloud from other multi marker object. 
Pose representation derived from the Rotation class 
CapturePluginVector enumeratePlugins()
Enumerate capture plugins currently available. 
Basic 2D Marker functionality. 
void PointCloudAdd(int marker_id, double edge_length, Pose &pose)
Adds marker corners to 3D point cloud of multi marker. 
int getMeasurementCount()
void outputEnumeratedDevices(CaptureFactory::CaptureDeviceVector &devices, int selectedDevice)
void MeasurementsAdd(MarkerIterator &begin, MarkerIterator &end)
This file implements a initialization algorithm to create a multi-marker field configuration. 
void videocallback(IplImage *image)
bool Load(const char *fname, FILE_FORMAT format=FILE_FORMAT_DEFAULT)
Loads multi marker configuration from a text file. 
MultiMarkerInitializer * multi_marker_init
Capture interface that plugins must implement. 
void SetMarkerSize(double _edge_length=0, int _res=0, double _margin=0)
Method for resizing the marker dimensions. 
int Detect(IplImage *image, Camera *cam, bool track=false, bool visualize=false, double max_new_marker_error=0.08, double max_track_error=0.2, LabelingMethod labeling_method=CVSEQ, bool update_pose=true)
Detect Marker 's from image 
int main(int argc, char *argv[])
double GetMultiMarkerPose(IplImage *image, Camera *cam, Pose &pose)
This file implements a pose. 
virtual bool loadSettings(std::string filename)
Load camera settings from a file. 
int defaultDevice(CaptureFactory::CaptureDeviceVector &devices)
virtual void setResolution(const unsigned long xResolution, const unsigned long yResolution)
Set the resolution. 
This file implements an algorithm to create a multi-marker field configuration. 
int Initialize(Camera *cam)
void MeasurementsReset()
Resets the measurements and camera poses that are stored for bundle adjustment. If something goes fro...
int SetTrackMarkers(MarkerDetector< M > &marker_detector, Camera *cam, Pose &pose, IplImage *image=0)
Set new markers to be tracked for MarkerDetector Sometimes the MultiMarker implementation knows more ...
const std::vector< MarkerMeasurement, Eigen::aligned_allocator< MarkerMeasurement > > & getMeasurementMarkers(int measurement)
double Update(const std::vector< M, Eigen::aligned_allocator< M > > *markers, Camera *cam, Pose &pose, IplImage *image=0)
Calls GetPose to obtain camera pose. 
virtual bool saveSettings(std::string filename)
Save camera settings to a file. 
bool Save(const char *fname, FILE_FORMAT format=FILE_FORMAT_DEFAULT)
Saves multi marker configuration to a text file. 
MultiMarkerBundle * multi_marker_bundle