Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
5edb5662
Commit
5edb5662
authored
Nov 16, 2013
by
Davis King
Browse files
Added the --add option to the imglab tool.
parent
8fc2f436
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
2 deletions
+42
-2
tools/imglab/src/main.cpp
tools/imglab/src/main.cpp
+42
-2
No files found.
tools/imglab/src/main.cpp
View file @
5edb5662
...
...
@@ -16,7 +16,7 @@
#include <dlib/dir_nav.h>
const
char
*
VERSION
=
"0.
6
"
;
const
char
*
VERSION
=
"0.
7
"
;
...
...
@@ -228,6 +228,34 @@ void rename_labels (
// ----------------------------------------------------------------------------------------
void
merge_metadata_files
(
const
command_line_parser
&
parser
)
{
image_dataset_metadata
::
dataset
src
,
dest
;
load_image_dataset_metadata
(
src
,
parser
.
option
(
"add"
).
argument
(
0
));
load_image_dataset_metadata
(
dest
,
parser
.
option
(
"add"
).
argument
(
1
));
std
::
map
<
string
,
image_dataset_metadata
::
image
>
merged_data
;
for
(
unsigned
long
i
=
0
;
i
<
dest
.
images
.
size
();
++
i
)
merged_data
[
dest
.
images
[
i
].
filename
]
=
dest
.
images
[
i
];
// now add in the src data and overwrite anything if there are duplicate entries.
for
(
unsigned
long
i
=
0
;
i
<
src
.
images
.
size
();
++
i
)
merged_data
[
src
.
images
[
i
].
filename
]
=
src
.
images
[
i
];
// copy merged data into dest
dest
.
images
.
clear
();
for
(
std
::
map
<
string
,
image_dataset_metadata
::
image
>::
const_iterator
i
=
merged_data
.
begin
();
i
!=
merged_data
.
end
();
++
i
)
{
dest
.
images
.
push_back
(
i
->
second
);
}
save_image_dataset_metadata
(
dest
,
"merged.xml"
);
}
// ----------------------------------------------------------------------------------------
int
main
(
int
argc
,
char
**
argv
)
{
try
...
...
@@ -257,19 +285,25 @@ int main(int argc, char** argv)
"images with objects labeled <arg> and another file with all the other images. Additionally, the file "
"containing the <arg> labeled objects will not contain any other labels other than <arg>. "
"That is, the images in the first file are stripped of all labels other than the <arg> labels."
,
1
);
parser
.
add_option
(
"add"
,
"Add the image metadata from <arg1> into <arg2>. If any of the image "
"tags are in both files then the ones in <arg2> are deleted and replaced with the "
"image tags from <arg1>. The results are saved into merged.xml and neither <arg1> or "
"<arg2> files are modified."
,
2
);
parser
.
parse
(
argc
,
argv
);
const
char
*
singles
[]
=
{
"h"
,
"c"
,
"r"
,
"l"
,
"convert"
,
"parts"
,
"rmdiff"
,
"seed"
,
"shuffle"
,
"split"
};
const
char
*
singles
[]
=
{
"h"
,
"c"
,
"r"
,
"l"
,
"convert"
,
"parts"
,
"rmdiff"
,
"seed"
,
"shuffle"
,
"split"
,
"add"
};
parser
.
check_one_time_options
(
singles
);
const
char
*
c_sub_ops
[]
=
{
"r"
,
"convert"
};
parser
.
check_sub_options
(
"c"
,
c_sub_ops
);
parser
.
check_sub_option
(
"shuffle"
,
"seed"
);
parser
.
check_incompatible_options
(
"c"
,
"l"
);
parser
.
check_incompatible_options
(
"c"
,
"rmdiff"
);
parser
.
check_incompatible_options
(
"c"
,
"add"
);
parser
.
check_incompatible_options
(
"c"
,
"rename"
);
parser
.
check_incompatible_options
(
"c"
,
"parts"
);
parser
.
check_incompatible_options
(
"l"
,
"rename"
);
parser
.
check_incompatible_options
(
"l"
,
"add"
);
parser
.
check_incompatible_options
(
"l"
,
"parts"
);
parser
.
check_incompatible_options
(
"convert"
,
"l"
);
parser
.
check_incompatible_options
(
"convert"
,
"rename"
);
...
...
@@ -286,6 +320,12 @@ int main(int argc, char** argv)
return
EXIT_SUCCESS
;
}
if
(
parser
.
option
(
"add"
))
{
merge_metadata_files
(
parser
);
return
EXIT_SUCCESS
;
}
if
(
parser
.
option
(
"v"
))
{
cout
<<
"imglab v"
<<
VERSION
...
...
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