annotate test.py @ 3:0e5a584fd6b2

add apply_mc()
author Peter Meerwald <pmeerw@cosy.sbg.ac.at>
date Tue, 18 Dec 2007 10:04:01 +0100
parents 4214d9245f8e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
1 #!/usr/bin/env python
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
2
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
3 import pymctf
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
4 import sys
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
5 import numpy
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
6 import time
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
7
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
8 # CIF
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
9 size = 352, 288
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
10 subsampling = 2, 2
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
11 chroma_size = size[0]//subsampling[0], size[1]//subsampling[1]
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
12
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
13 fname = 'foreman-cif.yuv'
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
14
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
15 f = open(fname, 'rb')
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
16 frame0 = f.read(size[0]*size[1] + 2*chroma_size[0]*chroma_size[1])
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
17 frame1 = f.read(size[0]*size[1] + 2*chroma_size[0]*chroma_size[1])
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
18 f.close()
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
19
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
20 if not frame0 or not frame1:
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
21 print >>sys.stderr, 'failed to read YUV input, exit.'
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
22 sys.exit(1)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
23
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
24 frame0 = numpy.asarray(numpy.fromstring(frame0[:size[0]*size[1]], numpy.uint8), numpy.float).reshape((size[1], size[0]))
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
25 frame1 = numpy.asarray(numpy.fromstring(frame1[:size[0]*size[1]], numpy.uint8), numpy.float).reshape((size[1], size[0]))
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
26
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
27 sad, mvf = pymctf.motion_estimation(frame0, frame1, blocksize=8, searchrange=32, hlevel=1)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
28
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
29 print time.clock()
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
30 print sad
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
31
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
32 sys.exit(0)

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