if (init) {
cout<<"Using manual multimarker approach with MultiMarkerInitializer & MultiMarkerBundle."<<endl;
cout<<"Use 'p' for taking keyframes and 'o' for optimizing."<<endl;
init=false;
vector<int> id_vector;
id_vector.push_back(i);
}
double error = -1;
error = multi_marker_init->
Update(marker_detector.
markers, cam, pose, image);
else
error = multi_marker_init->
Update(marker_detector.
markers, cam, pose);
}
} else {
error = multi_marker_bundle->
Update(marker_detector.
markers, cam, pose, image);
else
error = multi_marker_bundle->
Update(marker_detector.
markers, cam, pose);
if ((multi_marker_bundle->
SetTrackMarkers(marker_detector, cam, pose, image) > 0) &&
{
error = multi_marker_bundle->
Update(marker_detector.
markers, cam, pose, image);
else
error = multi_marker_bundle->
Update(marker_detector.
markers, cam, pose);
}
}
}
if (marker_detector.
markers->size() >= 2) {
cout<<"Adding measurement..."<<endl;
}
}
cout<<"Initializing..."<<endl;
cout<<"Initialization failed, add some more measurements."<<endl;
} else {
multi_marker_bundle->
Reset();
const std::vector<MultiMarkerInitializer::MarkerMeasurement> markers
}
cout<<"Optimizing..."<<endl;
if (multi_marker_bundle->
Optimize(cam, 0.01, 20)) {
cout<<"Optimizing done"<<endl;
} else {
cout<<"Optimizing FAILED!"<<endl;
}
}
}
return error;
}
{
bool flip_image = (image->origin?true:false);
if (flip_image) {
cvFlip(image);
image->origin = !image->origin;
}
if (init)
{
init = false;
{
cout<<" [Ok]"<<endl;
}
else
{
cam.
SetRes(image->width, image->height);
cout<<" [Fail]"<<endl;
}
}
if ((error >= 0) && (error < 5))
{
}
if (flip_image) {
cvFlip(image);
image->origin = !image->origin;
}
}
{
static bool fixed = false;
if(key == 'r')
{
cout<<"Reseting multi marker"<<endl;
multi_marker_init->
Reset();
multi_marker_bundle->
Reset();
}
else if(key == 'v')
{
}
else if(key == 'l')
{
{
cout<<"Multi marker loaded"<<endl;
}
else
cout<<"Cannot load multi marker"<<endl;
}
else if(key == 's')
{
cout<<"Multi marker saved"<<endl;
else
cout<<"Cannot save multi marker"<<endl;
}
else if(key == 'p')
{
}
else if(key == 'o')
{
}
else return key;
return 0;
}
int main(
int argc,
char *argv[])
{
try {
filename = filename.substr(filename.find_last_of('\\') + 1);
std::cout << "SampleMultiMarkerBundle" << std::endl;
std::cout << "=======================" << std::endl;
std::cout << std::endl;
std::cout << "Description:" << std::endl;
std::cout << " This is an example of how to use the 'MultiMarkerBundle' class to" << std::endl;
std::cout << " automatically deduce and optimize 'MultiMarker' setups." << std::endl;
std::cout << std::endl;
std::cout << "Usage:" << std::endl;
std::cout << " " << filename << " [device]" << std::endl;
std::cout << std::endl;
std::cout << " device integer selecting device from enumeration list (default 0)" << std::endl;
std::cout << " highgui capture devices are prefered" << std::endl;
std::cout << std::endl;
std::cout << "Keyboard Shortcuts:" << std::endl;
std::cout << " l: load marker configuration from mmarker.txt" << std::endl;
std::cout << " s: save marker configuration to mmarker.txt" << std::endl;
std::cout << " r: reset marker configuration" << std::endl;
std::cout << " p: add measurement" << std::endl;
std::cout << " o: optimize bundle" << std::endl;
std::cout << " q: quit" << std::endl;
std::cout << std::endl;
if (plugins.size() < 1) {
std::cout << "Could not find any capture plugins." << std::endl;
return 0;
}
std::cout << "Available Plugins: ";
std::cout << std::endl;
if (devices.size() < 1) {
std::cout << "Could not find any capture devices." << std::endl;
return 0;
}
if (argc > 1) {
selectedDevice = atoi(argv[1]);
}
if (selectedDevice >= (int)devices.size()) {
}
std::cout << "Enumerated Capture Devices:" << std::endl;
std::cout << std::endl;
std::string uniqueName = devices[selectedDevice].uniqueName();
if (cap) {
std::stringstream settingsFilename;
settingsFilename << "camera_settings_" << uniqueName << ".xml";
std::cout << "Loading settings: " << settingsFilename.str() << std::endl;
}
std::stringstream title;
std::cout << "Saving settings: " << settingsFilename.str() << std::endl;
}
delete cap;
}
}
else {
std::cout << "Could not initialize the selected capture backend." << std::endl;
}
return 0;
}
catch (const std::exception &e) {
std::cout << "Exception: " << e.what() << endl;
}
catch (...) {
std::cout << "Exception: unknown" << std::endl;
}
}