diff --git a/camera.py b/camera.py index 6692daee72ce34f7a22c04b9918cc7f441f090bb..ca330615344ac1486d13269d5d914ad9ddee26d2 100644 --- a/camera.py +++ b/camera.py @@ -15,7 +15,8 @@ class take_img(Thread): self._running = True self.save_IMGS = CONFIG['save-IMGS'] self.save_GPS = CONFIG['save-GPS'] - self.usb = USB_class() + + self.usb = USB_class(CONFIG['save-every-x']) # connecting to the first available camera self.camera = pylon.InstantCamera(pylon.TlFactory.GetInstance().CreateFirstDevice()) diff --git a/cfg/detection.yaml b/cfg/detection.yaml index 495fce7350543c89c6aaa77ce34da943ce5f6758..2fb93a7bab75f51432a77049b9de3dda1b64e0d7 100644 --- a/cfg/detection.yaml +++ b/cfg/detection.yaml @@ -15,8 +15,8 @@ logging: False GPS: True Camera: True AGENSO: True -save-GPS: False -save-IMGS: False +save-GPS: True +save-IMGS: True save-every-x: 10 #dont save all imgs & GPS coordinates, its simply to much #folders diff --git a/usb_Filestorage.py b/usb_Filestorage.py index 35892fc42bb972aa68d971d2adad58bb08843454..9217778fec4aedbc67fc03e70a679590f38a16bb 100644 --- a/usb_Filestorage.py +++ b/usb_Filestorage.py @@ -23,7 +23,8 @@ class USB_class: self.UUID = None #UUID of the disk self.reconnect() self.free_USBGBs = self.check_free_diskspace() - self.writenum = 0 #counter to avoid checking diskspace for every call + self.writeIMg_cnt = 0 #counter to avoid checking diskspace for every call + self.writeGPS_cnt = 0 self.save_frequency = save_frequency #need sudo rights for these folders... @@ -153,15 +154,15 @@ class USB_class: if not self.reconnect(): return file_dir = os.path.join(MOUNT_DIR, IMG_folder, subfolder) - self.writenum = self.writenum + 1 + self.writeIMg_cnt = self.writeIMg_cnt + 1 try: #avoid overflowing the disk, we save one/x files and check the diskspace every 50 files. - if self.writenum %(self.save_frequency*50) == 0: + if self.writeIMg_cnt %(self.save_frequency*50) == 0: self.free_USBGBs = self.check_free_diskspace() - self.writenum = 0 + self.writeIMg_cnt = 0 if self.free_USBGBs < 0.1: return - elif self.writenum % save_frequency: + elif self.writeIMg_cnt % self.save_frequency == 0: #create subfolder if it not there yet & save image if not self.check_direxists(file_dir): raise Exception("disk not connected") @@ -179,15 +180,15 @@ class USB_class: if self.UUID == None: if not self.reconnect(): return - self.writenum = self.writenum + 1 + self.writeGPS_cnt = self.writeGPS_cnt + 1 try: #avoid overflowing the disk - if self.writenum %(self.save_frequency*50) == 0: + if self.writeGPS_cnt %(self.save_frequency*50) == 0: self.free_USBGBs = self.check_free_diskspace() - self.writenum = 0 + self.writeGPS_cnt = 0 if self.free_USBGBs < 0.1: return - elif self.writenum % save_frequency: + elif self.writeGPS_cnt % self.save_frequency ==0: with open(os.path.join(MOUNT_DIR, GPS_folder, (filename + ".txt")), "a") as file: file.write(data_string) except Exception as e: