Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenCV
opencv
提交
b796eded
O
opencv
项目概览
OpenCV
/
opencv
上一次同步 7 个月
通知
979
Star
71099
Fork
55580
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
opencv
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
b796eded
编写于
1月 21, 2022
作者:
A
Alexander Alekhin
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #21437 from alalek:dnn_api_explicit_const_4.x
上级
22f0bcaf
eb7b45d2
变更
6
展开全部
隐藏空白更改
内联
并排
Showing
6 changed file
with
126 addition
and
98 deletion
+126
-98
modules/dnn/include/opencv2/dnn/dict.hpp
modules/dnn/include/opencv2/dnn/dict.hpp
+7
-7
modules/dnn/include/opencv2/dnn/dnn.hpp
modules/dnn/include/opencv2/dnn/dnn.hpp
+23
-10
modules/dnn/misc/objc/gen_dict.json
modules/dnn/misc/objc/gen_dict.json
+5
-1
modules/dnn/src/dnn.cpp
modules/dnn/src/dnn.cpp
+88
-77
modules/dnn/src/dnn_common.hpp
modules/dnn/src/dnn_common.hpp
+2
-2
modules/dnn/src/layers/recurrent_layers.cpp
modules/dnn/src/layers/recurrent_layers.cpp
+1
-1
未找到文件。
modules/dnn/include/opencv2/dnn/dict.hpp
浏览文件 @
b796eded
...
...
@@ -60,13 +60,13 @@ CV__DNN_INLINE_NS_BEGIN
struct
CV_EXPORTS_W
DictValue
{
DictValue
(
const
DictValue
&
r
);
DictValue
(
bool
i
)
:
type
(
Param
::
INT
),
pi
(
new
AutoBuffer
<
int64
,
1
>
)
{
(
*
pi
)[
0
]
=
i
?
1
:
0
;
}
//!< Constructs integer scalar
DictValue
(
int64
i
=
0
)
:
type
(
Param
::
INT
),
pi
(
new
AutoBuffer
<
int64
,
1
>
)
{
(
*
pi
)[
0
]
=
i
;
}
//!< Constructs integer scalar
CV_WRAP
DictValue
(
int
i
)
:
type
(
Param
::
INT
),
pi
(
new
AutoBuffer
<
int64
,
1
>
)
{
(
*
pi
)[
0
]
=
i
;
}
//!< Constructs integer scalar
DictValue
(
unsigned
p
)
:
type
(
Param
::
INT
),
pi
(
new
AutoBuffer
<
int64
,
1
>
)
{
(
*
pi
)[
0
]
=
p
;
}
//!< Constructs integer scalar
CV_WRAP
DictValue
(
double
p
)
:
type
(
Param
::
REAL
),
pd
(
new
AutoBuffer
<
double
,
1
>
)
{
(
*
pd
)[
0
]
=
p
;
}
//!< Constructs floating point scalar
CV_WRAP
DictValue
(
const
String
&
s
)
:
type
(
Param
::
STRING
),
ps
(
new
AutoBuffer
<
String
,
1
>
)
{
(
*
ps
)[
0
]
=
s
;
}
//!< Constructs string scalar
DictValue
(
const
char
*
s
)
:
type
(
Param
::
STRING
),
ps
(
new
AutoBuffer
<
String
,
1
>
)
{
(
*
ps
)[
0
]
=
s
;
}
//!< @overload
explicit
DictValue
(
bool
i
)
:
type
(
Param
::
INT
),
pi
(
new
AutoBuffer
<
int64
,
1
>
)
{
(
*
pi
)[
0
]
=
i
?
1
:
0
;
}
//!< Constructs integer scalar
explicit
DictValue
(
int64
i
=
0
)
:
type
(
Param
::
INT
),
pi
(
new
AutoBuffer
<
int64
,
1
>
)
{
(
*
pi
)[
0
]
=
i
;
}
//!< Constructs integer scalar
CV_WRAP
explicit
DictValue
(
int
i
)
:
type
(
Param
::
INT
),
pi
(
new
AutoBuffer
<
int64
,
1
>
)
{
(
*
pi
)[
0
]
=
i
;
}
//!< Constructs integer scalar
explicit
DictValue
(
unsigned
p
)
:
type
(
Param
::
INT
),
pi
(
new
AutoBuffer
<
int64
,
1
>
)
{
(
*
pi
)[
0
]
=
p
;
}
//!< Constructs integer scalar
CV_WRAP
explicit
DictValue
(
double
p
)
:
type
(
Param
::
REAL
),
pd
(
new
AutoBuffer
<
double
,
1
>
)
{
(
*
pd
)[
0
]
=
p
;
}
//!< Constructs floating point scalar
CV_WRAP
explicit
DictValue
(
const
String
&
s
)
:
type
(
Param
::
STRING
),
ps
(
new
AutoBuffer
<
String
,
1
>
)
{
(
*
ps
)[
0
]
=
s
;
}
//!< Constructs string scalar
explicit
DictValue
(
const
char
*
s
)
:
type
(
Param
::
STRING
),
ps
(
new
AutoBuffer
<
String
,
1
>
)
{
(
*
ps
)[
0
]
=
s
;
}
//!< @overload
template
<
typename
TypeIter
>
static
DictValue
arrayInt
(
TypeIter
begin
,
int
size
);
//!< Constructs integer array
...
...
modules/dnn/include/opencv2/dnn/dnn.hpp
浏览文件 @
b796eded
...
...
@@ -134,7 +134,7 @@ CV__DNN_INLINE_NS_BEGIN
class
BackendNode
{
public:
BackendNode
(
int
backendId
);
explicit
BackendNode
(
int
backendId
);
virtual
~
BackendNode
();
//!< Virtual destructor to make polymorphism.
...
...
@@ -277,18 +277,18 @@ CV__DNN_INLINE_NS_BEGIN
* Each layer input and output can be labeled to easily identify them using "%<layer_name%>[.output_name]" notation.
* This method maps label of input blob to its index into input vector.
*/
virtual
int
inputNameToIndex
(
String
inputName
);
virtual
int
inputNameToIndex
(
String
inputName
);
// FIXIT const
/** @brief Returns index of output blob in output array.
* @see inputNameToIndex()
*/
CV_WRAP
virtual
int
outputNameToIndex
(
const
String
&
outputName
);
CV_WRAP
virtual
int
outputNameToIndex
(
const
String
&
outputName
);
// FIXIT const
/**
* @brief Ask layer if it support specific backend for doing computations.
* @param[in] backendId computation backend identifier.
* @see Backend
*/
virtual
bool
supportBackend
(
int
backendId
);
virtual
bool
supportBackend
(
int
backendId
);
// FIXIT const
/**
* @brief Returns Halide backend node.
...
...
@@ -495,18 +495,29 @@ CV__DNN_INLINE_NS_BEGIN
/** @brief Converts string name of the layer to the integer identifier.
* @returns id of the layer, or -1 if the layer wasn't found.
*/
CV_WRAP
int
getLayerId
(
const
String
&
layer
);
CV_WRAP
int
getLayerId
(
const
String
&
layer
)
const
;
CV_WRAP
std
::
vector
<
String
>
getLayerNames
()
const
;
/** @brief Container for strings and integers. */
/** @brief Container for strings and integers.
*
* @deprecated Use getLayerId() with int result.
*/
typedef
DictValue
LayerId
;
/** @brief Returns pointer to layer with specified id or name which the network use. */
CV_WRAP
Ptr
<
Layer
>
getLayer
(
LayerId
layerId
);
CV_WRAP
Ptr
<
Layer
>
getLayer
(
int
layerId
)
const
;
/** @overload
* @deprecated Use int getLayerId(const String &layer)
*/
CV_WRAP
inline
Ptr
<
Layer
>
getLayer
(
const
String
&
layerName
)
const
{
return
getLayer
(
getLayerId
(
layerName
));
}
/** @overload
* @deprecated to be removed
*/
CV_WRAP
Ptr
<
Layer
>
getLayer
(
const
LayerId
&
layerId
)
const
;
/** @brief Returns pointers to input layers of specific layer. */
std
::
vector
<
Ptr
<
Layer
>
>
getLayerInputs
(
LayerId
layerId
)
;
// FIXIT: CV_WRAP
std
::
vector
<
Ptr
<
Layer
>
>
getLayerInputs
(
int
layerId
)
const
;
// FIXIT: CV_WRAP
/** @brief Connects output of the first layer to input of the second layer.
* @param outPin descriptor of the first layer output.
...
...
@@ -662,14 +673,16 @@ CV__DNN_INLINE_NS_BEGIN
* @note If shape of the new blob differs from the previous shape,
* then the following forward pass may fail.
*/
CV_WRAP
void
setParam
(
LayerId
layer
,
int
numParam
,
const
Mat
&
blob
);
CV_WRAP
void
setParam
(
int
layer
,
int
numParam
,
const
Mat
&
blob
);
CV_WRAP
inline
void
setParam
(
const
String
&
layerName
,
int
numParam
,
const
Mat
&
blob
)
{
return
setParam
(
getLayerId
(
layerName
),
numParam
,
blob
);
}
/** @brief Returns parameter blob of the layer.
* @param layer name or id of the layer.
* @param numParam index of the layer parameter in the Layer::blobs array.
* @see Layer::blobs
*/
CV_WRAP
Mat
getParam
(
LayerId
layer
,
int
numParam
=
0
);
CV_WRAP
Mat
getParam
(
int
layer
,
int
numParam
=
0
)
const
;
CV_WRAP
inline
Mat
getParam
(
const
String
&
layerName
,
int
numParam
=
0
)
const
{
return
getParam
(
getLayerId
(
layerName
),
numParam
);
}
/** @brief Returns indexes of layers with unconnected outputs.
*/
...
...
modules/dnn/misc/objc/gen_dict.json
浏览文件 @
b796eded
...
...
@@ -18,8 +18,12 @@
"(long)getFLOPS:(NSArray<IntVector*>*)netInputShapes"
:
{
"getFLOPS"
:
{
"name"
:
"getFLOPSWithNetInputShapes"
}
},
"(long)getFLOPS:(int)layerId netInputShape:(IntVector*)netInputShape"
:
{
"getFLOPS"
:
{
"name"
:
"getFLOPSWithLayerId"
}
},
"(long)getFLOPS:(int)layerId netInputShapes:(NSArray<IntVector*>*)netInputShapes"
:
{
"getFLOPS"
:
{
"name"
:
"getFLOPSWithLayerId"
}
},
"(Layer*)getLayer:(NSString*)layerName"
:
{
"getLayer"
:
{
"name"
:
"getLayerByName"
}
},
"(Layer*)getLayer:(DictValue*)layerId"
:
{
"getLayer"
:
{
"name"
:
"getLayerByDictValue"
}
},
"(void)getLayersShapes:(IntVector*)netInputShape layersIds:(IntVector*)layersIds inLayersShapes:(NSMutableArray<NSMutableArray<IntVector*>*>*)inLayersShapes outLayersShapes:(NSMutableArray<NSMutableArray<IntVector*>*>*)outLayersShapes"
:
{
"getLayersShapes"
:
{
"name"
:
"getLayersShapesWithNetInputShape"
}
},
"(void)getLayersShapes:(NSArray<IntVector*>*)netInputShapes layersIds:(IntVector*)layersIds inLayersShapes:(NSMutableArray<NSMutableArray<IntVector*>*>*)inLayersShapes outLayersShapes:(NSMutableArray<NSMutableArray<IntVector*>*>*)outLayersShapes"
:
{
"getLayersShapes"
:
{
"name"
:
"getLayersShapesWithNetInputShapes"
}
}
"(void)getLayersShapes:(NSArray<IntVector*>*)netInputShapes layersIds:(IntVector*)layersIds inLayersShapes:(NSMutableArray<NSMutableArray<IntVector*>*>*)inLayersShapes outLayersShapes:(NSMutableArray<NSMutableArray<IntVector*>*>*)outLayersShapes"
:
{
"getLayersShapes"
:
{
"name"
:
"getLayersShapesWithNetInputShapes"
}
},
"(Mat*)getParam:(NSString*)layerName numParam:(int)numParam"
:
{
"getParam"
:
{
"name"
:
"getParamByName"
}
},
"(void)setParam:(NSString*)layerName numParam:(int)numParam blob:(Mat*)blob"
:
{
"setParam"
:
{
"name"
:
"setParamByName"
}
}
}
},
"type_dict"
:
{
...
...
modules/dnn/src/dnn.cpp
浏览文件 @
b796eded
此差异已折叠。
点击以展开。
modules/dnn/src/dnn_common.hpp
浏览文件 @
b796eded
...
...
@@ -71,12 +71,12 @@ private:
struct
NetImplBase
{
const
int
networkId
;
// network global identifier
int
networkDumpCounter
;
// dump counter
mutable
int
networkDumpCounter
;
// dump counter
int
dumpLevel
;
// level of information dumps (initialized through OPENCV_DNN_NETWORK_DUMP parameter)
NetImplBase
();
std
::
string
getDumpFileNameBase
();
std
::
string
getDumpFileNameBase
()
const
;
};
}
// namespace detail
...
...
modules/dnn/src/layers/recurrent_layers.cpp
浏览文件 @
b796eded
...
...
@@ -184,7 +184,7 @@ public:
CV_Assert
(
!
reverse
||
!
bidirectional
);
// read activations
DictValue
activations
=
params
.
get
<
DictValue
>
(
"activations"
,
""
);
DictValue
activations
=
params
.
get
<
DictValue
>
(
"activations"
,
DictValue
(
String
())
);
if
(
activations
.
size
()
==
1
)
// if activations wasn't specified use default
{
f_activation
=
sigmoid
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录