aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--utils/processTobiiRecords.sh95
1 files changed, 42 insertions, 53 deletions
diff --git a/utils/processTobiiRecords.sh b/utils/processTobiiRecords.sh
index bbe6c86..ebbded6 100644
--- a/utils/processTobiiRecords.sh
+++ b/utils/processTobiiRecords.sh
@@ -6,8 +6,9 @@
# - context "segment" field is modified to bind on it,
# - context "pipeline" field is modified to bind on a temporary patched pipeline \
# resulting from the merging of the given pipeline and an optionnal "patch.json" file in Tobii record segment,
+# - pipeline "projection_cache" field is added to create or bind a "layers_projection.csv" file in segment folder,
# - then, ArGaze executes the modified context from output folder ($3) to export all records into it,
-# - finally, context is resetted and temporary patched pipeline is removed.
+# - finally, context and pipeline files are resetted and temporary patched pipeline is removed.
#
# Arguments:
# $1: ArGaze context file
@@ -33,32 +34,7 @@ else
brew install jq
fi
-# Check context
ctx_folder="$(dirname "$context_file")"
-ctx_class=$(jq "keys[0]" $context_file)
-ctx_name=$(jq .$ctx_class.name $context_file)
-ctx_segment=$(jq .$ctx_class.segment $context_file)
-pipeline_file=$(jq -r .$ctx_class.pipeline $context_file)
-
-echo "*** Loading $ctx_class context:"
-echo "- Name: $ctx_name"
-
-# Move to context folder
-cd $ctx_folder
-
-# Check pipeline
-if [ -f "$pipeline_file" ]; then
-
- ppl_class=$(jq "keys[0]" $pipeline_file)
- ppl_name=$(jq .$ppl_class.name $pipeline_file)
- echo "- Pipeline: $ppl_name"
-
-else
-
- echo "!!! Missing $pipeline_file pipeline file"
- exit 1
-
-fi
#######################################
# Process Tobii segment folder
@@ -78,27 +54,49 @@ function process_segment() {
echo " - Lenght: $seg_length"
echo " - Calibration: $ca_state"
+ # Move to context folder
+ cd $ctx_folder
+
+ # Create temporary context file
+ temp_context_file=".$rec_id-$seg_id.context.json"
+ yes | cp -f $context_file $temp_context_file
+ ctx_class=$(jq "keys[0]" $temp_context_file)
+ ctx_name=$(jq .$ctx_class.name $temp_context_file)
+ ctx_pipeline=$(jq -r .$ctx_class.pipeline $temp_context_file)
+
+ echo "- Context $(basename $temp_context_file):"
+ echo " - Name: $ctx_name"
+
+ # Create temporary pipeline file
+ temp_pipeline_file=".$rec_id-$seg_id.pipeline.json"
+ yes | cp -f $ctx_pipeline $temp_pipeline_file
+ ppl_class=$(jq "keys[0]" $temp_pipeline_file)
+ ppl_name=$(jq .$ppl_class.name $temp_pipeline_file)
+
+ echo "- Pipeline: $(basename $temp_pipeline_file)"
+ echo " - Name: $ppl_name"
+
+ # Modify temporary context segment
+ echo "$(jq --tab ".$ctx_class.segment = \"$seg_folder\"" $temp_context_file)" > "$ctx_folder/$temp_context_file"
+
+ # Modify temporary context pipeline
+ echo "$(jq --tab ".$ctx_class.pipeline = \"$temp_pipeline_file\"" $temp_context_file)" > "$ctx_folder/$temp_context_file"
+
+ # Modify temporary pipeline projection_cache
+ echo "$(jq --tab ".$ppl_class.projection_cache = \"$seg_folder/layers_projection.csv\"" $temp_pipeline_file)" > "$ctx_folder/$temp_pipeline_file"
+
# Check patch
patch_file="$seg_folder/patch.json"
if [ -f "$patch_file" ]; then
- echo "+ Patch:"
+ echo " + Patch:"
echo "$(jq . $patch_file)"
- # Edit temporary patched pipeline
- temp_file=".$rec_id-$seg_id.patch.json"
- echo "$(jq --tab -s ".[0] * .[1]" $pipeline_file $patch_file)" > "$ctx_folder/$temp_file"
-
- # Modify context pipeline
- echo "$(jq --tab ".$ctx_class.pipeline = \"$temp_file\"" $context_file)" > $context_file
-
- echo "*** $ctx_folder/$temp_file file created"
+ # Merge patch with temporary pipeline
+ echo "$(jq --tab -s ".[0] * .[1]" $temp_pipeline_file $patch_file)" > "$ctx_folder/$temp_pipeline_file"
fi
- # Modify context segment
- echo "$(jq --tab ".$ctx_class.segment = \"$seg_folder\"" $context_file)" > $context_file
-
- # Create segment output folder then, move into
+ # Create segment output folder
seg_output=$output_folder/$rec_id/segments/$seg_id
mkdir -p $seg_output
cd $seg_output
@@ -106,27 +104,18 @@ function process_segment() {
# Launch modified context with argaze load command
echo "*** ArGaze starts context"
- python -m argaze load $context_file
+ python -m argaze load "$ctx_folder/$temp_context_file"
echo "*** ArGaze ends context"
# Move back to context folder
cd $ctx_folder
- # Reset context segment
- echo "$(jq --tab ".$ctx_class.segment = $ctx_segment" $context_file)" > $context_file
-
- # Check temporary pipeline
- if [ -f "$temp_file" ]; then
+ # Delete temporary context file
+ rm "$ctx_folder/$temp_context_file"
- # Delete temporary patched pipeline
- rm "$ctx_folder/$temp_file"
-
- # Reset context pipeline
- echo "$(jq --tab ".$ctx_class.pipeline = \"$pipeline_file\"" $context_file)" > $context_file
-
- echo "*** $ctx_folder/$temp_file file removed"
- fi
+ # Delete temporary pipeline file
+ rm "$ctx_folder/$temp_pipeline_file"
}
#######################################