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
1449823b
Commit
1449823b
authored
Jan 11, 2014
by
Anatoly Baksheev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implemented showImage
parent
d90a068e
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
74 additions
and
23 deletions
+74
-23
launching_viz.rst
doc/tutorials/viz/launching_viz/launching_viz.rst
+1
-1
viz3d.rst
modules/viz/doc/viz3d.rst
+11
-0
widget.rst
modules/viz/doc/widget.rst
+10
-10
viz.hpp
modules/viz/include/opencv2/viz.hpp
+3
-0
viz3d.hpp
modules/viz/include/opencv2/viz/viz3d.hpp
+2
-0
widgets.hpp
modules/viz/include/opencv2/viz/widgets.hpp
+5
-5
shapes.cpp
modules/viz/src/shapes.cpp
+10
-7
viz3d.cpp
modules/viz/src/viz3d.cpp
+11
-0
vizcore.cpp
modules/viz/src/vizcore.cpp
+7
-0
tests_simple.cpp
modules/viz/test/tests_simple.cpp
+14
-0
No files found.
doc/tutorials/viz/launching_viz/launching_viz.rst
View file @
1449823b
...
...
@@ -43,7 +43,7 @@ You can download the code from :download:`here <../../../../samples/cpp/tutorial
cout << "First event loop is over" << endl;
/// Access window via its name
viz::Viz3d sameWindow = viz::get("Viz Demo");
viz::Viz3d sameWindow = viz::get
WindowByName
("Viz Demo");
/// Start event loop
sameWindow.spin();
...
...
modules/viz/doc/viz3d.rst
View file @
1449823b
...
...
@@ -102,6 +102,8 @@ The Viz3d class represents a 3D visualizer window. This class is implicitly shar
void setWidgetPose(const String &id, const Affine3d &pose);
void updateWidgetPose(const String &id, const Affine3d &pose);
Affine3d getWidgetPose(const String &id) const;
void showImage(InputArray image, const Size& window_size = Size(-1, -1));
void setCamera(const Camera &camera);
Camera getCamera() const;
...
...
@@ -182,6 +184,15 @@ Removes all widgets from the window.
.. ocv:function:: void removeAllWidgets()
viz::Viz3d::showImage
---------------------
Removed all widgets and displays image scaled to whole window area.
.. ocv:function:: void showImage(InputArray image, const Size& window_size = Size(-1, -1));
:param image: Image to be displayed.
:param size: Size of Viz3d window. Default value means no change.
viz::Viz3d::setWidgetPose
-------------------------
Sets pose of a widget in the window.
...
...
modules/viz/doc/widget.rst
View file @
1449823b
...
...
@@ -580,16 +580,16 @@ This 2D Widget represents an image overlay. ::
class CV_EXPORTS WImageOverlay : public Widget2D
{
public:
WImageOverlay(
const Mat &
image, const Rect &rect);
WImageOverlay(
InputArray
image, const Rect &rect);
void setImage(
const Mat &
image);
void setImage(
InputArray
image);
};
viz::WImageOverlay::WImageOverlay
---------------------------------
Constructs an WImageOverlay.
.. ocv:function:: WImageOverlay(
const Mat &
image, const Rect &rect)
.. ocv:function:: WImageOverlay(
InputArray
image, const Rect &rect)
:param image: BGR or Gray-Scale image.
:param rect: Image is scaled and positioned based on rect.
...
...
@@ -598,7 +598,7 @@ viz::WImageOverlay::setImage
----------------------------
Sets the image content of the widget.
.. ocv:function:: void setImage(
const Mat &
image)
.. ocv:function:: void setImage(
InputArray
image)
:param image: BGR or Gray-Scale image.
...
...
@@ -612,23 +612,23 @@ This 3D Widget represents an image in 3D space. ::
{
public:
//! Creates 3D image at the origin
WImage3D(
const Mat &
image, const Size2d &size);
WImage3D(
InputArray
image, const Size2d &size);
//! Creates 3D image at a given position, pointing in the direction of the normal, and having the up_vector orientation
WImage3D(
const Mat &
image, const Size2d &size, const Vec3d &position, const Vec3d &normal, const Vec3d &up_vector);
WImage3D(
InputArray
image, const Size2d &size, const Vec3d &position, const Vec3d &normal, const Vec3d &up_vector);
void setImage(
const Mat &
image);
void setImage(
InputArray
image);
};
viz::WImage3D::WImage3D
-----------------------
Constructs an WImage3D.
.. ocv:function:: WImage3D(
const Mat &
image, const Size2d &size)
.. ocv:function:: WImage3D(
InputArray
image, const Size2d &size)
:param image: BGR or Gray-Scale image.
:param size: Size of the image.
.. ocv:function:: WImage3D(
const Mat &
image, const Size2d &size, const Vec3d &position, const Vec3d &normal, const Vec3d &up_vector)
.. ocv:function:: WImage3D(
InputArray
image, const Size2d &size, const Vec3d &position, const Vec3d &normal, const Vec3d &up_vector)
:param position: Position of the image.
:param normal: Normal of the plane that represents the image.
...
...
@@ -640,7 +640,7 @@ viz::WImage3D::setImage
-----------------------
Sets the image content of the widget.
.. ocv:function:: void setImage(
const Mat &
image)
.. ocv:function:: void setImage(
InputArray
image)
:param image: BGR or Gray-Scale image.
...
...
modules/viz/include/opencv2/viz.hpp
View file @
1449823b
...
...
@@ -66,6 +66,9 @@ namespace cv
//! Unregisters all Viz windows from internal database. After it 'getWindowByName()' will create new windows instead getting existing from the database.
CV_EXPORTS
void
unregisterAllWindows
();
//! Displays image in specified window
CV_EXPORTS
Viz3d
imshow
(
const
String
&
window_name
,
InputArray
image
,
const
Size
&
window_size
=
Size
(
-
1
,
-
1
));
//! checks float value for Nan
inline
bool
isNan
(
float
x
)
{
...
...
modules/viz/include/opencv2/viz/viz3d.hpp
View file @
1449823b
...
...
@@ -75,6 +75,8 @@ namespace cv
Widget
getWidget
(
const
String
&
id
)
const
;
void
removeAllWidgets
();
void
showImage
(
InputArray
image
,
const
Size
&
window_size
=
Size
(
-
1
,
-
1
));
void
setWidgetPose
(
const
String
&
id
,
const
Affine3d
&
pose
);
void
updateWidgetPose
(
const
String
&
id
,
const
Affine3d
&
pose
);
Affine3d
getWidgetPose
(
const
String
&
id
)
const
;
...
...
modules/viz/include/opencv2/viz/widgets.hpp
View file @
1449823b
...
...
@@ -210,8 +210,8 @@ namespace cv
class
CV_EXPORTS
WImageOverlay
:
public
Widget2D
{
public
:
WImageOverlay
(
const
Mat
&
image
,
const
Rect
&
rect
);
void
setImage
(
const
Mat
&
image
);
WImageOverlay
(
InputArray
image
,
const
Rect
&
rect
);
void
setImage
(
InputArray
image
);
};
class
CV_EXPORTS
WImage3D
:
public
Widget3D
...
...
@@ -219,12 +219,12 @@ namespace cv
public
:
//! Creates 3D image in a plane centered at the origin with normal orientaion along z-axis,
//! image x- and y-axes are oriented along x- and y-axes of 3d world
WImage3D
(
const
Mat
&
image
,
const
Size2d
&
size
);
WImage3D
(
InputArray
image
,
const
Size2d
&
size
);
//! Creates 3D image at a given position, pointing in the direction of the normal, and having the up_vector orientation
WImage3D
(
const
Mat
&
image
,
const
Size2d
&
size
,
const
Vec3d
&
center
,
const
Vec3d
&
normal
,
const
Vec3d
&
up_vector
);
WImage3D
(
InputArray
image
,
const
Size2d
&
size
,
const
Vec3d
&
center
,
const
Vec3d
&
normal
,
const
Vec3d
&
up_vector
);
void
setImage
(
const
Mat
&
image
);
void
setImage
(
InputArray
image
);
};
/////////////////////////////////////////////////////////////////////////////
...
...
modules/viz/src/shapes.cpp
View file @
1449823b
...
...
@@ -613,15 +613,16 @@ cv::String cv::viz::WText::getText() const
///////////////////////////////////////////////////////////////////////////////////////////////
/// image overlay widget implementation
cv
::
viz
::
WImageOverlay
::
WImageOverlay
(
const
Mat
&
image
,
const
Rect
&
rect
)
cv
::
viz
::
WImageOverlay
::
WImageOverlay
(
InputArray
image
,
const
Rect
&
rect
)
{
CV_Assert
(
!
image
.
empty
()
&&
image
.
depth
()
==
CV_8U
);
vtkSmartPointer
<
vtkImageMatSource
>
source
=
vtkSmartPointer
<
vtkImageMatSource
>::
New
();
source
->
SetImage
(
image
);
Size
sz
=
image
.
size
();
// Scale the image based on the Rect, and flip to match y-ais orientation
vtkSmartPointer
<
vtkTransform
>
transform
=
vtkSmartPointer
<
vtkTransform
>::
New
();
transform
->
Scale
(
image
.
cols
/
(
double
)
rect
.
width
,
image
.
rows
/
(
double
)
rect
.
height
,
1.0
);
transform
->
Scale
(
sz
.
width
/
(
double
)
rect
.
width
,
sz
.
height
/
(
double
)
rect
.
height
,
1.0
);
transform
->
RotateX
(
180
);
vtkSmartPointer
<
vtkImageReslice
>
image_reslice
=
vtkSmartPointer
<
vtkImageReslice
>::
New
();
...
...
@@ -640,11 +641,12 @@ cv::viz::WImageOverlay::WImageOverlay(const Mat &image, const Rect &rect)
vtkSmartPointer
<
vtkActor2D
>
actor
=
vtkSmartPointer
<
vtkActor2D
>::
New
();
actor
->
SetMapper
(
image_mapper
);
actor
->
SetPosition
(
rect
.
x
,
rect
.
y
);
actor
->
GetProperty
()
->
SetDisplayLocationToForeground
();
WidgetAccessor
::
setProp
(
*
this
,
actor
);
}
void
cv
::
viz
::
WImageOverlay
::
setImage
(
const
Mat
&
image
)
void
cv
::
viz
::
WImageOverlay
::
setImage
(
InputArray
image
)
{
CV_Assert
(
!
image
.
empty
()
&&
image
.
depth
()
==
CV_8U
);
...
...
@@ -661,10 +663,11 @@ void cv::viz::WImageOverlay::setImage(const Mat &image)
// Create the vtk image and set its parameters based on input image
vtkSmartPointer
<
vtkImageMatSource
>
source
=
vtkSmartPointer
<
vtkImageMatSource
>::
New
();
source
->
SetImage
(
image
);
Size
sz
=
image
.
size
();
// Scale the image based on the Rect, and flip to match y-ais orientation
vtkSmartPointer
<
vtkTransform
>
transform
=
vtkSmartPointer
<
vtkTransform
>::
New
();
transform
->
Scale
(
image
.
cols
/
(
double
)
size
.
width
,
image
.
rows
/
(
double
)
size
.
height
,
1.0
);
transform
->
Scale
(
sz
.
width
/
(
double
)
size
.
width
,
sz
.
height
/
(
double
)
size
.
height
,
1.0
);
transform
->
RotateX
(
180
);
vtkSmartPointer
<
vtkImageReslice
>
image_reslice
=
vtkSmartPointer
<
vtkImageReslice
>::
New
();
...
...
@@ -687,7 +690,7 @@ template<> cv::viz::WImageOverlay cv::viz::Widget::cast<cv::viz::WImageOverlay>(
///////////////////////////////////////////////////////////////////////////////////////////////
/// image 3D widget implementation
cv
::
viz
::
WImage3D
::
WImage3D
(
const
Mat
&
image
,
const
Size2d
&
size
)
cv
::
viz
::
WImage3D
::
WImage3D
(
InputArray
image
,
const
Size2d
&
size
)
{
CV_Assert
(
!
image
.
empty
()
&&
image
.
depth
()
==
CV_8U
);
...
...
@@ -717,7 +720,7 @@ cv::viz::WImage3D::WImage3D(const Mat &image, const Size2d &size)
WidgetAccessor
::
setProp
(
*
this
,
actor
);
}
cv
::
viz
::
WImage3D
::
WImage3D
(
const
Mat
&
image
,
const
Size2d
&
size
,
const
Vec3d
&
center
,
const
Vec3d
&
normal
,
const
Vec3d
&
up_vector
)
cv
::
viz
::
WImage3D
::
WImage3D
(
InputArray
image
,
const
Size2d
&
size
,
const
Vec3d
&
center
,
const
Vec3d
&
normal
,
const
Vec3d
&
up_vector
)
{
CV_Assert
(
!
image
.
empty
()
&&
image
.
depth
()
==
CV_8U
);
...
...
@@ -732,7 +735,7 @@ cv::viz::WImage3D::WImage3D(const Mat &image, const Size2d &size, const Vec3d &c
*
this
=
image3d
;
}
void
cv
::
viz
::
WImage3D
::
setImage
(
const
Mat
&
image
)
void
cv
::
viz
::
WImage3D
::
setImage
(
InputArray
image
)
{
CV_Assert
(
!
image
.
empty
()
&&
image
.
depth
()
==
CV_8U
);
...
...
modules/viz/src/viz3d.cpp
View file @
1449823b
...
...
@@ -112,6 +112,17 @@ void cv::viz::Viz3d::showWidget(const String &id, const Widget &widget, const Af
void
cv
::
viz
::
Viz3d
::
removeWidget
(
const
String
&
id
)
{
impl_
->
removeWidget
(
id
);
}
cv
::
viz
::
Widget
cv
::
viz
::
Viz3d
::
getWidget
(
const
String
&
id
)
const
{
return
impl_
->
getWidget
(
id
);
}
void
cv
::
viz
::
Viz3d
::
removeAllWidgets
()
{
impl_
->
removeAllWidgets
();
}
void
cv
::
viz
::
Viz3d
::
showImage
(
InputArray
image
,
const
Size
&
window_size
)
{
removeAllWidgets
();
if
(
window_size
.
width
>
0
&&
window_size
.
height
>
0
)
setWindowSize
(
window_size
);
showWidget
(
"showImage"
,
WImageOverlay
(
image
,
Rect
(
Point
(
0
,
0
),
getWindowSize
())));
}
void
cv
::
viz
::
Viz3d
::
setWidgetPose
(
const
String
&
id
,
const
Affine3d
&
pose
)
{
impl_
->
setWidgetPose
(
id
,
pose
);
}
void
cv
::
viz
::
Viz3d
::
updateWidgetPose
(
const
String
&
id
,
const
Affine3d
&
pose
)
{
impl_
->
updateWidgetPose
(
id
,
pose
);
}
cv
::
Affine3d
cv
::
viz
::
Viz3d
::
getWidgetPose
(
const
String
&
id
)
const
{
return
impl_
->
getWidgetPose
(
id
);
}
...
...
modules/viz/src/vizcore.cpp
View file @
1449823b
...
...
@@ -122,6 +122,13 @@ cv::String cv::viz::VizStorage::generateWindowName(const String &window_name)
cv
::
viz
::
Viz3d
cv
::
viz
::
getWindowByName
(
const
String
&
window_name
)
{
return
Viz3d
(
window_name
);
}
void
cv
::
viz
::
unregisterAllWindows
()
{
VizStorage
::
unregisterAll
();
}
cv
::
viz
::
Viz3d
cv
::
viz
::
imshow
(
const
String
&
window_name
,
InputArray
image
,
const
Size
&
window_size
)
{
Viz3d
viz
=
getWindowByName
(
window_name
);
viz
.
showImage
(
image
,
window_size
);
return
viz
;
}
///////////////////////////////////////////////////////////////////////////////////////////////
/// Read/write clouds. Supported formats: ply, stl, xyz, obj
...
...
modules/viz/test/tests_simple.cpp
View file @
1449823b
...
...
@@ -250,6 +250,20 @@ TEST(Viz, DISABLED_show_overlay_image)
//viz.spin();
}
TEST
(
Viz
,
DISABLED_show_image_method
)
{
Mat
lena
=
imread
(
Path
::
combine
(
cvtest
::
TS
::
ptr
()
->
get_data_path
(),
"lena.png"
));
Viz3d
viz
(
"show_image_method"
);
viz
.
showImage
(
lena
);
viz
.
spinOnce
(
1500
,
true
);
viz
.
showImage
(
lena
,
lena
.
size
());
viz
.
spinOnce
(
1500
,
true
);
cv
::
viz
::
imshow
(
"show_image_method"
,
make_gray
(
lena
)).
spin
();
}
TEST
(
Viz
,
DISABLED_show_image_3d
)
{
Mat
lena
=
imread
(
Path
::
combine
(
cvtest
::
TS
::
ptr
()
->
get_data_path
(),
"lena.png"
));
...
...
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