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
f4fdd94c
Commit
f4fdd94c
authored
Jan 11, 2017
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7976 from StevenPuttemans:fix_opencv_annotation_tool
parents
65598e40
46fa9a6b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
33 deletions
+15
-33
opencv_annotation.cpp
apps/annotation/opencv_annotation.cpp
+15
-33
No files found.
apps/annotation/opencv_annotation.cpp
View file @
f4fdd94c
...
...
@@ -59,12 +59,7 @@ Adapted by: Puttemans Steven - April 2016 - Vectorize the process to enable bett
#include <fstream>
#include <iostream>
#if defined(_WIN32)
#include <direct.h>
#else
#include <sys/stat.h>
#endif
#include <map>
using
namespace
std
;
using
namespace
cv
;
...
...
@@ -249,34 +244,20 @@ int main( int argc, const char** argv )
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
#if defined(_WIN32)
if
(
_mkdir
(
image_folder
.
c_str
())
!=
-
1
){
// Generate an error message
cerr
<<
"The image folder given does not exist. Please check again!"
<<
endl
;
// Remove the created folder again, to ensure a second run with same code fails again
_rmdir
(
image_folder
.
c_str
());
return
0
;
}
#else
if
(
mkdir
(
image_folder
.
c_str
(),
0777
)
!=
-
1
){
// Generate an error message
cerr
<<
"The image folder given does not exist. Please check again!"
<<
endl
;
// Remove the created folder again, to ensure a second run with same code fails again
remove
(
image_folder
.
c_str
());
return
0
;
}
#endif
// Start by processing the data
// Return the image filenames inside the image folder
vector
<
vector
<
Rect
>
>
annotations
;
map
<
String
,
vector
<
Rect
>
>
annotations
;
vector
<
String
>
filenames
;
String
folder
(
image_folder
);
glob
(
folder
,
filenames
);
// Add key tips on how to use the software when running it
cout
<<
"* mark rectangles with the left mouse button,"
<<
endl
;
cout
<<
"* press 'c' to accept a selection,"
<<
endl
;
cout
<<
"* press 'd' to delete the latest selection,"
<<
endl
;
cout
<<
"* press 'n' to proceed with next image,"
<<
endl
;
cout
<<
"* press 'esc' to stop."
<<
endl
;
// Loop through each image stored in the images folder
// Create and temporarily store the annotations
// At the end write everything to the annotations file
...
...
@@ -306,7 +287,7 @@ int main( int argc, const char** argv )
current_annotations
[
j
].
height
=
current_annotations
[
j
].
height
*
resizeFactor
;
}
}
annotations
.
push_back
(
current_annotations
)
;
annotations
[
filenames
[
i
]]
=
current_annotations
;
// Check if the ESC key was hit, then exit earlier then expected
if
(
stop
){
...
...
@@ -323,10 +304,11 @@ int main( int argc, const char** argv )
}
// Store the annotations, write to the output file
for
(
int
i
=
0
;
i
<
(
int
)
annotations
.
size
();
i
++
){
output
<<
filenames
[
i
]
<<
" "
<<
annotations
[
i
].
size
();
for
(
int
j
=
0
;
j
<
(
int
)
annotations
[
i
].
size
();
j
++
){
Rect
temp
=
annotations
[
i
][
j
];
for
(
map
<
String
,
vector
<
Rect
>
>::
iterator
it
=
annotations
.
begin
();
it
!=
annotations
.
end
();
it
++
){
vector
<
Rect
>
&
anno
=
it
->
second
;
output
<<
it
->
first
<<
" "
<<
anno
.
size
();
for
(
size_t
j
=
0
;
j
<
anno
.
size
();
j
++
){
Rect
temp
=
anno
[
j
];
output
<<
" "
<<
temp
.
x
<<
" "
<<
temp
.
y
<<
" "
<<
temp
.
width
<<
" "
<<
temp
.
height
;
}
output
<<
endl
;
...
...
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