35 lines
864 B
Python
35 lines
864 B
Python
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()
|
|
floorImage = floorCam.get_image()
|
|
merged = pygame.Surface([640,480])
|
|
merged.blit(goalImage,(0,0))
|
|
merged.blit(floorImage,(320,0))
|
|
data = pygame.image.tostring(merged,"RGB")
|
|
try:
|
|
connection.sendall(data)
|
|
except socket.error:
|
|
print("error")
|
|
time.sleep(0.05)
|
|
connection.close()
|