inital commit with server
This commit is contained in:
commit
6847abbe5a
34
server.py
Normal file
34
server.py
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import socket
|
||||||
|
import pygame
|
||||||
|
import pygame.camera
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
|
||||||
|
port = 5802
|
||||||
|
pygame.init()
|
||||||
|
|
||||||
|
serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
|
serversocket.bind(("",port))
|
||||||
|
serversocket.listen(1)
|
||||||
|
|
||||||
|
pygame.camera.init()
|
||||||
|
goalCam = pygame.camera.Camera("/dev/video0",(320,240))
|
||||||
|
floorCam = pygame.camera.Camera("/dev/video1",(320,240))
|
||||||
|
goalCam.start()
|
||||||
|
floorCam.start()
|
||||||
|
|
||||||
|
|
||||||
|
while True:
|
||||||
|
connection, address = serversocket.accept()
|
||||||
|
goalImage = goalCam.get_image() # capture image
|
||||||
|
floorImage = floorCam.get_image() # capture image
|
||||||
|
merged = pygame.Surface([640,480])
|
||||||
|
merged.blit(goalImage,(0,0))
|
||||||
|
merged.blit(floorImage,(320,0))
|
||||||
|
data = pygame.image.tostring(merged,"RGB") # convert captured image to string, use RGB color scheme
|
||||||
|
try:
|
||||||
|
connection.sendall(data)
|
||||||
|
except socket.error:
|
||||||
|
print("error")
|
||||||
|
time.sleep(0.05)
|
||||||
|
connection.close()
|
Loading…
Reference in New Issue
Block a user