예제 #1
0
 async def recv_server_func(self, websocket):
     while 1:
         tmp = await websocket.recv()
         print(tmp)
         tmp = json.loads(tmp)
         
         for key in tmp:
             self.recv_dict[key] = tmp[key]
         print("recv_dict: %s"%self.recv_dict)
         self.remote_control(self.recv_dict['JA'])
         self.camera_contrl(self.recv_dict['JB'])
         # print(recv_dict)
         if self.recv_dict['MS'][0] =='on':
             car.set_motor_speed(int(self.recv_dict['MS'][1]), int(self.recv_dict['MS'][2]))
         if self.recv_dict['DO'][0] =='on':
             car.dir_servo_angle_calibration(int(self.recv_dict['DO'][1]))
         if self.recv_dict['PO'][0] =='on':
             car.camera_servo1_angle_calibration(-int(self.recv_dict['PO'][1]))
         if self.recv_dict['TO'][0] =='on':
             car.camera_servo2_angle_calibration(-int(self.recv_dict['TO'][1]))
         Vilib.detect_color_name(str(self.recv_dict['CC']))
예제 #2
0
import time
from vilib import Vilib
# from ezblock import Servo,PWM
# from robothat import *
import numpy as np
# from th_test import task_start
Vilib.camera_start(web_func=True)
# Vilib.human_detect_switch(True)
Vilib.color_detect_switch(True)
Vilib.detect_color_name('blue')

while True:
    # print(Vilib.human_detect_object('number'))
    # print(Vilib.human_detect_object('y'))
    start_time = time.time()
    time.sleep(10)
    Vilib.detect_color_name('blue')
    time.sleep(10)
    Vilib.detect_color_name('red')
    # print("  ")
    # count+=1

    # for i in range(1000):
    #     pass
    #     # print("end")
    #     # pass

    # this_time = time.time() - start_time
    # print(round(this_time,3))
    # all_time += this_time
    # avge_time = round(all_time/float(count),3)