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
68ed806b
Commit
68ed806b
authored
Jan 24, 2011
by
Maria Dimashova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
replaced own point cloud computing by OpenNI ConvertProjectiveToRealWorld()
parent
a47b6c23
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
2 deletions
+17
-2
cap_openni.cpp
modules/highgui/src/cap_openni.cpp
+16
-1
kinect_maps.cpp
samples/cpp/kinect_maps.cpp
+1
-1
No files found.
modules/highgui/src/cap_openni.cpp
View file @
68ed806b
...
...
@@ -131,10 +131,12 @@ protected:
xn
::
ImageMetaData
imageMetaData
;
// Cameras settings:
#if 1
// Distance between IR projector and IR camera (in meters)
XnDouble
baseline
;
// Focal length for the IR camera in VGA resolution (in pixels)
XnUInt64
depthFocalLength_VGA
;
#endif
// The value for shadow (occluded pixels)
XnUInt64
shadowValue
;
// The value for pixels without a valid disparity measurement
...
...
@@ -215,6 +217,7 @@ CvCapture_OpenNI::~CvCapture_OpenNI()
void
CvCapture_OpenNI
::
readCamerasParams
()
{
#if 1
XnDouble
pixelSize
=
0
;
if
(
depthGenerator
.
GetRealProperty
(
"ZPPS"
,
pixelSize
)
!=
XN_STATUS_OK
)
CV_Error
(
CV_StsError
,
"Could not read pixel size!"
);
...
...
@@ -235,6 +238,7 @@ void CvCapture_OpenNI::readCamerasParams()
// focal length from mm -> pixels (valid for 640x480)
depthFocalLength_VGA
=
(
XnUInt64
)((
double
)
zpd
/
(
double
)
pixelSize
);
#endif
if
(
depthGenerator
.
GetIntProperty
(
"ShadowValue"
,
shadowValue
)
!=
XN_STATUS_OK
)
CV_Error
(
CV_StsError
,
"Could not read shadow value!"
);
...
...
@@ -305,14 +309,17 @@ IplImage* CvCapture_OpenNI::retrievePointCloudMap()
if
(
cols
<=
0
||
rows
<=
0
)
return
0
;
#if 0
// X = (x - centerX) * depth / F[in pixels]
// Y = (y - centerY) * depth / F[in pixels]
// Z = depth
// Multiply by 0.001 to convert from mm in meters.
float mult = 0.001f / depthFocalLength_VGA;
int centerX = cols >> 1;
int centerY = rows >> 1;
#endif
cv
::
Mat
depth
;
...
...
@@ -331,7 +338,7 @@ IplImage* CvCapture_OpenNI::retrievePointCloudMap()
// Check for invalid measurements
if
(
d
==
badDepth
)
// not valid
continue
;
#if 0
// Fill in XYZ
cv::Point3f point3D;
point3D.x = (x - centerX) * d * mult;
...
...
@@ -339,6 +346,14 @@ IplImage* CvCapture_OpenNI::retrievePointCloudMap()
point3D.z = d * 0.001f;
XYZ.at<cv::Point3f>(y,x) = point3D;
#else
XnPoint3D
proj
,
real
;
proj
.
X
=
x
;
proj
.
Y
=
y
;
proj
.
Z
=
d
;
depthGenerator
.
ConvertProjectiveToRealWorld
(
1
,
&
proj
,
&
real
);
XYZ
.
at
<
cv
::
Point3f
>
(
y
,
x
)
=
cv
::
Point3f
(
real
.
X
*
0.001
f
,
real
.
Y
*
0.001
f
,
real
.
Z
*
0.001
f
);
// from mm to meters
#endif
}
}
...
...
samples/cpp/kinect_maps.cpp
View file @
68ed806b
...
...
@@ -124,7 +124,7 @@ int main()
}
if
(
capture
.
retrieve
(
validDepthMap
,
OPENNI_VALID_DEPTH_MASK
)
)
imshow
(
"valid depth ma
p
"
,
validDepthMap
);
imshow
(
"valid depth ma
sk
"
,
validDepthMap
);
if
(
capture
.
retrieve
(
bgrImage
,
OPENNI_BGR_IMAGE
)
)
imshow
(
"rgb image"
,
bgrImage
);
...
...
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