예제 #1
0
 def activate(source_uid):
     if not source_uid:
         return
     if not uvc.is_accessible(source_uid):
         logger.error(
             "The selected camera is already in use or blocked.")
         return
     settings = {
         'frame_size': self.g_pool.capture.frame_size,
         'frame_rate': self.g_pool.capture.frame_rate,
         'uid': source_uid
     }
     if self.g_pool.process == 'world':
         self.notify_all({
             'subject': 'start_plugin',
             "name": "UVC_Source",
             'args': settings
         })
     else:
         self.notify_all({
             'subject': 'start_eye_capture',
             'target': self.g_pool.process,
             "name": "UVC_Source",
             'args': settings
         })
예제 #2
0
    def activate_source(self, source_uid):
        if not source_uid:
            return

        try:
            if not uvc.is_accessible(source_uid):
                logger.error(
                    "The selected camera is already in use or blocked.")
                return
        except ValueError as ve:
            logger.error(str(ve))
            return

        settings = {
            "frame_size": self.g_pool.capture.frame_size,
            "frame_rate": self.g_pool.capture.frame_rate,
            "uid": source_uid,
        }
        if self.g_pool.process == "world":
            self.notify_all({
                "subject": "start_plugin",
                "name": "UVC_Source",
                "args": settings
            })
        else:
            self.notify_all({
                "subject": "start_eye_plugin",
                "target": self.g_pool.process,
                "name": "UVC_Source",
                "args": settings,
            })
예제 #3
0
    def activate(self, source_uid):
        if not source_uid:
            return

        try:
            if not uvc.is_accessible(source_uid):
                logger.error("The selected camera is already in use or blocked.")
                return
        except ValueError as ve:
            logger.error(str(ve))
            return

        settings = {
            "frame_size": self.g_pool.capture.frame_size,
            "frame_rate": self.g_pool.capture.frame_rate,
            "uid": source_uid,
        }
        if self.g_pool.process == "world":
            self.notify_all(
                {"subject": "start_plugin", "name": "UVC_Source", "args": settings}
            )
        else:
            self.notify_all(
                {
                    "subject": "start_eye_capture",
                    "target": self.g_pool.process,
                    "name": "UVC_Source",
                    "args": settings,
                }
            )
예제 #4
0
파일: uvc_backend.py 프로젝트: papr/pupil
 def activate(source_uid):
     if not source_uid:
         return
     if not uvc.is_accessible(source_uid):
         logger.error("The selected camera is already in use or blocked.")
         return
     settings = {
         'source_class_name': UVC_Source.class_name(),
         'frame_size': self.g_pool.capture.frame_size,
         'frame_rate': self.g_pool.capture.frame_rate,
         'uid': source_uid
     }
     self.activate_source(settings)
예제 #5
0
 def gui_init_cam_by_uid(requested_id):
     if requested_id is None:
         self.re_init_capture(None)
     else:
         for cam in uvc.device_list():
             if cam['uid'] == requested_id:
                 if is_accessible(requested_id):
                     self.re_init_capture(requested_id)
                 else:
                     logger.error("The selected Camera is already in use or blocked.")
                 return
         logger.warning("could not reinit capture, src_id not valid anymore")
         return
예제 #6
0
 def gui_init_cam_by_uid(requested_id):
     if requested_id is None:
         self.re_init_capture(None)
     else:
         for cam in uvc.device_list():
             if cam['uid'] == requested_id:
                 if is_accessible(requested_id):
                     self.re_init_capture(requested_id)
                 else:
                     logger.error("The selected Camera is already in use or blocked.")
                 return
         logger.warning("could not reinit capture, src_id not valid anymore")
         return
예제 #7
0
 def activate(source_uid):
     if not source_uid:
         return
     if not uvc.is_accessible(source_uid):
         logger.error("The selected camera is already in use or blocked.")
         return
     settings = {
         'source_class_name': UVC_Source.class_name(),
         'frame_size': self.g_pool.capture.frame_size,
         'frame_rate': self.g_pool.capture.frame_rate,
         'uid': source_uid
     }
     self.activate_source(settings)
예제 #8
0
 def activate(source_uid):
     if not source_uid:
         return
     if not uvc.is_accessible(source_uid):
         logger.error("The selected camera is already in use or blocked.")
         return
     settings = {
         'frame_size': self.g_pool.capture.frame_size,
         'frame_rate': self.g_pool.capture.frame_rate,
         'uid': source_uid
     }
     if self.g_pool.process == 'world':
         self.notify_all({'subject': 'start_plugin', "name": "UVC_Source", 'args': settings})
     else:
         self.notify_all({'subject': 'start_eye_capture', 'target': self.g_pool.process, "name": "UVC_Source", 'args': settings})
예제 #9
0
                "res"             : None,
                "def"             : 0,
                "caption"         : 'Frame Rate',
                "readonly"        : False,
                "map"             : [{
                    'value'  : idx,
                    'caption': '%.1f Hz'%fr
                } for idx,fr in enumerate(self.cap.frame_rates)]
            }
        })

    def bind(self, ctx, sock_type, url, public_ep, set_hwm=None):
        sock = ctx.socket(sock_type)
        if set_hwm: sock.set_hwm(set_hwm)
        sock.bind(url)
        ep = sock.last_endpoint
        port = ep.split(':')[-1]
        public_ep.split(':')[-1]
        public_addr = public_ep.split(':')[:-1]
        return sock, ':'.join(public_addr+[port])

if __name__ == '__main__':
    uuid = None
    dev_list =  uvc.Device_List()
    for dev in dev_list:
        uuid = dev['uid']
        if uvc.is_accessible(uuid):
            break

    if uuid: Bridge(uuid).loop()
예제 #10
0
                "caption": 'Frame Rate',
                "readonly": False,
                "map": [{
                    'value': idx,
                    'caption': '{:.1f} Hz'.format(fr)
                } for idx, fr in enumerate(self.cap.frame_rates)]
            }
        })

    def bind(self, ctx, sock_type, url, public_ep, set_hwm=None):
        sock = ctx.socket(sock_type)
        if set_hwm:
            sock.set_hwm(set_hwm)
        sock.bind(url)
        ep = sock.last_endpoint.decode()
        port = ep.split(':')[-1]
        public_ep.split(':')[-1]
        public_addr = public_ep.split(':')[:-1]
        return sock, ':'.join(public_addr+[port])


if __name__ == '__main__':
    uuid = None
    dev_list = uvc.Device_List()
    for dev in dev_list:
        uuid = dev['uid']
        if uvc.is_accessible(uuid):
            break
    if uuid:
        Bridge(uuid).loop()