|
|
|
@ -107,70 +107,46 @@ namespace cv { namespace viz |
|
|
|
|
}} |
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
/// Viz accessor implementation
|
|
|
|
|
/// VizStorage implementation
|
|
|
|
|
|
|
|
|
|
cv::viz::VizAccessor * cv::viz::VizAccessor::instance_ = 0; |
|
|
|
|
cv::viz::VizMap cv::viz::VizStorage::storage; |
|
|
|
|
void cv::viz::VizStorage::unregisterAll() { storage.clear(); } |
|
|
|
|
|
|
|
|
|
struct cv::viz::VizAccessor::VizAccessorImpl |
|
|
|
|
cv::viz::Viz3d cv::viz::VizStorage::get(const String &window_name) |
|
|
|
|
{ |
|
|
|
|
cv::viz::VizMap viz_map; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
cv::viz::VizAccessor::VizAccessor() { impl_ = new cv::viz::VizAccessor::VizAccessorImpl;} |
|
|
|
|
cv::viz::VizAccessor::~VizAccessor() { delete impl_; } |
|
|
|
|
|
|
|
|
|
cv::viz::VizAccessor & cv::viz::VizAccessor::getInstance() |
|
|
|
|
{ |
|
|
|
|
if (!instance_) |
|
|
|
|
instance_ = new VizAccessor(); |
|
|
|
|
|
|
|
|
|
return *instance_; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void cv::viz::VizAccessor::release() |
|
|
|
|
{ |
|
|
|
|
if (instance_) |
|
|
|
|
{ |
|
|
|
|
delete instance_; |
|
|
|
|
instance_ = 0; |
|
|
|
|
} |
|
|
|
|
String name = generateWindowName(window_name); |
|
|
|
|
VizMap::iterator vm_itr = storage.find(name); |
|
|
|
|
CV_Assert(vm_itr != storage.end()); |
|
|
|
|
return vm_itr->second; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
cv::viz::Viz3d cv::viz::VizAccessor::get(const String & window_name) |
|
|
|
|
void cv::viz::VizStorage::add(Viz3d window) |
|
|
|
|
{ |
|
|
|
|
// Add the prefix Viz
|
|
|
|
|
String name; |
|
|
|
|
generateWindowName(window_name, name); |
|
|
|
|
|
|
|
|
|
VizMap::iterator vm_itr = impl_->viz_map.find(name); |
|
|
|
|
return vm_itr != impl_->viz_map.end() ? vm_itr->second : Viz3d(window_name); |
|
|
|
|
String window_name = window.getWindowName(); |
|
|
|
|
VizMap::iterator vm_itr = storage.find(window_name); |
|
|
|
|
CV_Assert(vm_itr == storage.end()); |
|
|
|
|
storage.insert(VizPair(window_name, window)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void cv::viz::VizAccessor::add(Viz3d window) |
|
|
|
|
bool cv::viz::VizStorage::windowExists(const String &window_name) |
|
|
|
|
{ |
|
|
|
|
String window_name = window.getWindowName(); |
|
|
|
|
VizMap::iterator vm_itr = impl_->viz_map.find(window_name); |
|
|
|
|
if (vm_itr == impl_->viz_map.end()) |
|
|
|
|
impl_->viz_map.insert(VizPair(window_name, window)); |
|
|
|
|
String name = generateWindowName(window_name); |
|
|
|
|
return storage.find(name) != storage.end(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void cv::viz::VizAccessor::remove(const String &window_name) |
|
|
|
|
void cv::viz::VizStorage::removeUnreferenced() |
|
|
|
|
{ |
|
|
|
|
// Add the prefix Viz
|
|
|
|
|
String name; |
|
|
|
|
generateWindowName(window_name, name); |
|
|
|
|
|
|
|
|
|
VizMap::iterator vm_itr = impl_->viz_map.find(name); |
|
|
|
|
if (vm_itr != impl_->viz_map.end()) |
|
|
|
|
impl_->viz_map.erase(vm_itr); |
|
|
|
|
for(VizMap::iterator pos = storage.begin(); pos != storage.end(); ++pos) |
|
|
|
|
if(pos->second.impl_->ref_counter == 1) |
|
|
|
|
storage.erase(pos); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void cv::viz::VizAccessor::generateWindowName(const String &window_name, String &output) |
|
|
|
|
cv::String cv::viz::VizStorage::generateWindowName(const String &window_name) |
|
|
|
|
{ |
|
|
|
|
output = "Viz"; |
|
|
|
|
String output = "Viz"; |
|
|
|
|
// Already is Viz
|
|
|
|
|
if (window_name == output) |
|
|
|
|
return; |
|
|
|
|
return output; |
|
|
|
|
|
|
|
|
|
String prefixed = output + " - "; |
|
|
|
|
if (window_name.substr(0, prefixed.length()) == prefixed) |
|
|
|
@ -179,9 +155,9 @@ void cv::viz::VizAccessor::generateWindowName(const String &window_name, String |
|
|
|
|
output = prefixed + window_name; // Doesn't have prefix
|
|
|
|
|
else |
|
|
|
|
output = (window_name == "" ? output : prefixed + window_name); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
cv::viz::Viz3d cv::viz::get(const String &window_name) |
|
|
|
|
{ |
|
|
|
|
return cv::viz::VizAccessor::getInstance().get(window_name); |
|
|
|
|
return output; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
cv::viz::Viz3d cv::viz::get(const String &window_name) { return Viz3d(window_name); } |
|
|
|
|
void cv::viz::unregisterAllWindows() { VizStorage::unregisterAll(); } |
|
|
|
|