mirror of
https://github.com/PhotonVision/photonvision
synced 2026-07-03 03:01:40 +00:00
bug fixes for calibration module
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import asyncio
|
||||
|
||||
import tornado.websocket
|
||||
import json
|
||||
from ..classes.Exceptions import NoCameraConnectedException
|
||||
@@ -14,7 +16,7 @@ def send_all_async(message):
|
||||
web_socket_clients.remove(ws)
|
||||
else:
|
||||
try:
|
||||
ws.write_message(message)
|
||||
ws.write_message(json.dumps(message))
|
||||
except AssertionError as a:
|
||||
pass
|
||||
except AssertionError:
|
||||
@@ -47,11 +49,14 @@ class ChameleonWebSocket(tornado.websocket.WebSocketHandler):
|
||||
print("WebSocket opened")
|
||||
|
||||
def on_message(self, message):
|
||||
message_dic = json.loads(message)
|
||||
try:
|
||||
message_dic = json.loads(message)
|
||||
|
||||
for key in message_dic:
|
||||
self.actions.get(key, self.actions["change_pipeline_values"])(message_dic)
|
||||
print(message)
|
||||
for key in message_dic:
|
||||
self.actions.get(key, self.actions["change_pipeline_values"])(message_dic)
|
||||
print(message)
|
||||
except:
|
||||
print("crash " + message)
|
||||
|
||||
def on_close(self):
|
||||
self.settings_manager.save_settings()
|
||||
|
||||
@@ -241,7 +241,6 @@ class VisionHandler(metaclass=Singleton):
|
||||
return pitch
|
||||
|
||||
def calculate_yaw(self, pixel_x, center_x, h_focal_length):
|
||||
|
||||
yaw = math.degrees(math.atan((pixel_x - center_x) / h_focal_length))
|
||||
return yaw
|
||||
|
||||
@@ -389,8 +388,8 @@ class VisionHandler(metaclass=Singleton):
|
||||
center = final_contour[0]
|
||||
center_x = (center[1] - curr_pipeline['B']) / curr_pipeline["M"]
|
||||
center_y = (center[0] * curr_pipeline["M"]) + curr_pipeline["B"]
|
||||
pitch = self.calculate_pitch(pixel_y=center[1], center_y=center_x, v_focal_length=V_FOCAL_LENGTH)
|
||||
yaw = self.calculate_yaw(pixel_x=center[0], center_x=center_y, h_focal_length=H_FOCAL_LENGTH)
|
||||
pitch = self.calculate_pitch(pixel_y=center[1], center_y=center_y, v_focal_length=V_FOCAL_LENGTH)
|
||||
yaw = self.calculate_yaw(pixel_x=center[0], center_x=center_x, h_focal_length=H_FOCAL_LENGTH)
|
||||
valid = True
|
||||
except IndexError:
|
||||
center = None
|
||||
|
||||
Reference in New Issue
Block a user