-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlocalisationServer2D-WeekTwo.py
More file actions
executable file
·34 lines (27 loc) · 1.19 KB
/
localisationServer2D-WeekTwo.py
File metadata and controls
executable file
·34 lines (27 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import cameraLocalisation2D
import socketserver
import cv2 as cv
class Handler(socketserver.BaseRequestHandler):
def setup(self):
self.fishEyeCamera = cameraLocalisation2D.FishEyeCamera(deviceID=1)
self.robotDetector = cameraLocalisation2D.RobotDetector(numberOfColours=3)
# robotDetector.calibrateColour(self.fishEyeCamera)
self.robotDetector.setCalibration([360.0, 140.5, 220.9], [15.7, 12.5, 8.6])
self.robotDetector.displayCalibration()
def handle(self):
# self.data = self.request.recv(1024).strip()
# print "{} wrote".format(self.client_address[0])
# print self.data
while True:
undistortedFrame = self.fishEyeCamera.getUndistortedFrame()
self.robotDetector.updateLocations(undistortedFrame, self.fishEyeCamera, debug=False)
cv.imshow("Processed Frame", undistortedFrame)
result = ""
for robot in self.robotDetector.robots:
result += "\n" + str(robot)
self.request.sendall(result)
if __name__ == "__main__":
host = "localhost"
port = 9999
server = socketserver.TCPServer((host, port), Handler)
server.serve_forever()