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
fedff092
Commit
fedff092
authored
Mar 21, 2012
by
Maria Dimashova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removed unnecessary members of CvCapture_OpenNI
parent
5c23d526
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
56 deletions
+76
-56
cap.cpp
modules/highgui/src/cap.cpp
+5
-0
cap_openni.cpp
modules/highgui/src/cap_openni.cpp
+70
-56
precomp.hpp
modules/highgui/src/precomp.hpp
+1
-0
No files found.
modules/highgui/src/cap.cpp
View file @
fedff092
...
...
@@ -326,6 +326,11 @@ CV_IMPL CvCapture * cvCreateFileCapture (const char * filename)
if
(
!
result
)
result
=
cvCreateFileCapture_AVFoundation
(
filename
);
#endif
#ifdef HAVE_OPENNI
if
(
!
result
)
result
=
cvCreateFileCapture_OpenNI
(
filename
);
#endif
if
(
!
result
)
result
=
cvCreateFileCapture_Images
(
filename
);
...
...
modules/highgui/src/cap_openni.cpp
View file @
fedff092
...
...
@@ -82,7 +82,8 @@ public:
static
const
int
INVALID_PIXEL_VAL
=
0
;
static
const
int
INVALID_COORDINATE_VAL
=
0
;
CvCapture_OpenNI
(
int
index
=
0
);
CvCapture_OpenNI
(
int
index
=
0
);
CvCapture_OpenNI
(
const
char
*
filename
);
virtual
~
CvCapture_OpenNI
();
virtual
double
getProperty
(
int
propIdx
);
...
...
@@ -121,18 +122,14 @@ protected:
// OpenNI context
xn
::
Context
context
;
bool
m_isOpened
;
bool
m_isDepthGeneratorPresent
;
bool
m_isImageGeneratorPresent
;
bool
isContextOpened
;
// Data generators with its metadata
xn
::
DepthGenerator
depthGenerator
;
xn
::
DepthMetaData
depthMetaData
;
XnMapOutputMode
depthOutputMode
;
xn
::
ImageGenerator
imageGenerator
;
xn
::
ImageMetaData
imageMetaData
;
XnMapOutputMode
imageOutputMode
;
// Cameras settings:
// TODO find in OpenNI function to convert z->disparity and remove fields "baseline" and depthFocalLength_VGA
...
...
@@ -160,27 +157,28 @@ IplImage* CvCapture_OpenNI::OutputMap::getIplImagePtr()
bool
CvCapture_OpenNI
::
isOpened
()
const
{
return
m_is
Opened
;
return
isContext
Opened
;
}
CvCapture_OpenNI
::
CvCapture_OpenNI
(
int
index
)
XnMapOutputMode
defaultMapOutputMode
(
)
{
Xn
Status
status
=
XN_STATUS_OK
;
// Initialize image output modes (VGA_30HZ by default).
depthOutputMode
.
nXRes
=
imageOutputMode
.
nXRes
=
XN_VGA_X_RES
;
depthOutputMode
.
nYRes
=
imageOutputMode
.
nYRes
=
XN_VGA_Y_RES
;
depthOutputMode
.
nFPS
=
imageOutputMode
.
nFPS
=
30
;
Xn
MapOutputMode
mode
;
mode
.
nXRes
=
XN_VGA_X_RES
;
mode
.
nYRes
=
XN_VGA_Y_RES
;
mode
.
nFPS
=
30
;
return
mode
;
}
m_isOpened
=
false
;
m_isImageGeneratorPresent
=
false
;
CvCapture_OpenNI
::
CvCapture_OpenNI
(
int
index
)
{
isContextOpened
=
false
;
// Initialize and configure the context.
if
(
context
.
Init
()
==
XN_STATUS_OK
)
{
// Find devices
xn
::
NodeInfoList
devicesList
;
status
=
context
.
EnumerateProductionTrees
(
XN_NODE_TYPE_DEVICE
,
NULL
,
devicesList
,
0
);
XnStatus
status
=
context
.
EnumerateProductionTrees
(
XN_NODE_TYPE_DEVICE
,
NULL
,
devicesList
,
0
);
if
(
status
!=
XN_STATUS_OK
)
{
std
::
cerr
<<
"CvCapture_OpenNI::CvCapture_OpenNI : Failed to enumerate production trees: "
...
...
@@ -224,7 +222,6 @@ CvCapture_OpenNI::CvCapture_OpenNI( int index )
std
::
cerr
<<
"CvCapture_OpenNI::CvCapture_OpenNI : The device doesn't have depth generator. Such devices aren't supported now."
<<
std
::
endl
;
return
;
}
m_isDepthGeneratorPresent
=
true
;
status
=
depthGenerator
.
Create
(
context
);
if
(
status
!=
XN_STATUS_OK
)
{
...
...
@@ -245,7 +242,6 @@ CvCapture_OpenNI::CvCapture_OpenNI( int index )
if
(
!
imageList
.
IsEmpty
()
)
{
m_isImageGeneratorPresent
=
true
;
status
=
imageGenerator
.
Create
(
context
);
if
(
status
!=
XN_STATUS_OK
)
{
...
...
@@ -256,8 +252,10 @@ CvCapture_OpenNI::CvCapture_OpenNI( int index )
}
// Set map output mode.
CV_Assert
(
depthGenerator
.
SetMapOutputMode
(
depthOutputMode
)
==
XN_STATUS_OK
);
// xn::DepthGenerator supports VGA only! (Jan 2011)
CV_Assert
(
m_isImageGeneratorPresent
?
(
imageGenerator
.
SetMapOutputMode
(
imageOutputMode
)
==
XN_STATUS_OK
)
:
true
);
if
(
depthGenerator
.
IsValid
()
)
CV_DbgAssert
(
depthGenerator
.
SetMapOutputMode
(
defaultMapOutputMode
())
==
XN_STATUS_OK
);
// xn::DepthGenerator supports VGA only! (Jan 2011)
if
(
imageGenerator
.
IsValid
()
)
CV_DbgAssert
(
imageGenerator
.
SetMapOutputMode
(
defaultMapOutputMode
())
==
XN_STATUS_OK
);
// Start generating data.
status
=
context
.
StartGeneratingAll
();
...
...
@@ -276,12 +274,17 @@ CvCapture_OpenNI::CvCapture_OpenNI( int index )
outputMaps
.
resize
(
outputMapsTypesCount
);
m_is
Opened
=
true
;
isContext
Opened
=
true
;
}
setProperty
(
CV_CAP_PROP_OPENNI_REGISTRATION
,
1.0
);
}
CvCapture_OpenNI
::
CvCapture_OpenNI
(
const
char
*
filename
)
{
CV_Assert
(
0
);
}
CvCapture_OpenNI
::~
CvCapture_OpenNI
()
{
context
.
StopGeneratingAll
();
...
...
@@ -387,25 +390,28 @@ bool CvCapture_OpenNI::setProperty( int propIdx, double propValue )
double
CvCapture_OpenNI
::
getDepthGeneratorProperty
(
int
propIdx
)
{
double
propValue
=
0
;
if
(
!
m_isDepthGeneratorPresent
)
if
(
!
depthGenerator
.
IsValid
()
)
return
propValue
;
CV_Assert
(
depthGenerator
.
IsValid
()
)
;
XnMapOutputMode
mode
;
switch
(
propIdx
)
{
case
CV_CAP_PROP_OPENNI_GENERATOR_PRESENT
:
CV_
Assert
(
m_isDepthGeneratorPresent
);
CV_
DbgAssert
(
depthGenerator
.
IsValid
()
);
propValue
=
1.
;
break
;
case
CV_CAP_PROP_FRAME_WIDTH
:
propValue
=
depthOutputMode
.
nXRes
;
if
(
depthGenerator
.
GetMapOutputMode
(
mode
)
==
XN_STATUS_OK
)
propValue
=
mode
.
nXRes
;
break
;
case
CV_CAP_PROP_FRAME_HEIGHT
:
propValue
=
depthOutputMode
.
nYRes
;
if
(
depthGenerator
.
GetMapOutputMode
(
mode
)
==
XN_STATUS_OK
)
propValue
=
mode
.
nYRes
;
break
;
case
CV_CAP_PROP_FPS
:
propValue
=
depthOutputMode
.
nFPS
;
if
(
depthGenerator
.
GetMapOutputMode
(
mode
)
==
XN_STATUS_OK
)
propValue
=
mode
.
nFPS
;
break
;
case
CV_CAP_PROP_OPENNI_FRAME_MAX_DEPTH
:
propValue
=
depthGenerator
.
GetDeviceMaxDepth
();
...
...
@@ -443,9 +449,8 @@ bool CvCapture_OpenNI::setDepthGeneratorProperty( int propIdx, double propValue
{
// if there isn't image generator (i.e. ASUS XtionPro doesn't have it)
// then the property isn't avaliable
if
(
m_isImageGeneratorPresent
)
if
(
imageGenerator
.
IsValid
()
)
{
CV_Assert
(
imageGenerator
.
IsValid
()
);
if
(
!
depthGenerator
.
GetAlternativeViewPointCap
().
IsViewPointAs
(
imageGenerator
)
)
{
if
(
depthGenerator
.
GetAlternativeViewPointCap
().
IsViewPointSupported
(
imageGenerator
)
)
...
...
@@ -487,25 +492,27 @@ bool CvCapture_OpenNI::setDepthGeneratorProperty( int propIdx, double propValue
double
CvCapture_OpenNI
::
getImageGeneratorProperty
(
int
propIdx
)
{
double
propValue
=
0.
;
if
(
!
m_isImageGeneratorPresent
)
if
(
!
imageGenerator
.
IsValid
()
)
return
propValue
;
CV_Assert
(
imageGenerator
.
IsValid
()
);
XnMapOutputMode
mode
;
switch
(
propIdx
)
{
case
CV_CAP_PROP_OPENNI_GENERATOR_PRESENT
:
CV_
Assert
(
m_isImageGeneratorPresent
);
CV_
DbgAssert
(
imageGenerator
.
IsValid
()
);
propValue
=
1.
;
break
;
case
CV_CAP_PROP_FRAME_WIDTH
:
propValue
=
imageOutputMode
.
nXRes
;
if
(
imageGenerator
.
GetMapOutputMode
(
mode
)
==
XN_STATUS_OK
)
propValue
=
mode
.
nXRes
;
break
;
case
CV_CAP_PROP_FRAME_HEIGHT
:
propValue
=
imageOutputMode
.
nYRes
;
if
(
imageGenerator
.
GetMapOutputMode
(
mode
)
==
XN_STATUS_OK
)
propValue
=
mode
.
nYRes
;
break
;
case
CV_CAP_PROP_FPS
:
propValue
=
imageOutputMode
.
nFPS
;
if
(
imageGenerator
.
GetMapOutputMode
(
mode
)
==
XN_STATUS_OK
)
propValue
=
mode
.
nFPS
;
break
;
default
:
{
...
...
@@ -521,46 +528,41 @@ double CvCapture_OpenNI::getImageGeneratorProperty( int propIdx )
bool
CvCapture_OpenNI
::
setImageGeneratorProperty
(
int
propIdx
,
double
propValue
)
{
bool
isSet
=
false
;
if
(
!
m_isImageGeneratorPresent
)
if
(
!
imageGenerator
.
IsValid
()
)
return
isSet
;
CV_Assert
(
imageGenerator
.
IsValid
()
);
switch
(
propIdx
)
{
case
CV_CAP_PROP_OPENNI_OUTPUT_MODE
:
{
XnMapOutputMode
newImageOutputMode
=
imageOutputM
ode
;
XnMapOutputMode
m
ode
;
switch
(
cvRound
(
propValue
)
)
{
case
CV_CAP_OPENNI_VGA_30HZ
:
newImageOutputM
ode
.
nXRes
=
XN_VGA_X_RES
;
newImageOutputM
ode
.
nYRes
=
XN_VGA_Y_RES
;
newImageOutputM
ode
.
nFPS
=
30
;
m
ode
.
nXRes
=
XN_VGA_X_RES
;
m
ode
.
nYRes
=
XN_VGA_Y_RES
;
m
ode
.
nFPS
=
30
;
break
;
case
CV_CAP_OPENNI_SXGA_15HZ
:
newImageOutputM
ode
.
nXRes
=
XN_SXGA_X_RES
;
newImageOutputM
ode
.
nYRes
=
XN_SXGA_Y_RES
;
newImageOutputM
ode
.
nFPS
=
15
;
m
ode
.
nXRes
=
XN_SXGA_X_RES
;
m
ode
.
nYRes
=
XN_SXGA_Y_RES
;
m
ode
.
nFPS
=
15
;
break
;
case
CV_CAP_OPENNI_SXGA_30HZ
:
newImageOutputM
ode
.
nXRes
=
XN_SXGA_X_RES
;
newImageOutputM
ode
.
nYRes
=
XN_SXGA_Y_RES
;
newImageOutputM
ode
.
nFPS
=
30
;
m
ode
.
nXRes
=
XN_SXGA_X_RES
;
m
ode
.
nYRes
=
XN_SXGA_Y_RES
;
m
ode
.
nFPS
=
30
;
break
;
default
:
CV_Error
(
CV_StsBadArg
,
"Unsupported image generator output mode.
\n
"
);
}
XnStatus
status
=
imageGenerator
.
SetMapOutputMode
(
newImageOutputM
ode
);
XnStatus
status
=
imageGenerator
.
SetMapOutputMode
(
m
ode
);
if
(
status
!=
XN_STATUS_OK
)
std
::
cerr
<<
"CvCapture_OpenNI::setImageGeneratorProperty : "
<<
xnGetStatusString
(
status
)
<<
std
::
endl
;
else
{
imageOutputMode
=
newImageOutputMode
;
isSet
=
true
;
}
break
;
}
default
:
...
...
@@ -583,8 +585,9 @@ bool CvCapture_OpenNI::grabFrame()
if
(
status
!=
XN_STATUS_OK
)
return
false
;
depthGenerator
.
GetMetaData
(
depthMetaData
);
if
(
m_isImageGeneratorPresent
)
if
(
depthGenerator
.
IsValid
()
)
depthGenerator
.
GetMetaData
(
depthMetaData
);
if
(
imageGenerator
.
IsValid
()
)
imageGenerator
.
GetMetaData
(
imageMetaData
);
return
true
;
...
...
@@ -813,4 +816,15 @@ CvCapture* cvCreateCameraCapture_OpenNI( int index )
return
0
;
}
CvCapture
*
cvCreateFileCapture_OpenNI
(
const
char
*
filename
)
{
CvCapture_OpenNI
*
capture
=
new
CvCapture_OpenNI
(
filename
);
if
(
capture
->
isOpened
()
)
return
capture
;
delete
capture
;
return
0
;
}
#endif
modules/highgui/src/precomp.hpp
View file @
fedff092
...
...
@@ -132,6 +132,7 @@ 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
);
CvCapture
*
cvCreateFileCapture_OpenNI
(
const
char
*
filename
);
CvCapture
*
cvCreateCameraCapture_Android
(
int
index
);
CvCapture
*
cvCreateCameraCapture_XIMEA
(
int
index
);
CvCapture
*
cvCreateCameraCapture_AVFoundation
(
int
index
);
...
...
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