# 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)
#calculations for movement for c in cnts: area=cv2.contourArea(c) if Move_low<area<Move_high: movement+=1 #counter check if(counter_prev==counter): counter_check+=1 else: counter_check=0 #send try: if (counter!=counter_prev) or (counter_check>=check): con.send({'sensor': ID, 'activity': movement,'Roger':counter}) counter_check=0 counter_prev=counter #if server down, I will try to connect again except: con = RBConnection('ID',IP, port) #display the values if keyA: print "CountB=%d" %counter print "Move=%d" %movement #drawing a rectangle over the interested area <---remove this after tunning if keyA: cv2.rectangle(image_with_blobs,(X_low,Y_low),(X_high,Y_high),(255,0,0),1)