Exemplo n.º 1
0
def Video2IplList(i_file, i_scale=1.0, i_reverse_list=False):
    from frame_grabber import FrameGrabberFile
    """Return a list of video frames in opencv format - first frame first in list if i_reverse_list=False, otherwise first frame is last"""
    frame_grabber = FrameGrabberFile(i_file, i_loop_back = False)
    o_data = [] 

    while True:
        current_frame = frame_grabber.nextFrame() 
        if current_frame == None:
            break
        else:
            current_frame = frame_grabber.currentFrame()
            w = int( i_scale * float(current_frame.width) + 0.5 )
            h = int( i_scale * float(current_frame.height) + 0.5 )
            o_data.append( IplResizeAndConvert(current_frame,w,h) )
    if i_reverse_list:
        o_data.reverse()
    return o_data
Exemplo n.º 2
0
def Video2IplList(i_file, i_scale=1.0, i_reverse_list=False):
    from frame_grabber import FrameGrabberFile
    """Return a list of video frames in opencv format - first frame first in list if i_reverse_list=False, otherwise first frame is last"""
    frame_grabber = FrameGrabberFile(i_file, i_loop_back=False)
    o_data = []

    while True:
        current_frame = frame_grabber.nextFrame()
        if current_frame == None:
            break
        else:
            current_frame = frame_grabber.currentFrame()
            w = int(i_scale * float(current_frame.width) + 0.5)
            h = int(i_scale * float(current_frame.height) + 0.5)
            o_data.append(IplResizeAndConvert(current_frame, w, h))
    if i_reverse_list:
        o_data.reverse()
    return o_data
Exemplo n.º 3
0
def Video2Numpy( i_file, i_scale=1. ):
    from frame_grabber import FrameGrabberFile
    """Return a 3D numpy array from a video file"""
    frame_grabber = FrameGrabberFile(i_file, i_loop_back = False)
    o_data = None 
    nframes = 0
    while True:
        current_frame = frame_grabber.nextFrame() 
        if current_frame == None:
            break
        else:
            current_frame = frame_grabber.currentFrame()
            w = int( i_scale * float(current_frame.width) + 0.5 )
            h = int( i_scale * float(current_frame.height) + 0.5 )
            image = IplResizeAndConvert(current_frame,w,h)
            image = cv.Ipl2NumPy(image)
            if o_data == None:
                o_data = image 
            else:
                o_data = numpy.dstack([o_data, image])
    return o_data
Exemplo n.º 4
0
def Video2Numpy(i_file, i_scale=1.):
    from frame_grabber import FrameGrabberFile
    """Return a 3D numpy array from a video file"""
    frame_grabber = FrameGrabberFile(i_file, i_loop_back=False)
    o_data = None
    nframes = 0
    while True:
        current_frame = frame_grabber.nextFrame()
        if current_frame == None:
            break
        else:
            current_frame = frame_grabber.currentFrame()
            w = int(i_scale * float(current_frame.width) + 0.5)
            h = int(i_scale * float(current_frame.height) + 0.5)
            image = IplResizeAndConvert(current_frame, w, h)
            image = cv.Ipl2NumPy(image)
            if o_data == None:
                o_data = image
            else:
                o_data = numpy.dstack([o_data, image])
    return o_data