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
5bf39ceb
Commit
5bf39ceb
authored
Oct 27, 2017
by
Vladislav Sovrasov
Committed by
Vadim Pisarevsky
Oct 27, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dnn: handle 4-channel images in blobFromImage (#9944)
parent
e5766513
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
4 deletions
+34
-4
dnn.hpp
modules/dnn/include/opencv2/dnn/dnn.hpp
+2
-2
dnn.cpp
modules/dnn/src/dnn.cpp
+2
-2
test_misc.cpp
modules/dnn/test/test_misc.cpp
+30
-0
No files found.
modules/dnn/include/opencv2/dnn/dnn.hpp
View file @
5bf39ceb
...
...
@@ -688,7 +688,7 @@ CV__DNN_EXPERIMENTAL_NS_BEGIN
CV_EXPORTS_W
Mat
readTorchBlob
(
const
String
&
filename
,
bool
isBinary
=
true
);
/** @brief Creates 4-dimensional blob from image. Optionally resizes and crops @p image from center,
* subtract @p mean values, scales values by @p scalefactor, swap Blue and Red channels.
* @param image input image (with 1-
or 3
-channels).
* @param image input image (with 1-
, 3- or 4
-channels).
* @param size spatial size for output image
* @param mean scalar with mean values which are subtracted from channels. Values are intended
* to be in (mean-R, mean-G, mean-B) order if @p image has BGR ordering and @p swapRB is true.
...
...
@@ -706,7 +706,7 @@ CV__DNN_EXPERIMENTAL_NS_BEGIN
/** @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.
* @param images input images (all with 1-
or 3
-channels).
* @param images input images (all with 1-
, 3- or 4
-channels).
* @param size spatial size for output image
* @param mean scalar with mean values which are subtracted from channels. Values are intended
* to be in (mean-R, mean-G, mean-B) order if @p image has BGR ordering and @p swapRB is true.
...
...
modules/dnn/src/dnn.cpp
View file @
5bf39ceb
...
...
@@ -136,7 +136,7 @@ Mat blobFromImages(const std::vector<Mat>& images_, double scalefactor, Size siz
Mat
blob
,
image
;
if
(
nch
==
3
||
nch
==
4
)
{
int
sz
[]
=
{
(
int
)
nimages
,
3
,
image0
.
rows
,
image0
.
cols
};
int
sz
[]
=
{
(
int
)
nimages
,
nch
,
image0
.
rows
,
image0
.
cols
};
blob
=
Mat
(
4
,
sz
,
CV_32F
);
Mat
ch
[
4
];
...
...
@@ -148,7 +148,7 @@ Mat blobFromImages(const std::vector<Mat>& images_, double scalefactor, Size siz
CV_Assert
(
image
.
dims
==
2
&&
(
nch
==
3
||
nch
==
4
));
CV_Assert
(
image
.
size
()
==
image0
.
size
());
for
(
int
j
=
0
;
j
<
3
;
j
++
)
for
(
int
j
=
0
;
j
<
nch
;
j
++
)
ch
[
j
]
=
Mat
(
image
.
rows
,
image
.
cols
,
CV_32F
,
blob
.
ptr
((
int
)
i
,
j
));
if
(
swapRB
)
std
::
swap
(
ch
[
0
],
ch
[
2
]);
...
...
modules/dnn/test/test_misc.cpp
0 → 100644
View file @
5bf39ceb
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
//
// Copyright (C) 2017, Intel Corporation, all rights reserved.
// Third party copyrights are property of their respective owners.
#include "test_precomp.hpp"
namespace
cvtest
{
TEST
(
blobFromImage_4ch
,
Regression
)
{
Mat
ch
[
4
];
for
(
int
i
=
0
;
i
<
4
;
i
++
)
ch
[
i
]
=
Mat
::
ones
(
10
,
10
,
CV_8U
)
*
i
;
Mat
img
;
merge
(
ch
,
4
,
img
);
Mat
blob
=
dnn
::
blobFromImage
(
img
,
1.
,
Size
(),
Scalar
(),
false
,
false
);
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
ch
[
i
]
=
Mat
(
img
.
rows
,
img
.
cols
,
CV_32F
,
blob
.
ptr
(
0
,
i
));
ASSERT_DOUBLE_EQ
(
cvtest
::
norm
(
ch
[
i
],
cv
::
NORM_INF
),
i
);
}
}
}
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