Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
697f3a109e
@ -4,7 +4,7 @@ description = LAPTOP
|
|||||||
[hardware_config]
|
[hardware_config]
|
||||||
archive_synchronizer: absent
|
archive_synchronizer: absent
|
||||||
galaxy_camera: absent
|
galaxy_camera: absent
|
||||||
uvc_camera: absent
|
uvc_camera: present
|
||||||
label_printer: present
|
label_printer: present
|
||||||
neo_pixels: absent
|
neo_pixels: absent
|
||||||
remote_api: absent
|
remote_api: absent
|
||||||
@ -21,4 +21,13 @@ model: t3l
|
|||||||
[recipe]
|
[recipe]
|
||||||
part_number_field: pn
|
part_number_field: pn
|
||||||
recipe_name_field: rc
|
recipe_name_field: rc
|
||||||
label_template_field: modello_etichetta
|
label_template_field: modello_etichetta
|
||||||
|
|
||||||
|
[uvc_camera]
|
||||||
|
horizontal_resolution: 3264
|
||||||
|
vertical_resolution: 2448
|
||||||
|
exposure_time: 1000
|
||||||
|
focus: 235
|
||||||
|
balance_red: 1
|
||||||
|
balance_green: 1.0
|
||||||
|
balance_blue: 1.0
|
||||||
|
|||||||
@ -28,9 +28,9 @@ class VisionSaver(Component):
|
|||||||
self.time_format = self.config[self.name]["time_format"]
|
self.time_format = self.config[self.name]["time_format"]
|
||||||
|
|
||||||
@Component.reconfig_on_error
|
@Component.reconfig_on_error
|
||||||
def save(self, save_time=None, suffix=None, frame=None, vision=None, resize=None, mask=None):
|
def save(self, save_time=None, suffix=None, frame=None, vision=None, resize=None, mask=None,location=None):
|
||||||
self.remove_older_images_if_needed()
|
self.remove_older_images_if_needed()
|
||||||
if type(save_time) is None:
|
if save_time is None:
|
||||||
save_time = datetime.now()
|
save_time = datetime.now()
|
||||||
else:
|
else:
|
||||||
if type(save_time) is float:
|
if type(save_time) is float:
|
||||||
@ -40,7 +40,9 @@ class VisionSaver(Component):
|
|||||||
if type(save_time) is not datetime:
|
if type(save_time) is not datetime:
|
||||||
raise ValueError(f"save_time must be float int or datetime, not {type(save_time)}")
|
raise ValueError(f"save_time must be float int or datetime, not {type(save_time)}")
|
||||||
timestamp = save_time.strftime(self.time_format)
|
timestamp = save_time.strftime(self.time_format)
|
||||||
save_dir = self.location / save_time.strftime("%Y") / save_time.strftime("%m")
|
save_location = self.location if location is None else Path(location)
|
||||||
|
save_dir = save_location / save_time.strftime("%Y") / save_time.strftime("%m")
|
||||||
|
|
||||||
os.makedirs(save_dir, exist_ok=True)
|
os.makedirs(save_dir, exist_ok=True)
|
||||||
out_paths = []
|
out_paths = []
|
||||||
if frame is not None:
|
if frame is not None:
|
||||||
@ -83,6 +85,7 @@ class VisionSaver(Component):
|
|||||||
json.dump(vision, f)
|
json.dump(vision, f)
|
||||||
return list(map(str, out_paths))
|
return list(map(str, out_paths))
|
||||||
|
|
||||||
|
|
||||||
def remove_older_images_if_needed(self):
|
def remove_older_images_if_needed(self):
|
||||||
if self.minimum_disk_free_space_gb is None:
|
if self.minimum_disk_free_space_gb is None:
|
||||||
return
|
return
|
||||||
|
|||||||
@ -118,14 +118,15 @@ try:
|
|||||||
self.components["vision"].set_sources({"galaxy_camera": self.components["galaxy_camera"].out})
|
self.components["vision"].set_sources({"galaxy_camera": self.components["galaxy_camera"].out})
|
||||||
self.components["uvc_camera"].out.connect(self.update_gui)
|
self.components["uvc_camera"].out.connect(self.update_gui)
|
||||||
self.components["uvc_camera"].resume()
|
self.components["uvc_camera"].resume()
|
||||||
|
|
||||||
self.main_window = Main_Window()
|
self.main_window = Main_Window()
|
||||||
|
self.main_window.btn_save_image.clicked.connect(self.save_frame)
|
||||||
|
|
||||||
# SHOW MAIN WINDOW
|
# SHOW MAIN WINDOW
|
||||||
self.main_window.show()
|
self.main_window.show()
|
||||||
|
|
||||||
def update_gui(self,frame):
|
def update_gui(self,frame):
|
||||||
if frame[0]["uvc_camera"] is not None:
|
if frame[0]["uvc_camera"] is not None:
|
||||||
|
self.frame = frame[0]["uvc_camera"]
|
||||||
render = QPixmap.fromImage(self.components["vision"].render(
|
render = QPixmap.fromImage(self.components["vision"].render(
|
||||||
frame[0]["uvc_camera"],
|
frame[0]["uvc_camera"],
|
||||||
detections=None,
|
detections=None,
|
||||||
@ -135,6 +136,10 @@ try:
|
|||||||
))
|
))
|
||||||
self.main_window.image_l.setPixmap(render.scaled(self.main_window.image_l.width(), self.main_window.image_l.height(), Qt.KeepAspectRatio, Qt.SmoothTransformation))
|
self.main_window.image_l.setPixmap(render.scaled(self.main_window.image_l.width(), self.main_window.image_l.height(), Qt.KeepAspectRatio, Qt.SmoothTransformation))
|
||||||
|
|
||||||
|
def save_frame(self):
|
||||||
|
self.components["vision_saver"].save(frame=self.frame, location="tmp")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app = QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
main = Main()
|
main = Main()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user