cv::viz::get(window_name) implementation

This commit is contained in:
ozantonkal 2013-08-20 20:22:14 +02:00
parent c37f091cc5
commit 6bc393676d
3 changed files with 9 additions and 6 deletions

View File

@ -112,7 +112,11 @@ cv::viz::VizAccessor * cv::viz::VizAccessor::getInstance()
cv::viz::Viz3d cv::viz::VizAccessor::get(const String & window_name)
{
VizMap::iterator vm_itr = viz_map_.find(window_name);
// Add the prefix Viz
String name("Viz");
name = window_name.empty() ? name : name + " - " + window_name;
VizMap::iterator vm_itr = viz_map_.find(name);
bool exists = vm_itr != viz_map_.end();
if (exists) return vm_itr->second;
else return viz_map_.insert(VizPair(window_name, Viz3d(window_name))).first->second;

View File

@ -28,13 +28,14 @@ void cv::viz::Viz3d::create(const String &window_name)
impl_ = new VizImpl(window_name);
impl_->ref_counter = 1;
// Register the window
// cv::viz::VizAccessor::getInstance()->add(*this);
cv::viz::VizAccessor::getInstance()->add(*this);
}
void cv::viz::Viz3d::release()
{
if (impl_ && CV_XADD(&impl_->ref_counter, -1) == 1)
{
// Erase the window
cv::viz::VizAccessor::getInstance()->remove(getWindowName());
delete impl_;
impl_ = 0;

View File

@ -83,10 +83,8 @@ cv::viz::Viz3d::VizImpl::VizImpl (const std::string &name)
/////////////////////////////////////////////////////////////////////////////////////////////
cv::viz::Viz3d::VizImpl::~VizImpl ()
{
if (interactor_ != NULL)
interactor_->DestroyTimer (timer_id_);
if (renderer_) renderer_->Clear();
if (interactor_)
interactor_->DestroyTimer(timer_id_);
}
/////////////////////////////////////////////////////////////////////////////////////////////