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
d8698fc3
Commit
d8698fc3
authored
Aug 01, 2016
by
StevenPuttemans
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow for screen size related resizing
parent
f2e9588c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
0 deletions
+19
-0
opencv_annotation.cpp
apps/annotation/opencv_annotation.cpp
+19
-0
No files found.
apps/annotation/opencv_annotation.cpp
View file @
d8698fc3
...
...
@@ -229,6 +229,8 @@ int main( int argc, const char** argv )
"{ help h usage ? | | show this message }"
"{ images i | | (required) path to image folder [example - /data/testimages/] }"
"{ annotations a | | (required) path to annotations txt file [example - /data/annotations.txt] }"
"{ maxWindowHeight m | -1 | (optional) images larger in height than this value will be scaled down }"
"{ resizeFactor r | 2 | (optional) factor for scaling down [default = half the size] }"
);
// Read in the input arguments
if
(
parser
.
has
(
"help"
)){
...
...
@@ -244,6 +246,9 @@ int main( int argc, const char** argv )
return
-
1
;
}
int
resizeFactor
=
parser
.
get
<
int
>
(
"resizeFactor"
);
int
const
maxWindowHeight
=
parser
.
get
<
int
>
(
"maxWindowHeight"
)
>
0
?
parser
.
get
<
int
>
(
"maxWindowHeight"
)
:
-
1
;
// Check if the folder actually exists
// If -1 is returned then the folder actually exists, and thus you can continue
// In all other cases there was a folder creation and thus the folder did not exist
...
...
@@ -278,6 +283,7 @@ int main( int argc, const char** argv )
for
(
size_t
i
=
0
;
i
<
filenames
.
size
();
i
++
){
// Read in an image
Mat
current_image
=
imread
(
filenames
[
i
]);
bool
const
resize_bool
=
(
maxWindowHeight
>
0
)
&&
(
current_image
.
rows
>
maxWindowHeight
);
// Check if the image is actually read - avoid other files in the folder, because glob() takes them all
// If not then simply skip this iteration
...
...
@@ -285,8 +291,21 @@ int main( int argc, const char** argv )
continue
;
}
if
(
resize_bool
){
resize
(
current_image
,
current_image
,
Size
(
current_image
.
cols
/
resizeFactor
,
current_image
.
rows
/
resizeFactor
));
}
// Perform annotations & store the result inside the vectorized structure
// If the image was resized before, then resize the found annotations back to original dimensions
vector
<
Rect
>
current_annotations
=
get_annotations
(
current_image
);
if
(
resize_bool
){
for
(
int
j
=
0
;
j
<
(
int
)
current_annotations
.
size
();
j
++
){
current_annotations
[
j
].
x
=
current_annotations
[
j
].
x
*
resizeFactor
;
current_annotations
[
j
].
y
=
current_annotations
[
j
].
y
*
resizeFactor
;
current_annotations
[
j
].
width
=
current_annotations
[
j
].
width
*
resizeFactor
;
current_annotations
[
j
].
height
=
current_annotations
[
j
].
height
*
resizeFactor
;
}
}
annotations
.
push_back
(
current_annotations
);
// Check if the ESC key was hit, then exit earlier then expected
...
...
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