Пример #1
0
	if val[0] == 's':
		u2 = np.loads(val[1:])
		fr1 += 1
	elif val[0] == 'e':
		running1 = False
		
def socket_cb2(socket,val):
	global u1,running2,fr2
	if val[0] == 's':
		u1 = np.loads(val[1:])
		fr2 += 1
	elif val[0] == 'e':
		running2 = False
			
##########set callbacks #####################################
tcps.add_tcp_callback(8000,socket_cb,threaded_callback =True)
tcps.add_tcp_callback(8080,socket_cb2,threaded_callback =True)
wait_for_interrupts(tcps,threaded=True)

##########   main loop #####################################

while running1 or running2:
	p1 = u1.copy()
	p2 = u2.copy()
	m1 = np.cross(p1,p2)
	m2 = np.cross(p1,p2)
	m3 = np.dot(m1,m2)
	p3 =  p1 + p2
	#print m3
	#print fr2 ': received', p2
	print fr1, fr2
def socket_cb2(socket,val):
    global u2,c2, running2,fr2,dat2
    if val[0] == 'u':
        u2 = np.loads(val[1:])
        fr2 += 1
        dat2 = True
    elif val[0] == 'c':
        c2 = np.loads(val[1:])
    elif val[0] == 'd':
        dat2 = False
    elif val[0] == 'e':
    	dat2 = False
        running2 = False
			
##########set callbacks #####################################
tcps1.add_tcp_callback(8000,socket_cb1,threaded_callback = True)
tcps1.add_tcp_callback(8080,socket_cb2,threaded_callback = True)
wait_for_interrupts(tcps1,threaded=True)
#wait_for_interrupts(tcps2,threaded=True)

##########videostream class################################

class WebcamVideoStream:
    def __init__(self, src=0):
        # initialize the video camera stream and read the first frame
        # from the stream
        self.stream = cv2.VideoCapture(src)
        (self.grabbed, self.frame) = self.stream.read()

        # initialize the variable used to indicate if the thread should
        # be stopped
Пример #3
0
	if val[0] == 's':
		u2 = np.loads(val[1:])
		fr1 += 1
	elif val[0] == 'e':
		running1 = False
		
def socket_cb2(socket,val):
	global u1,running2,fr2
	if val[0] == 's':
		u1 = np.loads(val[1:])
		fr2 += 1
	elif val[0] == 'e':
		running2 = False
			
##########set callbacks #####################################
tcps.add_tcp_callback(8000,socket_cb,threaded_callback = False)
tcps2.add_tcp_callback(8080,socket_cb2,threaded_callback = False)
wait_for_interrupts(tcps,threaded=True)
wait_for_interrupts(tcps2,threaded=True)

##########   main loop #####################################

while running1 or running2:
	p1 = u1.copy()
	p2 = u2.copy()
	m1 = np.cross(p1,p2)
	m2 = np.cross(p1,p2)
	m3 = np.dot(m1,m2)
	p3 =  p1 + p2
	#print m3
	#print fr2 ': received', p2