# from socketIO_client import SocketIO, BaseNamespace # class MsgNamespace(BaseNamespace): # def on_stat_response(self, *args): # print('on_stat_response', args) # socketIO = SocketIO('localhost', 3000) # msg_namespace = socketIO.define(BaseNamespace, '/fromremote') # msg_namespace.emit('sensor_msg', {'sensor': 1, 'activity': 6}) # socketIO.wait(seconds=10) from RBConnection import RBConnection con = RBConnection('S1', 'localhost', 3000) con.send({'sensor': 1, 'activity': 6}) con.wait(2)
#extract data from the input file f = open('/home/pi/Desktop/lights/sg_1/pro/input.txt',"r") lines = f.readlines() results = re.findall('=([\d.]+)',lines[0]) results2 = re.findall('=([\d.]+)',lines[2]) config=map(float,results) #assign extracted values for each variables [resX,resY,frameRate,minThresh,maxTresh,minArea,maxArea]=[ int(config[0]),int(config[1]),float(config[2]),float(config[3]), float(config[4]),float(config[5]),float(config[6])] [minCir,minConv,minInert,LR,Move_low,Move_high]=[float(config[7]),float(config[8]),float(config[9]),float(config[10]),float(config[11]),float(config[12]) ] [X_low,X_high,Y_low,Y_high,keyA,ID,check,port]=[ int(config[13]),int(config[14]),int(config[15]),int(config[16]),int(config[17]),int(config[18]),int(config[19]),int(config[20])] IP=results2[0] #connection con = RBConnection('ID', IP, port) #camera configuration camera = PiCamera() camera.resolution = (resX,resY) camera.framerate = frameRate rawCapture = PiRGBArray(camera, size= (resX,resY) ) #image filtering kernel = cv2.getStructuringElement(cv2.MORPH_RECT,(5,5)) #background substraction fgbg = cv2.BackgroundSubtractorMOG2() #set up parameters for blob detection params = cv2.SimpleBlobDetector_Params()