Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import os, time
from core.images_processing import ImagesProcessing
#import deeplabcut
start = time.time()
xyz_path = os.path.join(os.getcwd(), 'calib_files/xyz_calibration_device_small.csv')
#xy_path = os.path.join(os.getcwd(), 'calib_files/20200615_xypts-rot.csv')
xy_path = os.path.join(os.getcwd(), 'calib_files/20200615_xypts.csv')
dlt_path = os.path.join(os.getcwd(), 'calib_files/20200615_DLTcoefs-py.csv')
dlc_cfg_path = '/home/user/Desktop/Antoine/_DLC/config.yaml'
img_size = (896, 896)
# Generate dlt coefficients
#gen_dlt(3, img_size, xyz_path, xy_path, dlt_path)
img_process = ImagesProcessing(3, dlt_path)
img_process.cam_paths = {1: '/media/user/MosquitoLanding_Photron1_Backup/Photron1/_MatingKinematics',
2: '/media/user/MosquitoLanding_Photron2_Backup/Photron2/_MatingKinematics',
3: '/media/user/MosquitoLanding_Photron3_Backup/Photron3/_MatingKinematics'}
img_process.cam_save_paths = {1: '/media/user/MosquitoLanding_Photron1_Backup/Photron1/_MatingKinematics/_Process',
2: '/media/user/MosquitoLanding_Photron2_Backup/Photron2/_MatingKinematics/_Process',
3: '/media/user/MosquitoLanding_Photron3_Backup/Photron3/_MatingKinematics/_Process'}
img_process.update_leading_zero = False
img_process.init_paths_names()
img_process.max_diff_date_s = 90
# # Fill dict with name of recordings to process
# # > either all recordings from a given date
# date_to_process = '20200303'
# rec_names_to_process = {}
# 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]
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)
# 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')
# 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))