mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-20 00:51:41 +00:00
Fully merged CmerasHandler to SettingManger
hadn't the time to check, also refractord every use of cameras handler to settings manager, might have missed
This commit is contained in:
@@ -3,14 +3,11 @@ import tornado.ioloop
|
||||
from app.ChameleonVisionApp import ChameleonApplication
|
||||
from app.classes.SettingsManager import SettingsManager
|
||||
from tornado.options import options
|
||||
from app.handlers.CamerasHandler import CamerasHandler
|
||||
from app.handlers.VisionHandler import VisionHandler
|
||||
|
||||
if __name__ == "__main__":
|
||||
SettingsManager()
|
||||
# CamerasHandler.init_camera()
|
||||
|
||||
|
||||
|
||||
#VisionHandler().run()
|
||||
# SettingsManager().save_settings()
|
||||
|
||||
|
||||
@@ -59,9 +59,7 @@ class SettingsManager(metaclass=Singleton):
|
||||
|
||||
# Initiate our camera's settings
|
||||
def _init_cameras(self):
|
||||
cameras = self._get_cameras_info()
|
||||
|
||||
for cam in cameras:
|
||||
for cam in self.usb_cameras_info:
|
||||
if os.path.exists(os.path.join(self.cams_path, cam.name + '.json')):
|
||||
|
||||
with open(os.path.join(self.cams_path, cam.name + '.json'), 'r') as camera:
|
||||
@@ -72,17 +70,6 @@ class SettingsManager(metaclass=Singleton):
|
||||
else:
|
||||
self.create_new_cam(cam.name)
|
||||
|
||||
if "path" not in self.cams[cam.name]:
|
||||
self.cams[cam.name]["path"] = cam.otherPaths[0] if len(cam.otherPaths) == 1 else cam.otherPaths[1]
|
||||
if "video_mode" not in self.cams[cam.name]:
|
||||
video_mode: VideoMode = self.cams(cam.name).enumerateVideoModes()[0]
|
||||
self.cams[cam.name]["video_mode"] = {
|
||||
"fps": video_mode.fps,
|
||||
"width": video_mode.width,
|
||||
"height": video_mode.height,
|
||||
"pixel_format": str(video_mode.pixelFormat).split('.')[1]
|
||||
}
|
||||
|
||||
# Initiate true usb cameras(filters microphones and double cameras)
|
||||
def _init_cameras_info(self):
|
||||
true_cameras = []
|
||||
@@ -198,6 +185,17 @@ class SettingsManager(metaclass=Singleton):
|
||||
self.cams[cam_name]["pipelines"] = {}
|
||||
self.create_new_pipeline(cam_name=cam_name)
|
||||
|
||||
self.cams[cam_name]["path"] = self.usb_cameras[cam_name].otherPaths[0] if len(
|
||||
self.usb_cameras[cam_name].otherPaths) == 1 else self.usb_cameras[cam_name].otherPaths[1]
|
||||
|
||||
video_mode: VideoMode = self.usb_cameras[self.usb_cameras[cam_name].name].enumerateVideoModes()[0]
|
||||
self.cams[self.usb_cameras[cam_name].name]["video_mode"] = {
|
||||
"fps": video_mode.fps,
|
||||
"width": video_mode.width,
|
||||
"height": video_mode.height,
|
||||
"pixel_format": str(video_mode.pixelFormat).split('.')[1]
|
||||
}
|
||||
|
||||
# Savers
|
||||
|
||||
def save_settings(self):
|
||||
|
||||
@@ -4,7 +4,7 @@ from cscore._cscore import VideoMode
|
||||
|
||||
class CamerasHandler:
|
||||
|
||||
@staticmethod
|
||||
#@staticmethod
|
||||
# def get_cameras_info():
|
||||
#
|
||||
# if not getattr(CamerasHandler, "cams_info", False):
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import tornado.websocket
|
||||
import json
|
||||
|
||||
from ..classes.Exceptions import NoCameraConnectedException
|
||||
from .CamerasHandler import CamerasHandler
|
||||
from ..classes.SettingsManager import SettingsManager
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ import networktables
|
||||
import cv2
|
||||
import numpy
|
||||
from cscore import CameraServer
|
||||
from .CamerasHandler import CamerasHandler
|
||||
from app.classes.SettingsManager import SettingsManager
|
||||
import time
|
||||
import json
|
||||
@@ -76,9 +75,8 @@ class VisionHandler:
|
||||
NetworkTables.initialize("localhost")
|
||||
# NetworkTables.initialize()
|
||||
|
||||
cams = CamerasHandler.get_or_start_cameras(CamerasHandler.get_cameras_info())
|
||||
for cam in cams:
|
||||
self.camera_process(cams[cam])
|
||||
for cam in SettingsManager().usb_cameras:
|
||||
self.camera_process(SettingsManager().usb_cameras[cam])
|
||||
|
||||
def camera_process(self, camera):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user