mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-19 00:41:41 +00:00
initial integration between ui and be
This commit is contained in:
70
.vscode/launch.json
vendored
Normal file
70
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Python: Current File (Integrated Terminal)",
|
||||
"type": "python",
|
||||
"request": "launch",
|
||||
"program": "${file}",
|
||||
"console": "integratedTerminal"
|
||||
},
|
||||
{
|
||||
"name": "Python: Remote Attach",
|
||||
"type": "python",
|
||||
"request": "attach",
|
||||
"port": 5678,
|
||||
"host": "localhost",
|
||||
"pathMappings": [
|
||||
{
|
||||
"localRoot": "${workspaceFolder}",
|
||||
"remoteRoot": "."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Python: Module",
|
||||
"type": "python",
|
||||
"request": "launch",
|
||||
"module": "enter-your-module-name-here",
|
||||
"console": "integratedTerminal"
|
||||
},
|
||||
{
|
||||
"name": "Python: Django",
|
||||
"type": "python",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/manage.py",
|
||||
"console": "integratedTerminal",
|
||||
"args": [
|
||||
"runserver",
|
||||
"--noreload",
|
||||
"--nothreading"
|
||||
],
|
||||
"django": true
|
||||
},
|
||||
{
|
||||
"name": "Python: Flask",
|
||||
"type": "python",
|
||||
"request": "launch",
|
||||
"module": "flask",
|
||||
"env": {
|
||||
"FLASK_APP": "app.py"
|
||||
},
|
||||
"args": [
|
||||
"run",
|
||||
"--no-debugger",
|
||||
"--no-reload"
|
||||
],
|
||||
"jinja": true
|
||||
},
|
||||
{
|
||||
"name": "Python: Current File (External Terminal)",
|
||||
"type": "python",
|
||||
"request": "launch",
|
||||
"program": "${file}",
|
||||
"console": "externalTerminal"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -25,4 +25,7 @@ if __name__ == "__main__":
|
||||
SettingsManager()
|
||||
|
||||
VisionHandler().run()
|
||||
run_server()
|
||||
|
||||
while True:
|
||||
pass
|
||||
|
||||
@@ -47,13 +47,14 @@ class SettingsManager(metaclass=Singleton):
|
||||
self._init_cameras()
|
||||
self._init_usb_cameras_settings()
|
||||
|
||||
if self.general_settings["curr_camera"] not in self.cams and len(self.cams) > 0:
|
||||
cam_name = list(self.cams.keys())[0]
|
||||
self.general_settings["curr_camera"] = cam_name
|
||||
self.general_settings["curr_pipeline"] = list(self.cams[cam_name]["pipelines"].keys())[0]
|
||||
else:
|
||||
self.general_settings["curr_camera"] = ""
|
||||
self.general_settings["curr_pipeline"] = ""
|
||||
if self.general_settings["curr_camera"] not in self.cams:
|
||||
if len(self.cams) > 0:
|
||||
cam_name = list(self.cams.keys())[0]
|
||||
self.general_settings["curr_camera"] = cam_name
|
||||
self.general_settings["curr_pipeline"] = list(self.cams[cam_name]["pipelines"].keys())[0]
|
||||
else:
|
||||
self.general_settings["curr_camera"] = ""
|
||||
self.general_settings["curr_pipeline"] = ""
|
||||
|
||||
def _init_general_settings(self):
|
||||
try:
|
||||
@@ -156,7 +157,7 @@ class SettingsManager(metaclass=Singleton):
|
||||
pipe_name = self.general_settings["curr_pipeline"]
|
||||
|
||||
for key in dic:
|
||||
if self.default_pipeline[key]:
|
||||
if key in self.default_pipeline:
|
||||
self.cams[cam_name]["pipelines"][pipe_name][key] = dic[key]
|
||||
|
||||
def change_general_settings_values(self, dic):
|
||||
|
||||
@@ -21,7 +21,7 @@ class ChameleonWebSocket(tornado.websocket.WebSocketHandler):
|
||||
self.actions["change_pipeline"] = self.change_curr_pipeline
|
||||
|
||||
def open(self):
|
||||
|
||||
|
||||
self.send_full_settings()
|
||||
|
||||
print("WebSocket opened")
|
||||
@@ -31,7 +31,7 @@ class ChameleonWebSocket(tornado.websocket.WebSocketHandler):
|
||||
message_dic = json.loads(message)
|
||||
|
||||
for key in message_dic:
|
||||
self.actions.get(key, self.actions["change_pipeline_values"])(message_dic[key])
|
||||
self.actions.get(key, self.actions["change_pipeline_values"])(message_dic)
|
||||
|
||||
print(message)
|
||||
|
||||
@@ -59,9 +59,9 @@ class ChameleonWebSocket(tornado.websocket.WebSocketHandler):
|
||||
|
||||
def send_full_settings(self):
|
||||
full_settings = self.settings_manager.general_settings.copy()
|
||||
|
||||
full_settings["cameraList"] = list(self.settings_manager.cams.copy().keys())
|
||||
try:
|
||||
full_settings = self.settings_manager.get_curr_pipeline()
|
||||
full_settings.update(self.settings_manager.get_curr_pipeline())
|
||||
except NoCameraConnectedException:
|
||||
# TODO: return something if no camera connected
|
||||
full_settings["data"] = None
|
||||
@@ -82,4 +82,4 @@ class ChameleonWebSocket(tornado.websocket.WebSocketHandler):
|
||||
for key in self.set_this_camera_settings:
|
||||
if key in dic:
|
||||
self.settings_manager.set_camera_settings(self.settings_manager.general_settings["curr_camera"],
|
||||
dic[key])
|
||||
dic)
|
||||
|
||||
@@ -4,6 +4,7 @@ import networktables
|
||||
import cv2
|
||||
import numpy
|
||||
from cscore import CameraServer
|
||||
# from .app.classes.SettingsManager import SettingsManager
|
||||
from app.classes.SettingsManager import SettingsManager
|
||||
from ..classes.Singleton import Singleton
|
||||
import time
|
||||
@@ -85,6 +86,7 @@ class VisionHandler(metaclass=Singleton):
|
||||
|
||||
def thread_proc(self, cs, cam_name, port="5557"):
|
||||
cv_sink = cs.getVideo(camera=SettingsManager.usb_cameras[cam_name])
|
||||
|
||||
width = SettingsManager().cams[cam_name]["video_mode"]["width"]
|
||||
height = SettingsManager().cams[cam_name]["video_mode"]["height"]
|
||||
|
||||
@@ -106,7 +108,7 @@ class VisionHandler(metaclass=Singleton):
|
||||
image = socket.recv_pyobj()
|
||||
cv_publish.putFrame(image)
|
||||
end = time.time()
|
||||
print(cam_name + " " + str(1 / (end - start)))
|
||||
# print(cam_name + " " + str(1 / (end - start)))
|
||||
|
||||
def camera_process(self, cam_name, port):
|
||||
|
||||
|
||||
1
backend/settings/cams/USB Camera-B4.09.24.1.json
Normal file
1
backend/settings/cams/USB Camera-B4.09.24.1.json
Normal file
@@ -0,0 +1 @@
|
||||
{"pipelines": {"pipeline0": {"exposure": 50, "brightness": 50, "orientation": "Normal", "resolution": [320, 160], "hue": [0, 58], "saturation": [0, 100], "value": [0, 100], "erode": false, "dilate": false, "area": [0, 100], "ratio": [0, 20], "extent": [0, 100], "is_binary": "Normal"}}, "path": "/dev/v4l/by-path/pci-0000:02:03.0-usb-0:1:1.0-video-index0", "video_mode": {"fps": 187, "width": 320, "height": 240, "pixel_format": "kYUYV"}}
|
||||
1
backend/settings/settings.json
Normal file
1
backend/settings/settings.json
Normal file
@@ -0,0 +1 @@
|
||||
{"team_number": 1577, "connection_type": "DHCP", "ip": "", "gateway": "", "hostname": "Chameleon-Vision", "curr_camera": "USB Camera-B4.09.24.1", "curr_pipeline": "pipeline0"}
|
||||
@@ -33,7 +33,7 @@ export const store = new Vuex.Store({
|
||||
gateWay:0,
|
||||
hostName:"",
|
||||
//live info
|
||||
streamAdress:("http://"+location.hostname + ":1181/?stream"),
|
||||
streamAdress:("http://"+location.hostname + ":1181/stream.mjpg"),
|
||||
isBinaryImage:0,
|
||||
//camera lists
|
||||
cameraList:[],
|
||||
|
||||
1
settings/cams/USB Camera-B4.09.24.1.json
Normal file
1
settings/cams/USB Camera-B4.09.24.1.json
Normal file
@@ -0,0 +1 @@
|
||||
{"pipelines": {"pipeline0": {"exposure": 50, "brightness": 50, "orientation": "Normal", "resolution": [320, 160], "hue": [0, 100], "saturation": [0, 100], "value": [0, 100], "erode": false, "dilate": false, "area": [0, 100], "ratio": [0, 20], "extent": [0, 100], "is_binary": "Normal"}}, "path": "/dev/v4l/by-path/pci-0000:02:03.0-usb-0:1:1.0-video-index0", "video_mode": {"fps": 187, "width": 320, "height": 240, "pixel_format": "kYUYV"}}
|
||||
1
settings/settings.json
Normal file
1
settings/settings.json
Normal file
@@ -0,0 +1 @@
|
||||
{"team_number": 1577, "connection_type": "DHCP", "ip": "", "gateway": "", "hostname": "Chameleon-Vision", "curr_camera": "USB Camera-B4.09.24.1", "curr_pipeline": "pipeline0"}
|
||||
Reference in New Issue
Block a user