Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
b88fdc73
Commit
b88fdc73
authored
Nov 24, 2013
by
Anatoly Baksheev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
VizAccessor is now private and renamed to VizStorage
parent
d970d583
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
76 additions
and
101 deletions
+76
-101
viz.hpp
modules/viz/include/opencv2/viz.hpp
+4
-27
viz3d.hpp
modules/viz/include/opencv2/viz/viz3d.hpp
+2
-0
precomp.hpp
modules/viz/src/precomp.hpp
+24
-9
viz.cpp
modules/viz/src/viz.cpp
+27
-51
viz3d.cpp
modules/viz/src/viz3d.cpp
+19
-14
No files found.
modules/viz/include/opencv2/viz.hpp
View file @
b88fdc73
...
@@ -63,9 +63,12 @@ namespace cv
...
@@ -63,9 +63,12 @@ namespace cv
//! constructs camera pose from position, focal_point and up_vector (see gluLookAt() for more infromation)
//! constructs camera pose from position, focal_point and up_vector (see gluLookAt() for more infromation)
CV_EXPORTS
Affine3f
makeCameraPose
(
const
Vec3f
&
position
,
const
Vec3f
&
focal_point
,
const
Vec3f
&
y_dir
);
CV_EXPORTS
Affine3f
makeCameraPose
(
const
Vec3f
&
position
,
const
Vec3f
&
focal_point
,
const
Vec3f
&
y_dir
);
//! retrieves a window by its name
//! retrieves a window by its name
. If no window with such name, then it creates new.
CV_EXPORTS
Viz3d
get
(
const
String
&
window_name
);
CV_EXPORTS
Viz3d
get
(
const
String
&
window_name
);
//! Unregisters all Viz windows from internal database. After it 'get()' will create new windows instead getting existing from the database.
CV_EXPORTS
void
unregisterAllWindows
();
//! checks float value for Nan
//! checks float value for Nan
inline
bool
isNan
(
float
x
)
inline
bool
isNan
(
float
x
)
{
{
...
@@ -88,32 +91,6 @@ namespace cv
...
@@ -88,32 +91,6 @@ namespace cv
template
<
typename
_Tp
>
inline
bool
isNan
(
const
Point3_
<
_Tp
>&
p
)
template
<
typename
_Tp
>
inline
bool
isNan
(
const
Point3_
<
_Tp
>&
p
)
{
return
isNan
(
p
.
x
)
||
isNan
(
p
.
y
)
||
isNan
(
p
.
z
);
}
{
return
isNan
(
p
.
x
)
||
isNan
(
p
.
y
)
||
isNan
(
p
.
z
);
}
//! helper class that provides access by name infrastructure
class
CV_EXPORTS
VizAccessor
{
public
:
static
VizAccessor
&
getInstance
();
static
void
release
();
Viz3d
get
(
const
String
&
window_name
);
//! window names automatically have Viz - prefix even though not provided by the users
static
void
generateWindowName
(
const
String
&
window_name
,
String
&
output
);
private
:
VizAccessor
();
// Singleton
~
VizAccessor
();
void
add
(
Viz3d
window
);
void
remove
(
const
String
&
window_name
);
static
VizAccessor
*
instance_
;
struct
VizAccessorImpl
;
VizAccessorImpl
*
impl_
;
friend
class
Viz3d
;
};
}
/* namespace viz */
}
/* namespace viz */
}
/* namespace cv */
}
/* namespace cv */
...
...
modules/viz/include/opencv2/viz/viz3d.hpp
View file @
b88fdc73
...
@@ -121,6 +121,8 @@ namespace cv
...
@@ -121,6 +121,8 @@ namespace cv
void
create
(
const
String
&
window_name
);
void
create
(
const
String
&
window_name
);
void
release
();
void
release
();
friend
class
VizStorage
;
};
};
}
/* namespace viz */
}
/* namespace viz */
...
...
modules/viz/src/precomp.hpp
View file @
b88fdc73
...
@@ -135,20 +135,35 @@ namespace cv
...
@@ -135,20 +135,35 @@ namespace cv
namespace
viz
namespace
viz
{
{
typedef
std
::
map
<
String
,
vtkSmartPointer
<
vtkProp
>
>
WidgetActorMap
;
typedef
std
::
map
<
String
,
vtkSmartPointer
<
vtkProp
>
>
WidgetActorMap
;
typedef
std
::
map
<
String
,
Viz3d
>
VizMap
;
typedef
std
::
pair
<
String
,
Viz3d
>
VizPair
;
class
VizStorage
{
public
:
static
void
unregisterAll
();
//! window names automatically have Viz - prefix even though not provided by the users
static
String
generateWindowName
(
const
String
&
window_name
);
private
:
VizStorage
();
// Static
~
VizStorage
();
static
void
add
(
Viz3d
window
);
static
Viz3d
get
(
const
String
&
window_name
);
static
void
remove
(
const
String
&
window_name
);
static
bool
windowExists
(
const
String
&
window_name
);
static
void
removeUnreferenced
();
static
VizMap
storage
;
friend
class
Viz3d
;
};
}
}
}
}
#include "interactor_style.h"
#include "interactor_style.h"
#include "viz3d_impl.hpp"
#include "viz3d_impl.hpp"
namespace
cv
{
namespace
viz
{
typedef
std
::
map
<
String
,
Viz3d
>
VizMap
;
typedef
std
::
pair
<
String
,
Viz3d
>
VizPair
;
}
}
#endif
#endif
modules/viz/src/viz.cpp
View file @
b88fdc73
...
@@ -107,70 +107,46 @@ namespace cv { namespace viz
...
@@ -107,70 +107,46 @@ namespace cv { namespace viz
}}
}}
///////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
/// Viz
accessor
implementation
/// Viz
Storage
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
;
String
name
=
generateWindowName
(
window_name
);
};
VizMap
::
iterator
vm_itr
=
storage
.
find
(
name
);
CV_Assert
(
vm_itr
!=
storage
.
end
());
cv
::
viz
::
VizAccessor
::
VizAccessor
()
{
impl_
=
new
cv
::
viz
::
VizAccessor
::
VizAccessorImpl
;}
return
vm_itr
->
second
;
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
;
}
}
}
cv
::
viz
::
Viz3d
cv
::
viz
::
VizAccessor
::
get
(
const
String
&
window_name
)
void
cv
::
viz
::
VizStorage
::
add
(
Viz3d
window
)
{
{
// Add the prefix Viz
String
window_name
=
window
.
getWindowName
();
String
name
;
VizMap
::
iterator
vm_itr
=
storage
.
find
(
window_name
);
generateWindowName
(
window_name
,
name
);
CV_Assert
(
vm_itr
==
storage
.
end
());
storage
.
insert
(
VizPair
(
window_name
,
window
));
VizMap
::
iterator
vm_itr
=
impl_
->
viz_map
.
find
(
name
);
return
vm_itr
!=
impl_
->
viz_map
.
end
()
?
vm_itr
->
second
:
Viz3d
(
window_name
);
}
}
void
cv
::
viz
::
VizAccessor
::
add
(
Viz3d
window
)
bool
cv
::
viz
::
VizStorage
::
windowExists
(
const
String
&
window_name
)
{
{
String
window_name
=
window
.
getWindowName
();
String
name
=
generateWindowName
(
window_name
);
VizMap
::
iterator
vm_itr
=
impl_
->
viz_map
.
find
(
window_name
);
return
storage
.
find
(
name
)
!=
storage
.
end
();
if
(
vm_itr
==
impl_
->
viz_map
.
end
())
impl_
->
viz_map
.
insert
(
VizPair
(
window_name
,
window
));
}
}
void
cv
::
viz
::
Viz
Accessor
::
remove
(
const
String
&
window_name
)
void
cv
::
viz
::
Viz
Storage
::
removeUnreferenced
(
)
{
{
// Add the prefix Viz
for
(
VizMap
::
iterator
pos
=
storage
.
begin
();
pos
!=
storage
.
end
();
++
pos
)
String
name
;
if
(
pos
->
second
.
impl_
->
ref_counter
==
1
)
generateWindowName
(
window_name
,
name
);
storage
.
erase
(
pos
);
VizMap
::
iterator
vm_itr
=
impl_
->
viz_map
.
find
(
name
);
if
(
vm_itr
!=
impl_
->
viz_map
.
end
())
impl_
->
viz_map
.
erase
(
vm_itr
);
}
}
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
// Already is Viz
if
(
window_name
==
output
)
if
(
window_name
==
output
)
return
;
return
output
;
String
prefixed
=
output
+
" - "
;
String
prefixed
=
output
+
" - "
;
if
(
window_name
.
substr
(
0
,
prefixed
.
length
())
==
prefixed
)
if
(
window_name
.
substr
(
0
,
prefixed
.
length
())
==
prefixed
)
...
@@ -179,9 +155,9 @@ void cv::viz::VizAccessor::generateWindowName(const String &window_name, String
...
@@ -179,9 +155,9 @@ void cv::viz::VizAccessor::generateWindowName(const String &window_name, String
output
=
prefixed
+
window_name
;
// Doesn't have prefix
output
=
prefixed
+
window_name
;
// Doesn't have prefix
else
else
output
=
(
window_name
==
""
?
output
:
prefixed
+
window_name
);
output
=
(
window_name
==
""
?
output
:
prefixed
+
window_name
);
}
cv
::
viz
::
Viz3d
cv
::
viz
::
get
(
const
String
&
window_name
)
return
output
;
{
return
cv
::
viz
::
VizAccessor
::
getInstance
().
get
(
window_name
);
}
}
cv
::
viz
::
Viz3d
cv
::
viz
::
get
(
const
String
&
window_name
)
{
return
Viz3d
(
window_name
);
}
void
cv
::
viz
::
unregisterAllWindows
()
{
VizStorage
::
unregisterAll
();
}
modules/viz/src/viz3d.cpp
View file @
b88fdc73
...
@@ -52,7 +52,8 @@ cv::viz::Viz3d::Viz3d(const String& window_name) : impl_(0) { create(window_name
...
@@ -52,7 +52,8 @@ cv::viz::Viz3d::Viz3d(const String& window_name) : impl_(0) { create(window_name
cv
::
viz
::
Viz3d
::
Viz3d
(
const
Viz3d
&
other
)
:
impl_
(
other
.
impl_
)
cv
::
viz
::
Viz3d
::
Viz3d
(
const
Viz3d
&
other
)
:
impl_
(
other
.
impl_
)
{
{
if
(
impl_
)
CV_XADD
(
&
impl_
->
ref_counter
,
1
);
if
(
impl_
)
CV_XADD
(
&
impl_
->
ref_counter
,
1
);
}
}
cv
::
viz
::
Viz3d
&
cv
::
viz
::
Viz3d
::
operator
=
(
const
Viz3d
&
other
)
cv
::
viz
::
Viz3d
&
cv
::
viz
::
Viz3d
::
operator
=
(
const
Viz3d
&
other
)
...
@@ -70,24 +71,28 @@ cv::viz::Viz3d::~Viz3d() { release(); }
...
@@ -70,24 +71,28 @@ cv::viz::Viz3d::~Viz3d() { release(); }
void
cv
::
viz
::
Viz3d
::
create
(
const
String
&
window_name
)
void
cv
::
viz
::
Viz3d
::
create
(
const
String
&
window_name
)
{
{
if
(
impl_
)
release
();
if
(
impl_
)
impl_
=
new
VizImpl
(
window_name
);
release
();
impl_
->
ref_counter
=
1
;
// Register the window
if
(
VizStorage
::
windowExists
(
window_name
))
cv
::
viz
::
VizAccessor
::
getInstance
().
add
(
*
this
);
*
this
=
VizStorage
::
get
(
window_name
);
else
{
impl_
=
new
VizImpl
(
window_name
);
impl_
->
ref_counter
=
1
;
// Register the window
VizStorage
::
add
(
*
this
);
}
}
}
void
cv
::
viz
::
Viz3d
::
release
()
void
cv
::
viz
::
Viz3d
::
release
()
{
{
// If the current referene count is equal to 2, we can delete it
if
(
impl_
&&
CV_XADD
(
&
impl_
->
ref_counter
,
-
1
)
==
1
)
// - 2 : because minimum there will be two instances, one of which is in the map
if
(
impl_
&&
CV_XADD
(
&
impl_
->
ref_counter
,
-
1
)
==
2
)
{
// Erase the window
cv
::
viz
::
VizAccessor
::
getInstance
().
remove
(
getWindowName
());
delete
impl_
;
delete
impl_
;
impl_
=
0
;
}
impl_
=
0
;
VizStorage
::
removeUnreferenced
();
}
}
void
cv
::
viz
::
Viz3d
::
spin
()
{
impl_
->
spin
();
}
void
cv
::
viz
::
Viz3d
::
spin
()
{
impl_
->
spin
();
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment