camera config

This commit is contained in:
matteo porta 2022-06-29 13:12:09 +02:00
parent e2b0912aa8
commit 514964d7c6
2 changed files with 29 additions and 21 deletions

View File

@ -1,13 +1,17 @@
[galaxy_camera]
exposure time: 10000
horizontal crop offset: 0
horizontal crop resolution: 2448
vertical crop offset: 724
vertical crop resolution: 800
rotate 90 clockwise times: 0
balance red: 1.0
balance green: 1.0
balance blue: 1.0
horizontal_resolution: 2448
vertical_resolution: 2048
; frame_time_ms: 300
exposure_time: 10000
; horizontal_crop_offset: 0
; horizontal_crop_resolution: 2448
; vertical_crop_offset: 0
; vertical_crop_resolution: 2048
; rotate_90_clockwise times: 0
; auto_white_balance: off
; balance_red: 1.0
; balance_green: 1.0
; balance_blue: 1.0
[vision_saver]
time_format: %Y-%m-%d_%H-%M-%S

View File

@ -29,20 +29,24 @@ class GalaxyCamera(Component):
self._last_frame = None
def config_changed(self):
self._period = int(self.config[self.name].get("frame time ms", 300)) / 1000
self.exposure_time = int(self.config[self.name]["exposure time"])
self.roi = {
"x": int(self.round_4(self.config[self.name]["horizontal crop offset"])),
"w": int(self.round_4(self.config[self.name]["horizontal crop resolution"])),
"y": int(self.round_4(self.config[self.name]["vertical crop offset"])),
"h": int(self.round_4(self.config[self.name]["vertical crop resolution"])),
"r": int(self.config[self.name]["rotate 90 clockwise times"]),
self.resolution = {
"w": int(self.round_4(self.config[self.name]["horizontal_resolution"])),
"h": int(self.round_4(self.config[self.name]["vertical_resolution"])),
}
self.auto_white_balance = bool(self.config[self.name].get("auto white balance", False))
self._period = int(self.config[self.name].get("frame_time_ms", 300)) / 1000
self.exposure_time = int(self.config[self.name]["exposure_time"])
self.roi = {
"x": int(self.round_4(self.config[self.name].get("horizontal_crop_offset", 0))),
"w": int(self.round_4(self.config[self.name].get("horizontal_crop_resolution", self.resolution["w"]))),
"y": int(self.round_4(self.config[self.name].get("vertical_crop_offset", 0))),
"h": int(self.round_4(self.config[self.name].get("vertical_crop_resolution", self.resolution["h"]))),
"r": int(self.config[self.name].get("rotate_90_clockwise_times", 0)),
}
self.auto_white_balance = self.config[self.name].get("auto_white_balance", "").lower() in {"on", "1", "y", "yes", "true", "enable", "enabled", }
self.balance = {
"r": float(self.config[self.name].get("balance red", 1)),
"g": float(self.config[self.name].get("balance green", 1)),
"b": float(self.config[self.name].get("balance blue", 1)),
"r": float(self.config[self.name].get("balance_red", 1)),
"g": float(self.config[self.name].get("balance_green", 1)),
"b": float(self.config[self.name].get("balance_blue", 1)),
}
self.lock.lock()
self.camera.stream_off()