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
d1a598c6
Commit
d1a598c6
authored
Jun 08, 2018
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #11730 from paroj:realsensev2
parents
45dd575e
bfc227b8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
26 deletions
+26
-26
OpenCVFindLibRealsense.cmake
cmake/OpenCVFindLibRealsense.cmake
+2
-2
cap_librealsense.cpp
modules/videoio/src/cap_librealsense.cpp
+20
-21
cap_librealsense.hpp
modules/videoio/src/cap_librealsense.hpp
+4
-3
No files found.
cmake/OpenCVFindLibRealsense.cmake
View file @
d1a598c6
...
...
@@ -2,8 +2,8 @@
# LIBREALSENSE_LIBRARIES and LIBREALSENSE_INCLUDE to link Intel librealsense modules
# HAVE_LIBREALSENSE for conditional compilation OpenCV with/without librealsense
find_path
(
LIBREALSENSE_INCLUDE_DIR
"librealsense/rs.hpp"
PATHS
"$ENV{LIBREALSENSE_INCLUDE}"
DOC
"Path to librealsense interface headers"
)
find_library
(
LIBREALSENSE_LIBRARIES
"realsense"
PATHS
"$ENV{LIBREALSENSE_LIB}"
DOC
"Path to librealsense interface libraries"
)
find_path
(
LIBREALSENSE_INCLUDE_DIR
"librealsense
2
/rs.hpp"
PATHS
"$ENV{LIBREALSENSE_INCLUDE}"
DOC
"Path to librealsense interface headers"
)
find_library
(
LIBREALSENSE_LIBRARIES
"realsense
2
"
PATHS
"$ENV{LIBREALSENSE_LIB}"
DOC
"Path to librealsense interface libraries"
)
if
(
LIBREALSENSE_INCLUDE_DIR AND LIBREALSENSE_LIBRARIES
)
set
(
HAVE_LIBREALSENSE TRUE
)
...
...
modules/videoio/src/cap_librealsense.cpp
View file @
d1a598c6
...
...
@@ -10,20 +10,19 @@
namespace
cv
{
VideoCapture_LibRealsense
::
VideoCapture_LibRealsense
(
int
index
)
VideoCapture_LibRealsense
::
VideoCapture_LibRealsense
(
int
)
:
mAlign
(
RS2_STREAM_COLOR
)
{
try
{
mDev
=
mContext
.
get_device
(
index
)
;
// Configure all streams to run at VGA resolution at
60 frames per second
mDev
->
enable_stream
(
rs
::
stream
::
depth
,
640
,
480
,
rs
::
format
::
z16
,
60
);
mDev
->
enable_stream
(
rs
::
stream
::
color
,
640
,
480
,
rs
::
format
::
bgr8
,
60
);
mDev
->
enable_stream
(
rs
::
stream
::
infrared
,
640
,
480
,
rs
::
format
::
y8
,
60
);
m
Dev
->
start
();
rs2
::
config
config
;
// Configure all streams to run at VGA resolution at
default fps
config
.
enable_stream
(
RS2_STREAM_DEPTH
,
640
,
480
,
RS2_FORMAT_Z16
);
config
.
enable_stream
(
RS2_STREAM_COLOR
,
640
,
480
,
RS2_FORMAT_BGR8
);
config
.
enable_stream
(
RS2_STREAM_INFRARED
,
640
,
480
,
RS2_FORMAT_Y8
);
m
Pipe
.
start
();
}
catch
(
rs
::
error
&
)
catch
(
const
rs2
::
error
&
)
{
mDev
=
nullptr
;
}
}
VideoCapture_LibRealsense
::~
VideoCapture_LibRealsense
(){}
...
...
@@ -32,8 +31,8 @@ double VideoCapture_LibRealsense::getProperty(int prop) const
{
double
propValue
=
0
;
if
(
prop
==
CAP_PROP_INTELPERC_DEPTH_SATURATION_VALUE
)
return
m
Dev
->
get_depth_scale
();
if
(
prop
==
CAP_PROP_INTELPERC_DEPTH_SATURATION_VALUE
)
return
m
Pipe
.
get_active_profile
().
get_device
().
first
<
rs2
::
depth_sensor
>
().
get_depth_scale
();
return
propValue
;
}
...
...
@@ -50,9 +49,9 @@ bool VideoCapture_LibRealsense::grabFrame()
try
{
mD
ev
->
wait_for_frames
(
);
mD
ata
=
mAlign
.
process
(
mPipe
.
wait_for_frames
()
);
}
catch
(
rs
::
error
&
)
catch
(
const
rs2
::
error
&
)
{
return
false
;
}
...
...
@@ -61,20 +60,20 @@ bool VideoCapture_LibRealsense::grabFrame()
}
bool
VideoCapture_LibRealsense
::
retrieveFrame
(
int
outputType
,
cv
::
OutputArray
frame
)
{
rs
::
stream
stream
;
rs
2
::
video_frame
_frame
(
nullptr
)
;
int
type
;
switch
(
outputType
)
{
case
CAP_INTELPERC_DEPTH_MAP
:
stream
=
rs
::
stream
::
depth_aligned_to_color
;
_frame
=
mData
.
get_depth_frame
().
as
<
rs2
::
video_frame
>
()
;
type
=
CV_16UC1
;
break
;
case
CAP_INTELPERC_IR_MAP
:
stream
=
rs
::
stream
::
infrared
;
_frame
=
mData
.
get_infrared_frame
()
;
type
=
CV_8UC1
;
break
;
case
CAP_INTELPERC_IMAGE
:
stream
=
rs
::
stream
::
color
;
_frame
=
mData
.
get_color_frame
()
;
type
=
CV_8UC3
;
break
;
default
:
...
...
@@ -84,10 +83,10 @@ bool VideoCapture_LibRealsense::retrieveFrame(int outputType, cv::OutputArray fr
try
{
// we copy the data straight away, so const_cast should be fine
void
*
data
=
const_cast
<
void
*>
(
mDev
->
get_frame_data
(
stream
));
Mat
(
mDev
->
get_stream_height
(
stream
),
mDev
->
get_stream_width
(
stream
),
type
,
data
).
copyTo
(
frame
);
void
*
data
=
const_cast
<
void
*>
(
_frame
.
get_data
(
));
Mat
(
_frame
.
get_height
(),
_frame
.
get_width
(),
type
,
data
,
_frame
.
get_stride_in_bytes
()
).
copyTo
(
frame
);
}
catch
(
rs
::
error
&
)
catch
(
const
rs2
::
error
&
)
{
return
false
;
}
...
...
@@ -101,7 +100,7 @@ int VideoCapture_LibRealsense::getCaptureDomain()
bool
VideoCapture_LibRealsense
::
isOpened
()
const
{
return
mDev
&&
mDev
->
is_streaming
(
);
return
bool
(
std
::
shared_ptr
<
rs2_pipeline
>
(
mPipe
)
);
}
}
...
...
modules/videoio/src/cap_librealsense.hpp
View file @
d1a598c6
...
...
@@ -7,7 +7,7 @@
#ifdef HAVE_LIBREALSENSE
#include <librealsense/rs.hpp>
#include <librealsense
2
/rs.hpp>
namespace
cv
{
...
...
@@ -26,8 +26,9 @@ public:
virtual
int
getCaptureDomain
()
CV_OVERRIDE
;
virtual
bool
isOpened
()
const
CV_OVERRIDE
;
protected
:
rs
::
context
mContext
;
rs
::
device
*
mDev
=
nullptr
;
rs2
::
pipeline
mPipe
;
rs2
::
frameset
mData
;
rs2
::
align
mAlign
;
};
}
...
...
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