Skip to content
Snippets Groups Projects
Commit 19600d42 authored by Cribellier, Antoine's avatar Cribellier, Antoine
Browse files

Update example files

parent 68bcd5ae
No related branches found
No related tags found
No related merge requests found
......@@ -29,6 +29,8 @@ img_process.update_leading_zero = False
img_process.init_paths_names()
img_process.max_diff_date_s = 90
img_process.show_plot = False
# # Fill dict with name of recordings to process
# # > either all recordings from a given date
# date_to_process = '20200303'
......@@ -36,25 +38,77 @@ img_process.max_diff_date_s = 90
# for camn in range(1, img_process.nb_cam + 1):
# rec_names_to_process[camn] = [s for s in img_process.all_folders_rec_cam[camn] if date_to_process in s]
# > all recordings
rec_names_to_process = {}
for camn in range(1, img_process.nb_cam + 1):
rec_names_to_process[camn] = img_process.all_folders_rec_cam[camn]
img_process.show_plot = False
# Convert image to 8 bits and reduce framerate (save in cam_save_paths/_Sample)
img_process.do_batch('sample', rec_names=rec_names_to_process, step_frame=10, delete_previous=True)
#img_process.do_batch('save_avi', from_fn_name='sample', delete_previous=True)
# # Keep only rec_names that haven't been processed yet
# non_processed_rec_names = {1: [], 2: [], 3: []}
# for camn in range(1, img_process.nb_cam + 1):
# for i, rec_name in enumerate(rec_names_to_process[camn]):
# if not os.path.exists(os.path.join(img_process.cam_save_paths[camn], '_Avi', rec_name)):
# non_processed_rec_names[camn].append(rec_names_to_process[camn][i])
#
# rec_names_to_process = non_processed_rec_names
# Enhance images (increase sharpness and contrast)
# img_process.do_batch('autocontrast', rec_names=rec_names_to_process, from_fn_name='sample', delete_previous=True)
# Do 2d tracking (blob detection) on images in cam_save_paths/_Sample
# img_process.do_batch('track2d', rec_names=rec_names_to_process, from_fn_name='autocontrast')
# -----------------------------------------------------------------------------------------------------------------------
# Will prepare recordings to be used by Deeplabcut
# > do everything automatically use 'multi_processes'
# Do cropping, rotating, stitching, etc at once and save as .avi (save much time and space)
# img_process.do_batch('multi_processes', rec_names=rec_names_to_process, yaml_path='processes.yaml', delete_previous=True)
print('> All processes as been processed (total time elapsed: {0:.4f} s)'.format(time.time() - start))
img_process.do_batch('multi_processes', rec_names=rec_names_to_process, yaml_path='processes.yaml', delete_previous=True)
# > OR do each step separately
# Convert image to 8 bits and reduce framerate (save in cam_save_paths/_Sample)
# img_process.do_batch('sample', rec_names=rec_names_to_process, step_frame=50, delete_previous=True)
#
# # Do 2d tracking (blob detection) on images in cam_save_paths/_Sample
# img_process.do_batch('track2d', rec_names=rec_names_to_process, from_fn_name='sample')
#
# # Do 3d reconstruction of tracks
# img_process.do_batch('recon3d', rec_names=rec_names_to_process, from_fn_name='sample')
#
# # Crop all frames and save in cam_save_paths/_Cropped
# img_process.do_batch('crop', rec_names=rec_names_to_process, from_fn_name='sample', height_crop=200, width_crop=200, delete_previous=True)
#
# # Rotate view 2 (to always have piston coming from right side)
# img_process.do_batch('rotate', rec_names=rec_names_to_process, from_fn_name='crop', camns=[2], degrees=270)
#
# # Stitch all views together and save in cam_save_paths/_Stitched
# img_process.do_batch('stitch', rec_names=rec_names_to_process, from_fn_name='crop', delete_previous=True)
# -----------------------------------------------------------------------------------------------------------------------
# Run Deeplabcut analysis + Fit 3D skeleton to 2D coordinate from Deeplabcut
dlc_cfg_path = '/home/user/Desktop/Antoine/_maDLC/config.yaml'
shuffle = 31
iteration = 70000
model_name = 'DLC_resnet50_MatingKinematicsshuffle{0}_{1}'.format(shuffle, iteration)
res_method = '3d' # '2d', '3d' or '2d_geo'
opt_method = 'leastsq' # 'powell' or 'leastsq' or 'least_squares'
body_param_names = ['yaw_a', 'pitch_a', 'roll_a', 'x_com', 'y_com', 'z_com']
wing_param_names = ['stroke_a', 'deviation_a', 'rotation_a']
# # Track features using DeepLabCut
# img_process.do_batch('analyse_dlc', rec_names=rec_names_to_process, from_fn_name='save_avi', cfg_path=dlc_cfg_path,
# shuffle=shuffle, trainingsetindex=0, batchsize=5, save_avi=False, model_name=model_name, delete_previous=True)
# # Load (+ filtering and unscrambling) 2d coords from DLC + Reverse processes (unstitch, rotate back, uncrop) + Reconstruct 3d coord
# img_process.do_batch('load_dlc', rec_names=rec_names_to_process, from_fn_name='analyse_dlc', model_name=model_name,
# tracker_method='skeleton')
# # Optimize fit of skeleton to find body and wings angles
# img_process.multiprocessing = True
# img_process.threshold_likelihood = 0.85
# img_process.do_batch('fit_skeleton', rec_names=rec_names_to_process, from_fn_name='load_dlc', model_name=model_name,
# csv_path=csv_wings_geo_path, body_param_names=body_param_names, wing_param_names=wing_param_names,
# res_method=res_method, opt_method=opt_method)
print('> All processes as been processed (total time elapsed: {0:.4f} s)'.format(time.time() - start))
\ No newline at end of file
File moved
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment