diff test.py @ 0:4214d9245f8e

import
author Peter Meerwald <pmeerw@cosy.sbg.ac.at>
date Thu, 06 Sep 2007 13:45:48 +0200
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test.py	Thu Sep 06 13:45:48 2007 +0200
@@ -0,0 +1,32 @@
+#!/usr/bin/env python
+
+import pymctf
+import sys
+import numpy
+import time
+
+# CIF
+size = 352, 288
+subsampling = 2, 2
+chroma_size = size[0]//subsampling[0], size[1]//subsampling[1]
+
+fname = 'foreman-cif.yuv'
+
+f = open(fname, 'rb')
+frame0 = f.read(size[0]*size[1] + 2*chroma_size[0]*chroma_size[1])
+frame1 = f.read(size[0]*size[1] + 2*chroma_size[0]*chroma_size[1])
+f.close()
+
+if not frame0 or not frame1: 
+    print >>sys.stderr, 'failed to read YUV input, exit.'
+    sys.exit(1)
+
+frame0 = numpy.asarray(numpy.fromstring(frame0[:size[0]*size[1]], numpy.uint8), numpy.float).reshape((size[1], size[0]))
+frame1 = numpy.asarray(numpy.fromstring(frame1[:size[0]*size[1]], numpy.uint8), numpy.float).reshape((size[1], size[0]))
+
+sad, mvf = pymctf.motion_estimation(frame0, frame1, blocksize=8, searchrange=32, hlevel=1)
+
+print time.clock()
+print sad
+
+sys.exit(0)

Repositories maintained by Peter Meerwald, pmeerw@pmeerw.net.