Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv_contrib
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_contrib
Commits
ceb68526
Commit
ceb68526
authored
Oct 24, 2019
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
parents
f6a6e1fd
8fde8d74
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
12 deletions
+47
-12
.travis.yml
.travis.yml
+1
-1
pd_inria.cpp
modules/datasets/samples/pd_inria.cpp
+46
-11
No files found.
.travis.yml
View file @
ceb68526
...
...
@@ -4,7 +4,7 @@ compiler:
-
clang
before_script
:
-
cd ../
-
git clone --depth=1 https://github.com/opencv/opencv.git
-
git clone --
branch master --
depth=1 https://github.com/opencv/opencv.git
-
mkdir build-opencv
-
cd build-opencv
-
cmake
...
...
modules/datasets/samples/pd_inria.cpp
View file @
ceb68526
...
...
@@ -10,11 +10,20 @@ using namespace cv::datasets;
int
main
(
int
argc
,
char
*
argv
[])
{
const
char
*
keys
=
"{ help h usage ? | | show this message }"
"{ path p |true| path to dataset }"
;
"{ help h usage ? | | show this message }"
"{ path p |true | path to dataset }"
"{ save s |false| save resized positive images }"
"{ rwidth rw |64 | width of resized positive images }"
"{ rheight rh |128 | height of resized positive images }"
"{ padding |8 | vertical padding of resized positive images }"
;
CommandLineParser
parser
(
argc
,
argv
,
keys
);
bool
savebbox
=
parser
.
get
<
bool
>
(
"save"
);
int
rwidth
=
parser
.
get
<
int
>
(
"rwidth"
);
int
rheight
=
parser
.
get
<
int
>
(
"rheight"
);
int
padding
=
parser
.
get
<
int
>
(
"padding"
);
string
path
(
parser
.
get
<
string
>
(
"path"
));
if
(
parser
.
has
(
"help"
)
||
path
==
"true"
)
{
parser
.
printMessage
();
...
...
@@ -29,6 +38,8 @@ int main(int argc, char *argv[])
cout
<<
"train size: "
<<
train_size
<<
endl
;
cout
<<
"test size: "
<<
test_size
<<
endl
;
int
bbox_count
=
0
;
for
(
size_t
i
=
0
;
i
<
train_size
;
i
++
)
{
PD_inriaObj
*
example
=
static_cast
<
PD_inriaObj
*>
(
dataset
->
getTrain
()[
i
].
get
());
...
...
@@ -46,18 +57,42 @@ int main(int argc, char *argv[])
// bounding boxes
for
(
size_t
j
=
0
;
j
<
example
->
bndboxes
.
size
();
j
++
)
{
cout
<<
"object "
<<
j
<<
endl
;
int
x
=
example
->
bndboxes
[
j
].
x
;
int
y
=
example
->
bndboxes
[
j
].
y
;
cout
<<
" - xmin = "
<<
x
<<
endl
;
cout
<<
" - ymin = "
<<
y
<<
endl
;
cout
<<
" - xmax = "
<<
example
->
bndboxes
[
j
].
width
+
x
<<
endl
;
cout
<<
" - ymax = "
<<
example
->
bndboxes
[
j
].
height
+
y
<<
endl
;
rectangle
(
img
,
example
->
bndboxes
[
j
],
Scalar
(
0
,
0
,
255
),
2
);
Rect
obj_bndbox
=
example
->
bndboxes
[
j
];
// bounding box of object
cout
<<
" - bounding box: "
<<
j
<<
" - "
<<
obj_bndbox
<<
endl
;
int
vpadding
,
hpadding
;
Rect
ex_bndbox
;
// variable used for calculating expanded bounding box
vpadding
=
cvRound
(
padding
*
obj_bndbox
.
height
/
rheight
);
// calculate vertical padding
ex_bndbox
.
y
=
obj_bndbox
.
y
-
vpadding
;
ex_bndbox
.
height
=
2
*
vpadding
+
obj_bndbox
.
height
;
ex_bndbox
.
x
=
obj_bndbox
.
x
+
(
obj_bndbox
.
width
/
2
);
ex_bndbox
.
width
=
ex_bndbox
.
height
*
rwidth
/
rheight
;
ex_bndbox
.
x
-=
(
ex_bndbox
.
width
+
1
)
/
2
;
if
(
obj_bndbox
.
width
>
ex_bndbox
.
width
)
{
obj_bndbox
.
x
+=
(
obj_bndbox
.
width
-
ex_bndbox
.
width
+
1
)
/
2
;
obj_bndbox
.
width
=
ex_bndbox
.
width
;
}
hpadding
=
obj_bndbox
.
x
-
ex_bndbox
.
x
;
// calculate horizontal padding
if
(
savebbox
)
{
Mat
dst
;
copyMakeBorder
(
img
(
obj_bndbox
),
dst
,
vpadding
,
vpadding
,
hpadding
,
hpadding
,
BORDER_REFLECT
);
resize
(
dst
,
dst
,
Size
(
rwidth
,
rheight
),
0
,
0
,
INTER_AREA
);
imwrite
(
path
+
format
(
"person_%04d.png"
,
bbox_count
++
),
dst
);
}
else
rectangle
(
img
,
obj_bndbox
,
Scalar
(
0
,
0
,
255
),
2
);
}
imshow
(
"INRIAPerson Dataset Train Images"
,
img
);
if
(
savebbox
)
continue
;
// skip UI updates
imshow
(
"INRIAPerson Dataset Train Images"
,
img
);
cout
<<
"
\n
Press a key to continue or ESC to exit."
<<
endl
;
int
key
=
waitKey
();
if
(
key
==
27
)
break
;
...
...
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