Various Python samples updated for Python 2/3 compatibility.
This commit is contained in:
@@ -12,6 +12,14 @@ browse.py [image filename]
|
||||
|
||||
'''
|
||||
|
||||
# Python 2/3 compatibility
|
||||
from __future__ import print_function
|
||||
import sys
|
||||
PY3 = sys.version_info[0] == 3
|
||||
|
||||
if PY3:
|
||||
xrange = range
|
||||
|
||||
import numpy as np
|
||||
import cv2
|
||||
|
||||
@@ -19,21 +27,21 @@ import cv2
|
||||
import sys
|
||||
|
||||
if __name__ == '__main__':
|
||||
print 'This sample shows how to implement a simple hi resolution image navigation.'
|
||||
print 'USAGE: browse.py [image filename]'
|
||||
print
|
||||
print('This sample shows how to implement a simple hi resolution image navigation.')
|
||||
print('USAGE: browse.py [image filename]')
|
||||
print()
|
||||
|
||||
if len(sys.argv) > 1:
|
||||
fn = sys.argv[1]
|
||||
print 'loading %s ...' % fn
|
||||
print('loading %s ...' % fn)
|
||||
img = cv2.imread(fn)
|
||||
if img is None:
|
||||
print 'Failed to load fn:', fn
|
||||
print('Failed to load fn:', fn)
|
||||
sys.exit(1)
|
||||
|
||||
else:
|
||||
sz = 4096
|
||||
print 'generating %dx%d procedural image ...' % (sz, sz)
|
||||
print('generating %dx%d procedural image ...' % (sz, sz))
|
||||
img = np.zeros((sz, sz), np.uint8)
|
||||
track = np.cumsum(np.random.rand(500000, 2)-0.5, axis=0)
|
||||
track = np.int32(track*10 + (sz/2, sz/2))
|
||||
|
Reference in New Issue
Block a user