Commit 7c828d08 authored by Davis King's avatar Davis King

Added some scripts that help with imglab XML file management.

parent f77ca0c7
...@@ -36,4 +36,5 @@ TARGET_LINK_LIBRARIES(${target_name} dlib ) ...@@ -36,4 +36,5 @@ TARGET_LINK_LIBRARIES(${target_name} dlib )
INSTALL(TARGETS ${target_name} INSTALL(TARGETS ${target_name}
RUNTIME DESTINATION bin RUNTIME DESTINATION bin
) )
INSTALL(PROGRAMS convert_imglab_paths_to_relative copy_imglab_dataset DESTINATION bin )
#!/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
}
}
#!/bin/bash
if [ "$#" -ne 2 ]; then
echo "This script copies an imglab XML file and its associated images to a new folder."
echo "Notably, it will avoid copying unnecessary images."
echo "Call this script like this:"
echo " ./copy_dataset some_file.xml dest_dir"
exit 1
fi
XML_FILE=$1
DEST=$2
if [ -d "$DEST" ]; then
echo "Error, $DEST directory already exists"
exit 1
fi
FILES=`imglab --files cluster_001.xml.RESAMPLED.xml | xargs perl -e 'use File::Spec; foreach (@ARGV) {print File::Spec->abs2rel($_) . "\n"}' | sort | uniq`
mkdir $DEST
cp -a --parents $FILES $DEST
convert_imglab_paths_to_relative $XML_FILE > $DEST/$(basename $XML_FILE)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment