camera test
This commit is contained in:
parent
a20bef6538
commit
2264a28a3f
@ -30,6 +30,19 @@ class GalaxyCamera(Component):
|
||||
self._last_frame = None
|
||||
|
||||
def config_changed(self):
|
||||
if self.simulate:
|
||||
self.device_manager = None
|
||||
self.camera = DummyCamera()
|
||||
self.sim_imgs = cycle(sorted(pathlib.Path("data/simulation_images/").glob("*.png")))
|
||||
else:
|
||||
self.device_manager = gx.DeviceManager()
|
||||
# create a device manager
|
||||
dev_num, dev_info_list = self.device_manager.update_device_list()
|
||||
if dev_num == 0:
|
||||
self.log.exception("camera not detected")
|
||||
QMessageBox.critical(None, "Errore hardware", "Telecamera non rilevata.\nControllare connessione usb")
|
||||
quit()
|
||||
self.camera = self.device_manager.open_device_by_index(1)
|
||||
self.resolution = {
|
||||
"w": int(self.round_4(self.config[self.name]["horizontal_resolution"])),
|
||||
"h": int(self.round_4(self.config[self.name]["vertical_resolution"])),
|
||||
@ -99,21 +112,6 @@ class GalaxyCamera(Component):
|
||||
def round_4(x):
|
||||
return 4 * round(int(x) / 4)
|
||||
|
||||
def start(self):
|
||||
if self.simulate:
|
||||
self.camera = DummyCamera()
|
||||
self.sim_imgs = cycle(sorted(pathlib.Path("data/simulation_images/").glob("*.png")))
|
||||
else:
|
||||
self.device_manager = gx.DeviceManager()
|
||||
# create a device manager
|
||||
dev_num, dev_info_list = self.device_manager.update_device_list()
|
||||
if dev_num == 0:
|
||||
self.log.exception("camera not detected")
|
||||
QMessageBox.critical(None, "Errore hardware", "Telecamera non rilevata.\nControllare connessione usb")
|
||||
quit()
|
||||
self.camera = self.device_manager.open_device_by_index(1)
|
||||
super().start()
|
||||
|
||||
@Component.reconfig_on_error
|
||||
def _get(self):
|
||||
# print("GALAXY CAMERA", str(int(QThread.currentThreadId())), flush=True)
|
||||
@ -145,6 +143,7 @@ class GalaxyCamera(Component):
|
||||
super()._get([frame])
|
||||
|
||||
def __del__(self, event=None):
|
||||
if self.camera is not None:
|
||||
self.camera.stream_off()
|
||||
self.camera.close_device()
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user