From 455bffeb72536746338508482fc81928be757bd1 Mon Sep 17 00:00:00 2001 From: hollydinkel Date: Fri, 22 Mar 2024 13:54:09 -0700 Subject: [PATCH] [WIP] testing data processing run sequence --- .../create_cameras_xml.py | 2 +- .../poses_to_file.py | 6 ++-- .../process_sequential_poses.py | 4 +-- process_data.sh | 36 +++++++++++-------- 4 files changed, 27 insertions(+), 21 deletions(-) diff --git a/astrobee_data_processing_scripts/create_cameras_xml.py b/astrobee_data_processing_scripts/create_cameras_xml.py index bc174e4..a62ed4a 100644 --- a/astrobee_data_processing_scripts/create_cameras_xml.py +++ b/astrobee_data_processing_scripts/create_cameras_xml.py @@ -16,7 +16,7 @@ images_dir = f'./data/{args.date}/{args.robot}/bayer/survey{args.survey}' poses_dir = f'./data/{args.date}/{args.robot}/pose/survey{args.survey}' poses = sorted(os.listdir(poses_dir)) -fastcd_data_dir = f'/home/hollydinkel/change_ws/src/fast_change_detection/example/dataset/{args.date}_{args.robot}_survey{args.survey}' +fastcd_data_dir = f'./fast_change_detection/example/dataset/{args.date}_{args.robot}_survey{args.survey}' try: os.mkdir(fastcd_data_dir) except FileExistsError: diff --git a/astrobee_data_processing_scripts/poses_to_file.py b/astrobee_data_processing_scripts/poses_to_file.py index 13ef93f..1313b1f 100644 --- a/astrobee_data_processing_scripts/poses_to_file.py +++ b/astrobee_data_processing_scripts/poses_to_file.py @@ -21,10 +21,10 @@ def main(): args = parser.parse_args() - bag_dir = f"./data/{args.date}/{args.robot}/bags/survey{args.survey}" + bag_dir = f"{args.date}/{args.robot}/bags/survey{args.survey}" - output_dir = f"./data/{args.date}/{args.robot}/bayer/survey{args.survey}" - output_dir_poses = f"./data/{args.date}/{args.robot}/pose/survey{args.survey}" + output_dir = f"{args.date}/{args.robot}/bayer/survey{args.survey}" + output_dir_poses = f"{args.date}/{args.robot}/pose/survey{args.survey}" try: os.mkdir(output_dir) except FileExistsError: print(f"{output_dir} already exists!") diff --git a/astrobee_data_processing_scripts/process_sequential_poses.py b/astrobee_data_processing_scripts/process_sequential_poses.py index c4ac329..e57fd31 100644 --- a/astrobee_data_processing_scripts/process_sequential_poses.py +++ b/astrobee_data_processing_scripts/process_sequential_poses.py @@ -11,8 +11,8 @@ args = parser.parse_args() -img_dir = f"./data/{args.date}/{args.robot}/bayer/survey{args.survey}" -pose_dir = f"./data/{args.date}/{args.robot}/pose/survey{args.survey}" +img_dir = f"{args.date}/{args.robot}/bayer/survey{args.survey}" +pose_dir = f"{args.date}/{args.robot}/pose/survey{args.survey}" pose_list = sorted([int(os.path.splitext(file)[0]) for file in os.listdir(pose_dir)]) img_list = sorted([int(os.path.splitext(file)[0]) for file in os.listdir(img_dir)]) diff --git a/process_data.sh b/process_data.sh index 02e9428..0de6a53 100755 --- a/process_data.sh +++ b/process_data.sh @@ -4,29 +4,35 @@ export CATKIN_WS=$HOME/test_ws/src export ASTROBEE=$HOME/astrobee export ASTROBEE_CHANGE_DETECTION=$CATKIN_WS/astrobee_change_detection export DATA=$ASTROBEE_CHANGE_DETECTION/data +export FASTCD=$ASTROBEE_CHANGE_DETECTION/fast_change_detection export DATE=20230419 export ROBOT=bsharp source $ASTROBEE/devel/setup.bash -mkdir $DATA +# mkdir $DATA -# Install dependencies -apt-get update -apt-get install -y python3-pip -pip install numpy --upgrade -pip install gdown pyquaternion pandas +# # Install dependencies +# apt-get update +# apt-get install -y python3-pip +# pip install numpy --upgrade +# pip install gdown pyquaternion pandas -# Download data -cd $DATA && gdown https://drive.google.com/uc?id=1qNCRl9XceINrHLFUp4pBti9I4oJO2zf1 -unzip data.zip -rm $DATA/data.zip +# # Download data +# cd $DATA && gdown https://drive.google.com/uc?id=1qNCRl9XceINrHLFUp4pBti9I4oJO2zf1 +# unzip data.zip +# cp data/ ../ +# rm -rf data/ +# rm $DATA/data.zip -for SURVEY_NUMBER in 1 2 3 4 +for SURVEY_NUMBER in 2 3 4 do export SURVEY=$SURVEY_NUMBER cd $DATA && python3 $ASTROBEE_CHANGE_DETECTION/astrobee_data_processing_scripts/poses_to_file.py $SURVEY $DATE $ROBOT - rosrun sparse_mapping process_sequential_images.py $DATA/$DATE/$ROBOT/bayer/survey$SURVEY $ASTROBEE/src/astrobee/config - cd $DATA && python3 $ASTROBEE_CHANGE_DETECTION/astrobee_data_processing_scripts/process_sequential_poses.py $SURVEY $DATE $ROBOT - cd $DATA/$DATE/$ROBOT/bayer/survey$SURVEY - ls -v | nl -v 0 | while read n f; do mv -n "$f" "Image$n.JPG"; done + rosrun sparse_mapping process_sequential_images.py $DATA/$DATE/$ROBOT/bayer/survey$SURVEY $ASTROBEE/src/astrobee + mv $DATA/$DATE/$ROBOT/bayer/survey$SURVEY/0/* $DATA/$DATE/$ROBOT/bayer/survey$SURVEY/ + rm -rf $DATA/$DATE/$ROBOT/bayer/survey$SURVEY/0 $DATA/$DATE/$ROBOT/bayer/survey$SURVEY/invalid $DATA/$DATE/$ROBOT/bayer/survey$SURVEY/rotation + cd $DATA && python3 $ASTROBEE_CHANGE_DETECTION/astrobee_data_processing_scripts/process_sequential_poses.py $SURVEY $DATE $ROBOT && rm *.txt + cd $DATA/$DATE/$ROBOT/bayer/survey$SURVEY && ls -v | nl -v 0 | while read n f; do mv -n "$f" "Image$n.JPG"; done + cp -r $DATA/$DATE/$ROBOT/bayer/survey$SURVEY $FASTCD/ + cd $ASTROBEE_CHANGE_DETECTION && python3 astrobee_data_processing_scripts/create_cameras_xml.py $SURVEY $DATE $ROBOT done \ No newline at end of file