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
119d97f1
Commit
119d97f1
authored
Aug 05, 2013
by
ozantonkal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove old camera, rename new camera
parent
f060eee5
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
20 additions
and
151 deletions
+20
-151
types.hpp
modules/viz/include/opencv2/viz/types.hpp
+4
-4
viz3d.hpp
modules/viz/include/opencv2/viz/viz3d.hpp
+2
-1
common.cpp
modules/viz/src/common.cpp
+0
-45
common.h
modules/viz/src/common.h
+0
-73
types.cpp
modules/viz/src/types.cpp
+6
-6
viz3d.cpp
modules/viz/src/viz3d.cpp
+2
-1
viz3d_impl.cpp
modules/viz/src/viz3d_impl.cpp
+4
-19
viz3d_impl.hpp
modules/viz/src/viz3d_impl.hpp
+2
-2
No files found.
modules/viz/include/opencv2/viz/types.hpp
View file @
119d97f1
...
...
@@ -94,12 +94,12 @@ namespace cv
unsigned
int
key_state
;
};
class
CV_EXPORTS
Camera
2
class
CV_EXPORTS
Camera
{
public
:
Camera
2
(
float
f_x
,
float
f_y
,
float
c_x
,
float
c_y
,
const
Size
&
window_size
);
Camera
2
(
const
Vec2f
&
fov
,
const
Size
&
window_size
);
Camera
2
(
const
cv
::
Mat
&
K
,
const
Size
&
window_size
);
Camera
(
float
f_x
,
float
f_y
,
float
c_x
,
float
c_y
,
const
Size
&
window_size
);
Camera
(
const
Vec2f
&
fov
,
const
Size
&
window_size
);
Camera
(
const
cv
::
Mat
&
K
,
const
Size
&
window_size
);
inline
const
Vec2d
&
getClip
()
const
{
return
clip_
;
}
inline
void
setClip
(
const
Vec2d
&
clip
)
{
clip_
=
clip
;
}
...
...
modules/viz/include/opencv2/viz/viz3d.hpp
View file @
119d97f1
...
...
@@ -39,7 +39,8 @@ namespace cv
void
updateWidgetPose
(
const
String
&
id
,
const
Affine3f
&
pose
);
Affine3f
getWidgetPose
(
const
String
&
id
)
const
;
void
setCamera
(
const
Camera2
&
camera
);
void
setCamera
(
const
Camera
&
camera
);
Camera
getCamera
()
const
;
Affine3f
getViewerPose
();
void
setViewerPose
(
const
Affine3f
&
pose
);
...
...
modules/viz/src/common.cpp
View file @
119d97f1
...
...
@@ -263,48 +263,3 @@ int hull_vertex_table[43][7] = {
// return (fabsf (float (sum * 0.5f)));
//}
/////////////////////////////////////////////////////////////////////////////////////////////
void
cv
::
viz
::
Camera
::
computeViewMatrix
(
Affine3d
&
view_mat
)
const
{
//constructs view matrix from camera pos, view up, and the point it is looking at
//this code is based off of gluLookAt http://www.opengl.org/wiki/GluLookAt_code
Vec3d
zAxis
=
normalized
(
focal
-
pos
);
Vec3d
xAxis
=
normalized
(
zAxis
.
cross
(
view_up
));
Vec3d
yAxis
=
xAxis
.
cross
(
zAxis
);
Matx33d
R
;
R
(
0
,
0
)
=
xAxis
[
0
];
R
(
0
,
1
)
=
xAxis
[
1
];
R
(
0
,
2
)
=
xAxis
[
2
];
R
(
1
,
0
)
=
yAxis
[
0
];
R
(
1
,
1
)
=
yAxis
[
1
];
R
(
1
,
2
)
=
yAxis
[
2
];
R
(
1
,
0
)
=
-
zAxis
[
0
];
R
(
2
,
1
)
=
-
zAxis
[
1
];
R
(
2
,
2
)
=
-
zAxis
[
2
];
Vec3d
t
=
R
*
(
-
pos
);
view_mat
=
Affine3d
(
R
,
t
);
}
///////////////////////////////////////////////////////////////////////
void
cv
::
viz
::
Camera
::
computeProjectionMatrix
(
Matx44d
&
proj
)
const
{
double
top
=
clip
[
0
]
*
tan
(
0.5
*
fovy
);
double
left
=
-
(
top
*
window_size
[
0
])
/
window_size
[
1
];
double
right
=
-
left
;
double
bottom
=
-
top
;
double
temp1
=
2.0
*
clip
[
0
];
double
temp2
=
1.0
/
(
right
-
left
);
double
temp3
=
1.0
/
(
top
-
bottom
);
double
temp4
=
1.0
/
clip
[
1
]
-
clip
[
0
];
proj
=
Matx44d
::
zeros
();
proj
(
0
,
0
)
=
temp1
*
temp2
;
proj
(
1
,
1
)
=
temp1
*
temp3
;
proj
(
0
,
2
)
=
(
right
+
left
)
*
temp2
;
proj
(
1
,
2
)
=
(
top
+
bottom
)
*
temp3
;
proj
(
2
,
2
)
=
(
-
clip
[
1
]
-
clip
[
0
])
*
temp4
;
proj
(
3
,
2
)
=
-
1.0
;
proj
(
2
,
3
)
=
(
-
temp1
*
clip
[
1
])
*
temp4
;
}
modules/viz/src/common.h
View file @
119d97f1
...
...
@@ -48,79 +48,6 @@ namespace cv
SHADING_PHONG
};
class
CV_EXPORTS
Camera
{
public
:
/** Focal point or lookAt. The view direction can be obtained by (focal-pos).normalized () */
Vec3d
focal
;
/** \brief Position of the camera. */
Vec3d
pos
;
/** \brief Up vector of the camera. */
Vec3d
view_up
;
/** \brief Near/far clipping planes depths */
Vec2d
clip
;
/** \brief Field of view angle in y direction (radians). */
double
fovy
;
// the following variables are the actual position and size of the window on the screen and NOT the viewport!
// except for the size, which is the same the viewport is assumed to be centered and same size as the window.
Vec2i
window_size
;
Vec2i
window_pos
;
/** \brief Computes View matrix for Camera (Based on gluLookAt)
* \param[out] view_mat the resultant matrix
*/
void
computeViewMatrix
(
Affine3d
&
view_mat
)
const
;
/** \brief Computes Projection Matrix for Camera
* \param[out] proj the resultant matrix
*/
void
computeProjectionMatrix
(
Matx44d
&
proj
)
const
;
/** \brief converts point to window coordiantes
* \param[in] pt xyz point to be converted
* \param[out] window_cord vector containing the pts' window X,Y, Z and 1
*
* This function computes the projection and view matrix every time.
* It is very inefficient to use this for every point in the point cloud!
*/
void
cvtWindowCoordinates
(
const
cv
::
Point3f
&
pt
,
Vec4d
&
window_cord
)
const
{
Affine3d
view
;
computeViewMatrix
(
view
);
Matx44d
proj
;
computeProjectionMatrix
(
proj
);
cvtWindowCoordinates
(
pt
,
proj
*
view
.
matrix
,
window_cord
);
return
;
}
/** \brief converts point to window coordiantes
* \param[in] pt xyz point to be converted
* \param[out] window_cord vector containing the pts' window X,Y, Z and 1
* \param[in] composite_mat composite transformation matrix (proj*view)
*
* Use this function to compute window coordinates with a precomputed
* transformation function. The typical composite matrix will be
* the projection matrix * the view matrix. However, additional
* matrices like a camera disortion matrix can also be added.
*/
void
cvtWindowCoordinates
(
const
Point3f
&
pt
,
const
Matx44d
&
composite_mat
,
Vec4d
&
window_cord
)
const
{
Vec4d
pte
(
pt
.
x
,
pt
.
y
,
pt
.
z
,
1
);
window_cord
=
composite_mat
*
pte
;
window_cord
=
window_cord
/
window_cord
[
3
];
window_cord
[
0
]
=
(
window_cord
[
0
]
+
1
.
0
)
/
2
.
0
*
window_size
[
0
];
window_cord
[
1
]
=
(
window_cord
[
1
]
+
1
.
0
)
/
2
.
0
*
window_size
[
1
];
window_cord
[
2
]
=
(
window_cord
[
2
]
+
1
.
0
)
/
2
.
0
;
}
};
}
}
modules/viz/src/types.cpp
View file @
119d97f1
...
...
@@ -146,7 +146,7 @@ cv::viz::Mesh3d cv::viz::Mesh3d::loadMesh(const String& file)
////////////////////////////////////////////////////////////////////
/// Camera implementation
cv
::
viz
::
Camera
2
::
Camera2
(
float
f_x
,
float
f_y
,
float
c_x
,
float
c_y
,
const
Size
&
window_size
)
cv
::
viz
::
Camera
::
Camera
(
float
f_x
,
float
f_y
,
float
c_x
,
float
c_y
,
const
Size
&
window_size
)
{
CV_Assert
(
window_size
.
width
>
0
&&
window_size
.
height
>
0
);
setClip
(
Vec2d
(
0.01
,
1000.01
));
// Default clipping
...
...
@@ -161,7 +161,7 @@ cv::viz::Camera2::Camera2(float f_x, float f_y, float c_x, float c_y, const Size
focal_
[
1
]
=
f_y
;
}
cv
::
viz
::
Camera
2
::
Camera2
(
const
Vec2f
&
fov
,
const
Size
&
window_size
)
cv
::
viz
::
Camera
::
Camera
(
const
Vec2f
&
fov
,
const
Size
&
window_size
)
{
CV_Assert
(
window_size
.
width
>
0
&&
window_size
.
height
>
0
);
setClip
(
Vec2d
(
0.01
,
1000.01
));
// Default clipping
...
...
@@ -171,7 +171,7 @@ cv::viz::Camera2::Camera2(const Vec2f &fov, const Size &window_size)
setWindowSize
(
window_size
);
}
cv
::
viz
::
Camera
2
::
Camera2
(
const
cv
::
Mat
&
K
,
const
Size
&
window_size
)
cv
::
viz
::
Camera
::
Camera
(
const
cv
::
Mat
&
K
,
const
Size
&
window_size
)
{
CV_Assert
(
K
.
rows
==
3
&&
K
.
cols
==
3
);
CV_Assert
(
window_size
.
width
>
0
&&
window_size
.
height
>
0
);
...
...
@@ -180,10 +180,10 @@ cv::viz::Camera2::Camera2(const cv::Mat & K, const Size &window_size)
float
f_y
=
K
.
at
<
float
>
(
1
,
1
);
float
c_x
=
K
.
at
<
float
>
(
0
,
2
);
float
c_y
=
K
.
at
<
float
>
(
1
,
2
);
Camera
2
(
f_x
,
f_y
,
c_x
,
c_y
,
window_size
);
Camera
(
f_x
,
f_y
,
c_x
,
c_y
,
window_size
);
}
void
cv
::
viz
::
Camera
2
::
setWindowSize
(
const
Size
&
window_size
)
void
cv
::
viz
::
Camera
::
setWindowSize
(
const
Size
&
window_size
)
{
CV_Assert
(
window_size
.
width
>
0
&&
window_size
.
height
>
0
);
...
...
@@ -199,7 +199,7 @@ void cv::viz::Camera2::setWindowSize(const Size &window_size)
window_size_
=
window_size
;
}
void
cv
::
viz
::
Camera
2
::
computeProjectionMatrix
(
Matx44f
&
proj
)
const
void
cv
::
viz
::
Camera
::
computeProjectionMatrix
(
Matx44f
&
proj
)
const
{
double
top
=
clip_
[
0
]
*
tan
(
0.5
*
fov_
[
1
]);
double
left
=
-
(
top
*
window_size_
.
width
)
/
window_size_
.
height
;
...
...
modules/viz/src/viz3d.cpp
View file @
119d97f1
...
...
@@ -46,7 +46,8 @@ void cv::viz::Viz3d::setWidgetPose(const String &id, const Affine3f &pose) { imp
void
cv
::
viz
::
Viz3d
::
updateWidgetPose
(
const
String
&
id
,
const
Affine3f
&
pose
)
{
impl_
->
updateWidgetPose
(
id
,
pose
);
}
cv
::
Affine3f
cv
::
viz
::
Viz3d
::
getWidgetPose
(
const
String
&
id
)
const
{
return
impl_
->
getWidgetPose
(
id
);
}
void
cv
::
viz
::
Viz3d
::
setCamera
(
const
Camera2
&
camera
)
{
impl_
->
setCamera
(
camera
);
}
void
cv
::
viz
::
Viz3d
::
setCamera
(
const
Camera
&
camera
)
{
impl_
->
setCamera
(
camera
);
}
cv
::
viz
::
Camera
cv
::
viz
::
Viz3d
::
getCamera
()
const
{
return
impl_
->
getCamera
();
}
void
cv
::
viz
::
Viz3d
::
setViewerPose
(
const
Affine3f
&
pose
)
{
impl_
->
setViewerPose
(
pose
);
}
cv
::
Affine3f
cv
::
viz
::
Viz3d
::
getViewerPose
()
{
return
impl_
->
getViewerPose
();
}
...
...
modules/viz/src/viz3d_impl.cpp
View file @
119d97f1
...
...
@@ -545,7 +545,7 @@ void cv::viz::Viz3d::VizImpl::initCameraParameters ()
Vec2i
window_size
(
window_
->
GetScreenSize
());
window_size
/=
2
;
Camera
2
camera_temp
(
Vec2f
(
0.0
,
0.8575
),
Size
(
window_size
[
0
],
window_size
[
1
]));
Camera
camera_temp
(
Vec2f
(
0.0
,
0.8575
),
Size
(
window_size
[
0
],
window_size
[
1
]));
setCamera
(
camera_temp
);
setViewerPose
(
makeCameraPose
(
Vec3f
(
0.0
f
,
0.0
f
,
0.0
f
),
Vec3f
(
0.0
f
,
0.0
f
,
1.0
f
),
Vec3f
(
0.0
f
,
1.0
f
,
0.0
f
)));
}
...
...
@@ -564,22 +564,7 @@ void cv::viz::Viz3d::VizImpl::updateCamera ()
}
/////////////////////////////////////////////////////////////////////////////////////////////
// void cv::viz::Viz3d::VizImpl::getCameras (cv::viz::Camera& camera)
// {
// vtkCamera* active_camera = renderer_->GetActiveCamera ();
//
// camera.pos = cv::Vec3d(active_camera->GetPosition());
// camera.focal = cv::Vec3d(active_camera->GetFocalPoint());
// camera.clip = cv::Vec2d(active_camera->GetClippingRange());
// camera.view_up = cv::Vec3d(active_camera->GetViewUp());
//
// camera.fovy = active_camera->GetViewAngle()/ 180.0 * CV_PI;
// camera.window_size = cv::Vec2i(renderer_->GetRenderWindow()->GetSize());
// camera.window_pos = cv::Vec2d::all(0);
// }
/////////////////////////////////////////////////////////////////////////////////////////////
void
cv
::
viz
::
Viz3d
::
VizImpl
::
setCamera
(
const
Camera2
&
camera
)
void
cv
::
viz
::
Viz3d
::
VizImpl
::
setCamera
(
const
Camera
&
camera
)
{
vtkCamera
&
active_camera
=
*
renderer_
->
GetActiveCamera
();
...
...
@@ -591,7 +576,7 @@ void cv::viz::Viz3d::VizImpl::setCamera(const Camera2 &camera)
}
/////////////////////////////////////////////////////////////////////////////////////////////
cv
::
viz
::
Camera
2
cv
::
viz
::
Viz3d
::
VizImpl
::
getCamera
()
const
cv
::
viz
::
Camera
cv
::
viz
::
Viz3d
::
VizImpl
::
getCamera
()
const
{
vtkCamera
&
active_camera
=
*
renderer_
->
GetActiveCamera
();
...
...
@@ -600,7 +585,7 @@ cv::viz::Camera2 cv::viz::Viz3d::VizImpl::getCamera() const
Size
window_size
(
renderer_
->
GetRenderWindow
()
->
GetSize
()[
0
],
renderer_
->
GetRenderWindow
()
->
GetSize
()[
1
]);
Camera
2
camera
(
fov
,
window_size
);
Camera
camera
(
fov
,
window_size
);
camera
.
setClip
(
clip
);
return
camera
;
}
...
...
modules/viz/src/viz3d_impl.hpp
View file @
119d97f1
...
...
@@ -110,8 +110,8 @@ public:
// All camera methods to refactor into set/getViewwerPose, setCamera()
// and 'Camera' class itself with various constructors/fields
void
setCamera
(
const
Camera
2
&
camera
);
Camera
2
getCamera
()
const
;
void
setCamera
(
const
Camera
&
camera
);
Camera
getCamera
()
const
;
void
initCameraParameters
();
/** \brief Initialize camera parameters with some default values. */
bool
cameraParamsSet
()
const
;
/** \brief Checks whether the camera parameters were manually loaded from file.*/
...
...
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