mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-22 01:11: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
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"pipelines": {"pipeline0": {"exposure": 50, "brightness": 16, "orientation": "Normal", "hue": [0, 127], "saturation": [0, 138], "value": [0, 122], "erode": false, "dilate": false, "area": [20, 37], "ratio": [0, 80.5], "extent": [0, 100], "is_binary": 1, "sort_mode": "Rightmost", "target_group": "Single", "target_intersection": "Up", "M": 1, "B": 0}}, "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"}, "resolution": 0, "FOV": 56}
|
||||
{"pipelines": {"pipeline0": {"exposure": 3, "brightness": 0, "orientation": "Normal", "hue": [85, 136], "saturation": [115, 175], "value": [190, 255], "erode": false, "dilate": false, "area": [0, 99], "ratio": [0, 94.4], "extent": [0, 100], "is_binary": 1, "sort_mode": "Largest", "target_group": "Single", "target_intersection": "Up", "M": 1, "B": 0}}, "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"}, "resolution": 0, "FOV": 56}
|
||||
@@ -43,11 +43,19 @@ import chrange from './ch-range.vue'
|
||||
if(this.pointA !== undefined && this.pointB !== undefined){
|
||||
let m = (this.pointB[1] - this.pointA[1]) / (this.pointB[0] - this.pointA[0]);
|
||||
let b = this.pointA[1] - (m * this.pointA[0]);
|
||||
this.sendSlope(m,b);
|
||||
if(isNaN(m) === false && isNaN(b) === false){
|
||||
this.sendSlope(m,b);
|
||||
} else{
|
||||
this.$Message.error("Point A and B are to close apart");
|
||||
}
|
||||
this.pointA = undefined;
|
||||
this.pointB = undefined;
|
||||
}
|
||||
},
|
||||
clearPoints:function(){
|
||||
this.sendSlope(1,0);
|
||||
this.pointA = undefined;
|
||||
this.pointB = undefined;
|
||||
},
|
||||
sendSlope(m,b){
|
||||
this.$socket.sendObj({'M':m});
|
||||
|
||||
Reference in New Issue
Block a user