view test.py @ 5:b235e08ebd04

cleaner recursion, eliminate parameters
author Peter Meerwald <pmeerw@cosy.sbg.ac.at>
date Tue, 18 Dec 2007 15:16:56 +0100
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)

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