image_write_speed.py
Go to the documentation of this file.
00001 
00002 from opencv.cv import *
00003 from opencv.highgui import *
00004 
00005 import time
00006 
00007 
00008 def write_separate_frames(n_frames, cvim):
00009     for i in range(n_frames):
00010         cvSaveImage('b.png', cvim)
00011         print 'done %d'%i
00012 
00013 def write_video(n_frames, cvim):
00014     vwr = cvCreateVideoWriter('b.avi', CV_FOURCC('I','4','2','0'),
00015     #vwr = cvCreateVideoWriter('b.avi', CV_FOURCC_DEFAULT,
00016                               30, cvGetSize(cvim), True)
00017 
00018     for i in range(n_frames):
00019         cvWriteFrame(vwr, cvim)
00020         print 'done %d'%i
00021 
00022 
00023 if __name__ == '__main__':
00024     
00025     print 'Hello World'
00026 
00027     cvim = cvLoadImage('a.png')
00028 
00029     n_frames = 100
00030 
00031     t0 = time.time()
00032     #write_separate_frames(n_frames, cvim)
00033     write_video(n_frames, cvim)
00034     t1 = time.time()
00035 
00036     print 'Writing rate: ', n_frames/(t1-t0)
00037 
00038 


2010_biorob_everyday_mechanics
Author(s): Advait Jain, Hai Nguyen, Charles C. Kemp (Healthcare Robotics Lab, Georgia Tech)
autogenerated on Wed Nov 27 2013 11:58:43