summaryrefslogtreecommitdiffstats
path: root/ml/dlib/tools/imglab/convert_imglab_paths_to_relative
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-03-09 13:19:22 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-03-09 13:19:22 +0000
commitc21c3b0befeb46a51b6bf3758ffa30813bea0ff0 (patch)
tree9754ff1ca740f6346cf8483ec915d4054bc5da2d /ml/dlib/tools/imglab/convert_imglab_paths_to_relative
parentAdding upstream version 1.43.2. (diff)
downloadnetdata-c21c3b0befeb46a51b6bf3758ffa30813bea0ff0.tar.xz
netdata-c21c3b0befeb46a51b6bf3758ffa30813bea0ff0.zip
Adding upstream version 1.44.3.upstream/1.44.3
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ml/dlib/tools/imglab/convert_imglab_paths_to_relative')
-rwxr-xr-xml/dlib/tools/imglab/convert_imglab_paths_to_relative24
1 files changed, 24 insertions, 0 deletions
diff --git a/ml/dlib/tools/imglab/convert_imglab_paths_to_relative b/ml/dlib/tools/imglab/convert_imglab_paths_to_relative
new file mode 100755
index 000000000..09c5ef7a5
--- /dev/null
+++ b/ml/dlib/tools/imglab/convert_imglab_paths_to_relative
@@ -0,0 +1,24 @@
+#!/usr/bin/perl
+
+use File::Spec;
+
+die "This script converts all the file names in an imglab XML file to have paths relative to the current folder. Call it like this: ./convert_imglab_paths_to_relative some_file.xml" if @ARGV != 1;
+
+$file = @ARGV[0];
+open(INFO, $file) or die('Could not open file.');
+
+foreach $line (<INFO>)
+{
+ if (index($line, 'file=\'') != -1)
+ {
+ $line =~ /file='(.*)'/;
+ $relpath = File::Spec->abs2rel($1);
+ $line =~ s/$1/$relpath/;
+ print $line
+ }
+ else
+ {
+ print $line
+ }
+}
+