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
b1002996
Commit
b1002996
authored
Jan 07, 2014
by
Anatoly Baksheev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
code beatification
parent
e26b7e1e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
63 deletions
+25
-63
interactor_style.hpp
modules/viz/src/interactor_style.hpp
+1
-1
precomp.hpp
modules/viz/src/precomp.hpp
+1
-0
shapes.cpp
modules/viz/src/shapes.cpp
+23
-62
No files found.
modules/viz/src/interactor_style.hpp
View file @
b1002996
...
...
@@ -63,7 +63,7 @@ namespace cv
virtual
void
Initialize
();
void
setWidgetActorMap
(
const
Ptr
<
WidgetActorMap
>&
actors
)
{
widget_actor_map_
=
actors
;
}
void
setRenderer
(
vtkSmartPointer
<
vtkRenderer
>&
ren
)
{
renderer_
=
ren
;
}
void
setRenderer
(
vtkSmartPointer
<
vtkRenderer
>&
ren
derer
)
{
renderer_
=
renderer
;
}
void
registerMouseCallback
(
void
(
*
callback
)(
const
MouseEvent
&
,
void
*
),
void
*
cookie
=
0
);
void
registerKeyboardCallback
(
void
(
*
callback
)(
const
KeyboardEvent
&
,
void
*
),
void
*
cookie
=
0
);
void
saveScreenshot
(
const
String
&
file
);
...
...
modules/viz/src/precomp.hpp
View file @
b1002996
...
...
@@ -124,6 +124,7 @@
#include <vtkSTLReader.h>
#include <vtkOBJExporter.h>
#include <vtkVRMLExporter.h>
#include <vtkTensorGlyph.h>
#if !defined(_WIN32) || defined(__CYGWIN__)
# include <unistd.h>
/* unlink */
...
...
modules/viz/src/shapes.cpp
View file @
b1002996
...
...
@@ -189,28 +189,22 @@ cv::viz::WArrow::WArrow(const Point3f& pt1, const Point3f& pt2, float thickness,
arrowSource
->
SetTipRadius
(
thickness
*
3.0
);
arrowSource
->
SetTipLength
(
thickness
*
10.0
);
Vec3f
startPoint
(
pt1
.
x
,
pt1
.
y
,
pt1
.
z
),
endPoint
(
pt2
.
x
,
pt2
.
y
,
pt2
.
z
);
Vec3f
arbitrary
(
theRNG
().
uniform
(
-
10.
f
,
10.
f
),
theRNG
().
uniform
(
-
10.
f
,
10.
f
),
theRNG
().
uniform
(
-
10.
f
,
10.
f
));
RNG
rng
=
theRNG
();
Vec3d
arbitrary
(
rng
.
uniform
(
-
10.0
,
10.0
),
rng
.
uniform
(
-
10.0
,
10.0
),
rng
.
uniform
(
-
10.0
,
10.0
));
Vec3d
startPoint
(
pt1
.
x
,
pt1
.
y
,
pt1
.
z
),
endPoint
(
pt2
.
x
,
pt2
.
y
,
pt2
.
z
);
double
length
=
cv
::
norm
(
endPoint
-
startPoint
);
Vec3
f
xvec
=
normalized
(
endPoint
-
startPoint
);
Vec3
f
zvec
=
normalized
(
xvec
.
cross
(
arbitrary
));
Vec3
f
yvec
=
zvec
.
cross
(
xvec
);
Vec3
d
xvec
=
normalized
(
endPoint
-
startPoint
);
Vec3
d
zvec
=
normalized
(
xvec
.
cross
(
arbitrary
));
Vec3
d
yvec
=
zvec
.
cross
(
xvec
);
// Create the direction cosine matrix
vtkSmartPointer
<
vtkMatrix4x4
>
matrix
=
vtkSmartPointer
<
vtkMatrix4x4
>::
New
();
matrix
->
Identity
();
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
matrix
->
SetElement
(
i
,
0
,
xvec
[
i
]);
matrix
->
SetElement
(
i
,
1
,
yvec
[
i
]);
matrix
->
SetElement
(
i
,
2
,
zvec
[
i
]);
}
Affine3d
pose
=
makeTransformToGlobal
(
xvec
,
yvec
,
zvec
);
// Apply the transforms
vtkSmartPointer
<
vtkTransform
>
transform
=
vtkSmartPointer
<
vtkTransform
>::
New
();
transform
->
Translate
(
startPoint
.
val
);
transform
->
Concatenate
(
matrix
);
transform
->
Concatenate
(
vtkmatrix
(
pose
.
matrix
)
);
transform
->
Scale
(
length
,
length
,
length
);
// Transform the polydata
...
...
@@ -523,34 +517,18 @@ cv::viz::WGrid::WGrid(const Vec4f &coefs, const Vec2i &dimensions, const Vec2f &
vtkSmartPointer
<
vtkPolyData
>
grid
=
GridUtils
::
createGrid
(
dimensions
,
spacing
);
// Estimate the transform to set the normal based on the coefficients
Vec3
f
normal
(
coefs
[
0
],
coefs
[
1
],
coefs
[
2
]);
Vec3
f
up_vector
(
0.0
f
,
1.0
f
,
0.0
f
);
// Just set as default
Vec3
d
normal
(
coefs
[
0
],
coefs
[
1
],
coefs
[
2
]);
Vec3
d
up_vector
(
0.0
,
1.0
,
0.0
);
// Just set as default
double
push_distance
=
-
coefs
[
3
]
/
cv
::
norm
(
Vec3f
(
coefs
.
val
));
Vec3f
u
,
v
,
n
;
n
=
normalize
(
normal
);
u
=
normalize
(
up_vector
.
cross
(
n
));
v
=
n
.
cross
(
u
);
vtkSmartPointer
<
vtkMatrix4x4
>
mat_trans
=
vtkSmartPointer
<
vtkMatrix4x4
>::
New
();
mat_trans
->
SetElement
(
0
,
0
,
u
[
0
]);
mat_trans
->
SetElement
(
0
,
1
,
u
[
1
]);
mat_trans
->
SetElement
(
0
,
2
,
u
[
2
]);
mat_trans
->
SetElement
(
1
,
0
,
v
[
0
]);
mat_trans
->
SetElement
(
1
,
1
,
v
[
1
]);
mat_trans
->
SetElement
(
1
,
2
,
v
[
2
]);
mat_trans
->
SetElement
(
2
,
0
,
n
[
0
]);
mat_trans
->
SetElement
(
2
,
1
,
n
[
1
]);
mat_trans
->
SetElement
(
2
,
2
,
n
[
2
]);
// Inverse rotation (orthogonal, so just take transpose)
mat_trans
->
Transpose
();
mat_trans
->
SetElement
(
0
,
3
,
n
[
0
]
*
push_distance
);
mat_trans
->
SetElement
(
1
,
3
,
n
[
1
]
*
push_distance
);
mat_trans
->
SetElement
(
2
,
3
,
n
[
2
]
*
push_distance
);
mat_trans
->
SetElement
(
3
,
3
,
1
);
Vec3d
n
=
normalize
(
normal
);
Vec3d
u
=
normalize
(
up_vector
.
cross
(
n
));
Vec3d
v
=
n
.
cross
(
u
);
Affine3d
pose
=
makeTransformToGlobal
(
u
,
v
,
n
,
n
*
push_distance
);
vtkSmartPointer
<
vtkTransform
>
transform
=
vtkSmartPointer
<
vtkTransform
>::
New
();
transform
->
PreMultiply
();
transform
->
SetMatrix
(
mat_trans
);
transform
->
SetMatrix
(
vtkmatrix
(
pose
.
matrix
)
);
vtkSmartPointer
<
vtkTransformPolyDataFilter
>
transform_filter
=
vtkSmartPointer
<
vtkTransformPolyDataFilter
>::
New
();
transform_filter
->
SetTransform
(
transform
);
...
...
@@ -837,28 +815,11 @@ cv::viz::WImage3D::WImage3D(const Vec3f &position, const Vec3f &normal, const Ve
plane
->
SetNormal
(
0.0
,
0.0
,
1.0
);
// Compute the transformation matrix for drawing the camera frame in a scene
Vec3f
u
,
v
,
n
;
n
=
normalize
(
normal
);
u
=
normalize
(
up_vector
.
cross
(
n
));
v
=
n
.
cross
(
u
);
vtkSmartPointer
<
vtkMatrix4x4
>
mat_trans
=
vtkSmartPointer
<
vtkMatrix4x4
>::
New
();
mat_trans
->
SetElement
(
0
,
0
,
u
[
0
]);
mat_trans
->
SetElement
(
0
,
1
,
u
[
1
]);
mat_trans
->
SetElement
(
0
,
2
,
u
[
2
]);
mat_trans
->
SetElement
(
1
,
0
,
v
[
0
]);
mat_trans
->
SetElement
(
1
,
1
,
v
[
1
]);
mat_trans
->
SetElement
(
1
,
2
,
v
[
2
]);
mat_trans
->
SetElement
(
2
,
0
,
n
[
0
]);
mat_trans
->
SetElement
(
2
,
1
,
n
[
1
]);
mat_trans
->
SetElement
(
2
,
2
,
n
[
2
]);
// Inverse rotation (orthogonal, so just take transpose)
mat_trans
->
Transpose
();
// Then translate the coordinate frame to camera position
mat_trans
->
SetElement
(
0
,
3
,
position
[
0
]);
mat_trans
->
SetElement
(
1
,
3
,
position
[
1
]);
mat_trans
->
SetElement
(
2
,
3
,
position
[
2
]);
mat_trans
->
SetElement
(
3
,
3
,
1
);
Vec3d
n
=
normalize
(
normal
);
Vec3d
u
=
normalize
(
up_vector
.
cross
(
n
));
Vec3d
v
=
n
.
cross
(
u
);
Affine3d
pose
=
makeTransformToGlobal
(
u
,
v
,
n
,
position
);
// Apply the texture
vtkSmartPointer
<
vtkTexture
>
texture
=
vtkSmartPointer
<
vtkTexture
>::
New
();
...
...
@@ -870,7 +831,7 @@ cv::viz::WImage3D::WImage3D(const Vec3f &position, const Vec3f &normal, const Ve
// Apply the transform after texture mapping
vtkSmartPointer
<
vtkTransform
>
transform
=
vtkSmartPointer
<
vtkTransform
>::
New
();
transform
->
PreMultiply
();
transform
->
SetMatrix
(
mat_trans
);
transform
->
SetMatrix
(
vtkmatrix
(
pose
)
);
transform
->
Scale
(
size
.
width
,
size
.
height
,
1.0
);
vtkSmartPointer
<
vtkTransformPolyDataFilter
>
transform_filter
=
vtkSmartPointer
<
vtkTransformPolyDataFilter
>::
New
();
...
...
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