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
a76cc9ef
Commit
a76cc9ef
authored
Aug 02, 2013
by
ozantonkal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
initial camera implementation (camera2), fix bug (zeros method)
parent
8fa6b6a6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
79 additions
and
0 deletions
+79
-0
types.hpp
modules/viz/include/opencv2/viz/types.hpp
+25
-0
types.cpp
modules/viz/src/types.cpp
+54
-0
No files found.
modules/viz/include/opencv2/viz/types.hpp
View file @
a76cc9ef
#pragma once
#pragma once
#include <string>
#include <string>
#include <boost/concept_check.hpp>
#include <opencv2/core.hpp>
#include <opencv2/core.hpp>
#include <opencv2/core/affine.hpp>
#include <opencv2/core/affine.hpp>
...
@@ -93,6 +94,30 @@ namespace cv
...
@@ -93,6 +94,30 @@ namespace cv
Point
pointer
;
Point
pointer
;
unsigned
int
key_state
;
unsigned
int
key_state
;
};
};
class
CV_EXPORTS
Camera2
{
public
:
Camera2
(
float
f_x
,
float
f_y
,
float
c_x
,
float
c_y
,
const
Size
&
window_size
);
Camera2
(
const
Vec2f
&
fov
,
const
Size
&
window_size
);
Camera2
(
const
cv
::
Mat
&
K
,
const
Size
&
window_size
);
inline
const
Vec2d
&
getClip
()
const
{
return
clip_
;
}
inline
void
setClip
(
const
Vec2d
&
clip
)
{
clip_
=
clip
;
}
inline
const
Size
&
getWindowSize
()
const
{
return
window_size_
;
}
void
setWindowSize
(
const
Size
&
window_size
);
inline
const
Vec2f
&
getFov
()
const
{
return
fov_
;
}
inline
void
setFov
(
const
Vec2f
&
fov
)
{
fov_
=
fov
;
}
private
:
Vec2d
clip_
;
Vec2f
fov_
;
Size
window_size_
;
Vec2f
principal_point_
;
Vec2f
focal_
;
};
}
/* namespace viz */
}
/* namespace viz */
}
/* namespace cv */
}
/* namespace cv */
modules/viz/src/types.cpp
View file @
a76cc9ef
...
@@ -142,3 +142,57 @@ cv::viz::Mesh3d cv::viz::Mesh3d::loadMesh(const String& file)
...
@@ -142,3 +142,57 @@ cv::viz::Mesh3d cv::viz::Mesh3d::loadMesh(const String& file)
{
{
return
loadMeshImpl
::
loadMesh
(
file
);
return
loadMeshImpl
::
loadMesh
(
file
);
}
}
////////////////////////////////////////////////////////////////////
/// Camera implementation
cv
::
viz
::
Camera2
::
Camera2
(
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
fov_
[
0
]
=
(
atan2
(
c_x
,
f_x
)
+
atan2
(
window_size
.
width
-
c_x
,
f_x
))
*
180
/
CV_PI
;
fov_
[
1
]
=
(
atan2
(
c_y
,
f_y
)
+
atan2
(
window_size
.
height
-
c_y
,
f_y
))
*
180
/
CV_PI
;
principal_point_
[
0
]
=
c_x
;
principal_point_
[
1
]
=
c_y
;
focal_
[
0
]
=
f_x
;
focal_
[
1
]
=
f_y
;
}
cv
::
viz
::
Camera2
::
Camera2
(
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
window_size_
=
window_size
;
fov_
=
fov
;
principal_point_
=
Vec2f
(
-
1.0
f
,
-
1.0
f
);
// Symmetric lens
focal_
=
Vec2f
(
-
1.0
f
,
-
1.0
f
);
}
cv
::
viz
::
Camera2
::
Camera2
(
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
);
float
f_x
=
K
.
at
<
float
>
(
0
,
0
);
float
f_y
=
K
.
at
<
float
>
(
1
,
1
);
float
c_x
=
K
.
at
<
float
>
(
0
,
2
);
float
c_y
=
K
.
at
<
float
>
(
1
,
2
);
Camera2
(
f_x
,
f_y
,
c_x
,
c_y
,
window_size
);
}
void
cv
::
viz
::
Camera2
::
setWindowSize
(
const
Size
&
window_size
)
{
CV_Assert
(
window_size
.
width
>
0
&&
window_size
.
height
>
0
);
// Vertical field of view is fixed!
// Horizontal field of view is expandable based on the aspect ratio
float
aspect_ratio_new
=
window_size
.
width
/
window_size
.
height
;
if
(
principal_point_
[
0
]
<
0.0
f
)
fov_
[
0
]
=
2
*
atan2
(
tan
(
fov_
[
0
]
*
0.5
),
aspect_ratio_new
);
// This assumes that the lens is symmetric!
else
fov_
[
0
]
=
(
atan2
(
principal_point_
[
0
],
focal_
[
0
])
+
atan2
(
window_size
.
width
-
principal_point_
[
0
],
focal_
[
0
]))
*
180
/
CV_PI
;
}
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