Exemple #1
0
def uid_from_name(pattern):
    # looking for attached cameras that match the suggested names
    # give precedence to camera that matches the first pattern in list.
    matching_devices = []
    attached_devices = device_list()
    for name_pattern in pattern:
        for device in attached_devices:
            if name_pattern in device['name']:
                if is_accessible(device['uid']):
                    return device['uid']
                else:
                    logger.warning("Camera '%s' matches the pattern but is already in use"%device['name'])
    logger.error('No accessible device found that matched %s'%pattern)
Exemple #2
0
def uid_from_name(pattern):
    # looking for attached cameras that match the suggested names
    # give precedence to camera that matches the first pattern in list.
    matching_devices = []
    attached_devices = device_list()
    for name_pattern in pattern:
        for device in attached_devices:
            if name_pattern in device['name']:
                if is_accessible(device['uid']):
                    return device['uid']
                else:
                    logger.warning(
                        "Camera '%s' matches the pattern but is already in use"
                        % device['name'])
    logger.error('No accessible device found that matched %s' % pattern)
Exemple #3
0
def autoCreateCapture(src, timestamps=None, timebase=None):
    '''
    src can be one of the following:
     - a path to video file
     - patter of name matches
     - a device index
     - None
    '''
    # video source
    if type(src) is str and os.path.isfile(src):
        return File_Capture(src, timestamps=timestamps)

    # live src - select form idx
    if type(src) == int:
        try:
            uid = device_list()[src]['uid']
        except IndexError:
            logger.warning("UVC Camera at index:'%s' not found." % src)
            src = None
        else:
            if is_accessible(uid):
                logger.info("UVC Camera with id:'%s' selected." % src)
                return Camera_Capture(uid, timebase=timebase)
            else:
                logger.warning(
                    "Camera selected by id matches is found but already in use"
                )
                src = None

    # live src - select form pattern
    elif type(src) in (list, tuple):
        src = uid_from_name(src)

    # fake capture
    if src is None:
        logger.warning("Starting with Fake_Capture.")

    return Camera_Capture(src, timebase=timebase)
Exemple #4
0
def autoCreateCapture(src,timestamps=None,timebase = None):
    '''
    src can be one of the following:
     - a path to video file
     - patter of name matches
     - a device index
     - None
    '''
    # video source
    if type(src) is str and os.path.isfile(src):
        return File_Capture(src,timestamps=timestamps)

    # live src - select form idx
    if type(src) == int:
        try:
            uid = device_list()[src]['uid']
        except IndexError:
            logger.warning("UVC Camera at index:'%s' not found."%src)
            src = None
        else:
            if is_accessible(uid):
                logger.info("UVC Camera with id:'%s' selected."%src)
                return Camera_Capture(uid,timebase=timebase)
            else:
                logger.warning("Camera selected by id matches is found but already in use")
                src = None

    # live src - select form pattern
    elif type(src) in (list,tuple):
        src = uid_from_name(src)

    # fake capture
    if src is None:
        logger.warning("Starting with Fake_Capture.")

    return Camera_Capture(src,timebase=timebase)