Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
f8398d80
O
Opencv
项目概览
Greenplum
/
Opencv
大约 1 年 前同步成功
通知
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,发现更多精彩内容 >>
提交
f8398d80
编写于
9月 25, 2018
作者:
D
Dmitry Kurtaev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add Net::getUnconnectedOutLayersNames method
上级
a610be63
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
21 addition
and
20 deletion
+21
-20
modules/dnn/include/opencv2/dnn/dnn.hpp
modules/dnn/include/opencv2/dnn/dnn.hpp
+5
-0
modules/dnn/src/dnn.cpp
modules/dnn/src/dnn.cpp
+12
-0
samples/dnn/object_detection.cpp
samples/dnn/object_detection.cpp
+2
-15
samples/dnn/object_detection.py
samples/dnn/object_detection.py
+2
-5
未找到文件。
modules/dnn/include/opencv2/dnn/dnn.hpp
浏览文件 @
f8398d80
...
@@ -535,6 +535,11 @@ CV__DNN_EXPERIMENTAL_NS_BEGIN
...
@@ -535,6 +535,11 @@ CV__DNN_EXPERIMENTAL_NS_BEGIN
/** @brief Returns indexes of layers with unconnected outputs.
/** @brief Returns indexes of layers with unconnected outputs.
*/
*/
CV_WRAP
std
::
vector
<
int
>
getUnconnectedOutLayers
()
const
;
CV_WRAP
std
::
vector
<
int
>
getUnconnectedOutLayers
()
const
;
/** @brief Returns names of layers with unconnected outputs.
*/
CV_WRAP
std
::
vector
<
String
>
getUnconnectedOutLayersNames
()
const
;
/** @brief Returns input and output shapes for all layers in loaded model;
/** @brief Returns input and output shapes for all layers in loaded model;
* preliminary inferencing isn't necessary.
* preliminary inferencing isn't necessary.
* @param netInputShapes shapes for all input blobs in net input layer.
* @param netInputShapes shapes for all input blobs in net input layer.
...
...
modules/dnn/src/dnn.cpp
浏览文件 @
f8398d80
...
@@ -2789,6 +2789,18 @@ std::vector<int> Net::getUnconnectedOutLayers() const
...
@@ -2789,6 +2789,18 @@ std::vector<int> Net::getUnconnectedOutLayers() const
return
layersIds
;
return
layersIds
;
}
}
std
::
vector
<
String
>
Net
::
getUnconnectedOutLayersNames
()
const
{
std
::
vector
<
int
>
ids
=
getUnconnectedOutLayers
();
const
size_t
n
=
ids
.
size
();
std
::
vector
<
String
>
names
(
n
);
for
(
size_t
i
=
0
;
i
<
n
;
++
i
)
{
names
[
i
]
=
impl
->
layers
[
ids
[
i
]].
name
;
}
return
names
;
}
void
Net
::
getLayersShapes
(
const
ShapesVec
&
netInputShapes
,
void
Net
::
getLayersShapes
(
const
ShapesVec
&
netInputShapes
,
std
::
vector
<
int
>&
layersIds
,
std
::
vector
<
int
>&
layersIds
,
std
::
vector
<
ShapesVec
>&
inLayersShapes
,
std
::
vector
<
ShapesVec
>&
inLayersShapes
,
...
...
samples/dnn/object_detection.cpp
浏览文件 @
f8398d80
...
@@ -86,6 +86,7 @@ int main(int argc, char** argv)
...
@@ -86,6 +86,7 @@ int main(int argc, char** argv)
Net
net
=
readNet
(
parser
.
get
<
String
>
(
"model"
),
parser
.
get
<
String
>
(
"config"
),
parser
.
get
<
String
>
(
"framework"
));
Net
net
=
readNet
(
parser
.
get
<
String
>
(
"model"
),
parser
.
get
<
String
>
(
"config"
),
parser
.
get
<
String
>
(
"framework"
));
net
.
setPreferableBackend
(
parser
.
get
<
int
>
(
"backend"
));
net
.
setPreferableBackend
(
parser
.
get
<
int
>
(
"backend"
));
net
.
setPreferableTarget
(
parser
.
get
<
int
>
(
"target"
));
net
.
setPreferableTarget
(
parser
.
get
<
int
>
(
"target"
));
std
::
vector
<
String
>
outNames
=
net
.
getUnconnectedOutLayersNames
();
// Create a window
// Create a window
static
const
std
::
string
kWinName
=
"Deep learning object detection in OpenCV"
;
static
const
std
::
string
kWinName
=
"Deep learning object detection in OpenCV"
;
...
@@ -125,7 +126,7 @@ int main(int argc, char** argv)
...
@@ -125,7 +126,7 @@ int main(int argc, char** argv)
net
.
setInput
(
imInfo
,
"im_info"
);
net
.
setInput
(
imInfo
,
"im_info"
);
}
}
std
::
vector
<
Mat
>
outs
;
std
::
vector
<
Mat
>
outs
;
net
.
forward
(
outs
,
getOutputsNames
(
net
)
);
net
.
forward
(
outs
,
outNames
);
postprocess
(
frame
,
outs
,
net
);
postprocess
(
frame
,
outs
,
net
);
...
@@ -265,17 +266,3 @@ void callback(int pos, void*)
...
@@ -265,17 +266,3 @@ void callback(int pos, void*)
{
{
confThreshold
=
pos
*
0.01
f
;
confThreshold
=
pos
*
0.01
f
;
}
}
std
::
vector
<
String
>
getOutputsNames
(
const
Net
&
net
)
{
static
std
::
vector
<
String
>
names
;
if
(
names
.
empty
())
{
std
::
vector
<
int
>
outLayers
=
net
.
getUnconnectedOutLayers
();
std
::
vector
<
String
>
layersNames
=
net
.
getLayerNames
();
names
.
resize
(
outLayers
.
size
());
for
(
size_t
i
=
0
;
i
<
outLayers
.
size
();
++
i
)
names
[
i
]
=
layersNames
[
outLayers
[
i
]
-
1
];
}
return
names
;
}
samples/dnn/object_detection.py
浏览文件 @
f8398d80
...
@@ -78,14 +78,11 @@ if args.classes:
...
@@ -78,14 +78,11 @@ if args.classes:
net
=
cv
.
dnn
.
readNet
(
args
.
model
,
args
.
config
,
args
.
framework
)
net
=
cv
.
dnn
.
readNet
(
args
.
model
,
args
.
config
,
args
.
framework
)
net
.
setPreferableBackend
(
args
.
backend
)
net
.
setPreferableBackend
(
args
.
backend
)
net
.
setPreferableTarget
(
args
.
target
)
net
.
setPreferableTarget
(
args
.
target
)
outNames
=
net
.
getUnconnectedOutLayersNames
()
confThreshold
=
args
.
thr
confThreshold
=
args
.
thr
nmsThreshold
=
args
.
nms
nmsThreshold
=
args
.
nms
def
getOutputsNames
(
net
):
layersNames
=
net
.
getLayerNames
()
return
[
layersNames
[
i
[
0
]
-
1
]
for
i
in
net
.
getUnconnectedOutLayers
()]
def
postprocess
(
frame
,
outs
):
def
postprocess
(
frame
,
outs
):
frameHeight
=
frame
.
shape
[
0
]
frameHeight
=
frame
.
shape
[
0
]
frameWidth
=
frame
.
shape
[
1
]
frameWidth
=
frame
.
shape
[
1
]
...
@@ -213,7 +210,7 @@ while cv.waitKey(1) < 0:
...
@@ -213,7 +210,7 @@ while cv.waitKey(1) < 0:
if
net
.
getLayer
(
0
).
outputNameToIndex
(
'im_info'
)
!=
-
1
:
# Faster-RCNN or R-FCN
if
net
.
getLayer
(
0
).
outputNameToIndex
(
'im_info'
)
!=
-
1
:
# Faster-RCNN or R-FCN
frame
=
cv
.
resize
(
frame
,
(
inpWidth
,
inpHeight
))
frame
=
cv
.
resize
(
frame
,
(
inpWidth
,
inpHeight
))
net
.
setInput
(
np
.
array
([[
inpHeight
,
inpWidth
,
1.6
]],
dtype
=
np
.
float32
),
'im_info'
)
net
.
setInput
(
np
.
array
([[
inpHeight
,
inpWidth
,
1.6
]],
dtype
=
np
.
float32
),
'im_info'
)
outs
=
net
.
forward
(
getOutputsNames
(
net
)
)
outs
=
net
.
forward
(
outNames
)
postprocess
(
frame
,
outs
)
postprocess
(
frame
,
outs
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录