Files
yolocam-linux/yolocam-gui/yolocam_gui/backend/camera_client.py
T
2026-02-15 12:50:49 -08:00

62 lines
2.1 KiB
Python

# Copyright (C) 2026 Seth Hillbrand
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
"""Qt-integrated camera client for the YoloCam S3.
Thin wrapper around YoloCamClient that emits PySide6 signals for GUI integration.
"""
from PySide6.QtCore import QObject, Signal
from yolocam.client import YoloCamClient
from yolocam.protocol import CAMERA_IP, CAMERA_PORT, DEFAULT_TIMEOUT
class CameraClient(QObject, YoloCamClient):
"""Camera client with Qt signal integration.
Overrides YoloCamClient hook methods to emit signals, allowing GUI widgets
to receive updates via Qt's signal/slot mechanism.
"""
camera_connected = Signal()
camera_disconnected = Signal()
param_changed = Signal(str, object)
error_occurred = Signal(str)
recording_state_changed = Signal(bool)
recording_duration_changed = Signal(int)
def __init__(self, ip=CAMERA_IP, port=CAMERA_PORT, timeout=DEFAULT_TIMEOUT, parent=None):
QObject.__init__(self, parent)
YoloCamClient.__init__(self, ip, port, timeout)
def _on_connected(self):
self.camera_connected.emit()
def _on_disconnected(self):
self.camera_disconnected.emit()
def _on_error(self, message):
self.error_occurred.emit(message)
def _on_param_changed(self, name, value):
self.param_changed.emit(name, value)
def _on_recording_state_changed(self, recording):
self.recording_state_changed.emit(recording)
def _on_recording_duration_changed(self, duration):
self.recording_duration_changed.emit(duration)