def read(self): rval, im = self._read() if not rval: self.release() print_green('Waiting for new connection') self.init(self.ip, self.port) rval, im = self._read() return im
def init(self, ip, port): self.s_ = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.s_.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) print_green('Hostname: {:} READY'.format(socket.gethostname())) self.s_.bind((self.ip_, self.port_)) self.s_.listen(1) self.conn_, self.addr_ = self.s_.accept()
def run(self): rval = True while rval: start = time.time() rval, im = cap._read() end = time.time() if not rval: self.release() print_green('Waiting for new connection') self.init(self.ip_, self.port_) rval = True continue self.on_image(self, im)
def print_stats(self, finish=False): print_green( 'Sampler: Total: {:}, Samples: {:}, Ratio: {:3.2f} %'.format( self.all_items_.index, self.sampled_items_.index, self.sampled_items_.index * 100.0 / self.all_items_.index))