In [1]:
%matplotlib inline
%pylab inline


Populating the interactive namespace from numpy and matplotlib

In [19]:
import cv2
from menpofast.utils import convert_to_menpo 
from menpofast.image import Image

fr = Image(np.random.randn(3, 100, 100))

fitter_results = [fr] * 100000

# Define the codec and create VideoWriter object
out = cv2.VideoWriter('/data/output.avi', cv2.cv.CV_FOURCC('P','I','M','1'), 20.0, fr.shape[::-1])

for fr in fitter_results:
    
    frame = np.require(np.round(convert_to_menpo(fr).pixels * 255), dtype=np.uint8)

    #for l in fr.final_shape.points:
    #    cv2.circle(frame, (int(l[1]), int(l[0])), radius=1, color=(0, 255, 0), thickness=2)
    
    out.write(frame)

out.release()


---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
<ipython-input-19-3babdeb27785> in <module>()
     12 for fr in fitter_results:
     13 
---> 14     frame = np.require(np.round(convert_to_menpo(fr).pixels * 255), dtype=np.uint8)
     15 
     16     #for l in fr.final_shape.points:

/data/pythondev/src/menpofast/menpofast/utils.pyc in convert_to_menpo(image)
     33     if cls is Image:
     34         menpo_image = cls(np.rollaxis(image.pixels,  0, image.n_dims+1),
---> 35                           copy=True)
     36     elif cls is MaskedImage:
     37         menpo_image = cls(np.rollaxis(image.pixels, 0, image.n_dims+1),

/data/pythondev/src/menpofast/menpofast/image/base.pyc in __init__(self, image_data, copy)
     97                      'Please ensure the data you pass is C-contiguous.')
     98         else:
---> 99             image_data = np.array(image_data, copy=True, order='C')
    100             # Degenerate case whereby we can just put the extra axis
    101             # on ourselves

KeyboardInterrupt: 

In [18]:
len(fitter_results)


Out[18]:
90

In [ ]: