Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
05bfdeab
O
Opencv
项目概览
Greenplum
/
Opencv
10 个月 前同步成功
通知
7
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
Opencv
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
05bfdeab
编写于
12月 16, 2021
作者:
A
alessandro faria
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
New example for realsense
上级
b4bb98ea
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
34 addition
and
353 deletion
+34
-353
doc/tutorials/app/intelperc.markdown
doc/tutorials/app/intelperc.markdown
+1
-1
samples/cpp/videocapture_intelperc.cpp
samples/cpp/videocapture_intelperc.cpp
+0
-352
samples/cpp/videocapture_realsense.cpp
samples/cpp/videocapture_realsense.cpp
+33
-0
未找到文件。
doc/tutorials/app/intelperc.markdown
浏览文件 @
05bfdeab
...
...
@@ -81,5 +81,5 @@ there are two flags that should be used to set/get property of the needed genera
flag value is assumed by default if neither of the two possible values of the property is set.
For more information please refer to the example of usage
[
videocapture_
intelperc.cpp
](
https://github.com/opencv/opencv/tree/master/samples/cpp/videocapture_intelperc
.cpp
)
[
videocapture_
realsense.cpp
](
https://github.com/opencv/opencv/tree/master/samples/cpp/videocapture_realsense
.cpp
)
in opencv/samples/cpp folder.
samples/cpp/videocapture_intelperc.cpp
已删除
100644 → 0
浏览文件 @
b4bb98ea
#include "opencv2/videoio.hpp"
#include "opencv2/highgui.hpp"
#include <iostream>
using
namespace
cv
;
using
namespace
std
;
static
bool
g_printStreamSetting
;
static
int
g_imageStreamProfileIdx
;
static
int
g_depthStreamProfileIdx
;
static
bool
g_irStreamShow
;
static
double
g_imageBrightness
;
static
double
g_imageContrast
;
static
bool
g_printTiming
;
static
bool
g_showClosedPoint
;
static
int
g_closedDepthPoint
[
2
];
static
void
printUsage
(
const
char
*
arg0
)
{
const
char
*
filename
=
arg0
;
while
(
*
filename
)
filename
++
;
while
((
arg0
<=
filename
)
&&
(
'\\'
!=
*
filename
)
&&
(
'/'
!=
*
filename
))
filename
--
;
filename
++
;
cout
<<
"This program demonstrates usage of camera supported
\n
by Intel Perceptual computing SDK."
<<
endl
<<
endl
;
cout
<<
"usage: "
<<
filename
<<
"[-ps] [-isp=IDX] [-dsp=IDX]
\n
[-ir] [-imb=VAL] [-imc=VAL]"
<<
endl
<<
endl
;
cout
<<
" -ps, print streams setting and profiles"
<<
endl
;
cout
<<
" -isp=IDX, set profile index of the image stream"
<<
endl
;
cout
<<
" -dsp=IDX, set profile index of the depth stream"
<<
endl
;
cout
<<
" -ir, show data from IR stream"
<<
endl
;
cout
<<
" -imb=VAL, set brightness value for an image stream"
<<
endl
;
cout
<<
" -imc=VAL, set contrast value for a image stream"
<<
endl
;
cout
<<
" -pts, print frame index and frame time"
<<
endl
;
cout
<<
" --show-closed, print frame index and frame time"
<<
endl
;
cout
<<
endl
;
}
static
void
parseCMDLine
(
int
argc
,
char
*
argv
[])
{
cv
::
CommandLineParser
parser
(
argc
,
argv
,
"{ h help | | }"
"{ ps print-streams | | }"
"{ isp image-stream-prof | -1 | }"
"{ dsp depth-stream-prof | -1 | }"
"{ir||}{imb||}{imc||}{pts||}{show-closed||}"
);
if
(
parser
.
has
(
"h"
))
{
printUsage
(
argv
[
0
]);
exit
(
0
);
}
g_printStreamSetting
=
parser
.
has
(
"ps"
);
g_imageStreamProfileIdx
=
parser
.
get
<
int
>
(
"isp"
);
g_depthStreamProfileIdx
=
parser
.
get
<
int
>
(
"dsp"
);
g_irStreamShow
=
parser
.
has
(
"ir"
);
if
(
parser
.
has
(
"imb"
))
g_imageBrightness
=
parser
.
get
<
double
>
(
"imb"
);
else
g_imageBrightness
=
-
DBL_MAX
;
if
(
parser
.
has
(
"imc"
))
g_imageContrast
=
parser
.
get
<
double
>
(
"imc"
);
else
g_imageContrast
=
-
DBL_MAX
;
g_printTiming
=
parser
.
has
(
"pts"
);
g_showClosedPoint
=
parser
.
has
(
"show-closed"
);
if
(
!
parser
.
check
())
{
parser
.
printErrors
();
exit
(
-
1
);
}
if
(
g_showClosedPoint
&&
(
-
1
==
g_depthStreamProfileIdx
))
{
cerr
<<
"For --show-closed depth profile has be selected"
<<
endl
;
exit
(
-
1
);
}
}
static
void
printStreamProperties
(
VideoCapture
&
capture
)
{
size_t
profilesCount
=
(
size_t
)
capture
.
get
(
CAP_INTELPERC_IMAGE_GENERATOR
|
CAP_PROP_INTELPERC_PROFILE_COUNT
);
cout
<<
"Image stream."
<<
endl
;
cout
<<
" Brightness = "
<<
capture
.
get
(
CAP_INTELPERC_IMAGE_GENERATOR
|
CAP_PROP_BRIGHTNESS
)
<<
endl
;
cout
<<
" Contrast = "
<<
capture
.
get
(
CAP_INTELPERC_IMAGE_GENERATOR
|
CAP_PROP_CONTRAST
)
<<
endl
;
cout
<<
" Saturation = "
<<
capture
.
get
(
CAP_INTELPERC_IMAGE_GENERATOR
|
CAP_PROP_SATURATION
)
<<
endl
;
cout
<<
" Hue = "
<<
capture
.
get
(
CAP_INTELPERC_IMAGE_GENERATOR
|
CAP_PROP_HUE
)
<<
endl
;
cout
<<
" Gamma = "
<<
capture
.
get
(
CAP_INTELPERC_IMAGE_GENERATOR
|
CAP_PROP_GAMMA
)
<<
endl
;
cout
<<
" Sharpness = "
<<
capture
.
get
(
CAP_INTELPERC_IMAGE_GENERATOR
|
CAP_PROP_SHARPNESS
)
<<
endl
;
cout
<<
" Gain = "
<<
capture
.
get
(
CAP_INTELPERC_IMAGE_GENERATOR
|
CAP_PROP_GAIN
)
<<
endl
;
cout
<<
" Backligh = "
<<
capture
.
get
(
CAP_INTELPERC_IMAGE_GENERATOR
|
CAP_PROP_BACKLIGHT
)
<<
endl
;
cout
<<
"Image streams profiles:"
<<
endl
;
for
(
size_t
i
=
0
;
i
<
profilesCount
;
i
++
)
{
capture
.
set
(
CAP_INTELPERC_IMAGE_GENERATOR
|
CAP_PROP_INTELPERC_PROFILE_IDX
,
(
double
)
i
);
cout
<<
" Profile["
<<
i
<<
"]: "
;
cout
<<
"width = "
<<
(
int
)
capture
.
get
(
CAP_INTELPERC_IMAGE_GENERATOR
|
CAP_PROP_FRAME_WIDTH
);
cout
<<
", height = "
<<
(
int
)
capture
.
get
(
CAP_INTELPERC_IMAGE_GENERATOR
|
CAP_PROP_FRAME_HEIGHT
);
cout
<<
", fps = "
<<
capture
.
get
(
CAP_INTELPERC_IMAGE_GENERATOR
|
CAP_PROP_FPS
);
cout
<<
endl
;
}
profilesCount
=
(
size_t
)
capture
.
get
(
CAP_INTELPERC_DEPTH_GENERATOR
|
CAP_PROP_INTELPERC_PROFILE_COUNT
);
cout
<<
"Depth stream."
<<
endl
;
cout
<<
" Low confidence value = "
<<
capture
.
get
(
CAP_INTELPERC_DEPTH_GENERATOR
|
CAP_PROP_INTELPERC_DEPTH_LOW_CONFIDENCE_VALUE
)
<<
endl
;
cout
<<
" Saturation value = "
<<
capture
.
get
(
CAP_INTELPERC_DEPTH_GENERATOR
|
CAP_PROP_INTELPERC_DEPTH_SATURATION_VALUE
)
<<
endl
;
cout
<<
" Confidence threshold = "
<<
capture
.
get
(
CAP_INTELPERC_DEPTH_GENERATOR
|
CAP_PROP_INTELPERC_DEPTH_CONFIDENCE_THRESHOLD
)
<<
endl
;
cout
<<
" Focal length = ("
<<
capture
.
get
(
CAP_INTELPERC_DEPTH_GENERATOR
|
CAP_PROP_INTELPERC_DEPTH_FOCAL_LENGTH_HORZ
)
<<
", "
<<
capture
.
get
(
CAP_INTELPERC_DEPTH_GENERATOR
|
CAP_PROP_INTELPERC_DEPTH_FOCAL_LENGTH_VERT
)
<<
")"
<<
endl
;
cout
<<
"Depth streams profiles:"
<<
endl
;
for
(
size_t
i
=
0
;
i
<
profilesCount
;
i
++
)
{
capture
.
set
(
CAP_INTELPERC_DEPTH_GENERATOR
|
CAP_PROP_INTELPERC_PROFILE_IDX
,
(
double
)
i
);
cout
<<
" Profile["
<<
i
<<
"]: "
;
cout
<<
"width = "
<<
(
int
)
capture
.
get
(
CAP_INTELPERC_DEPTH_GENERATOR
|
CAP_PROP_FRAME_WIDTH
);
cout
<<
", height = "
<<
(
int
)
capture
.
get
(
CAP_INTELPERC_DEPTH_GENERATOR
|
CAP_PROP_FRAME_HEIGHT
);
cout
<<
", fps = "
<<
capture
.
get
(
CAP_INTELPERC_DEPTH_GENERATOR
|
CAP_PROP_FPS
);
cout
<<
endl
;
}
}
static
void
imshowImage
(
const
char
*
winname
,
Mat
&
image
,
VideoCapture
&
capture
)
{
if
(
g_showClosedPoint
)
{
Mat
uvMap
;
if
(
capture
.
retrieve
(
uvMap
,
CAP_INTELPERC_UVDEPTH_MAP
))
{
float
*
uvmap
=
(
float
*
)
uvMap
.
ptr
()
+
2
*
(
g_closedDepthPoint
[
0
]
*
uvMap
.
cols
+
g_closedDepthPoint
[
1
]);
int
x
=
(
int
)((
*
uvmap
)
*
image
.
cols
);
uvmap
++
;
int
y
=
(
int
)((
*
uvmap
)
*
image
.
rows
);
if
((
0
<=
x
)
&&
(
0
<=
y
))
{
static
const
int
pointSize
=
4
;
for
(
int
row
=
y
;
row
<
min
(
y
+
pointSize
,
image
.
rows
);
row
++
)
{
uchar
*
ptrDst
=
image
.
ptr
(
row
)
+
x
*
3
+
2
;
//+2 -> Red
for
(
int
col
=
0
;
col
<
min
(
pointSize
,
image
.
cols
-
x
);
col
++
,
ptrDst
+=
3
)
{
*
ptrDst
=
255
;
}
}
}
}
}
imshow
(
winname
,
image
);
}
static
void
imshowIR
(
const
char
*
winname
,
Mat
&
ir
)
{
Mat
image
;
if
(
g_showClosedPoint
)
{
image
.
create
(
ir
.
rows
,
ir
.
cols
,
CV_8UC3
);
for
(
int
row
=
0
;
row
<
ir
.
rows
;
row
++
)
{
uchar
*
ptrDst
=
image
.
ptr
(
row
);
short
*
ptrSrc
=
(
short
*
)
ir
.
ptr
(
row
);
for
(
int
col
=
0
;
col
<
ir
.
cols
;
col
++
,
ptrSrc
++
)
{
uchar
val
=
(
uchar
)
((
*
ptrSrc
)
>>
2
);
*
ptrDst
=
val
;
ptrDst
++
;
*
ptrDst
=
val
;
ptrDst
++
;
*
ptrDst
=
val
;
ptrDst
++
;
}
}
static
const
int
pointSize
=
4
;
for
(
int
row
=
g_closedDepthPoint
[
0
];
row
<
min
(
g_closedDepthPoint
[
0
]
+
pointSize
,
image
.
rows
);
row
++
)
{
uchar
*
ptrDst
=
image
.
ptr
(
row
)
+
g_closedDepthPoint
[
1
]
*
3
+
2
;
//+2 -> Red
for
(
int
col
=
0
;
col
<
min
(
pointSize
,
image
.
cols
-
g_closedDepthPoint
[
1
]);
col
++
,
ptrDst
+=
3
)
{
*
ptrDst
=
255
;
}
}
}
else
{
image
.
create
(
ir
.
rows
,
ir
.
cols
,
CV_8UC1
);
for
(
int
row
=
0
;
row
<
ir
.
rows
;
row
++
)
{
uchar
*
ptrDst
=
image
.
ptr
(
row
);
short
*
ptrSrc
=
(
short
*
)
ir
.
ptr
(
row
);
for
(
int
col
=
0
;
col
<
ir
.
cols
;
col
++
,
ptrSrc
++
,
ptrDst
++
)
{
*
ptrDst
=
(
uchar
)
((
*
ptrSrc
)
>>
2
);
}
}
}
imshow
(
winname
,
image
);
}
static
void
imshowDepth
(
const
char
*
winname
,
Mat
&
depth
,
VideoCapture
&
capture
)
{
short
lowValue
=
(
short
)
capture
.
get
(
CAP_INTELPERC_DEPTH_GENERATOR
|
CAP_PROP_INTELPERC_DEPTH_LOW_CONFIDENCE_VALUE
);
short
saturationValue
=
(
short
)
capture
.
get
(
CAP_INTELPERC_DEPTH_GENERATOR
|
CAP_PROP_INTELPERC_DEPTH_SATURATION_VALUE
);
Mat
image
;
if
(
g_showClosedPoint
)
{
image
.
create
(
depth
.
rows
,
depth
.
cols
,
CV_8UC3
);
for
(
int
row
=
0
;
row
<
depth
.
rows
;
row
++
)
{
uchar
*
ptrDst
=
image
.
ptr
(
row
);
short
*
ptrSrc
=
(
short
*
)
depth
.
ptr
(
row
);
for
(
int
col
=
0
;
col
<
depth
.
cols
;
col
++
,
ptrSrc
++
)
{
if
((
lowValue
==
(
*
ptrSrc
))
||
(
saturationValue
==
(
*
ptrSrc
)))
{
*
ptrDst
=
0
;
ptrDst
++
;
*
ptrDst
=
0
;
ptrDst
++
;
*
ptrDst
=
0
;
ptrDst
++
;
}
else
{
uchar
val
=
(
uchar
)
((
*
ptrSrc
)
>>
2
);
*
ptrDst
=
val
;
ptrDst
++
;
*
ptrDst
=
val
;
ptrDst
++
;
*
ptrDst
=
val
;
ptrDst
++
;
}
}
}
static
const
int
pointSize
=
4
;
for
(
int
row
=
g_closedDepthPoint
[
0
];
row
<
min
(
g_closedDepthPoint
[
0
]
+
pointSize
,
image
.
rows
);
row
++
)
{
uchar
*
ptrDst
=
image
.
ptr
(
row
)
+
g_closedDepthPoint
[
1
]
*
3
+
2
;
//+2 -> Red
for
(
int
col
=
0
;
col
<
min
(
pointSize
,
image
.
cols
-
g_closedDepthPoint
[
1
]);
col
++
,
ptrDst
+=
3
)
{
*
ptrDst
=
255
;
}
}
}
else
{
image
.
create
(
depth
.
rows
,
depth
.
cols
,
CV_8UC1
);
for
(
int
row
=
0
;
row
<
depth
.
rows
;
row
++
)
{
uchar
*
ptrDst
=
image
.
ptr
(
row
);
short
*
ptrSrc
=
(
short
*
)
depth
.
ptr
(
row
);
for
(
int
col
=
0
;
col
<
depth
.
cols
;
col
++
,
ptrSrc
++
,
ptrDst
++
)
{
if
((
lowValue
==
(
*
ptrSrc
))
||
(
saturationValue
==
(
*
ptrSrc
)))
*
ptrDst
=
0
;
else
*
ptrDst
=
(
uchar
)
((
*
ptrSrc
)
>>
2
);
}
}
}
imshow
(
winname
,
image
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
parseCMDLine
(
argc
,
argv
);
VideoCapture
capture
;
capture
.
open
(
CAP_INTELPERC
);
if
(
!
capture
.
isOpened
())
{
cerr
<<
"Can not open a capture object."
<<
endl
;
return
-
1
;
}
if
(
g_printStreamSetting
)
printStreamProperties
(
capture
);
if
(
-
1
!=
g_imageStreamProfileIdx
)
{
if
(
!
capture
.
set
(
CAP_INTELPERC_IMAGE_GENERATOR
|
CAP_PROP_INTELPERC_PROFILE_IDX
,
(
double
)
g_imageStreamProfileIdx
))
{
cerr
<<
"Can not setup a image stream."
<<
endl
;
return
-
1
;
}
}
if
(
-
1
!=
g_depthStreamProfileIdx
)
{
if
(
!
capture
.
set
(
CAP_INTELPERC_DEPTH_GENERATOR
|
CAP_PROP_INTELPERC_PROFILE_IDX
,
(
double
)
g_depthStreamProfileIdx
))
{
cerr
<<
"Can not setup a depth stream."
<<
endl
;
return
-
1
;
}
}
else
if
(
g_irStreamShow
)
{
if
(
!
capture
.
set
(
CAP_INTELPERC_DEPTH_GENERATOR
|
CAP_PROP_INTELPERC_PROFILE_IDX
,
0.0
))
{
cerr
<<
"Can not setup a IR stream."
<<
endl
;
return
-
1
;
}
}
else
{
cout
<<
"Streams not selected"
<<
endl
;
return
0
;
}
//Setup additional properties only after set profile of the stream
if
(
(
-
10000.0
<
g_imageBrightness
)
&&
(
g_imageBrightness
<
10000.0
))
capture
.
set
(
CAP_INTELPERC_IMAGE_GENERATOR
|
CAP_PROP_BRIGHTNESS
,
g_imageBrightness
);
if
(
(
0
<
g_imageContrast
)
&&
(
g_imageContrast
<
10000.0
))
capture
.
set
(
CAP_INTELPERC_IMAGE_GENERATOR
|
CAP_PROP_BRIGHTNESS
,
g_imageContrast
);
int
frame
=
0
;
for
(;;
frame
++
)
{
Mat
bgrImage
;
Mat
depthImage
;
Mat
irImage
;
if
(
!
capture
.
grab
())
{
cout
<<
"Can not grab images."
<<
endl
;
return
-
1
;
}
if
((
-
1
!=
g_depthStreamProfileIdx
)
&&
(
capture
.
retrieve
(
depthImage
,
CAP_INTELPERC_DEPTH_MAP
)))
{
if
(
g_showClosedPoint
)
{
double
minVal
=
0.0
;
double
maxVal
=
0.0
;
minMaxIdx
(
depthImage
,
&
minVal
,
&
maxVal
,
g_closedDepthPoint
);
}
imshowDepth
(
"depth image"
,
depthImage
,
capture
);
}
if
((
g_irStreamShow
)
&&
(
capture
.
retrieve
(
irImage
,
CAP_INTELPERC_IR_MAP
)))
imshowIR
(
"ir image"
,
irImage
);
if
((
-
1
!=
g_imageStreamProfileIdx
)
&&
(
capture
.
retrieve
(
bgrImage
,
CAP_INTELPERC_IMAGE
)))
imshowImage
(
"color image"
,
bgrImage
,
capture
);
if
(
g_printTiming
)
{
cout
<<
"Image frame: "
<<
capture
.
get
(
CAP_INTELPERC_IMAGE_GENERATOR
|
CAP_PROP_POS_FRAMES
)
<<
", Depth(IR) frame: "
<<
capture
.
get
(
CAP_INTELPERC_DEPTH_GENERATOR
|
CAP_PROP_POS_FRAMES
)
<<
endl
;
cout
<<
"Image frame: "
<<
capture
.
get
(
CAP_INTELPERC_IMAGE_GENERATOR
|
CAP_PROP_POS_MSEC
)
<<
", Depth(IR) frame: "
<<
capture
.
get
(
CAP_INTELPERC_DEPTH_GENERATOR
|
CAP_PROP_POS_MSEC
)
<<
endl
;
}
if
(
waitKey
(
30
)
>=
0
)
break
;
}
return
0
;
}
samples/cpp/videocapture_realsense.cpp
0 → 100644
浏览文件 @
05bfdeab
#include "opencv2/videoio.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp"
using
namespace
cv
;
using
namespace
std
;
int
main
()
{
VideoCapture
capture
(
CAP_INTELPERC
);
for
(;;)
{
Mat
depthMap
;
Mat
image
;
Mat
irImage
;
Mat
adjMap
;
capture
.
grab
();
capture
.
retrieve
(
depthMap
,
CAP_INTELPERC_DEPTH_MAP
);
capture
.
retrieve
(
image
,
CAP_INTELPERC_IMAGE
);
capture
.
retrieve
(
irImage
,
CAP_INTELPERC_IR_MAP
);
normalize
(
depthMap
,
adjMap
,
0
,
255
,
NORM_MINMAX
,
CV_8UC1
);
applyColorMap
(
adjMap
,
adjMap
,
COLORMAP_JET
);
imshow
(
"RGB"
,
image
);
imshow
(
"IR"
,
irImage
);
imshow
(
"DEPTH"
,
adjMap
);
if
(
waitKey
(
30
)
>=
0
)
break
;
}
return
0
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录