コード例 #1
0
 def default(self, event):
     w = SocketPacket()
     w.add_int(VP_CAM_DEFAULT)
     w.add_int(self.client_id)
     w.add_int(self.cam_id)
     w.encode_header()
     self.write_packet(w)
コード例 #2
0
 def default(self, event):
     w = SocketPacket()
     w.add_int(VP_CAM_DEFAULT)
     w.add_int(self.client_id)
     w.add_int(self.cam_id)
     w.encode_header()
     self.write_packet(w)
コード例 #3
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.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
            cv.ShowImage("Image", cv_im)
            if self.save_images:
                cv.SaveImage("cam%s_%s.jpg" % (cam_id, self.count), cv_im)
                self.count+=1
            cv.WaitKey()
コード例 #4
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.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
            cv.ShowImage("Image", cv_im)
            if self.save_images:
                cv.SaveImage("cam%s_%s.jpg" % (cam_id, self.count), cv_im)
                self.count += 1
            cv.WaitKey()
コード例 #5
0
 def setResolution(self, event):
     try:
         width = int(self.width.GetValue())
         height = int(self.height.GetValue())
         self.width.SetValue("")
         self.height.SetValue("")
     except Exception as e:
         logging.error("Resolution is not valid!")
     else:
         w = SocketPacket()
         w.add_int(VP_CAM_RESOLUTION)
         w.add_int(self.client_id)
         w.add_int(self.cam_id)
         w.add_int(width)
         w.add_int(height)
         w.encode_header()
         self.write_packet(w)
コード例 #6
0
 def setResolution(self, event):
     try:
         width = int(self.width.GetValue())
         height = int(self.height.GetValue())
         self.width.SetValue("")
         self.height.SetValue("")
     except Exception as e:
         logging.error("Resolution is not valid!")
     else:
         w = SocketPacket()
         w.add_int(VP_CAM_RESOLUTION)
         w.add_int(self.client_id)
         w.add_int(self.cam_id)
         w.add_int(width)
         w.add_int(height)
         w.encode_header()
         self.write_packet(w)
コード例 #7
0
 def getImage(self, event):
     w = SocketPacket()
     w.add_int(VP_CAM_IMAGE)
     w.add_int(self.client_id)
     w.add_int(self.cam_id)
     w.encode_header()
     self.write_packet(w)
コード例 #8
0
 def getImage(self, event):
     w = SocketPacket()
     w.add_int(VP_CAM_IMAGE)
     w.add_int(self.client_id)
     w.add_int(self.cam_id)
     w.encode_header()
     self.write_packet(w)
コード例 #9
0
    def customZoom(self, event):
        w = SocketPacket()
	w.add_int(VP_CAM_ZOOM)
        w.add_int(self.client_id)
        w.add_int(self.cam_id)
        w.add_float(event.GetDegrees())
	w.add_float(event.GetSpeed())
        w.encode_header()
        self.write_packet(w)
コード例 #10
0
    def pan(self, direction, degrees = 10, speed = DEFAULT_PAN_SPEED):
        angle = direction * degrees
        w = SocketPacket()
        w.add_int(VP_CAM_PAN)
        w.add_int(self.client_id)
        w.add_int(self.cam_id)
        w.add_float(angle)
	w.add_float(speed)
        w.encode_header()
        self.write_packet(w)
コード例 #11
0
    def getImage(self, event):
	button = event.GetEventObject()
	name_words_list = (button.GetName()).split()
	camera_number = int(name_words_list[4])
	w = SocketPacket()
        w.add_int(VP_CAM_IMAGE)
        index_camera_numbers = self.camera_numbers.index(str(camera_number))
        w.add_int(self.client_ids[index_camera_numbers])
        w.add_int(camera_number)
        w.encode_header()
        self.write_packet(w, index_camera_numbers)
コード例 #12
0
 def getImage(self, event):
     button = event.GetEventObject()
     name_words_list = (button.GetName()).split()
     camera_number = int(name_words_list[4])
     w = SocketPacket()
     w.add_int(VP_CAM_IMAGE)
     index_camera_numbers = self.camera_numbers.index(str(camera_number))
     w.add_int(self.client_ids[index_camera_numbers])
     w.add_int(camera_number)
     w.encode_header()
     self.write_packet(w, index_camera_numbers)
コード例 #13
0
 def zoomOut(self, event):
     button = event.GetEventObject()
     name_words_list = (button.GetName()).split()
     camera_number = int(name_words_list[2])
     indexTextCtrl = int(name_words_list[4])
     w = SocketPacket()
     w.add_int(VP_CAM_ZOOM)
     index_camera_numbers = self.camera_numbers.index(str(camera_number))
     w.add_int(self.client_ids[index_camera_numbers])
     w.add_int(camera_number)
     w.add_float(10.0)
     w.add_float(DEFAULT_ZOOM_SPEED)
     w.encode_header()
     self.write_packet(w, index_camera_numbers)
コード例 #14
0
    def zoomOut(self, event):
	button = event.GetEventObject()
	name_words_list = (button.GetName()).split()
	camera_number = int(name_words_list[2])
	indexTextCtrl = int(name_words_list[4])
	w = SocketPacket()
	w.add_int(VP_CAM_ZOOM)
	index_camera_numbers = self.camera_numbers.index(str(camera_number))
	w.add_int(self.client_ids[index_camera_numbers])
	w.add_int(camera_number)
	w.add_float(10.0)
	w.add_float(DEFAULT_ZOOM_SPEED)
	w.encode_header()
	self.write_packet(w, index_camera_numbers)
コード例 #15
0
    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()
コード例 #16
0
    def zoom(self, event):
        id = event.GetEventObject().GetId()

        if id == 104:
            direction = -1

        else:
            direction = 1

        angle = direction * 10
        w = SocketPacket()
        w.add_int(VP_CAM_ZOOM)
        w.add_int(self.client_id)
        w.add_int(self.cam_id)
        w.add_float(angle)
        w.encode_header()
        self.write_packet(w)
コード例 #17
0
    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()
コード例 #18
0
    def zoom(self, event):
        id = event.GetEventObject().GetId()

        if id == 104:
            direction = -1

        else:
            direction = 1

        angle = direction * 10
        w = SocketPacket()
        w.add_int(VP_CAM_ZOOM)
        w.add_int(self.client_id)
        w.add_int(self.cam_id)
        w.add_float(angle)
        w.encode_header()
        self.write_packet(w)
コード例 #19
0
    def zoom(self, event):
	button = event.GetEventObject()
	name_words_list = (button.GetName()).split()
	camera_number = int(name_words_list[2])
	indexTextCtrl = int(name_words_list[4])
	angle_string = (self.zoom_angle_values[indexTextCtrl]).GetValue()
	speed_string = (self.zoom_speed_values[indexTextCtrl]).GetValue()
	angle = float(angle_string)
	speed = float(speed_string)
	w = SocketPacket()
	w.add_int(VP_CAM_CUSTOM_ZOOM)
	index_camera_numbers = self.camera_numbers.index(str(camera_number))
	w.add_int(self.client_ids[index_camera_numbers])
	w.add_int(camera_number)
	w.add_float(angle)
	w.add_float(speed)
	w.encode_header()
	self.write_packet(w, index_camera_numbers)
コード例 #20
0
 def zoom(self, event):
     button = event.GetEventObject()
     name_words_list = (button.GetName()).split()
     camera_number = int(name_words_list[2])
     indexTextCtrl = int(name_words_list[4])
     angle_string = (self.zoom_angle_values[indexTextCtrl]).GetValue()
     speed_string = (self.zoom_speed_values[indexTextCtrl]).GetValue()
     angle = float(angle_string)
     speed = float(speed_string)
     w = SocketPacket()
     w.add_int(VP_CAM_CUSTOM_ZOOM)
     index_camera_numbers = self.camera_numbers.index(str(camera_number))
     w.add_int(self.client_ids[index_camera_numbers])
     w.add_int(camera_number)
     w.add_float(angle)
     w.add_float(speed)
     w.encode_header()
     self.write_packet(w, index_camera_numbers)
コード例 #21
0
    def tilt(self, event):
        id = event.GetEventObject().GetId()

        if id == 102:
            direction = 1

        else:
            direction = -1

        angle = direction * 10
        w = SocketPacket()
        w.add_int(VP_CAM_TILT)
        w.add_int(self.client_id)
        w.add_int(self.cam_id)
        w.add_float(angle)
        w.add_float(DEFAULT_TILT_SPEED)
        w.encode_header()
        self.write_packet(w)