Mercurial > hg > pymctf
view test.py @ 6:301673f39ff6 default tip
fix numpy import check
author | pmeerw@pan |
---|---|
date | Tue, 06 May 2008 22:24:13 +0200 |
parents | 4214d9245f8e |
children |
line wrap: on
line source
#!/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)