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
769512db
Commit
769512db
authored
Jul 24, 2013
by
ozantonkal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move image copying structure to viz3d_impl: ConvertToVtkImage
parent
952029a4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
8 deletions
+57
-8
widgets.hpp
modules/viz/include/opencv2/viz/widgets.hpp
+0
-8
shape_widgets.cpp
modules/viz/src/shape_widgets.cpp
+0
-0
viz3d_impl.hpp
modules/viz/src/viz3d_impl.hpp
+57
-0
No files found.
modules/viz/include/opencv2/viz/widgets.hpp
View file @
769512db
...
...
@@ -155,9 +155,6 @@ namespace cv
ImageOverlayWidget
(
const
Mat
&
image
,
const
Rect
&
rect
);
void
setImage
(
const
Mat
&
image
);
private
:
struct
CopyImpl
;
};
class
CV_EXPORTS
Image3DWidget
:
public
Widget3D
...
...
@@ -167,9 +164,6 @@ namespace cv
Image3DWidget
(
const
Vec3f
&
position
,
const
Vec3f
&
normal
,
const
Vec3f
&
up_vector
,
const
Mat
&
image
,
const
Size
&
size
);
void
setImage
(
const
Mat
&
image
);
private
:
struct
CopyImpl
;
};
class
CV_EXPORTS
CameraPositionWidget
:
public
Widget3D
...
...
@@ -181,8 +175,6 @@ namespace cv
CameraPositionWidget
(
const
Vec2f
&
fov
,
double
scale
=
1.0
,
const
Color
&
color
=
Color
::
white
());
CameraPositionWidget
(
const
Matx33f
&
K
,
const
Mat
&
img
,
double
scale
=
1.0
);
private
:
struct
CopyImpl
;
};
class
CV_EXPORTS
TrajectoryWidget
:
public
Widget3D
...
...
modules/viz/src/shape_widgets.cpp
View file @
769512db
This diff is collapsed.
Click to expand it.
modules/viz/src/viz3d_impl.hpp
View file @
769512db
...
...
@@ -410,6 +410,63 @@ namespace cv
inline
Vec3d
vtkpoint
(
const
Point3f
&
point
)
{
return
Vec3d
(
point
.
x
,
point
.
y
,
point
.
z
);
}
template
<
typename
_Tp
>
inline
_Tp
normalized
(
const
_Tp
&
v
)
{
return
v
*
1
/
cv
::
norm
(
v
);
}
struct
ConvertToVtkImage
{
struct
Impl
{
static
void
copyImageMultiChannel
(
const
Mat
&
image
,
vtkSmartPointer
<
vtkImageData
>
output
)
{
int
i_chs
=
image
.
channels
();
for
(
int
i
=
0
;
i
<
image
.
rows
;
++
i
)
{
const
unsigned
char
*
irows
=
image
.
ptr
<
unsigned
char
>
(
i
);
for
(
int
j
=
0
;
j
<
image
.
cols
;
++
j
,
irows
+=
i_chs
)
{
unsigned
char
*
vrows
=
static_cast
<
unsigned
char
*>
(
output
->
GetScalarPointer
(
j
,
i
,
0
));
memcpy
(
vrows
,
irows
,
i_chs
);
std
::
swap
(
vrows
[
0
],
vrows
[
2
]);
// BGR -> RGB
}
}
output
->
Modified
();
}
static
void
copyImageSingleChannel
(
const
Mat
&
image
,
vtkSmartPointer
<
vtkImageData
>
output
)
{
for
(
int
i
=
0
;
i
<
image
.
rows
;
++
i
)
{
const
unsigned
char
*
irows
=
image
.
ptr
<
unsigned
char
>
(
i
);
for
(
int
j
=
0
;
j
<
image
.
cols
;
++
j
,
++
irows
)
{
unsigned
char
*
vrows
=
static_cast
<
unsigned
char
*>
(
output
->
GetScalarPointer
(
j
,
i
,
0
));
*
vrows
=
*
irows
;
}
}
output
->
Modified
();
}
};
static
void
convert
(
const
Mat
&
image
,
vtkSmartPointer
<
vtkImageData
>
output
)
{
// Create the vtk image
output
->
SetDimensions
(
image
.
cols
,
image
.
rows
,
1
);
output
->
SetNumberOfScalarComponents
(
image
.
channels
());
output
->
SetScalarTypeToUnsignedChar
();
output
->
AllocateScalars
();
int
i_chs
=
image
.
channels
();
if
(
i_chs
>
1
)
{
// Multi channel images are handled differently because of BGR <-> RGB
Impl
::
copyImageMultiChannel
(
image
,
output
);
}
else
{
Impl
::
copyImageSingleChannel
(
image
,
output
);
}
}
};
}
}
...
...
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