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
3a04d08b
Commit
3a04d08b
authored
Jan 21, 2011
by
Maria Dimashova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added Kinect support (initial version without settings configuration yet) and sample on usage
parent
b63b3df5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
221 additions
and
3 deletions
+221
-3
CMakeLists.txt
CMakeLists.txt
+30
-1
cvconfig.h.cmake
cvconfig.h.cmake
+3
-0
CMakeLists.txt
modules/highgui/CMakeLists.txt
+16
-0
highgui_c.h
modules/highgui/include/opencv2/highgui/highgui_c.h
+20
-1
cap.cpp
modules/highgui/src/cap.cpp
+10
-1
cap_openni.cpp
modules/highgui/src/cap_openni.cpp
+0
-0
precomp.hpp
modules/highgui/src/precomp.hpp
+1
-0
kinect_maps.cpp
samples/cpp/kinect_maps.cpp
+141
-0
No files found.
CMakeLists.txt
View file @
3a04d08b
...
...
@@ -323,6 +323,7 @@ if(WIN32)
set
(
WITH_VIDEOINPUT ON CACHE BOOL
"Enable VideoInput support"
)
endif
()
set
(
WITH_OPENNI OFF CACHE BOOL
"Include OpenNI support"
)
# ===================================================
# Macros that checks if module have been installed.
...
...
@@ -753,6 +754,28 @@ if (WIN32 AND WITH_VIDEOINPUT)
endif
()
endif
()
############################### OpenNI ################################
set
(
HAVE_OPENNI FALSE
)
set
(
HAVE_PRIME_SENSOR_FOR_OPENNI FALSE
)
if
(
WITH_OPENNI
)
# find OpenNI library
unset
(
OPENNI_LIBRARY CACHE
)
unset
(
PRIME_SENSOR_MODULES_FOR_OPENNI CACHE
)
find_library
(
OPENNI_LIBRARY
"OpenNI"
PATHS
"/usr/lib"
"c:/Program Files/OpenNI/Lib"
DOC
"OpenNI library"
)
if
(
OPENNI_LIBRARY
)
set
(
HAVE_OPENNI TRUE
)
# the check: are PrimeSensor Modules for OpenNI installed?
if
(
WIN32
)
find_file
(
PRIME_SENSOR_MODULES_FOR_OPENNI
"XnCore.dll"
PATHS
"c:/Program Files/Prime Sense/Sensor/Bin"
DOC
"Core library of PrimeSensor Modules for OpenNI"
)
elseif
(
UNIX OR APPLE
)
find_library
(
PRIME_SENSOR_MODULES_FOR_OPENNI
"XnCore"
PATHS
"/usr/lib"
DOC
"Core library of PrimeSensor Modules for OpenNI"
)
endif
()
if
(
PRIME_SENSOR_MODULES_FOR_OPENNI
)
set
(
HAVE_PRIME_SENSOR_FOR_OPENNI TRUE
)
endif
()
endif
()
endif
()
#if(WITH_OPENNI)
############################## Eigen2 ##############################
...
...
@@ -1330,6 +1353,12 @@ else()
message
(
STATUS
" OpenEXR: NO"
)
endif
()
if
(
NOT HAVE_OPENNI OR HAVE_PRIME_SENSOR_FOR_OPENNI
)
message
(
STATUS
" OpenNI:
${
HAVE_OPENNI
}
"
)
else
()
message
(
STATUS
" OpenNI:
${
HAVE_OPENNI
}
(WARNING: PrimeSensor Modules for OpenNI are not installed.)"
)
endif
()
#if(NOT HAVE_OPENNI OR HAVE_PRIME_SENSOR_FOR_OPENNI)
if
(
UNIX AND NOT APPLE
)
message
(
STATUS
""
)
message
(
STATUS
" Video I/O: "
)
...
...
@@ -1350,7 +1379,7 @@ else()
message
(
STATUS
" V4L/V4L2:
${
HAVE_CAMV4L
}
/
${
HAVE_CAMV4L2
}
"
)
endif
()
message
(
STATUS
" Xine:
${
HAVE_XINE
}
"
)
endif
()
endif
()
#if(UNIX AND NOT APPLE)
if
(
APPLE
)
message
(
STATUS
""
)
...
...
cvconfig.h.cmake
View file @
3a04d08b
...
...
@@ -112,6 +112,9 @@
/* Xine video library */
#cmakedefine HAVE_XINE
/* OpenNI library */
#cmakedefine HAVE_OPENNI
/* LZ77 compression/decompression
library
(
used for PNG
)
*/
#cmakedefine HAVE_ZLIB
...
...
modules/highgui/CMakeLists.txt
View file @
3a04d08b
...
...
@@ -174,6 +174,18 @@ if(UNIX)
endforeach
()
endif
()
#OpenNI
if
(
WITH_OPENNI AND HAVE_OPENNI
)
set
(
highgui_srcs
${
highgui_srcs
}
src/cap_openni.cpp
)
if
(
WIN32
)
set
(
OPENNI_INCLUDE_DIR
"c:/Program Files/OpenNI/Include"
)
elseif
(
UNIX OR APPLE
)
set
(
OPENNI_INCLUDE_DIR
"/usr/include/ni"
)
endif
()
include_directories
(
${
OPENNI_INCLUDE_DIR
}
)
endif
()
#YV
if
(
APPLE
)
add_definitions
(
-DHAVE_QUICKTIME=1
)
...
...
@@ -286,6 +298,10 @@ if(WITH_TIFF AND NOT TIFF_FOUND)
endif
()
target_link_libraries
(
${
the_target
}
${
OPENCV_LINKER_LIBS
}
opencv_core opencv_imgproc zlib
${
JPEG_LIBRARIES
}
${
PNG_LIBRARIES
}
${
TIFF_LIBRARIES
}
${
JASPER_LIBRARIES
}
${
HIGHGUI_LIBRARIES
}
${
OPENEXR_LIBRARIES
}
)
if
(
OPENNI_LIBRARY
)
target_link_libraries
(
${
the_target
}
${
OPENNI_LIBRARY
}
)
endif
()
if
(
APPLE
)
target_link_libraries
(
${
the_target
}
"-lbz2 -framework Cocoa -framework QuartzCore"
)
...
...
modules/highgui/include/opencv2/highgui/highgui_c.h
View file @
3a04d08b
...
...
@@ -288,7 +288,9 @@ enum
CV_CAP_DSHOW
=
700
,
// DirectShow (via videoInput)
CV_CAP_PVAPI
=
800
// PvAPI, Prosilica GigE SDK
CV_CAP_PVAPI
=
800
,
// PvAPI, Prosilica GigE SDK
CV_CAP_OPENNI
=
900
// OpenNI (for Kinect)
};
/* start capturing frames from camera: index = camera_index + domain_offset (CV_CAP_*) */
...
...
@@ -367,6 +369,23 @@ CVAPI(int) cvWriteFrame( CvVideoWriter* writer, const IplImage* image );
/* close video file writer */
CVAPI
(
void
)
cvReleaseVideoWriter
(
CvVideoWriter
**
writer
);
enum
{
// Data given from depth generator.
OPENNI_DEPTH_MAP
=
0
,
// Depth values in mm (CV_16UC1)
OPENNI_POINT_CLOUD_MAP
=
1
,
// XYZ in meters (CV_32FC3)
OPENNI_DISPARITY_MAP
=
2
,
// Disparity in pixels (CV_8UC1)
OPENNI_DISPARITY_MAP_32F
=
3
,
// Disparity in pixels (CV_32FC1)
OPENNI_VALID_DEPTH_MASK
=
4
,
// CV_8UC1
// Data given from RGB image generator.
OPENNI_BGR_IMAGE
=
5
,
OPENNI_GRAY_IMAGE
=
6
};
const
int
OPENNI_BAD_DEPTH_VAL
=
0
;
const
int
OPENNI_BAD_DISP_VAL
=
0
;
/****************************************************************************************\
* Obsolete functions/synonyms *
\****************************************************************************************/
...
...
modules/highgui/src/cap.cpp
View file @
3a04d08b
...
...
@@ -123,6 +123,7 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index)
CV_CAP_MIL
,
CV_CAP_QT
,
CV_CAP_UNICAP
,
CV_CAP_OPENNI
,
-
1
};
...
...
@@ -142,7 +143,7 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index)
defined(HAVE_CAMV4L) || defined (HAVE_CAMV4L2) || defined(HAVE_GSTREAMER) || \
defined(HAVE_DC1394_2) || defined(HAVE_DC1394) || defined(HAVE_CMU1394) || \
defined(HAVE_GSTREAMER) || defined(HAVE_MIL) || defined(HAVE_QUICKTIME) || \
defined(HAVE_UNICAP) || defined(HAVE_PVAPI)
defined(HAVE_UNICAP) || defined(HAVE_PVAPI)
|| defined(HAVE_OPENNI)
// local variable to memorize the captured device
CvCapture
*
capture
;
#endif
...
...
@@ -241,6 +242,14 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index)
return
capture
;
break
;
#endif
#ifdef HAVE_OPENNI
case
CV_CAP_OPENNI
:
capture
=
cvCreateCameraCapture_OpenNI
(
index
);
if
(
capture
)
return
capture
;
break
;
#endif
}
}
...
...
modules/highgui/src/cap_openni.cpp
0 → 100644
View file @
3a04d08b
This diff is collapsed.
Click to expand it.
modules/highgui/src/precomp.hpp
View file @
3a04d08b
...
...
@@ -121,6 +121,7 @@ CvVideoWriter* cvCreateVideoWriter_Win32( const char* filename, int fourcc,
CvVideoWriter
*
cvCreateVideoWriter_VFW
(
const
char
*
filename
,
int
fourcc
,
double
fps
,
CvSize
frameSize
,
int
is_color
);
CvCapture
*
cvCreateCameraCapture_DShow
(
int
index
);
CvCapture
*
cvCreateCameraCapture_OpenNI
(
int
index
);
CVAPI
(
int
)
cvHaveImageReader
(
const
char
*
filename
);
CVAPI
(
int
)
cvHaveImageWriter
(
const
char
*
filename
);
...
...
samples/cpp/kinect_maps.cpp
0 → 100644
View file @
3a04d08b
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <iostream>
using
namespace
cv
;
using
namespace
std
;
void
colorizeDisparity
(
const
Mat
&
gray
,
Mat
&
rgb
,
float
S
=
1.
f
,
float
V
=
1.
f
)
{
CV_Assert
(
!
gray
.
empty
()
);
CV_Assert
(
gray
.
type
()
==
CV_8UC1
);
// TODO do maxDisp constant (when camera properties will be accessible)
double
maxDisp
=
0
;
minMaxLoc
(
gray
,
0
,
&
maxDisp
);
rgb
.
create
(
gray
.
size
(),
CV_8UC3
);
for
(
int
y
=
0
;
y
<
gray
.
rows
;
y
++
)
{
for
(
int
x
=
0
;
x
<
gray
.
cols
;
x
++
)
{
uchar
d
=
gray
.
at
<
uchar
>
(
y
,
x
);
unsigned
int
H
=
((
uchar
)
maxDisp
-
d
)
*
240
/
(
uchar
)
maxDisp
;
unsigned
int
hi
=
(
H
/
60
)
%
6
;
float
f
=
H
/
60.
f
-
H
/
60
;
float
p
=
V
*
(
1
-
S
);
float
q
=
V
*
(
1
-
f
*
S
);
float
t
=
V
*
(
1
-
(
1
-
f
)
*
S
);
Point3f
res
;
if
(
hi
==
0
)
//R = V, G = t, B = p
res
=
Point3f
(
p
,
t
,
V
);
if
(
hi
==
1
)
// R = q, G = V, B = p
res
=
Point3f
(
p
,
V
,
q
);
if
(
hi
==
2
)
// R = p, G = V, B = t
res
=
Point3f
(
t
,
V
,
p
);
if
(
hi
==
3
)
// R = p, G = q, B = V
res
=
Point3f
(
V
,
q
,
p
);
if
(
hi
==
4
)
// R = t, G = p, B = V
res
=
Point3f
(
V
,
p
,
t
);
if
(
hi
==
5
)
// R = V, G = p, B = q
res
=
Point3f
(
q
,
p
,
V
);
uchar
b
=
(
uchar
)(
std
::
max
(
0.
f
,
std
::
min
(
res
.
x
,
1.
f
))
*
255.
f
);
uchar
g
=
(
uchar
)(
std
::
max
(
0.
f
,
std
::
min
(
res
.
y
,
1.
f
))
*
255.
f
);
uchar
r
=
(
uchar
)(
std
::
max
(
0.
f
,
std
::
min
(
res
.
z
,
1.
f
))
*
255.
f
);
rgb
.
at
<
Point3_
<
uchar
>
>
(
y
,
x
)
=
Point3_
<
uchar
>
(
b
,
g
,
r
);
}
}
}
void
help
()
{
cout
<<
"
\n
This program demonstrates usage of Kinect sensor.
\n
"
"The user gets some of the supported output images.
\n
"
"
\n
All supported output map types:
\n
"
"1.) Data given from depth generator
\n
"
" OPENNI_DEPTH_MAP - depth values in mm (CV_16UC1)
\n
"
" OPENNI_POINT_CLOUD_MAP - XYZ in meters (CV_32FC3)
\n
"
" OPENNI_DISPARITY_MAP - disparity in pixels (CV_8UC1)
\n
"
" OPENNI_DISPARITY_MAP_32F - disparity in pixels (CV_32FC1)
\n
"
" OPENNI_VALID_DEPTH_MASK - mask of valid pixels (not ocluded, not shaded etc.) (CV_8UC1)
\n
"
"2.) Data given from RGB image generator
\n
"
" OPENNI_BGR_IMAGE - color image (CV_8UC3)
\n
"
" OPENNI_GRAY_IMAGE - gray image (CV_8UC1)
\n
"
<<
endl
;
}
/*
* To work with Kinect the user must install OpenNI library and PrimeSensorModule for OpenNI and
* configure OpenCV with WITH_OPENNI flag is ON (using CMake).
*/
int
main
()
{
help
();
cout
<<
"Kinect opening ..."
<<
endl
;
VideoCapture
capture
(
0
);
// or CV_CAP_OPENNI
cout
<<
"done."
<<
endl
;
if
(
!
capture
.
isOpened
()
)
{
cout
<<
"Can not open a capture object."
<<
endl
;
return
-
1
;
}
for
(;;)
{
Mat
depthMap
;
Mat
validDepthMap
;
Mat
disparityMap
;
Mat
bgrImage
;
Mat
grayImage
;
if
(
!
capture
.
grab
()
)
{
cout
<<
"Can not grab images."
<<
endl
;
return
-
1
;
}
else
{
if
(
capture
.
retrieve
(
depthMap
,
OPENNI_DEPTH_MAP
)
)
{
const
float
scaleFactor
=
0.05
f
;
Mat
show
;
depthMap
.
convertTo
(
show
,
CV_8UC1
,
scaleFactor
);
imshow
(
"depth map"
,
show
);
}
if
(
capture
.
retrieve
(
disparityMap
,
OPENNI_DISPARITY_MAP
)
)
{
#if 0 // original disparity
imshow( "original disparity map", disparityMap );
#else
// colorized disparity for more visibility
Mat
colorDisparityMap
;
colorizeDisparity
(
disparityMap
,
colorDisparityMap
);
Mat
validColorDisparityMap
;
colorDisparityMap
.
copyTo
(
validColorDisparityMap
,
disparityMap
!=
OPENNI_BAD_DISP_VAL
);
imshow
(
"colorized disparity map"
,
validColorDisparityMap
);
#endif
}
if
(
capture
.
retrieve
(
validDepthMap
,
OPENNI_VALID_DEPTH_MASK
)
)
imshow
(
"valid depth map"
,
validDepthMap
);
if
(
capture
.
retrieve
(
bgrImage
,
OPENNI_BGR_IMAGE
)
)
imshow
(
"rgb image"
,
bgrImage
);
if
(
capture
.
retrieve
(
grayImage
,
OPENNI_GRAY_IMAGE
)
)
imshow
(
"gray image"
,
grayImage
);
}
if
(
waitKey
(
30
)
>=
0
)
break
;
}
return
0
;
}
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