22 bool flip_image = (image->origin?
true:
false);
25 image->origin = !image->origin;
28 static bool init =
true;
43 cam.
SetRes(image->width, image->height);
44 cout<<
" [Fail]"<<endl;
47 vector<int> id_vector;
49 id_vector.push_back(i);
70 error = multi_marker->
Update(marker_detector.
markers, &cam, pose);
75 error = multi_marker->
Update(marker_detector.
markers, &cam, pose, image);
77 error = multi_marker->
Update(marker_detector.
markers, &cam, pose);
82 if ((error >= 0) && (error < 5))
90 image->origin = !image->origin;
104 cout<<
"Multi marker loaded"<<endl;
107 cout<<
"Cannot load multi marker"<<endl;
113 cout<<
"Unreadable marker detection enabled."<<endl;
115 cout<<
"Unreadable marker detection disabled."<<endl;
122 int main(
int argc,
char *argv[])
127 filename = filename.substr(filename.find_last_of(
'\\') + 1);
128 std::cout <<
"SampleMultiMarker" << std::endl;
129 std::cout <<
"=================" << std::endl;
130 std::cout << std::endl;
131 std::cout <<
"Description:" << std::endl;
132 std::cout <<
" This is an example of how to use the 'MultiMarker' class to detect" << std::endl;
133 std::cout <<
" preconfigured multi-marker setup (see ALVAR.pdf). A large cube is drawn" << std::endl;
134 std::cout <<
" over the detected multi-marker even when only some of the markers are" << std::endl;
135 std::cout <<
" visible." << std::endl;
136 std::cout << std::endl;
137 std::cout <<
"Usage:" << std::endl;
138 std::cout <<
" " << filename <<
" [device]" << std::endl;
139 std::cout << std::endl;
140 std::cout <<
" device integer selecting device from enumeration list (default 0)" << std::endl;
141 std::cout <<
" highgui capture devices are prefered" << std::endl;
142 std::cout << std::endl;
143 std::cout <<
"Keyboard Shortcuts:" << std::endl;
144 std::cout <<
" v: switch between three debug visualizations" << std::endl;
145 std::cout <<
" l: load marker configuration from mmarker.txt" << std::endl;
146 std::cout <<
" d: toggle the detection of non-readable markers" << std::endl;
147 std::cout <<
" q: quit" << std::endl;
148 std::cout << std::endl;
156 if (plugins.size() < 1) {
157 std::cout <<
"Could not find any capture plugins." << std::endl;
162 std::cout <<
"Available Plugins: ";
164 std::cout << std::endl;
168 if (devices.size() < 1) {
169 std::cout <<
"Could not find any capture devices." << std::endl;
176 selectedDevice = atoi(argv[1]);
178 if (selectedDevice >= (
int)devices.size()) {
183 std::cout <<
"Enumerated Capture Devices:" << std::endl;
185 std::cout << std::endl;
189 std::string uniqueName = devices[selectedDevice].uniqueName();
194 std::stringstream settingsFilename;
195 settingsFilename <<
"camera_settings_" << uniqueName <<
".xml";
202 std::cout <<
"Loading settings: " << settingsFilename.str() << std::endl;
205 std::stringstream title;
211 std::cout <<
"Saving settings: " << settingsFilename.str() << std::endl;
220 std::cout <<
"Could not initialize the selected capture backend." << std::endl;
225 catch (
const std::exception &e) {
226 std::cout <<
"Exception: " << e.what() << endl;
229 std::cout <<
"Exception: unknown" << std::endl;
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 stop()=0
Stops the camera capture.
virtual bool start()=0
Starts the camera capture.
void SetMarkerSize(double _edge_length=1, int _res=5, double _margin=2)
int main(int argc, char *argv[])
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...
Base class for using MultiMarker.
std::stringstream calibrationFilename
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...
void videocallback(IplImage *image)
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.
MarkerDetector< MarkerData > marker_detector
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.
CaptureDeviceVector enumerateDevices(const std::string &captureType="")
Enumerate capture devices currently available.
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.
void outputEnumeratedDevices(CaptureFactory::CaptureDeviceVector &devices, int selectedDevice)
This file implements a multi-marker.
MultiMarker * multi_marker
bool Load(const char *fname, FILE_FORMAT format=FILE_FORMAT_DEFAULT)
Loads multi marker configuration from a text file.
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
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.
void SetTranslation(const CvMat *tra)
void SetMarkerSizeForId(unsigned long id, double _edge_length=1)
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 ...
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.