Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
47e1133e
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,发现更多精彩内容 >>
提交
47e1133e
编写于
10月 11, 2017
作者:
V
Vladislav Sovrasov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
dnn: add crop flag to blobFromImage
上级
1ea1ff19
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
23 addition
and
14 deletion
+23
-14
modules/dnn/include/opencv2/dnn/dnn.hpp
modules/dnn/include/opencv2/dnn/dnn.hpp
+8
-4
modules/dnn/src/dnn.cpp
modules/dnn/src/dnn.cpp
+15
-10
未找到文件。
modules/dnn/include/opencv2/dnn/dnn.hpp
浏览文件 @
47e1133e
...
...
@@ -695,12 +695,14 @@ CV__DNN_EXPERIMENTAL_NS_BEGIN
* @param scalefactor multiplier for @p image values.
* @param swapRB flag which indicates that swap first and last channels
* in 3-channel image is necessary.
* @details input image is resized so one side after resize is equal to corresponing
* @param crop flag which indicates whether image will be cropped after resize or not
* @details if @p crop is true, input image is resized so one side after resize is equal to corresponing
* dimension in @p size and another one is equal or larger. Then, crop from the center is performed.
* If @p crop is false, direct resize without cropping and preserving aspect ratio is performed.
* @returns 4-dimansional Mat with NCHW dimensions order.
*/
CV_EXPORTS_W
Mat
blobFromImage
(
const
Mat
&
image
,
double
scalefactor
=
1.0
,
const
Size
&
size
=
Size
(),
const
Scalar
&
mean
=
Scalar
(),
bool
swapRB
=
true
);
const
Scalar
&
mean
=
Scalar
(),
bool
swapRB
=
true
,
bool
crop
=
true
);
/** @brief Creates 4-dimensional blob from series of images. Optionally resizes and
* crops @p images from center, subtract @p mean values, scales values by @p scalefactor,
* swap Blue and Red channels.
...
...
@@ -711,12 +713,14 @@ CV__DNN_EXPERIMENTAL_NS_BEGIN
* @param scalefactor multiplier for @p images values.
* @param swapRB flag which indicates that swap first and last channels
* in 3-channel image is necessary.
* @details input image is resized so one side after resize is equal to corresponing
* @param crop flag which indicates whether image will be cropped after resize or not
* @details if @p crop is true, input image is resized so one side after resize is equal to corresponing
* dimension in @p size and another one is equal or larger. Then, crop from the center is performed.
* If @p crop is false, direct resize without cropping and preserving aspect ratio is performed.
* @returns 4-dimansional Mat with NCHW dimensions order.
*/
CV_EXPORTS_W
Mat
blobFromImages
(
const
std
::
vector
<
Mat
>&
images
,
double
scalefactor
=
1.0
,
Size
size
=
Size
(),
const
Scalar
&
mean
=
Scalar
(),
bool
swapRB
=
true
);
Size
size
=
Size
(),
const
Scalar
&
mean
=
Scalar
(),
bool
swapRB
=
true
,
bool
crop
=
true
);
/** @brief Convert all weights of Caffe network to half precision floating point.
* @param src Path to origin model from Caffe framework contains single
...
...
modules/dnn/src/dnn.cpp
浏览文件 @
47e1133e
...
...
@@ -85,15 +85,15 @@ static String toString(const T &v)
}
Mat
blobFromImage
(
const
Mat
&
image
,
double
scalefactor
,
const
Size
&
size
,
const
Scalar
&
mean
,
bool
swapRB
)
const
Scalar
&
mean
,
bool
swapRB
,
bool
crop
)
{
CV_TRACE_FUNCTION
();
std
::
vector
<
Mat
>
images
(
1
,
image
);
return
blobFromImages
(
images
,
scalefactor
,
size
,
mean
,
swapRB
);
return
blobFromImages
(
images
,
scalefactor
,
size
,
mean
,
swapRB
,
crop
);
}
Mat
blobFromImages
(
const
std
::
vector
<
Mat
>&
images_
,
double
scalefactor
,
Size
size
,
const
Scalar
&
mean_
,
bool
swapRB
)
const
Scalar
&
mean_
,
bool
swapRB
,
bool
crop
)
{
CV_TRACE_FUNCTION
();
std
::
vector
<
Mat
>
images
=
images_
;
...
...
@@ -104,13 +104,18 @@ Mat blobFromImages(const std::vector<Mat>& images_, double scalefactor, Size siz
size
=
imgSize
;
if
(
size
!=
imgSize
)
{
float
resizeFactor
=
std
::
max
(
size
.
width
/
(
float
)
imgSize
.
width
,
size
.
height
/
(
float
)
imgSize
.
height
);
resize
(
images
[
i
],
images
[
i
],
Size
(),
resizeFactor
,
resizeFactor
);
Rect
crop
(
Point
(
0.5
*
(
images
[
i
].
cols
-
size
.
width
),
0.5
*
(
images
[
i
].
rows
-
size
.
height
)),
size
);
images
[
i
]
=
images
[
i
](
crop
);
if
(
crop
)
{
float
resizeFactor
=
std
::
max
(
size
.
width
/
(
float
)
imgSize
.
width
,
size
.
height
/
(
float
)
imgSize
.
height
);
resize
(
images
[
i
],
images
[
i
],
Size
(),
resizeFactor
,
resizeFactor
);
Rect
crop
(
Point
(
0.5
*
(
images
[
i
].
cols
-
size
.
width
),
0.5
*
(
images
[
i
].
rows
-
size
.
height
)),
size
);
images
[
i
]
=
images
[
i
](
crop
);
}
else
resize
(
images
[
i
],
images
[
i
],
size
);
}
if
(
images
[
i
].
depth
()
==
CV_8U
)
images
[
i
].
convertTo
(
images
[
i
],
CV_32F
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录