annotate 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
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.