Beispiel #1
0
    def new_data_callback(self, packet):
        message_type = packet.get_int()
        if message_type == VV_ACK_OK:
          server_ip = packet.get_string()
          server_port = packet.get_int()
          self.client_id = packet.get_int()
          logging.info("Connection Established.")

          w = SocketPacket()
          w.add_int(VP_SESSION)
          w.add_int(self.client_id)
          w.add_char(SESSION_TYPE)
          w.add_char(self.pipeline)
          w.add_int(self.req_cam_id)
          w.encode_header()
          self.write_packet(w)


        elif message_type == VV_VP_ACK_OK:
          packet.get_string()
          packet.get_int()
          self.cam_id = packet.get_int()
          self.connected = True


        elif message_type == VV_REQ_VIDEO_ANALYSIS:
            logging.debug("VV_REQ_VIDEO_ANALYSIS")
            ip = packet.get_string()
            port = packet.get_int()
            self.camera_id = packet.get_int()
            self.SetTitle("Camera %s Controller" % self.camera_id)


        elif message_type == VV_IMG:
            logging.debug("NEW IMAGE")
            server_ip = packet.get_string()
            server_port = packet.get_int()
            cam_id = packet.get_int()
            width = packet.get_int()
            height = packet.get_int()
            depth = packet.get_int()
            color_code = packet.get_char()
            jpeg =  packet.get_bool()
            time = packet.get_double()
            image = packet.get_string()

            cv_im = self.createImage(image, width, height, depth, color_code, jpeg)
            self.camera_id = cam_id
            if self.save_images:
                cv.SaveImage("cam%s_%s.jpg" % (cam_id, self.count), cv_im)
                self.count+=1
            else:
		cv.ShowImage("Image", cv_im)
            cv.WaitKey()
    def new_data_callback(self, packet, index):
        message_type = packet.get_int()
        if message_type == VV_ACK_OK:
            server_ip = packet.get_string()
            server_port = packet.get_int()
            self.client_ids[index] = packet.get_int()
            logging.info("Connection Established.")

            w = SocketPacket()
            w.add_int(VP_SESSION)
            w.add_int(self.client_ids[index])
            w.add_char(SESSION_TYPE)
            w.add_char(self.pipeline[index])
            w.add_int(int(self.camera_numbers[index]))
            w.encode_header()
            self.write_packet(w, index)

        elif message_type == VV_VP_ACK_OK:
            packet.get_string()
            packet.get_int()
            cam_id = packet.get_int()

        elif message_type == VV_REQ_VIDEO_ANALYSIS:
            logging.debug("VV_REQ_VIDEO_ANALYSIS")
            ip = packet.get_string()
            port = packet.get_int()
            camera_id = packet.get_int()

        elif message_type == VV_IMG:
            logging.debug("NEW IMAGE")
            server_ip = packet.get_string()
            server_port = packet.get_int()
            cam_id = packet.get_int()
            width = packet.get_int()
            height = packet.get_int()
            depth = packet.get_int()
            color_code = packet.get_char()
            jpeg = packet.get_bool()
            time = packet.get_double()
            image = packet.get_string()
            cv_im = self.createImage(image, width, height, depth, color_code,
                                     jpeg)
            index_camera_numbers = self.camera_numbers.index(str(cam_id))
            cv.SaveImage(
                "cam%s_%s.jpg" % (cam_id, self.counts[index_camera_numbers]),
                cv_im)
            self.counts[index_camera_numbers] += 1
            cv.ShowImage("Image", cv_im)
            cv.WaitKey()
    def new_data_callback(self, packet, index):
        message_type = packet.get_int()
        if message_type == VV_ACK_OK:
	    server_ip = packet.get_string()
	    server_port = packet.get_int()
	    self.client_ids[index] = packet.get_int()
	    logging.info("Connection Established.")

	    w = SocketPacket()
	    w.add_int(VP_SESSION)
	    w.add_int(self.client_ids[index])
	    w.add_char(SESSION_TYPE)
	    w.add_char(self.pipeline[index])
	    w.add_int(int(self.camera_numbers[index]))
	    w.encode_header()
	    self.write_packet(w, index)

        elif message_type == VV_VP_ACK_OK:
	    packet.get_string()
	    packet.get_int()
	    cam_id = packet.get_int()

        elif message_type == VV_REQ_VIDEO_ANALYSIS:
            logging.debug("VV_REQ_VIDEO_ANALYSIS")
            ip = packet.get_string()
            port = packet.get_int()
            camera_id = packet.get_int()
            
	elif message_type == VV_IMG:
            logging.debug("NEW IMAGE")
            server_ip = packet.get_string()
            server_port = packet.get_int()
            cam_id = packet.get_int()
            width = packet.get_int()
            height = packet.get_int()
            depth = packet.get_int()
            color_code = packet.get_char()
            jpeg =  packet.get_bool()
            time = packet.get_double()
            image = packet.get_string()
            cv_im = self.createImage(image, width, height, depth, color_code, jpeg)
            index_camera_numbers = self.camera_numbers.index(str(cam_id))
            cv.SaveImage("cam%s_%s.jpg" % (cam_id, self.counts[index_camera_numbers]), cv_im)
            self.counts[index_camera_numbers] += 1
	    cv.ShowImage("Image", cv_im)
            cv.WaitKey()