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
35d0a45d
Commit
35d0a45d
authored
8 years ago
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7020 from StevenPuttemans:add_scale_option
parents
d67e6f5c
d8698fc3
master
4.3.0
4.2.0
4.1.2
4.1.2-openvino
4.1.1
4.1.1-openvino
4.1.0
4.1.0-openvino
4.0.1
4.0.1-openvino
4.0.0
4.0.0-rc
4.0.0-openvino
4.0.0-beta
4.0.0-alpha
3.4.10
3.4.9
3.4.8
3.4.7
3.4.6
3.4.5
3.4.4
3.4.3
3.4.3-openvino
3.4.2
3.4.2-openvino
3.4.1
3.4.1-cvsdk
3.4.0
3.4.0-rc
3.3.1
3.3.1-cvsdk
3.3.0
3.3.0-rc
3.3.0-cvsdk
3.2.0
3.2.0-rc
No related merge requests found
Show 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 @
35d0a45d
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
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