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
70e22b68
Commit
70e22b68
authored
Mar 07, 2014
by
Roman Donchenko
Committed by
OpenCV Buildbot
Mar 07, 2014
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2397 from vbystricky:intelperc
parents
2879ff20
193e97a3
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
735 additions
and
629 deletions
+735
-629
highgui.hpp
modules/highgui/include/opencv2/highgui.hpp
+5
-1
cap.cpp
modules/highgui/src/cap.cpp
+63
-9
cap_intelperc.cpp
modules/highgui/src/cap_intelperc.cpp
+537
-617
cap_intelperc.hpp
modules/highgui/src/cap_intelperc.hpp
+116
-0
precomp.hpp
modules/highgui/src/precomp.hpp
+14
-2
No files found.
modules/highgui/include/opencv2/highgui.hpp
View file @
70e22b68
...
@@ -530,6 +530,8 @@ enum { CAP_INTELPERC_DEPTH_MAP = 0, // Each pixel is a 16-bit integ
...
@@ -530,6 +530,8 @@ enum { CAP_INTELPERC_DEPTH_MAP = 0, // Each pixel is a 16-bit integ
CAP_INTELPERC_IMAGE
=
3
CAP_INTELPERC_IMAGE
=
3
};
};
class
IVideoCapture
;
class
CV_EXPORTS_W
VideoCapture
class
CV_EXPORTS_W
VideoCapture
{
{
public
:
public
:
...
@@ -554,9 +556,11 @@ public:
...
@@ -554,9 +556,11 @@ public:
protected
:
protected
:
Ptr
<
CvCapture
>
cap
;
Ptr
<
CvCapture
>
cap
;
Ptr
<
IVideoCapture
>
icap
;
private
:
static
Ptr
<
IVideoCapture
>
createCameraCapture
(
int
index
);
};
};
class
CV_EXPORTS_W
VideoWriter
class
CV_EXPORTS_W
VideoWriter
{
{
public
:
public
:
...
...
modules/highgui/src/cap.cpp
View file @
70e22b68
...
@@ -40,6 +40,7 @@
...
@@ -40,6 +40,7 @@
//M*/
//M*/
#include "precomp.hpp"
#include "precomp.hpp"
#include "cap_intelperc.hpp"
#if defined _M_X64 && defined _MSC_VER && !defined CV_ICC
#if defined _M_X64 && defined _MSC_VER && !defined CV_ICC
#pragma optimize("",off)
#pragma optimize("",off)
...
@@ -345,14 +346,6 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index)
...
@@ -345,14 +346,6 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index)
return
capture
;
return
capture
;
break
;
// CV_CAP_GIGANETIX
break
;
// CV_CAP_GIGANETIX
#endif
#endif
#ifdef HAVE_INTELPERC
case
CV_CAP_INTELPERC
:
capture
=
cvCreateCameraCapture_IntelPerC
(
index
);
if
(
capture
)
return
capture
;
break
;
// CV_CAP_INTEL_PERC
#endif
}
}
}
}
...
@@ -497,6 +490,7 @@ VideoCapture::VideoCapture(int device)
...
@@ -497,6 +490,7 @@ VideoCapture::VideoCapture(int device)
VideoCapture
::~
VideoCapture
()
VideoCapture
::~
VideoCapture
()
{
{
icap
.
release
();
cap
.
release
();
cap
.
release
();
}
}
...
@@ -510,24 +504,36 @@ bool VideoCapture::open(const String& filename)
...
@@ -510,24 +504,36 @@ bool VideoCapture::open(const String& filename)
bool
VideoCapture
::
open
(
int
device
)
bool
VideoCapture
::
open
(
int
device
)
{
{
if
(
isOpened
())
release
();
if
(
isOpened
())
release
();
icap
=
createCameraCapture
(
device
);
if
(
!
icap
.
empty
())
return
true
;
cap
.
reset
(
cvCreateCameraCapture
(
device
));
cap
.
reset
(
cvCreateCameraCapture
(
device
));
return
isOpened
();
return
isOpened
();
}
}
bool
VideoCapture
::
isOpened
()
const
{
return
!
cap
.
empty
();
}
bool
VideoCapture
::
isOpened
()
const
{
return
(
!
cap
.
empty
()
||
!
icap
.
empty
());
}
void
VideoCapture
::
release
()
void
VideoCapture
::
release
()
{
{
icap
.
release
();
cap
.
release
();
cap
.
release
();
}
}
bool
VideoCapture
::
grab
()
bool
VideoCapture
::
grab
()
{
{
if
(
!
icap
.
empty
())
return
icap
->
grabFrame
();
return
cvGrabFrame
(
cap
)
!=
0
;
return
cvGrabFrame
(
cap
)
!=
0
;
}
}
bool
VideoCapture
::
retrieve
(
OutputArray
image
,
int
channel
)
bool
VideoCapture
::
retrieve
(
OutputArray
image
,
int
channel
)
{
{
if
(
!
icap
.
empty
())
return
icap
->
retrieveFrame
(
channel
,
image
);
IplImage
*
_img
=
cvRetrieveFrame
(
cap
,
channel
);
IplImage
*
_img
=
cvRetrieveFrame
(
cap
,
channel
);
if
(
!
_img
)
if
(
!
_img
)
{
{
...
@@ -567,14 +573,62 @@ VideoCapture& VideoCapture::operator >> (UMat& image)
...
@@ -567,14 +573,62 @@ VideoCapture& VideoCapture::operator >> (UMat& image)
bool
VideoCapture
::
set
(
int
propId
,
double
value
)
bool
VideoCapture
::
set
(
int
propId
,
double
value
)
{
{
if
(
!
icap
.
empty
())
return
icap
->
setProperty
(
propId
,
value
);
return
cvSetCaptureProperty
(
cap
,
propId
,
value
)
!=
0
;
return
cvSetCaptureProperty
(
cap
,
propId
,
value
)
!=
0
;
}
}
double
VideoCapture
::
get
(
int
propId
)
double
VideoCapture
::
get
(
int
propId
)
{
{
if
(
!
icap
.
empty
())
return
icap
->
getProperty
(
propId
);
return
cvGetCaptureProperty
(
cap
,
propId
);
return
cvGetCaptureProperty
(
cap
,
propId
);
}
}
Ptr
<
IVideoCapture
>
VideoCapture
::
createCameraCapture
(
int
index
)
{
int
domains
[]
=
{
#ifdef HAVE_INTELPERC
CV_CAP_INTELPERC
,
#endif
-
1
,
-
1
};
// interpret preferred interface (0 = autodetect)
int
pref
=
(
index
/
100
)
*
100
;
if
(
pref
)
{
domains
[
0
]
=
pref
;
index
%=
100
;
domains
[
1
]
=-
1
;
}
// try every possibly installed camera API
for
(
int
i
=
0
;
domains
[
i
]
>=
0
;
i
++
)
{
#if defined(HAVE_INTELPERC) || \
(0)
Ptr
<
IVideoCapture
>
capture
;
switch
(
domains
[
i
])
{
#ifdef HAVE_INTELPERC
case
CV_CAP_INTELPERC
:
capture
=
Ptr
<
IVideoCapture
>
(
new
cv
::
VideoCapture_IntelPerC
());
if
(
capture
)
return
capture
;
break
;
// CV_CAP_INTEL_PERC
#endif
}
#endif
}
// failed open a camera
return
Ptr
<
IVideoCapture
>
();
}
VideoWriter
::
VideoWriter
()
VideoWriter
::
VideoWriter
()
{}
{}
...
...
modules/highgui/src/cap_intelperc.cpp
View file @
70e22b68
#include "precomp.hpp"
#ifdef HAVE_INTELPERC
#ifdef HAVE_INTELPERC
#include "pxcsession.h"
#include "cap_intelperc.hpp"
#include "pxcsmartptr.h"
#include "pxccapture.h"
class
CvIntelPerCStreamBase
namespace
cv
{
{
protected
:
struct
FrameInternal
{
IplImage
*
retrieveFrame
()
{
if
(
m_mat
.
empty
())
return
NULL
;
m_iplHeader
=
IplImage
(
m_mat
);
return
&
m_iplHeader
;
}
cv
::
Mat
m_mat
;
private
:
IplImage
m_iplHeader
;
};
public
:
CvIntelPerCStreamBase
()
:
m_profileIdx
(
-
1
)
,
m_frameIdx
(
0
)
,
m_timeStampStartNS
(
0
)
{
}
virtual
~
CvIntelPerCStreamBase
()
{
}
bool
isValid
()
///////////////// IntelPerCStreamBase //////////////////
{
return
(
m_device
.
IsValid
()
&&
m_stream
.
IsValid
());
IntelPerCStreamBase
::
IntelPerCStreamBase
()
}
:
m_profileIdx
(
-
1
)
bool
grabFrame
()
,
m_frameIdx
(
0
)
,
m_timeStampStartNS
(
0
)
{
}
IntelPerCStreamBase
::~
IntelPerCStreamBase
()
{
}
bool
IntelPerCStreamBase
::
isValid
()
{
return
(
m_device
.
IsValid
()
&&
m_stream
.
IsValid
());
}
bool
IntelPerCStreamBase
::
grabFrame
()
{
if
(
!
m_stream
.
IsValid
())
return
false
;
if
(
-
1
==
m_profileIdx
)
{
{
if
(
!
m_stream
.
IsValid
(
))
if
(
!
setProperty
(
CV_CAP_PROP_INTELPERC_PROFILE_IDX
,
0
))
return
false
;
return
false
;
if
(
-
1
==
m_profileIdx
)
}
PXCSmartSP
sp
;
m_pxcImage
.
ReleaseRef
();
if
(
PXC_STATUS_NO_ERROR
>
m_stream
->
ReadStreamAsync
(
&
m_pxcImage
,
&
sp
))
return
false
;
if
(
PXC_STATUS_NO_ERROR
>
sp
->
Synchronize
())
return
false
;
if
(
0
==
m_timeStampStartNS
)
m_timeStampStartNS
=
m_pxcImage
->
QueryTimeStamp
();
m_timeStamp
=
(
double
)((
m_pxcImage
->
QueryTimeStamp
()
-
m_timeStampStartNS
)
/
10000
);
m_frameIdx
++
;
return
true
;
}
int
IntelPerCStreamBase
::
getProfileIDX
()
const
{
return
m_profileIdx
;
}
double
IntelPerCStreamBase
::
getProperty
(
int
propIdx
)
{
double
ret
=
0.0
;
switch
(
propIdx
)
{
case
CV_CAP_PROP_INTELPERC_PROFILE_COUNT
:
ret
=
(
double
)
m_profiles
.
size
();
break
;
case
CV_CAP_PROP_FRAME_WIDTH
:
if
((
0
<=
m_profileIdx
)
&&
(
m_profileIdx
<
m_profiles
.
size
()))
ret
=
(
double
)
m_profiles
[
m_profileIdx
].
imageInfo
.
width
;
break
;
case
CV_CAP_PROP_FRAME_HEIGHT
:
if
((
0
<=
m_profileIdx
)
&&
(
m_profileIdx
<
m_profiles
.
size
()))
ret
=
(
double
)
m_profiles
[
m_profileIdx
].
imageInfo
.
height
;
break
;
case
CV_CAP_PROP_FPS
:
if
((
0
<=
m_profileIdx
)
&&
(
m_profileIdx
<
m_profiles
.
size
()))
{
{
if
(
!
setProperty
(
CV_CAP_PROP_INTELPERC_PROFILE_IDX
,
0
))
ret
=
((
double
)
m_profiles
[
m_profileIdx
].
frameRateMin
.
numerator
/
(
double
)
m_profiles
[
m_profileIdx
].
frameRateMin
.
denominator
return
false
;
+
(
double
)
m_profiles
[
m_profileIdx
].
frameRateMax
.
numerator
/
(
double
)
m_profiles
[
m_profileIdx
].
frameRateMax
.
denominator
)
/
2.0
;
}
}
PXCSmartPtr
<
PXCImage
>
pxcImage
;
PXCSmartSP
sp
;
break
;
if
(
PXC_STATUS_NO_ERROR
>
m_stream
->
ReadStreamAsync
(
&
pxcImage
,
&
sp
))
case
CV_CAP_PROP_POS_FRAMES
:
return
false
;
ret
=
(
double
)
m_frameIdx
;
if
(
PXC_STATUS_NO_ERROR
>
sp
->
Synchronize
())
break
;
return
false
;
case
CV_CAP_PROP_POS_MSEC
:
if
(
0
==
m_timeStampStartNS
)
ret
=
m_timeStamp
;
m_timeStampStartNS
=
pxcImage
->
QueryTimeStamp
();
break
;
m_timeStamp
=
(
double
)((
pxcImage
->
QueryTimeStamp
()
-
m_timeStampStartNS
)
/
10000
);
};
m_frameIdx
++
;
return
ret
;
return
prepareIplImage
(
pxcImage
);
}
}
bool
IntelPerCStreamBase
::
setProperty
(
int
propIdx
,
double
propVal
)
int
getProfileIDX
()
const
{
{
bool
isSet
=
false
;
return
m_profileIdx
;
switch
(
propIdx
)
}
public
:
virtual
bool
initStream
(
PXCSession
*
session
)
=
0
;
virtual
double
getProperty
(
int
propIdx
)
{
{
double
ret
=
0.0
;
case
CV_CAP_PROP_INTELPERC_PROFILE_IDX
:
switch
(
propIdx
)
{
{
case
CV_CAP_PROP_INTELPERC_PROFILE_COUNT
:
int
propValInt
=
(
int
)
propVal
;
ret
=
(
double
)
m_profiles
.
size
();
if
(
0
>
propValInt
)
break
;
case
CV_CAP_PROP_FRAME_WIDTH
:
if
((
0
<=
m_profileIdx
)
&&
(
m_profileIdx
<
m_profiles
.
size
()))
ret
=
(
double
)
m_profiles
[
m_profileIdx
].
imageInfo
.
width
;
break
;
case
CV_CAP_PROP_FRAME_HEIGHT
:
if
((
0
<=
m_profileIdx
)
&&
(
m_profileIdx
<
m_profiles
.
size
()))
ret
=
(
double
)
m_profiles
[
m_profileIdx
].
imageInfo
.
height
;
break
;
case
CV_CAP_PROP_FPS
:
if
((
0
<=
m_profileIdx
)
&&
(
m_profileIdx
<
m_profiles
.
size
()))
{
{
ret
=
((
double
)
m_profiles
[
m_profileIdx
].
frameRateMin
.
numerator
/
(
double
)
m_profiles
[
m_profileIdx
].
frameRateMin
.
denominator
m_profileIdx
=
propValInt
;
+
(
double
)
m_profiles
[
m_profileIdx
].
frameRateMax
.
numerator
/
(
double
)
m_profiles
[
m_profileIdx
].
frameRateMax
.
denominator
)
/
2.0
;
isSet
=
true
;
}
}
break
;
else
if
(
propValInt
<
m_profiles
.
size
())
case
CV_CAP_PROP_POS_FRAMES
:
ret
=
(
double
)
m_frameIdx
;
break
;
case
CV_CAP_PROP_POS_MSEC
:
ret
=
m_timeStamp
;
break
;
};
return
ret
;
}
virtual
bool
setProperty
(
int
propIdx
,
double
propVal
)
{
bool
isSet
=
false
;
switch
(
propIdx
)
{
case
CV_CAP_PROP_INTELPERC_PROFILE_IDX
:
{
{
int
propValInt
=
(
int
)
propVal
;
if
(
m_profileIdx
!=
propValInt
)
if
((
0
<=
propValInt
)
&&
(
propValInt
<
m_profiles
.
size
()))
{
{
if
(
m_profileIdx
!=
propValInt
)
m_profileIdx
=
propValInt
;
{
if
(
m_stream
.
IsValid
())
m_profileIdx
=
propValInt
;
m_stream
->
SetProfile
(
&
m_profiles
[
m_profileIdx
]);
if
(
m_stream
.
IsValid
())
m_frameIdx
=
0
;
m_stream
->
SetProfile
(
&
m_profiles
[
m_profileIdx
]);
m_timeStampStartNS
=
0
;
m_frameIdx
=
0
;
m_timeStampStartNS
=
0
;
}
isSet
=
true
;
}
}
isSet
=
true
;
}
}
break
;
}
};
break
;
return
isSet
;
};
}
return
isSet
;
protected
:
}
PXCSmartPtr
<
PXCCapture
::
Device
>
m_device
;
bool
IntelPerCStreamBase
::
initDevice
(
PXCSession
*
session
)
bool
initDevice
(
PXCSession
*
session
)
{
if
(
NULL
==
session
)
return
false
;
pxcStatus
sts
=
PXC_STATUS_NO_ERROR
;
PXCSession
::
ImplDesc
templat
;
memset
(
&
templat
,
0
,
sizeof
(
templat
));
templat
.
group
=
PXCSession
::
IMPL_GROUP_SENSOR
;
templat
.
subgroup
=
PXCSession
::
IMPL_SUBGROUP_VIDEO_CAPTURE
;
for
(
int
modidx
=
0
;
PXC_STATUS_NO_ERROR
<=
sts
;
modidx
++
)
{
{
if
(
NULL
==
session
)
PXCSession
::
ImplDesc
desc
;
return
false
;
sts
=
session
->
QueryImpl
(
&
templat
,
modidx
,
&
desc
);
if
(
PXC_STATUS_NO_ERROR
>
sts
)
break
;
pxcStatus
sts
=
PXC_STATUS_NO_ERROR
;
PXCSmartPtr
<
PXCCapture
>
capture
;
PXCSession
::
ImplDesc
templat
;
sts
=
session
->
CreateImpl
<
PXCCapture
>
(
&
desc
,
&
capture
);
memset
(
&
templat
,
0
,
sizeof
(
templat
));
if
(
!
capture
.
IsValid
())
templat
.
group
=
PXCSession
::
IMPL_GROUP_SENSOR
;
continue
;
templat
.
subgroup
=
PXCSession
::
IMPL_SUBGROUP_VIDEO_CAPTURE
;
for
(
int
modidx
=
0
;
PXC_STATUS_NO_ERROR
<=
sts
;
modidx
++
)
/* enumerate devices */
for
(
int
devidx
=
0
;
PXC_STATUS_NO_ERROR
<=
sts
;
devidx
++
)
{
{
PXCSession
::
ImplDesc
desc
;
PXCSmartPtr
<
PXCCapture
::
Device
>
device
;
sts
=
session
->
QueryImpl
(
&
templat
,
modidx
,
&
desc
);
sts
=
capture
->
CreateDevice
(
devidx
,
&
device
);
if
(
PXC_STATUS_NO_ERROR
>
sts
)
if
(
PXC_STATUS_NO_ERROR
<=
sts
)
break
;
PXCSmartPtr
<
PXCCapture
>
capture
;
sts
=
session
->
CreateImpl
<
PXCCapture
>
(
&
desc
,
&
capture
);
if
(
!
capture
.
IsValid
())
continue
;
/* enumerate devices */
for
(
int
devidx
=
0
;
PXC_STATUS_NO_ERROR
<=
sts
;
devidx
++
)
{
{
PXCSmartPtr
<
PXCCapture
::
Device
>
device
;
m_device
=
device
.
ReleasePtr
();
sts
=
capture
->
CreateDevice
(
devidx
,
&
device
);
return
true
;
if
(
PXC_STATUS_NO_ERROR
<=
sts
)
{
m_device
=
device
.
ReleasePtr
();
return
true
;
}
}
}
}
}
return
false
;
}
}
return
false
;
}
PXCSmartPtr
<
PXCCapture
::
VideoStream
>
m_stream
;
void
IntelPerCStreamBase
::
initStreamImpl
(
PXCImage
::
ImageType
type
)
void
initStreamImpl
(
PXCImage
::
ImageType
type
)
{
{
if
(
!
m_device
.
IsValid
())
if
(
!
m_device
.
IsValid
())
return
;
return
;
pxcStatus
sts
=
PXC_STATUS_NO_ERROR
;
pxcStatus
sts
=
PXC_STATUS_NO_ERROR
;
/* enumerate streams */
/* enumerate streams */
for
(
int
streamidx
=
0
;
PXC_STATUS_NO_ERROR
<=
sts
;
streamidx
++
)
for
(
int
streamidx
=
0
;
PXC_STATUS_NO_ERROR
<=
sts
;
streamidx
++
)
{
PXCCapture
::
Device
::
StreamInfo
sinfo
;
sts
=
m_device
->
QueryStream
(
streamidx
,
&
sinfo
);
if
(
PXC_STATUS_NO_ERROR
>
sts
)
break
;
if
(
PXCCapture
::
VideoStream
::
CUID
!=
sinfo
.
cuid
)
continue
;
if
(
type
!=
sinfo
.
imageType
)
continue
;
sts
=
m_device
->
CreateStream
<
PXCCapture
::
VideoStream
>
(
streamidx
,
&
m_stream
);
if
(
PXC_STATUS_NO_ERROR
==
sts
)
break
;
m_stream
.
ReleaseRef
();
}
}
protected
:
std
::
vector
<
PXCCapture
::
VideoStream
::
ProfileInfo
>
m_profiles
;
int
m_profileIdx
;
int
m_frameIdx
;
pxcU64
m_timeStampStartNS
;
double
m_timeStamp
;
virtual
bool
validProfile
(
const
PXCCapture
::
VideoStream
::
ProfileInfo
&
/*pinfo*/
)
{
{
return
true
;
PXCCapture
::
Device
::
StreamInfo
sinfo
;
sts
=
m_device
->
QueryStream
(
streamidx
,
&
sinfo
);
if
(
PXC_STATUS_NO_ERROR
>
sts
)
break
;
if
(
PXCCapture
::
VideoStream
::
CUID
!=
sinfo
.
cuid
)
continue
;
if
(
type
!=
sinfo
.
imageType
)
continue
;
sts
=
m_device
->
CreateStream
<
PXCCapture
::
VideoStream
>
(
streamidx
,
&
m_stream
);
if
(
PXC_STATUS_NO_ERROR
==
sts
)
break
;
m_stream
.
ReleaseRef
();
}
}
void
enumProfiles
()
}
{
bool
IntelPerCStreamBase
::
validProfile
(
const
PXCCapture
::
VideoStream
::
ProfileInfo
&
/*pinfo*/
)
m_profiles
.
clear
();
{
if
(
!
m_stream
.
IsValid
())
return
true
;
return
;
}
pxcStatus
sts
=
PXC_STATUS_NO_ERROR
;
void
IntelPerCStreamBase
::
enumProfiles
()
for
(
int
profidx
=
0
;
PXC_STATUS_NO_ERROR
<=
sts
;
profidx
++
)
{
{
m_profiles
.
clear
();
PXCCapture
::
VideoStream
::
ProfileInfo
pinfo
;
if
(
!
m_stream
.
IsValid
())
sts
=
m_stream
->
QueryProfile
(
profidx
,
&
pinfo
);
return
;
if
(
PXC_STATUS_NO_ERROR
>
sts
)
pxcStatus
sts
=
PXC_STATUS_NO_ERROR
;
break
;
for
(
int
profidx
=
0
;
PXC_STATUS_NO_ERROR
<=
sts
;
profidx
++
)
if
(
validProfile
(
pinfo
))
{
m_profiles
.
push_back
(
pinfo
);
PXCCapture
::
VideoStream
::
ProfileInfo
pinfo
;
}
sts
=
m_stream
->
QueryProfile
(
profidx
,
&
pinfo
);
if
(
PXC_STATUS_NO_ERROR
>
sts
)
break
;
if
(
validProfile
(
pinfo
))
m_profiles
.
push_back
(
pinfo
);
}
}
virtual
bool
prepareIplImage
(
PXCImage
*
pxcImage
)
=
0
;
}
};
///////////////// IntelPerCStreamImage //////////////////
class
CvIntelPerCStreamImage
IntelPerCStreamImage
::
IntelPerCStreamImage
()
:
public
CvIntelPerCStreamBase
{
{
public
:
}
CvIntelPerCStreamImage
()
IntelPerCStreamImage
::~
IntelPerCStreamImage
()
{
{
}
}
virtual
~
CvIntelPerCStreamImage
()
{
}
virtual
bool
initStream
(
PXCSession
*
session
)
bool
IntelPerCStreamImage
::
initStream
(
PXCSession
*
session
)
{
{
if
(
!
initDevice
(
session
))
if
(
!
initDevice
(
session
))
return
false
;
return
false
;
initStreamImpl
(
PXCImage
::
IMAGE_TYPE_COLOR
);
initStreamImpl
(
PXCImage
::
IMAGE_TYPE_COLOR
);
if
(
!
m_stream
.
IsValid
())
if
(
!
m_stream
.
IsValid
())
return
false
;
return
false
;
enumProfiles
();
enumProfiles
();
return
true
;
return
true
;
}
}
virtual
double
getProperty
(
int
propIdx
)
double
IntelPerCStreamImage
::
getProperty
(
int
propIdx
)
{
switch
(
propIdx
)
{
{
switch
(
propIdx
)
case
CV_CAP_PROP_BRIGHTNESS
:
{
{
case
CV_CAP_PROP_BRIGHTNESS
:
if
(
!
m_device
.
IsValid
())
{
if
(
!
m_device
.
IsValid
())
return
0.0
;
float
fret
=
0.0
f
;
if
(
PXC_STATUS_NO_ERROR
==
m_device
->
QueryProperty
(
PXCCapture
::
Device
::
PROPERTY_COLOR_BRIGHTNESS
,
&
fret
))
return
(
double
)
fret
;
return
0.0
;
return
0.0
;
}
float
fret
=
0.0
f
;
break
;
if
(
PXC_STATUS_NO_ERROR
==
m_device
->
QueryProperty
(
PXCCapture
::
Device
::
PROPERTY_COLOR_BRIGHTNESS
,
&
fret
))
case
CV_CAP_PROP_CONTRAST
:
return
(
double
)
fret
;
{
return
0.0
;
if
(
!
m_device
.
IsValid
())
}
return
0.0
;
break
;
float
fret
=
0.0
f
;
case
CV_CAP_PROP_CONTRAST
:
if
(
PXC_STATUS_NO_ERROR
==
m_device
->
QueryProperty
(
PXCCapture
::
Device
::
PROPERTY_COLOR_CONTRAST
,
&
fret
))
{
return
(
double
)
fret
;
if
(
!
m_device
.
IsValid
())
return
0.0
;
return
0.0
;
}
float
fret
=
0.0
f
;
break
;
if
(
PXC_STATUS_NO_ERROR
==
m_device
->
QueryProperty
(
PXCCapture
::
Device
::
PROPERTY_COLOR_CONTRAST
,
&
fret
))
case
CV_CAP_PROP_SATURATION
:
return
(
double
)
fret
;
{
return
0.0
;
if
(
!
m_device
.
IsValid
())
}
return
0.0
;
break
;
float
fret
=
0.0
f
;
case
CV_CAP_PROP_SATURATION
:
if
(
PXC_STATUS_NO_ERROR
==
m_device
->
QueryProperty
(
PXCCapture
::
Device
::
PROPERTY_COLOR_SATURATION
,
&
fret
))
{
return
(
double
)
fret
;
if
(
!
m_device
.
IsValid
())
return
0.0
;
return
0.0
;
}
float
fret
=
0.0
f
;
break
;
if
(
PXC_STATUS_NO_ERROR
==
m_device
->
QueryProperty
(
PXCCapture
::
Device
::
PROPERTY_COLOR_SATURATION
,
&
fret
))
case
CV_CAP_PROP_HUE
:
return
(
double
)
fret
;
{
return
0.0
;
if
(
!
m_device
.
IsValid
())
}
return
0.0
;
break
;
float
fret
=
0.0
f
;
case
CV_CAP_PROP_HUE
:
if
(
PXC_STATUS_NO_ERROR
==
m_device
->
QueryProperty
(
PXCCapture
::
Device
::
PROPERTY_COLOR_HUE
,
&
fret
))
{
return
(
double
)
fret
;
if
(
!
m_device
.
IsValid
())
return
0.0
;
return
0.0
;
}
float
fret
=
0.0
f
;
break
;
if
(
PXC_STATUS_NO_ERROR
==
m_device
->
QueryProperty
(
PXCCapture
::
Device
::
PROPERTY_COLOR_HUE
,
&
fret
))
case
CV_CAP_PROP_GAMMA
:
return
(
double
)
fret
;
{
return
0.0
;
if
(
!
m_device
.
IsValid
())
}
return
0.0
;
break
;
float
fret
=
0.0
f
;
case
CV_CAP_PROP_GAMMA
:
if
(
PXC_STATUS_NO_ERROR
==
m_device
->
QueryProperty
(
PXCCapture
::
Device
::
PROPERTY_COLOR_GAMMA
,
&
fret
))
{
return
(
double
)
fret
;
if
(
!
m_device
.
IsValid
())
return
0.0
;
return
0.0
;
}
float
fret
=
0.0
f
;
break
;
if
(
PXC_STATUS_NO_ERROR
==
m_device
->
QueryProperty
(
PXCCapture
::
Device
::
PROPERTY_COLOR_GAMMA
,
&
fret
))
case
CV_CAP_PROP_SHARPNESS
:
return
(
double
)
fret
;
{
return
0.0
;
if
(
!
m_device
.
IsValid
())
}
return
0.0
;
break
;
float
fret
=
0.0
f
;
case
CV_CAP_PROP_SHARPNESS
:
if
(
PXC_STATUS_NO_ERROR
==
m_device
->
QueryProperty
(
PXCCapture
::
Device
::
PROPERTY_COLOR_SHARPNESS
,
&
fret
))
{
return
(
double
)
fret
;
if
(
!
m_device
.
IsValid
())
return
0.0
;
return
0.0
;
}
float
fret
=
0.0
f
;
break
;
if
(
PXC_STATUS_NO_ERROR
==
m_device
->
QueryProperty
(
PXCCapture
::
Device
::
PROPERTY_COLOR_SHARPNESS
,
&
fret
))
case
CV_CAP_PROP_GAIN
:
return
(
double
)
fret
;
{
return
0.0
;
if
(
!
m_device
.
IsValid
())
}
return
0.0
;
break
;
float
fret
=
0.0
f
;
case
CV_CAP_PROP_GAIN
:
if
(
PXC_STATUS_NO_ERROR
==
m_device
->
QueryProperty
(
PXCCapture
::
Device
::
PROPERTY_COLOR_GAIN
,
&
fret
))
{
return
(
double
)
fret
;
if
(
!
m_device
.
IsValid
())
return
0.0
;
return
0.0
;
}
float
fret
=
0.0
f
;
break
;
if
(
PXC_STATUS_NO_ERROR
==
m_device
->
QueryProperty
(
PXCCapture
::
Device
::
PROPERTY_COLOR_GAIN
,
&
fret
))
case
CV_CAP_PROP_BACKLIGHT
:
return
(
double
)
fret
;
{
return
0.0
;
if
(
!
m_device
.
IsValid
())
}
return
0.0
;
break
;
float
fret
=
0.0
f
;
case
CV_CAP_PROP_BACKLIGHT
:
if
(
PXC_STATUS_NO_ERROR
==
m_device
->
QueryProperty
(
PXCCapture
::
Device
::
PROPERTY_COLOR_BACK_LIGHT_COMPENSATION
,
&
fret
))
{
return
(
double
)
fret
;
if
(
!
m_device
.
IsValid
())
return
0.0
;
return
0.0
;
}
float
fret
=
0.0
f
;
break
;
if
(
PXC_STATUS_NO_ERROR
==
m_device
->
QueryProperty
(
PXCCapture
::
Device
::
PROPERTY_COLOR_BACK_LIGHT_COMPENSATION
,
&
fret
))
case
CV_CAP_PROP_EXPOSURE
:
return
(
double
)
fret
;
{
return
0.0
;
if
(
!
m_device
.
IsValid
())
}
return
0.0
;
break
;
float
fret
=
0.0
f
;
case
CV_CAP_PROP_EXPOSURE
:
if
(
PXC_STATUS_NO_ERROR
==
m_device
->
QueryProperty
(
PXCCapture
::
Device
::
PROPERTY_COLOR_EXPOSURE
,
&
fret
))
{
return
(
double
)
fret
;
if
(
!
m_device
.
IsValid
())
return
0.0
;
return
0.0
;
}
float
fret
=
0.0
f
;
break
;
if
(
PXC_STATUS_NO_ERROR
==
m_device
->
QueryProperty
(
PXCCapture
::
Device
::
PROPERTY_COLOR_EXPOSURE
,
&
fret
))
//Add image stream specific properties
return
(
double
)
fret
;
return
0.0
;
}
}
return
CvIntelPerCStreamBase
::
getProperty
(
propIdx
);
break
;
//Add image stream specific properties
}
}
virtual
bool
setProperty
(
int
propIdx
,
double
propVal
)
return
IntelPerCStreamBase
::
getProperty
(
propIdx
);
}
bool
IntelPerCStreamImage
::
setProperty
(
int
propIdx
,
double
propVal
)
{
switch
(
propIdx
)
{
{
switch
(
propIdx
)
case
CV_CAP_PROP_BRIGHTNESS
:
{
{
case
CV_CAP_PROP_BRIGHTNESS
:
if
(
!
m_device
.
IsValid
())
{
return
false
;
if
(
!
m_device
.
IsValid
())
return
(
PXC_STATUS_NO_ERROR
==
m_device
->
SetProperty
(
PXCCapture
::
Device
::
PROPERTY_COLOR_BRIGHTNESS
,
(
float
)
propVal
));
return
false
;
return
(
PXC_STATUS_NO_ERROR
==
m_device
->
SetProperty
(
PXCCapture
::
Device
::
PROPERTY_COLOR_BRIGHTNESS
,
(
float
)
propVal
));
}
break
;
case
CV_CAP_PROP_CONTRAST
:
{
if
(
!
m_device
.
IsValid
())
return
false
;
return
(
PXC_STATUS_NO_ERROR
==
m_device
->
SetProperty
(
PXCCapture
::
Device
::
PROPERTY_COLOR_CONTRAST
,
(
float
)
propVal
));
}
break
;
case
CV_CAP_PROP_SATURATION
:
{
if
(
!
m_device
.
IsValid
())
return
false
;
return
(
PXC_STATUS_NO_ERROR
==
m_device
->
SetProperty
(
PXCCapture
::
Device
::
PROPERTY_COLOR_SATURATION
,
(
float
)
propVal
));
}
break
;
case
CV_CAP_PROP_HUE
:
{
if
(
!
m_device
.
IsValid
())
return
false
;
return
(
PXC_STATUS_NO_ERROR
==
m_device
->
SetProperty
(
PXCCapture
::
Device
::
PROPERTY_COLOR_HUE
,
(
float
)
propVal
));
}
break
;
case
CV_CAP_PROP_GAMMA
:
{
if
(
!
m_device
.
IsValid
())
return
false
;
return
(
PXC_STATUS_NO_ERROR
==
m_device
->
SetProperty
(
PXCCapture
::
Device
::
PROPERTY_COLOR_GAMMA
,
(
float
)
propVal
));
}
break
;
case
CV_CAP_PROP_SHARPNESS
:
{
if
(
!
m_device
.
IsValid
())
return
false
;
return
(
PXC_STATUS_NO_ERROR
==
m_device
->
SetProperty
(
PXCCapture
::
Device
::
PROPERTY_COLOR_SHARPNESS
,
(
float
)
propVal
));
}
break
;
case
CV_CAP_PROP_GAIN
:
{
if
(
!
m_device
.
IsValid
())
return
false
;
return
(
PXC_STATUS_NO_ERROR
==
m_device
->
SetProperty
(
PXCCapture
::
Device
::
PROPERTY_COLOR_GAIN
,
(
float
)
propVal
));
}
break
;
case
CV_CAP_PROP_BACKLIGHT
:
{
if
(
!
m_device
.
IsValid
())
return
false
;
return
(
PXC_STATUS_NO_ERROR
==
m_device
->
SetProperty
(
PXCCapture
::
Device
::
PROPERTY_COLOR_BACK_LIGHT_COMPENSATION
,
(
float
)
propVal
));
}
break
;
case
CV_CAP_PROP_EXPOSURE
:
{
if
(
!
m_device
.
IsValid
())
return
false
;
return
(
PXC_STATUS_NO_ERROR
==
m_device
->
SetProperty
(
PXCCapture
::
Device
::
PROPERTY_COLOR_EXPOSURE
,
(
float
)
propVal
));
}
break
;
//Add image stream specific properties
}
}
return
CvIntelPerCStreamBase
::
setProperty
(
propIdx
,
propVal
);
break
;
}
case
CV_CAP_PROP_CONTRAST
:
public
:
{
IplImage
*
retrieveFrame
()
if
(
!
m_device
.
IsValid
())
{
return
false
;
return
m_frame
.
retrieveFrame
();
return
(
PXC_STATUS_NO_ERROR
==
m_device
->
SetProperty
(
PXCCapture
::
Device
::
PROPERTY_COLOR_CONTRAST
,
(
float
)
propVal
));
}
break
;
case
CV_CAP_PROP_SATURATION
:
{
if
(
!
m_device
.
IsValid
())
return
false
;
return
(
PXC_STATUS_NO_ERROR
==
m_device
->
SetProperty
(
PXCCapture
::
Device
::
PROPERTY_COLOR_SATURATION
,
(
float
)
propVal
));
}
break
;
case
CV_CAP_PROP_HUE
:
{
if
(
!
m_device
.
IsValid
())
return
false
;
return
(
PXC_STATUS_NO_ERROR
==
m_device
->
SetProperty
(
PXCCapture
::
Device
::
PROPERTY_COLOR_HUE
,
(
float
)
propVal
));
}
break
;
case
CV_CAP_PROP_GAMMA
:
{
if
(
!
m_device
.
IsValid
())
return
false
;
return
(
PXC_STATUS_NO_ERROR
==
m_device
->
SetProperty
(
PXCCapture
::
Device
::
PROPERTY_COLOR_GAMMA
,
(
float
)
propVal
));
}
break
;
case
CV_CAP_PROP_SHARPNESS
:
{
if
(
!
m_device
.
IsValid
())
return
false
;
return
(
PXC_STATUS_NO_ERROR
==
m_device
->
SetProperty
(
PXCCapture
::
Device
::
PROPERTY_COLOR_SHARPNESS
,
(
float
)
propVal
));
}
break
;
case
CV_CAP_PROP_GAIN
:
{
if
(
!
m_device
.
IsValid
())
return
false
;
return
(
PXC_STATUS_NO_ERROR
==
m_device
->
SetProperty
(
PXCCapture
::
Device
::
PROPERTY_COLOR_GAIN
,
(
float
)
propVal
));
}
break
;
case
CV_CAP_PROP_BACKLIGHT
:
{
if
(
!
m_device
.
IsValid
())
return
false
;
return
(
PXC_STATUS_NO_ERROR
==
m_device
->
SetProperty
(
PXCCapture
::
Device
::
PROPERTY_COLOR_BACK_LIGHT_COMPENSATION
,
(
float
)
propVal
));
}
break
;
case
CV_CAP_PROP_EXPOSURE
:
{
if
(
!
m_device
.
IsValid
())
return
false
;
return
(
PXC_STATUS_NO_ERROR
==
m_device
->
SetProperty
(
PXCCapture
::
Device
::
PROPERTY_COLOR_EXPOSURE
,
(
float
)
propVal
));
}
break
;
//Add image stream specific properties
}
}
protected
:
return
IntelPerCStreamBase
::
setProperty
(
propIdx
,
propVal
);
FrameInternal
m_frame
;
}
bool
prepareIplImage
(
PXCImage
*
pxcI
mage
)
bool
IntelPerCStreamImage
::
retrieveAsOutputArray
(
cv
::
OutputArray
i
mage
)
{
{
if
(
NULL
==
pxcImage
)
if
(
!
m_pxcImage
.
IsValid
()
)
return
false
;
return
false
;
PXCImage
::
ImageInfo
info
;
PXCImage
::
ImageInfo
info
;
pxcImage
->
QueryInfo
(
&
info
);
m_
pxcImage
->
QueryInfo
(
&
info
);
PXCImage
::
ImageData
data
;
PXCImage
::
ImageData
data
;
pxcImage
->
AcquireAccess
(
PXCImage
::
ACCESS_READ
,
PXCImage
::
COLOR_FORMAT_RGB24
,
&
data
);
m_
pxcImage
->
AcquireAccess
(
PXCImage
::
ACCESS_READ
,
PXCImage
::
COLOR_FORMAT_RGB24
,
&
data
);
if
(
PXCImage
::
SURFACE_TYPE_SYSTEM_MEMORY
!=
data
.
type
)
if
(
PXCImage
::
SURFACE_TYPE_SYSTEM_MEMORY
!=
data
.
type
)
return
false
;
return
false
;
cv
::
Mat
temp
(
info
.
height
,
info
.
width
,
CV_8UC3
,
data
.
planes
[
0
],
data
.
pitches
[
0
]);
cv
::
Mat
temp
(
info
.
height
,
info
.
width
,
CV_8UC3
,
data
.
planes
[
0
],
data
.
pitches
[
0
]);
temp
.
copyTo
(
m_frame
.
m_mat
);
temp
.
copyTo
(
image
);
pxcImage
->
ReleaseAccess
(
&
data
);
m_pxcImage
->
ReleaseAccess
(
&
data
);
return
true
;
return
true
;
}
}
};
class
CvIntelPerCStreamDepth
///////////////// IntelPerCStreamDepth //////////////////
:
public
CvIntelPerCStreamBase
IntelPerCStreamDepth
::
IntelPerCStreamDepth
()
{
{
public
:
}
CvIntelPerCStreamDepth
()
IntelPerCStreamDepth
::~
IntelPerCStreamDepth
()
{
{
}
}
virtual
~
CvIntelPerCStreamDepth
()
{
}
virtual
bool
initStream
(
PXCSession
*
session
)
bool
IntelPerCStreamDepth
::
initStream
(
PXCSession
*
session
)
{
{
if
(
!
initDevice
(
session
))
if
(
!
initDevice
(
session
))
return
false
;
return
false
;
initStreamImpl
(
PXCImage
::
IMAGE_TYPE_DEPTH
);
initStreamImpl
(
PXCImage
::
IMAGE_TYPE_DEPTH
);
if
(
!
m_stream
.
IsValid
())
if
(
!
m_stream
.
IsValid
())
return
false
;
return
false
;
enumProfiles
();
enumProfiles
();
return
true
;
return
true
;
}
}
virtual
double
getProperty
(
int
propIdx
)
double
IntelPerCStreamDepth
::
getProperty
(
int
propIdx
)
{
switch
(
propIdx
)
{
{
switch
(
propIdx
)
case
CV_CAP_PROP_INTELPERC_DEPTH_LOW_CONFIDENCE_VALUE
:
{
{
case
CV_CAP_PROP_INTELPERC_DEPTH_LOW_CONFIDENCE_VALUE
:
if
(
!
m_device
.
IsValid
())
{
if
(
!
m_device
.
IsValid
())
return
0.0
;
float
fret
=
0.0
f
;
if
(
PXC_STATUS_NO_ERROR
==
m_device
->
QueryProperty
(
PXCCapture
::
Device
::
PROPERTY_DEPTH_LOW_CONFIDENCE_VALUE
,
&
fret
))
return
(
double
)
fret
;
return
0.0
;
return
0.0
;
}
float
fret
=
0.0
f
;
break
;
if
(
PXC_STATUS_NO_ERROR
==
m_device
->
QueryProperty
(
PXCCapture
::
Device
::
PROPERTY_DEPTH_LOW_CONFIDENCE_VALUE
,
&
fret
))
case
CV_CAP_PROP_INTELPERC_DEPTH_SATURATION_VALUE
:
return
(
double
)
fret
;
{
return
0.0
;
if
(
!
m_device
.
IsValid
())
}
return
0.0
;
break
;
float
fret
=
0.0
f
;
case
CV_CAP_PROP_INTELPERC_DEPTH_SATURATION_VALUE
:
if
(
PXC_STATUS_NO_ERROR
==
m_device
->
QueryProperty
(
PXCCapture
::
Device
::
PROPERTY_DEPTH_SATURATION_VALUE
,
&
fret
))
{
return
(
double
)
fret
;
if
(
!
m_device
.
IsValid
())
return
0.0
;
}
break
;
case
CV_CAP_PROP_INTELPERC_DEPTH_CONFIDENCE_THRESHOLD
:
{
if
(
!
m_device
.
IsValid
())
return
0.0
;
float
fret
=
0.0
f
;
if
(
PXC_STATUS_NO_ERROR
==
m_device
->
QueryProperty
(
PXCCapture
::
Device
::
PROPERTY_DEPTH_CONFIDENCE_THRESHOLD
,
&
fret
))
return
(
double
)
fret
;
return
0.0
;
}
break
;
case
CV_CAP_PROP_INTELPERC_DEPTH_FOCAL_LENGTH_HORZ
:
{
if
(
!
m_device
.
IsValid
())
return
0.0
f
;
PXCPointF32
ptf
;
if
(
PXC_STATUS_NO_ERROR
==
m_device
->
QueryPropertyAsPoint
(
PXCCapture
::
Device
::
PROPERTY_DEPTH_FOCAL_LENGTH
,
&
ptf
))
return
(
double
)
ptf
.
x
;
return
0.0
;
return
0.0
;
}
float
fret
=
0.0
f
;
break
;
if
(
PXC_STATUS_NO_ERROR
==
m_device
->
QueryProperty
(
PXCCapture
::
Device
::
PROPERTY_DEPTH_SATURATION_VALUE
,
&
fret
))
case
CV_CAP_PROP_INTELPERC_DEPTH_FOCAL_LENGTH_VERT
:
return
(
double
)
fret
;
{
return
0.0
;
if
(
!
m_device
.
IsValid
())
}
return
0.0
f
;
break
;
PXCPointF32
ptf
;
case
CV_CAP_PROP_INTELPERC_DEPTH_CONFIDENCE_THRESHOLD
:
if
(
PXC_STATUS_NO_ERROR
==
m_device
->
QueryPropertyAsPoint
(
PXCCapture
::
Device
::
PROPERTY_DEPTH_FOCAL_LENGTH
,
&
ptf
))
{
return
(
double
)
ptf
.
y
;
if
(
!
m_device
.
IsValid
())
return
0.0
;
return
0.0
;
}
float
fret
=
0.0
f
;
break
;
if
(
PXC_STATUS_NO_ERROR
==
m_device
->
QueryProperty
(
PXCCapture
::
Device
::
PROPERTY_DEPTH_CONFIDENCE_THRESHOLD
,
&
fret
))
//Add depth stream sepcific properties
return
(
double
)
fret
;
return
0.0
;
}
}
return
CvIntelPerCStreamBase
::
getProperty
(
propIdx
);
break
;
}
case
CV_CAP_PROP_INTELPERC_DEPTH_FOCAL_LENGTH_HORZ
:
virtual
bool
setProperty
(
int
propIdx
,
double
propVal
)
{
switch
(
propIdx
)
{
{
case
CV_CAP_PROP_INTELPERC_DEPTH_LOW_CONFIDENCE_VALUE
:
if
(
!
m_device
.
IsValid
())
{
return
0.0
f
;
if
(
!
m_device
.
IsValid
())
PXCPointF32
ptf
;
return
false
;
if
(
PXC_STATUS_NO_ERROR
==
m_device
->
QueryPropertyAsPoint
(
PXCCapture
::
Device
::
PROPERTY_DEPTH_FOCAL_LENGTH
,
&
ptf
))
return
(
PXC_STATUS_NO_ERROR
==
m_device
->
SetProperty
(
PXCCapture
::
Device
::
PROPERTY_DEPTH_LOW_CONFIDENCE_VALUE
,
(
float
)
propVal
));
return
(
double
)
ptf
.
x
;
}
return
0.0
;
break
;
case
CV_CAP_PROP_INTELPERC_DEPTH_SATURATION_VALUE
:
{
if
(
!
m_device
.
IsValid
())
return
false
;
return
(
PXC_STATUS_NO_ERROR
==
m_device
->
SetProperty
(
PXCCapture
::
Device
::
PROPERTY_DEPTH_SATURATION_VALUE
,
(
float
)
propVal
));
}
break
;
case
CV_CAP_PROP_INTELPERC_DEPTH_CONFIDENCE_THRESHOLD
:
{
if
(
!
m_device
.
IsValid
())
return
false
;
return
(
PXC_STATUS_NO_ERROR
==
m_device
->
SetProperty
(
PXCCapture
::
Device
::
PROPERTY_DEPTH_CONFIDENCE_THRESHOLD
,
(
float
)
propVal
));
}
break
;
//Add depth stream sepcific properties
}
}
return
CvIntelPerCStreamBase
::
setProperty
(
propIdx
,
propVal
);
break
;
}
case
CV_CAP_PROP_INTELPERC_DEPTH_FOCAL_LENGTH_VERT
:
public
:
{
IplImage
*
retrieveDepthFrame
()
if
(
!
m_device
.
IsValid
())
{
return
0.0
f
;
return
m_frameDepth
.
retrieveFrame
();
PXCPointF32
ptf
;
}
if
(
PXC_STATUS_NO_ERROR
==
m_device
->
QueryPropertyAsPoint
(
PXCCapture
::
Device
::
PROPERTY_DEPTH_FOCAL_LENGTH
,
&
ptf
))
IplImage
*
retrieveIRFrame
()
return
(
double
)
ptf
.
y
;
{
return
0.0
;
return
m_frameIR
.
retrieveFrame
();
}
}
break
;
IplImage
*
retrieveUVFrame
()
//Add depth stream sepcific properties
{
return
m_frameUV
.
retrieveFrame
();
}
protected
:
virtual
bool
validProfile
(
const
PXCCapture
::
VideoStream
::
ProfileInfo
&
pinfo
)
{
return
(
PXCImage
::
COLOR_FORMAT_DEPTH
==
pinfo
.
imageInfo
.
format
);
}
}
protected
:
return
IntelPerCStreamBase
::
getProperty
(
propIdx
);
FrameInternal
m_frameDepth
;
}
FrameInternal
m_frameIR
;
bool
IntelPerCStreamDepth
::
setProperty
(
int
propIdx
,
double
propVal
)
FrameInternal
m_frameUV
;
{
switch
(
propIdx
)
bool
prepareIplImage
(
PXCImage
*
pxcImage
)
{
{
if
(
NULL
==
pxcImage
)
case
CV_CAP_PROP_INTELPERC_DEPTH_LOW_CONFIDENCE_VALUE
:
return
false
;
PXCImage
::
ImageInfo
info
;
pxcImage
->
QueryInfo
(
&
info
);
PXCImage
::
ImageData
data
;
pxcImage
->
AcquireAccess
(
PXCImage
::
ACCESS_READ
,
&
data
);
if
(
PXCImage
::
SURFACE_TYPE_SYSTEM_MEMORY
!=
data
.
type
)
return
false
;
if
(
PXCImage
::
COLOR_FORMAT_DEPTH
!=
data
.
format
)
return
false
;
{
{
cv
::
Mat
temp
(
info
.
height
,
info
.
width
,
CV_16SC1
,
data
.
planes
[
0
],
data
.
pitches
[
0
]);
if
(
!
m_device
.
IsValid
())
temp
.
copyTo
(
m_frameDepth
.
m_mat
);
return
false
;
return
(
PXC_STATUS_NO_ERROR
==
m_device
->
SetProperty
(
PXCCapture
::
Device
::
PROPERTY_DEPTH_LOW_CONFIDENCE_VALUE
,
(
float
)
propVal
));
}
}
break
;
case
CV_CAP_PROP_INTELPERC_DEPTH_SATURATION_VALUE
:
{
{
cv
::
Mat
temp
(
info
.
height
,
info
.
width
,
CV_16SC1
,
data
.
planes
[
1
],
data
.
pitches
[
1
]);
if
(
!
m_device
.
IsValid
())
temp
.
copyTo
(
m_frameIR
.
m_mat
);
return
false
;
return
(
PXC_STATUS_NO_ERROR
==
m_device
->
SetProperty
(
PXCCapture
::
Device
::
PROPERTY_DEPTH_SATURATION_VALUE
,
(
float
)
propVal
));
}
}
break
;
case
CV_CAP_PROP_INTELPERC_DEPTH_CONFIDENCE_THRESHOLD
:
{
{
cv
::
Mat
temp
(
info
.
height
,
info
.
width
,
CV_32FC2
,
data
.
planes
[
2
],
data
.
pitches
[
2
]);
if
(
!
m_device
.
IsValid
())
temp
.
copyTo
(
m_frameUV
.
m_mat
);
return
false
;
return
(
PXC_STATUS_NO_ERROR
==
m_device
->
SetProperty
(
PXCCapture
::
Device
::
PROPERTY_DEPTH_CONFIDENCE_THRESHOLD
,
(
float
)
propVal
));
}
}
break
;
pxcImage
->
ReleaseAccess
(
&
data
);
//Add depth stream sepcific properties
return
true
;
}
}
};
return
IntelPerCStreamBase
::
setProperty
(
propIdx
,
propVal
);
}
bool
IntelPerCStreamDepth
::
retrieveDepthAsOutputArray
(
cv
::
OutputArray
image
)
{
return
retriveFrame
(
CV_16SC1
,
0
,
image
);
}
bool
IntelPerCStreamDepth
::
retrieveIRAsOutputArray
(
cv
::
OutputArray
image
)
{
return
retriveFrame
(
CV_16SC1
,
1
,
image
);
}
bool
IntelPerCStreamDepth
::
retrieveUVAsOutputArray
(
cv
::
OutputArray
image
)
{
return
retriveFrame
(
CV_32FC2
,
2
,
image
);
}
bool
IntelPerCStreamDepth
::
validProfile
(
const
PXCCapture
::
VideoStream
::
ProfileInfo
&
pinfo
)
{
return
(
PXCImage
::
COLOR_FORMAT_DEPTH
==
pinfo
.
imageInfo
.
format
);
}
bool
IntelPerCStreamDepth
::
retriveFrame
(
int
type
,
int
planeIdx
,
cv
::
OutputArray
frame
)
{
if
(
!
m_pxcImage
.
IsValid
())
return
false
;
PXCImage
::
ImageInfo
info
;
m_pxcImage
->
QueryInfo
(
&
info
);
PXCImage
::
ImageData
data
;
m_pxcImage
->
AcquireAccess
(
PXCImage
::
ACCESS_READ
,
&
data
);
if
(
PXCImage
::
SURFACE_TYPE_SYSTEM_MEMORY
!=
data
.
type
)
return
false
;
cv
::
Mat
temp
(
info
.
height
,
info
.
width
,
type
,
data
.
planes
[
planeIdx
],
data
.
pitches
[
planeIdx
]);
temp
.
copyTo
(
frame
);
m_pxcImage
->
ReleaseAccess
(
&
data
);
return
true
;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////// VideoCapture_IntelPerC //////////////////
class
CvCapture_IntelPerC
:
public
CvCapture
VideoCapture_IntelPerC
::
VideoCapture_IntelPerC
()
:
m_contextOpened
(
false
)
{
pxcStatus
sts
=
PXCSession_Create
(
&
m_session
);
if
(
PXC_STATUS_NO_ERROR
>
sts
)
return
;
m_contextOpened
=
m_imageStream
.
initStream
(
m_session
);
m_contextOpened
&=
m_depthStream
.
initStream
(
m_session
);
}
VideoCapture_IntelPerC
::~
VideoCapture_IntelPerC
(){}
double
VideoCapture_IntelPerC
::
getProperty
(
int
propIdx
)
{
{
public
:
double
propValue
=
0
;
CvCapture_IntelPerC
(
int
/*index*/
)
int
purePropIdx
=
propIdx
&
~
CV_CAP_INTELPERC_GENERATORS_MASK
;
:
m_contextOpened
(
false
)
if
(
CV_CAP_INTELPERC_IMAGE_GENERATOR
==
(
propIdx
&
CV_CAP_INTELPERC_GENERATORS_MASK
)
)
{
{
pxcStatus
sts
=
PXCSession_Create
(
&
m_session
);
propValue
=
m_imageStream
.
getProperty
(
purePropIdx
);
if
(
PXC_STATUS_NO_ERROR
>
sts
)
return
;
m_contextOpened
=
m_imageStream
.
initStream
(
m_session
);
m_contextOpened
&=
m_depthStream
.
initStream
(
m_session
);
}
}
virtual
~
CvCapture_IntelPerC
(){}
else
if
(
CV_CAP_INTELPERC_DEPTH_GENERATOR
==
(
propIdx
&
CV_CAP_INTELPERC_GENERATORS_MASK
))
virtual
double
getProperty
(
int
propIdx
)
{
{
double
propValue
=
0
;
propValue
=
m_depthStream
.
getProperty
(
purePropIdx
);
int
purePropIdx
=
propIdx
&
~
CV_CAP_INTELPERC_GENERATORS_MASK
;
if
(
CV_CAP_INTELPERC_IMAGE_GENERATOR
==
(
propIdx
&
CV_CAP_INTELPERC_GENERATORS_MASK
))
{
propValue
=
m_imageStream
.
getProperty
(
purePropIdx
);
}
else
if
(
CV_CAP_INTELPERC_DEPTH_GENERATOR
==
(
propIdx
&
CV_CAP_INTELPERC_GENERATORS_MASK
))
{
propValue
=
m_depthStream
.
getProperty
(
purePropIdx
);
}
else
{
propValue
=
m_depthStream
.
getProperty
(
purePropIdx
);
}
return
propValue
;
}
}
virtual
bool
setProperty
(
int
propIdx
,
double
propVal
)
else
{
{
bool
isSet
=
false
;
propValue
=
m_depthStream
.
getProperty
(
purePropIdx
);
int
purePropIdx
=
propIdx
&
~
CV_CAP_INTELPERC_GENERATORS_MASK
;
if
(
CV_CAP_INTELPERC_IMAGE_GENERATOR
==
(
propIdx
&
CV_CAP_INTELPERC_GENERATORS_MASK
))
{
isSet
=
m_imageStream
.
setProperty
(
purePropIdx
,
propVal
);
}
else
if
(
CV_CAP_INTELPERC_DEPTH_GENERATOR
==
(
propIdx
&
CV_CAP_INTELPERC_GENERATORS_MASK
))
{
isSet
=
m_depthStream
.
setProperty
(
purePropIdx
,
propVal
);
}
else
{
isSet
=
m_depthStream
.
setProperty
(
purePropIdx
,
propVal
);
}
return
isSet
;
}
}
return
propValue
;
bool
grabFrame
()
}
bool
VideoCapture_IntelPerC
::
setProperty
(
int
propIdx
,
double
propVal
)
{
bool
isSet
=
false
;
int
purePropIdx
=
propIdx
&
~
CV_CAP_INTELPERC_GENERATORS_MASK
;
if
(
CV_CAP_INTELPERC_IMAGE_GENERATOR
==
(
propIdx
&
CV_CAP_INTELPERC_GENERATORS_MASK
))
{
{
if
(
!
isOpened
())
isSet
=
m_imageStream
.
setProperty
(
purePropIdx
,
propVal
);
return
false
;
bool
isGrabbed
=
false
;
if
(
m_depthStream
.
isValid
())
isGrabbed
=
m_depthStream
.
grabFrame
();
if
((
m_imageStream
.
isValid
())
&&
(
-
1
!=
m_imageStream
.
getProfileIDX
()))
isGrabbed
&=
m_imageStream
.
grabFrame
();
return
isGrabbed
;
}
}
else
if
(
CV_CAP_INTELPERC_DEPTH_GENERATOR
==
(
propIdx
&
CV_CAP_INTELPERC_GENERATORS_MASK
))
virtual
IplImage
*
retrieveFrame
(
int
outputType
)
{
{
IplImage
*
image
=
0
;
isSet
=
m_depthStream
.
setProperty
(
purePropIdx
,
propVal
);
switch
(
outputType
)
{
case
CV_CAP_INTELPERC_DEPTH_MAP
:
image
=
m_depthStream
.
retrieveDepthFrame
();
break
;
case
CV_CAP_INTELPERC_UVDEPTH_MAP
:
image
=
m_depthStream
.
retrieveUVFrame
();
break
;
case
CV_CAP_INTELPERC_IR_MAP
:
image
=
m_depthStream
.
retrieveIRFrame
();
break
;
case
CV_CAP_INTELPERC_IMAGE
:
image
=
m_imageStream
.
retrieveFrame
();
break
;
}
CV_Assert
(
NULL
!=
image
);
return
image
;
}
}
else
bool
isOpened
()
const
{
{
return
m_contextOpened
;
isSet
=
m_depthStream
.
setProperty
(
purePropIdx
,
propVal
)
;
}
}
protected
:
return
isSet
;
bool
m_contextOpened
;
}
PXCSmartPtr
<
PXCSession
>
m_session
;
bool
VideoCapture_IntelPerC
::
grabFrame
()
CvIntelPerCStreamImage
m_imageStream
;
{
CvIntelPerCStreamDepth
m_depthStream
;
if
(
!
isOpened
())
}
;
return
false
;
bool
isGrabbed
=
false
;
if
(
m_depthStream
.
isValid
())
isGrabbed
=
m_depthStream
.
grabFrame
();
if
((
m_imageStream
.
isValid
())
&&
(
-
1
!=
m_imageStream
.
getProfileIDX
()))
isGrabbed
&=
m_imageStream
.
grabFrame
();
CvCapture
*
cvCreateCameraCapture_IntelPerC
(
int
index
)
return
isGrabbed
;
}
bool
VideoCapture_IntelPerC
::
retrieveFrame
(
int
outputType
,
cv
::
OutputArray
frame
)
{
{
CvCapture_IntelPerC
*
capture
=
new
CvCapture_IntelPerC
(
index
);
switch
(
outputType
)
{
if
(
capture
->
isOpened
()
)
case
CV_CAP_INTELPERC_DEPTH_MAP
:
return
capture
;
return
m_depthStream
.
retrieveDepthAsOutputArray
(
frame
);
case
CV_CAP_INTELPERC_UVDEPTH_MAP
:
return
m_depthStream
.
retrieveUVAsOutputArray
(
frame
);
case
CV_CAP_INTELPERC_IR_MAP
:
return
m_depthStream
.
retrieveIRAsOutputArray
(
frame
);
case
CV_CAP_INTELPERC_IMAGE
:
return
m_imageStream
.
retrieveAsOutputArray
(
frame
);
}
return
false
;
}
int
VideoCapture_IntelPerC
::
getCaptureDomain
()
{
return
CV_CAP_INTELPERC
;
}
delete
capture
;
bool
VideoCapture_IntelPerC
::
isOpened
()
const
return
0
;
{
return
m_contextOpened
;
}
}
}
#endif //HAVE_INTELPERC
#endif //HAVE_INTELPERC
modules/highgui/src/cap_intelperc.hpp
0 → 100644
View file @
70e22b68
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
//
// Copyright (C) 2014, Itseez, Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
//M*/
#ifndef _CAP_INTELPERC_HPP_
#define _CAP_INTELPERC_HPP_
#include "precomp.hpp"
#ifdef HAVE_INTELPERC
#include "pxcsession.h"
#include "pxcsmartptr.h"
#include "pxccapture.h"
namespace
cv
{
class
IntelPerCStreamBase
{
public
:
IntelPerCStreamBase
();
virtual
~
IntelPerCStreamBase
();
bool
isValid
();
bool
grabFrame
();
int
getProfileIDX
()
const
;
public
:
virtual
bool
initStream
(
PXCSession
*
session
)
=
0
;
virtual
double
getProperty
(
int
propIdx
);
virtual
bool
setProperty
(
int
propIdx
,
double
propVal
);
protected
:
PXCSmartPtr
<
PXCCapture
::
Device
>
m_device
;
bool
initDevice
(
PXCSession
*
session
);
PXCSmartPtr
<
PXCCapture
::
VideoStream
>
m_stream
;
void
initStreamImpl
(
PXCImage
::
ImageType
type
);
protected
:
std
::
vector
<
PXCCapture
::
VideoStream
::
ProfileInfo
>
m_profiles
;
int
m_profileIdx
;
int
m_frameIdx
;
pxcU64
m_timeStampStartNS
;
double
m_timeStamp
;
PXCSmartPtr
<
PXCImage
>
m_pxcImage
;
virtual
bool
validProfile
(
const
PXCCapture
::
VideoStream
::
ProfileInfo
&
/*pinfo*/
);
void
enumProfiles
();
};
class
IntelPerCStreamImage
:
public
IntelPerCStreamBase
{
public
:
IntelPerCStreamImage
();
virtual
~
IntelPerCStreamImage
();
virtual
bool
initStream
(
PXCSession
*
session
);
virtual
double
getProperty
(
int
propIdx
);
virtual
bool
setProperty
(
int
propIdx
,
double
propVal
);
public
:
bool
retrieveAsOutputArray
(
OutputArray
image
);
};
class
IntelPerCStreamDepth
:
public
IntelPerCStreamBase
{
public
:
IntelPerCStreamDepth
();
virtual
~
IntelPerCStreamDepth
();
virtual
bool
initStream
(
PXCSession
*
session
);
virtual
double
getProperty
(
int
propIdx
);
virtual
bool
setProperty
(
int
propIdx
,
double
propVal
);
public
:
bool
retrieveDepthAsOutputArray
(
OutputArray
image
);
bool
retrieveIRAsOutputArray
(
OutputArray
image
);
bool
retrieveUVAsOutputArray
(
OutputArray
image
);
protected
:
virtual
bool
validProfile
(
const
PXCCapture
::
VideoStream
::
ProfileInfo
&
pinfo
);
protected
:
bool
retriveFrame
(
int
type
,
int
planeIdx
,
OutputArray
frame
);
};
class
VideoCapture_IntelPerC
:
public
IVideoCapture
{
public
:
VideoCapture_IntelPerC
();
virtual
~
VideoCapture_IntelPerC
();
virtual
double
getProperty
(
int
propIdx
);
virtual
bool
setProperty
(
int
propIdx
,
double
propVal
);
virtual
bool
grabFrame
();
virtual
bool
retrieveFrame
(
int
outputType
,
OutputArray
frame
);
virtual
int
getCaptureDomain
();
bool
isOpened
()
const
;
protected
:
bool
m_contextOpened
;
PXCSmartPtr
<
PXCSession
>
m_session
;
IntelPerCStreamImage
m_imageStream
;
IntelPerCStreamDepth
m_depthStream
;
};
}
#endif //HAVE_INTELPERC
#endif //_CAP_INTELPERC_HPP_
\ No newline at end of file
modules/highgui/src/precomp.hpp
View file @
70e22b68
...
@@ -136,8 +136,6 @@ CvCapture* cvCreateFileCapture_OpenNI( const char* filename );
...
@@ -136,8 +136,6 @@ CvCapture* cvCreateFileCapture_OpenNI( const char* filename );
CvCapture
*
cvCreateCameraCapture_Android
(
int
index
);
CvCapture
*
cvCreateCameraCapture_Android
(
int
index
);
CvCapture
*
cvCreateCameraCapture_XIMEA
(
int
index
);
CvCapture
*
cvCreateCameraCapture_XIMEA
(
int
index
);
CvCapture
*
cvCreateCameraCapture_AVFoundation
(
int
index
);
CvCapture
*
cvCreateCameraCapture_AVFoundation
(
int
index
);
CvCapture
*
cvCreateCameraCapture_IntelPerC
(
int
index
);
CVAPI
(
int
)
cvHaveImageReader
(
const
char
*
filename
);
CVAPI
(
int
)
cvHaveImageReader
(
const
char
*
filename
);
CVAPI
(
int
)
cvHaveImageWriter
(
const
char
*
filename
);
CVAPI
(
int
)
cvHaveImageWriter
(
const
char
*
filename
);
...
@@ -198,6 +196,20 @@ double cvGetRatioWindow_GTK(const char* name);
...
@@ -198,6 +196,20 @@ double cvGetRatioWindow_GTK(const char* name);
double
cvGetOpenGlProp_W32
(
const
char
*
name
);
double
cvGetOpenGlProp_W32
(
const
char
*
name
);
double
cvGetOpenGlProp_GTK
(
const
char
*
name
);
double
cvGetOpenGlProp_GTK
(
const
char
*
name
);
namespace
cv
{
class
IVideoCapture
{
public
:
virtual
~
IVideoCapture
()
{}
virtual
double
getProperty
(
int
)
{
return
0
;
}
virtual
bool
setProperty
(
int
,
double
)
{
return
0
;
}
virtual
bool
grabFrame
()
=
0
;
virtual
bool
retrieveFrame
(
int
,
cv
::
OutputArray
)
=
0
;
virtual
int
getCaptureDomain
()
{
return
CAP_ANY
;
}
// Return the type of the capture object: CAP_VFW, etc...
};
};
//for QT
//for QT
#if defined (HAVE_QT)
#if defined (HAVE_QT)
double
cvGetModeWindow_QT
(
const
char
*
name
);
double
cvGetModeWindow_QT
(
const
char
*
name
);
...
...
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