mirror of
https://github.com/opencv/opencv.git
synced 2025-01-18 14:13:15 +08:00
Fixed shebangs, added error checking
This commit is contained in:
parent
c0ba0c9099
commit
bd042d9cc3
@ -1,4 +1,4 @@
|
|||||||
#/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Utility for measuring python opencv API coverage by samples.
|
Utility for measuring python opencv API coverage by samples.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Scans current directory for *.py files and reports
|
Scans current directory for *.py files and reports
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Affine invariant feature-based image matching sample.
|
Affine invariant feature-based image matching sample.
|
||||||
@ -21,9 +21,12 @@ USAGE
|
|||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import cv2
|
import cv2
|
||||||
|
|
||||||
|
# built-in modules
|
||||||
import itertools as it
|
import itertools as it
|
||||||
from multiprocessing.pool import ThreadPool
|
from multiprocessing.pool import ThreadPool
|
||||||
|
|
||||||
|
# local modules
|
||||||
from common import Timer
|
from common import Timer
|
||||||
from find_obj import init_feature, filter_matches, explore_match
|
from find_obj import init_feature, filter_matches, explore_match
|
||||||
|
|
||||||
@ -85,15 +88,18 @@ def affine_detect(detector, img, mask=None, pool=None):
|
|||||||
if descrs is None:
|
if descrs is None:
|
||||||
descrs = []
|
descrs = []
|
||||||
return keypoints, descrs
|
return keypoints, descrs
|
||||||
|
|
||||||
keypoints, descrs = [], []
|
keypoints, descrs = [], []
|
||||||
if pool is None:
|
if pool is None:
|
||||||
ires = it.imap(f, params)
|
ires = it.imap(f, params)
|
||||||
else:
|
else:
|
||||||
ires = pool.imap(f, params)
|
ires = pool.imap(f, params)
|
||||||
|
|
||||||
for i, (k, d) in enumerate(ires):
|
for i, (k, d) in enumerate(ires):
|
||||||
print 'affine sampling: %d / %d\r' % (i+1, len(params)),
|
print 'affine sampling: %d / %d\r' % (i+1, len(params)),
|
||||||
keypoints.extend(k)
|
keypoints.extend(k)
|
||||||
descrs.extend(d)
|
descrs.extend(d)
|
||||||
|
|
||||||
print
|
print
|
||||||
return keypoints, np.array(descrs)
|
return keypoints, np.array(descrs)
|
||||||
|
|
||||||
@ -104,7 +110,8 @@ if __name__ == '__main__':
|
|||||||
opts, args = getopt.getopt(sys.argv[1:], '', ['feature='])
|
opts, args = getopt.getopt(sys.argv[1:], '', ['feature='])
|
||||||
opts = dict(opts)
|
opts = dict(opts)
|
||||||
feature_name = opts.get('--feature', 'sift-flann')
|
feature_name = opts.get('--feature', 'sift-flann')
|
||||||
try: fn1, fn2 = args
|
try:
|
||||||
|
fn1, fn2 = args
|
||||||
except:
|
except:
|
||||||
fn1 = 'data/aero1.jpg'
|
fn1 = 'data/aero1.jpg'
|
||||||
fn2 = 'data/aero3.jpg'
|
fn2 = 'data/aero3.jpg'
|
||||||
@ -112,11 +119,20 @@ if __name__ == '__main__':
|
|||||||
img1 = cv2.imread(fn1, 0)
|
img1 = cv2.imread(fn1, 0)
|
||||||
img2 = cv2.imread(fn2, 0)
|
img2 = cv2.imread(fn2, 0)
|
||||||
detector, matcher = init_feature(feature_name)
|
detector, matcher = init_feature(feature_name)
|
||||||
if detector != None:
|
|
||||||
print 'using', feature_name
|
if img1 is None:
|
||||||
else:
|
print 'Failed to load fn1:', fn1
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
if img2 is None:
|
||||||
|
print 'Failed to load fn2:', fn2
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
if detector is None:
|
||||||
print 'unknown feature:', feature_name
|
print 'unknown feature:', feature_name
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
print 'using', feature_name
|
||||||
|
|
||||||
pool=ThreadPool(processes = cv2.getNumberOfCPUs())
|
pool=ThreadPool(processes = cv2.getNumberOfCPUs())
|
||||||
kp1, desc1 = affine_detect(detector, img1, pool=pool)
|
kp1, desc1 = affine_detect(detector, img1, pool=pool)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
'''
|
'''
|
||||||
browse.py
|
browse.py
|
||||||
@ -14,6 +14,8 @@ browse.py [image filename]
|
|||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import cv2
|
import cv2
|
||||||
|
|
||||||
|
# built-in modules
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
@ -25,6 +27,10 @@ if __name__ == '__main__':
|
|||||||
fn = sys.argv[1]
|
fn = sys.argv[1]
|
||||||
print 'loading %s ...' % fn
|
print 'loading %s ...' % fn
|
||||||
img = cv2.imread(fn)
|
img = cv2.imread(fn)
|
||||||
|
if img is None:
|
||||||
|
print 'Failed to load fn:', fn
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
sz = 4096
|
sz = 4096
|
||||||
print 'generating %dx%d procedural image ...' % (sz, sz)
|
print 'generating %dx%d procedural image ...' % (sz, sz)
|
||||||
@ -33,6 +39,7 @@ if __name__ == '__main__':
|
|||||||
track = np.int32(track*10 + (sz/2, sz/2))
|
track = np.int32(track*10 + (sz/2, sz/2))
|
||||||
cv2.polylines(img, [track], 0, 255, 1, cv2.CV_AA)
|
cv2.polylines(img, [track], 0, 255, 1, cv2.CV_AA)
|
||||||
|
|
||||||
|
|
||||||
small = img
|
small = img
|
||||||
for i in xrange(3):
|
for i in xrange(3):
|
||||||
small = cv2.pyrDown(small)
|
small = cv2.pyrDown(small)
|
||||||
|
@ -1,10 +1,15 @@
|
|||||||
#/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import cv2
|
import cv2
|
||||||
import os
|
|
||||||
|
# local modules
|
||||||
from common import splitfn
|
from common import splitfn
|
||||||
|
|
||||||
|
# built-in modules
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
USAGE = '''
|
USAGE = '''
|
||||||
USAGE: calib.py [--save <filename>] [--debug <output path>] [--square_size] [<image mask>]
|
USAGE: calib.py [--save <filename>] [--debug <output path>] [--square_size] [<image mask>]
|
||||||
'''
|
'''
|
||||||
@ -12,13 +17,17 @@ USAGE: calib.py [--save <filename>] [--debug <output path>] [--square_size] [<im
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
import sys, getopt
|
import sys
|
||||||
|
import getopt
|
||||||
from glob import glob
|
from glob import glob
|
||||||
|
|
||||||
args, img_mask = getopt.getopt(sys.argv[1:], '', ['save=', 'debug=', 'square_size='])
|
args, img_mask = getopt.getopt(sys.argv[1:], '', ['save=', 'debug=', 'square_size='])
|
||||||
args = dict(args)
|
args = dict(args)
|
||||||
try: img_mask = img_mask[0]
|
try:
|
||||||
except: img_mask = '../cpp/left*.jpg'
|
img_mask = img_mask[0]
|
||||||
|
except:
|
||||||
|
img_mask = '../cpp/left*.jpg'
|
||||||
|
|
||||||
img_names = glob(img_mask)
|
img_names = glob(img_mask)
|
||||||
debug_dir = args.get('--debug')
|
debug_dir = args.get('--debug')
|
||||||
square_size = float(args.get('--square_size', 1.0))
|
square_size = float(args.get('--square_size', 1.0))
|
||||||
@ -34,6 +43,10 @@ if __name__ == '__main__':
|
|||||||
for fn in img_names:
|
for fn in img_names:
|
||||||
print 'processing %s...' % fn,
|
print 'processing %s...' % fn,
|
||||||
img = cv2.imread(fn, 0)
|
img = cv2.imread(fn, 0)
|
||||||
|
if img is None:
|
||||||
|
print "Failed to load", fn
|
||||||
|
continue
|
||||||
|
|
||||||
h, w = img.shape[:2]
|
h, w = img.shape[:2]
|
||||||
found, corners = cv2.findChessboardCorners(img, pattern_size)
|
found, corners = cv2.findChessboardCorners(img, pattern_size)
|
||||||
if found:
|
if found:
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Camshift tracker
|
Camshift tracker
|
||||||
@ -24,6 +24,8 @@ Keys:
|
|||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import cv2
|
import cv2
|
||||||
|
|
||||||
|
# local module
|
||||||
import video
|
import video
|
||||||
|
|
||||||
|
|
||||||
@ -98,8 +100,10 @@ class App(object):
|
|||||||
|
|
||||||
if self.show_backproj:
|
if self.show_backproj:
|
||||||
vis[:] = prob[...,np.newaxis]
|
vis[:] = prob[...,np.newaxis]
|
||||||
try: cv2.ellipse(vis, track_box, (0, 0, 255), 2)
|
try:
|
||||||
except: print track_box
|
cv2.ellipse(vis, track_box, (0, 0, 255), 2)
|
||||||
|
except:
|
||||||
|
print track_box
|
||||||
|
|
||||||
cv2.imshow('camshift', vis)
|
cv2.imshow('camshift', vis)
|
||||||
|
|
||||||
@ -113,8 +117,10 @@ class App(object):
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
import sys
|
import sys
|
||||||
try: video_src = sys.argv[1]
|
try:
|
||||||
except: video_src = 0
|
video_src = sys.argv[1]
|
||||||
|
except:
|
||||||
|
video_src = 0
|
||||||
print __doc__
|
print __doc__
|
||||||
App(video_src).run()
|
App(video_src).run()
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Coherence-enhancing filtering example
|
Coherence-enhancing filtering example
|
||||||
@ -40,8 +40,10 @@ def coherence_filter(img, sigma = 11, str_sigma = 11, blend = 0.5, iter_n = 4):
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
import sys
|
import sys
|
||||||
try: fn = sys.argv[1]
|
try:
|
||||||
except: fn = '../cpp/baboon.jpg'
|
fn = sys.argv[1]
|
||||||
|
except:
|
||||||
|
fn = '../cpp/baboon.jpg'
|
||||||
|
|
||||||
src = cv2.imread(fn)
|
src = cv2.imread(fn)
|
||||||
|
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
#/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import cv2
|
import cv2
|
||||||
from time import clock
|
|
||||||
import sys
|
|
||||||
|
|
||||||
|
# built-in modules
|
||||||
|
import sys
|
||||||
|
from time import clock
|
||||||
|
|
||||||
|
# local modules
|
||||||
import video
|
import video
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
@ -24,8 +27,10 @@ if __name__ == '__main__':
|
|||||||
hist_scale = val
|
hist_scale = val
|
||||||
cv2.createTrackbar('scale', 'hist', hist_scale, 32, set_scale)
|
cv2.createTrackbar('scale', 'hist', hist_scale, 32, set_scale)
|
||||||
|
|
||||||
try: fn = sys.argv[1]
|
try:
|
||||||
except: fn = 0
|
fn = sys.argv[1]
|
||||||
|
except:
|
||||||
|
fn = 0
|
||||||
cam = video.create_capture(fn, fallback='synth:bg=../cpp/baboon.jpg:class=chess:noise=0.05')
|
cam = video.create_capture(fn, fallback='synth:bg=../cpp/baboon.jpg:class=chess:noise=0.05')
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
#/usr/bin/env python
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
This module contains some common routines used by other samples.
|
This module contains some common routines used by other samples.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import cv2
|
import cv2
|
||||||
|
|
||||||
|
# built-in modules
|
||||||
import os
|
import os
|
||||||
from contextlib import contextmanager
|
|
||||||
import itertools as it
|
import itertools as it
|
||||||
|
from contextlib import contextmanager
|
||||||
|
|
||||||
image_extensions = ['.bmp', '.jpg', '.jpeg', '.png', '.tif', '.tiff', '.pbm', '.pgm', '.ppm']
|
image_extensions = ['.bmp', '.jpg', '.jpeg', '.png', '.tif', '.tiff', '.pbm', '.pgm', '.ppm']
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
'''
|
'''
|
||||||
This program illustrates the use of findContours and drawContours.
|
This program illustrates the use of findContours and drawContours.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Wiener deconvolution.
|
Wiener deconvolution.
|
||||||
@ -32,6 +32,8 @@ Examples:
|
|||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import cv2
|
import cv2
|
||||||
|
|
||||||
|
# local module
|
||||||
from common import nothing
|
from common import nothing
|
||||||
|
|
||||||
|
|
||||||
@ -65,12 +67,18 @@ if __name__ == '__main__':
|
|||||||
import sys, getopt
|
import sys, getopt
|
||||||
opts, args = getopt.getopt(sys.argv[1:], '', ['circle', 'angle=', 'd=', 'snr='])
|
opts, args = getopt.getopt(sys.argv[1:], '', ['circle', 'angle=', 'd=', 'snr='])
|
||||||
opts = dict(opts)
|
opts = dict(opts)
|
||||||
try: fn = args[0]
|
try:
|
||||||
except: fn = 'data/licenseplate_motion.jpg'
|
fn = args[0]
|
||||||
|
except:
|
||||||
|
fn = 'data/licenseplate_motion.jpg'
|
||||||
|
|
||||||
win = 'deconvolution'
|
win = 'deconvolution'
|
||||||
|
|
||||||
img = cv2.imread(fn, 0)
|
img = cv2.imread(fn, 0)
|
||||||
|
if img is None:
|
||||||
|
print 'Failed to load fn1:', fn1
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
img = np.float32(img)/255.0
|
img = np.float32(img)/255.0
|
||||||
cv2.imshow('input', img)
|
cv2.imshow('input', img)
|
||||||
|
|
||||||
|
@ -1,15 +1,20 @@
|
|||||||
#/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Sample-launcher application.
|
Sample-launcher application.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import Tkinter as tk
|
# local modules
|
||||||
from ScrolledText import ScrolledText
|
|
||||||
from glob import glob
|
|
||||||
from common import splitfn
|
from common import splitfn
|
||||||
|
|
||||||
|
# built-in modules
|
||||||
|
import sys
|
||||||
import webbrowser
|
import webbrowser
|
||||||
|
import Tkinter as tk
|
||||||
|
from glob import glob
|
||||||
from subprocess import Popen
|
from subprocess import Popen
|
||||||
|
from ScrolledText import ScrolledText
|
||||||
|
|
||||||
|
|
||||||
#from IPython.Shell import IPShellEmbed
|
#from IPython.Shell import IPShellEmbed
|
||||||
#ipshell = IPShellEmbed()
|
#ipshell = IPShellEmbed()
|
||||||
@ -136,7 +141,8 @@ class App:
|
|||||||
count = tk.IntVar()
|
count = tk.IntVar()
|
||||||
while True:
|
while True:
|
||||||
match_index = text.search(pattern, 'matchPos', count=count, regexp=regexp, stopindex='end')
|
match_index = text.search(pattern, 'matchPos', count=count, regexp=regexp, stopindex='end')
|
||||||
if not match_index: break
|
if not match_index:
|
||||||
|
break
|
||||||
end_index = text.index( "%s+%sc" % (match_index, count.get()) )
|
end_index = text.index( "%s+%sc" % (match_index, count.get()) )
|
||||||
text.mark_set('matchPos', end_index)
|
text.mark_set('matchPos', end_index)
|
||||||
if callable(tag_proc):
|
if callable(tag_proc):
|
||||||
@ -147,7 +153,7 @@ class App:
|
|||||||
def on_run(self, *args):
|
def on_run(self, *args):
|
||||||
cmd = self.cmd_entry.get()
|
cmd = self.cmd_entry.get()
|
||||||
print 'running:', cmd
|
print 'running:', cmd
|
||||||
Popen("python " + cmd, shell=True)
|
Popen(sys.executable + ' ' + cmd, shell=True)
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
tk.mainloop()
|
tk.mainloop()
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
'''
|
'''
|
||||||
SVM and KNearest digit recognition.
|
SVM and KNearest digit recognition.
|
||||||
@ -23,12 +23,19 @@ Usage:
|
|||||||
digits.py
|
digits.py
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import numpy as np
|
# built-in modules
|
||||||
import cv2
|
|
||||||
from multiprocessing.pool import ThreadPool
|
from multiprocessing.pool import ThreadPool
|
||||||
from common import clock, mosaic
|
|
||||||
|
import cv2
|
||||||
|
|
||||||
|
import numpy as np
|
||||||
from numpy.linalg import norm
|
from numpy.linalg import norm
|
||||||
|
|
||||||
|
# local modules
|
||||||
|
from common import clock, mosaic
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SZ = 20 # size of each digit is SZ x SZ
|
SZ = 20 # size of each digit is SZ x SZ
|
||||||
CLASS_N = 10
|
CLASS_N = 10
|
||||||
DIGITS_FN = 'data/digits.png'
|
DIGITS_FN = 'data/digits.png'
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Digit recognition adjustment.
|
Digit recognition adjustment.
|
||||||
|
@ -1,17 +1,23 @@
|
|||||||
#/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import cv2
|
import cv2
|
||||||
|
|
||||||
|
# built-in modules
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
# local modules
|
||||||
import video
|
import video
|
||||||
from common import mosaic
|
from common import mosaic
|
||||||
|
|
||||||
from digits import *
|
from digits import *
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
try: src = sys.argv[1]
|
try:
|
||||||
except: src = 0
|
src = sys.argv[1]
|
||||||
|
except:
|
||||||
|
src = 0
|
||||||
cap = video.create_capture(src)
|
cap = video.create_capture(src)
|
||||||
|
|
||||||
classifier_fn = 'digits_svm.dat'
|
classifier_fn = 'digits_svm.dat'
|
||||||
@ -30,8 +36,10 @@ def main():
|
|||||||
bin = cv2.adaptiveThreshold(gray, 255, cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY_INV, 31, 10)
|
bin = cv2.adaptiveThreshold(gray, 255, cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY_INV, 31, 10)
|
||||||
bin = cv2.medianBlur(bin, 3)
|
bin = cv2.medianBlur(bin, 3)
|
||||||
contours, heirs = cv2.findContours( bin.copy(), cv2.RETR_CCOMP, cv2.CHAIN_APPROX_SIMPLE)
|
contours, heirs = cv2.findContours( bin.copy(), cv2.RETR_CCOMP, cv2.CHAIN_APPROX_SIMPLE)
|
||||||
try: heirs = heirs[0]
|
try:
|
||||||
except: heirs = []
|
heirs = heirs[0]
|
||||||
|
except:
|
||||||
|
heirs = []
|
||||||
|
|
||||||
for cnt, heir in zip(contours, heirs):
|
for cnt, heir in zip(contours, heirs):
|
||||||
_, _, _, outer_i = heir
|
_, _, _, outer_i = heir
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Distance transform sample.
|
Distance transform sample.
|
||||||
@ -15,15 +15,22 @@ Keys:
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
import cv2
|
import cv2
|
||||||
import cv2.cv as cv
|
import cv2.cv as cv
|
||||||
|
|
||||||
from common import make_cmap
|
from common import make_cmap
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
import sys
|
import sys
|
||||||
try: fn = sys.argv[1]
|
try:
|
||||||
except: fn = '../cpp/fruits.jpg'
|
fn = sys.argv[1]
|
||||||
|
except:
|
||||||
|
fn = '../cpp/fruits.jpg'
|
||||||
print __doc__
|
print __doc__
|
||||||
|
|
||||||
img = cv2.imread(fn, 0)
|
img = cv2.imread(fn, 0)
|
||||||
|
if img is None:
|
||||||
|
print 'Failed to load fn:', fn
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
cm = make_cmap('jet')
|
cm = make_cmap('jet')
|
||||||
need_update = True
|
need_update = True
|
||||||
voronoi = False
|
voronoi = False
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
'''
|
'''
|
||||||
This sample demonstrates Canny edge detection.
|
This sample demonstrates Canny edge detection.
|
||||||
@ -11,15 +11,21 @@ Usage:
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
import cv2
|
import cv2
|
||||||
|
|
||||||
|
# relative module
|
||||||
import video
|
import video
|
||||||
|
|
||||||
|
# built-in module
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
print __doc__
|
print __doc__
|
||||||
|
|
||||||
try: fn = sys.argv[1]
|
try:
|
||||||
except: fn = 0
|
fn = sys.argv[1]
|
||||||
|
except:
|
||||||
|
fn = 0
|
||||||
|
|
||||||
def nothing(*arg):
|
def nothing(*arg):
|
||||||
pass
|
pass
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
#/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import cv2
|
import cv2
|
||||||
import cv2.cv as cv
|
import cv2.cv as cv
|
||||||
|
|
||||||
|
# local modules
|
||||||
from video import create_capture
|
from video import create_capture
|
||||||
from common import clock, draw_str
|
from common import clock, draw_str
|
||||||
|
|
||||||
@ -26,8 +28,10 @@ if __name__ == '__main__':
|
|||||||
print help_message
|
print help_message
|
||||||
|
|
||||||
args, video_src = getopt.getopt(sys.argv[1:], '', ['cascade=', 'nested-cascade='])
|
args, video_src = getopt.getopt(sys.argv[1:], '', ['cascade=', 'nested-cascade='])
|
||||||
try: video_src = video_src[0]
|
try:
|
||||||
except: video_src = 0
|
video_src = video_src[0]
|
||||||
|
except:
|
||||||
|
video_src = 0
|
||||||
args = dict(args)
|
args = dict(args)
|
||||||
cascade_fn = args.get('--cascade', "../../data/haarcascades/haarcascade_frontalface_alt.xml")
|
cascade_fn = args.get('--cascade', "../../data/haarcascades/haarcascade_frontalface_alt.xml")
|
||||||
nested_fn = args.get('--nested-cascade', "../../data/haarcascades/haarcascade_eye.xml")
|
nested_fn = args.get('--nested-cascade', "../../data/haarcascades/haarcascade_eye.xml")
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Feature homography
|
Feature homography
|
||||||
@ -24,6 +24,8 @@ Select a textured planar object to track by drawing a box with a mouse.
|
|||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import cv2
|
import cv2
|
||||||
|
|
||||||
|
# local modules
|
||||||
import video
|
import video
|
||||||
import common
|
import common
|
||||||
from common import getsize, draw_keypoints
|
from common import getsize, draw_keypoints
|
||||||
@ -85,6 +87,8 @@ if __name__ == '__main__':
|
|||||||
print __doc__
|
print __doc__
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
try: video_src = sys.argv[1]
|
try:
|
||||||
except: video_src = 0
|
video_src = sys.argv[1]
|
||||||
|
except:
|
||||||
|
video_src = 0
|
||||||
App(video_src).run()
|
App(video_src).run()
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Feature-based image matching sample.
|
Feature-based image matching sample.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Robust line fitting.
|
Robust line fitting.
|
||||||
@ -24,7 +24,11 @@ ESC - exit
|
|||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import cv2
|
import cv2
|
||||||
|
|
||||||
|
# built-in modules
|
||||||
import itertools as it
|
import itertools as it
|
||||||
|
|
||||||
|
# local modules
|
||||||
from common import draw_str
|
from common import draw_str
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Floodfill sample.
|
Floodfill sample.
|
||||||
@ -19,11 +19,17 @@ import cv2
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
import sys
|
import sys
|
||||||
try: fn = sys.argv[1]
|
try:
|
||||||
except: fn = '../cpp/fruits.jpg'
|
fn = sys.argv[1]
|
||||||
|
except:
|
||||||
|
fn = '../cpp/fruits.jpg'
|
||||||
print __doc__
|
print __doc__
|
||||||
|
|
||||||
img = cv2.imread(fn, True)
|
img = cv2.imread(fn, True)
|
||||||
|
if img is None:
|
||||||
|
print 'Failed to load image file:', fn
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
h, w = img.shape[:2]
|
h, w = img.shape[:2]
|
||||||
mask = np.zeros((h+2, w+2), np.uint8)
|
mask = np.zeros((h+2, w+2), np.uint8)
|
||||||
seed_pt = None
|
seed_pt = None
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
'''
|
'''
|
||||||
gabor_threads.py
|
gabor_threads.py
|
||||||
@ -49,10 +49,16 @@ if __name__ == '__main__':
|
|||||||
from common import Timer
|
from common import Timer
|
||||||
|
|
||||||
print __doc__
|
print __doc__
|
||||||
try: img_fn = sys.argv[1]
|
try:
|
||||||
except: img_fn = '../cpp/baboon.jpg'
|
img_fn = sys.argv[1]
|
||||||
|
except:
|
||||||
|
img_fn = '../cpp/baboon.jpg'
|
||||||
|
|
||||||
img = cv2.imread(img_fn)
|
img = cv2.imread(img_fn)
|
||||||
|
if img is None:
|
||||||
|
print 'Failed to load image file:', img_fn
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
filters = build_filters()
|
filters = build_filters()
|
||||||
|
|
||||||
with Timer('running single-threaded'):
|
with Timer('running single-threaded'):
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from numpy import random
|
from numpy import random
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
''' This is a sample for histogram plotting for RGB images and grayscale images for better understanding of colour distribution
|
''' This is a sample for histogram plotting for RGB images and grayscale images for better understanding of colour distribution
|
||||||
|
|
||||||
@ -55,11 +55,16 @@ if __name__ == '__main__':
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
if len(sys.argv)>1:
|
if len(sys.argv)>1:
|
||||||
im = cv2.imread(sys.argv[1])
|
fname = sys.argv[1]
|
||||||
else :
|
else :
|
||||||
im = cv2.imread('../cpp/lena.jpg')
|
fname = '../cpp/lena.jpg'
|
||||||
print "usage : python hist.py <image_file>"
|
print "usage : python hist.py <image_file>"
|
||||||
|
|
||||||
|
im = cv2.imread(fname)
|
||||||
|
|
||||||
|
if im is None:
|
||||||
|
print 'Failed to load image file:', fname
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
gray = cv2.cvtColor(im,cv2.COLOR_BGR2GRAY)
|
gray = cv2.cvtColor(im,cv2.COLOR_BGR2GRAY)
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Inpainting sample.
|
Inpainting sample.
|
||||||
@ -21,11 +21,18 @@ from common import Sketcher
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
import sys
|
import sys
|
||||||
try: fn = sys.argv[1]
|
try:
|
||||||
except: fn = '../cpp/fruits.jpg'
|
fn = sys.argv[1]
|
||||||
|
except:
|
||||||
|
fn = '../cpp/fruits.jpg'
|
||||||
|
|
||||||
print __doc__
|
print __doc__
|
||||||
|
|
||||||
img = cv2.imread(fn)
|
img = cv2.imread(fn)
|
||||||
|
if img is None:
|
||||||
|
print 'Failed to load image file:', fn
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
img_mark = img.copy()
|
img_mark = img.copy()
|
||||||
mark = np.zeros(img.shape[:2], np.uint8)
|
mark = np.zeros(img.shape[:2], np.uint8)
|
||||||
sketch = Sketcher('img', [img_mark, mark], lambda : ((255, 255, 255), 255))
|
sketch = Sketcher('img', [img_mark, mark], lambda : ((255, 255, 255), 255))
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
'''
|
'''
|
||||||
K-means clusterization sample.
|
K-means clusterization sample.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
''' An example of Laplacian Pyramid construction and merging.
|
''' An example of Laplacian Pyramid construction and merging.
|
||||||
|
|
||||||
@ -40,8 +40,10 @@ if __name__ == '__main__':
|
|||||||
import sys
|
import sys
|
||||||
print __doc__
|
print __doc__
|
||||||
|
|
||||||
try: fn = sys.argv[1]
|
try:
|
||||||
except: fn = 0
|
fn = sys.argv[1]
|
||||||
|
except:
|
||||||
|
fn = 0
|
||||||
cap = video.create_capture(fn)
|
cap = video.create_capture(fn)
|
||||||
|
|
||||||
leveln = 6
|
leveln = 6
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
'''
|
'''
|
||||||
The sample demonstrates how to train Random Trees classifier
|
The sample demonstrates how to train Random Trees classifier
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Lucas-Kanade homography tracker
|
Lucas-Kanade homography tracker
|
||||||
@ -103,8 +103,10 @@ class App:
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
import sys
|
import sys
|
||||||
try: video_src = sys.argv[1]
|
try:
|
||||||
except: video_src = 0
|
video_src = sys.argv[1]
|
||||||
|
except:
|
||||||
|
video_src = 0
|
||||||
|
|
||||||
print __doc__
|
print __doc__
|
||||||
App(video_src).run()
|
App(video_src).run()
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Lucas-Kanade tracker
|
Lucas-Kanade tracker
|
||||||
@ -88,8 +88,10 @@ class App:
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
import sys
|
import sys
|
||||||
try: video_src = sys.argv[1]
|
try:
|
||||||
except: video_src = 0
|
video_src = sys.argv[1]
|
||||||
|
except:
|
||||||
|
video_src = 0
|
||||||
|
|
||||||
print __doc__
|
print __doc__
|
||||||
App(video_src).run()
|
App(video_src).run()
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Morphology operations.
|
Morphology operations.
|
||||||
@ -23,9 +23,17 @@ if __name__ == '__main__':
|
|||||||
from itertools import cycle
|
from itertools import cycle
|
||||||
from common import draw_str
|
from common import draw_str
|
||||||
|
|
||||||
try: fn = sys.argv[1]
|
try:
|
||||||
except: fn = '../cpp/baboon.jpg'
|
fn = sys.argv[1]
|
||||||
|
except:
|
||||||
|
fn = '../cpp/baboon.jpg'
|
||||||
|
|
||||||
img = cv2.imread(fn)
|
img = cv2.imread(fn)
|
||||||
|
|
||||||
|
if img is None:
|
||||||
|
print 'Failed to load image file:', fn
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
cv2.imshow('original', img)
|
cv2.imshow('original', img)
|
||||||
|
|
||||||
modes = cycle(['erode/dilate', 'open/close', 'blackhat/tophat', 'gradient'])
|
modes = cycle(['erode/dilate', 'open/close', 'blackhat/tophat', 'gradient'])
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
'''
|
'''
|
||||||
MOSSE tracking sample
|
MOSSE tracking sample
|
||||||
@ -182,7 +182,9 @@ if __name__ == '__main__':
|
|||||||
import sys, getopt
|
import sys, getopt
|
||||||
opts, args = getopt.getopt(sys.argv[1:], '', ['pause'])
|
opts, args = getopt.getopt(sys.argv[1:], '', ['pause'])
|
||||||
opts = dict(opts)
|
opts = dict(opts)
|
||||||
try: video_src = args[0]
|
try:
|
||||||
except: video_src = '0'
|
video_src = args[0]
|
||||||
|
except:
|
||||||
|
video_src = '0'
|
||||||
|
|
||||||
App(video_src, paused = '--pause' in opts).run()
|
App(video_src, paused = '--pause' in opts).run()
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import cv2
|
import cv2
|
||||||
@ -20,8 +20,10 @@ def draw_motion_comp(vis, (x, y, w, h), angle, color):
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
import sys
|
import sys
|
||||||
try: video_src = sys.argv[1]
|
try:
|
||||||
except: video_src = 0
|
video_src = sys.argv[1]
|
||||||
|
except:
|
||||||
|
video_src = 0
|
||||||
|
|
||||||
cv2.namedWindow('motempl')
|
cv2.namedWindow('motempl')
|
||||||
visuals = ['input', 'frame_diff', 'motion_hist', 'grad_orient']
|
visuals = ['input', 'frame_diff', 'motion_hist', 'grad_orient']
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
#/usr/bin/env python
|
|
||||||
|
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
'''
|
'''
|
||||||
mouse_and_match.py [-i path | --input path: default ./]
|
mouse_and_match.py [-i path | --input path: default ./]
|
||||||
@ -11,12 +9,15 @@ Demonstrate using a mouse to interact with an image:
|
|||||||
ESC to exit
|
ESC to exit
|
||||||
'''
|
'''
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from math import *
|
import cv2 as cv
|
||||||
import sys
|
|
||||||
|
# built-in modules
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
import glob
|
import glob
|
||||||
import argparse
|
import argparse
|
||||||
import cv2 as cv
|
from math import *
|
||||||
|
|
||||||
|
|
||||||
drag_start = None
|
drag_start = None
|
||||||
sel = (0,0,0,0)
|
sel = (0,0,0,0)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
'''
|
'''
|
||||||
MSER detector demo
|
MSER detector demo
|
||||||
@ -20,8 +20,10 @@ import video
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
import sys
|
import sys
|
||||||
try: video_src = sys.argv[1]
|
try:
|
||||||
except: video_src = 0
|
video_src = sys.argv[1]
|
||||||
|
except:
|
||||||
|
video_src = 0
|
||||||
|
|
||||||
cam = video.create_capture(video_src)
|
cam = video.create_capture(video_src)
|
||||||
mser = cv2.MSER()
|
mser = cv2.MSER()
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import cv2
|
import cv2
|
||||||
@ -48,8 +48,10 @@ def warp_flow(img, flow):
|
|||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
import sys
|
import sys
|
||||||
print help_message
|
print help_message
|
||||||
try: fn = sys.argv[1]
|
try:
|
||||||
except: fn = 0
|
fn = sys.argv[1]
|
||||||
|
except:
|
||||||
|
fn = 0
|
||||||
|
|
||||||
cam = video.create_capture(fn)
|
cam = video.create_capture(fn)
|
||||||
ret, prev = cam.read()
|
ret, prev = cam.read()
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import cv2
|
import cv2
|
||||||
@ -36,6 +36,9 @@ if __name__ == '__main__':
|
|||||||
print fn, ' - ',
|
print fn, ' - ',
|
||||||
try:
|
try:
|
||||||
img = cv2.imread(fn)
|
img = cv2.imread(fn)
|
||||||
|
if img is None:
|
||||||
|
print 'Failed to load image file:', fn
|
||||||
|
continue
|
||||||
except:
|
except:
|
||||||
print 'loading error'
|
print 'loading error'
|
||||||
continue
|
continue
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Planar augmented reality
|
Planar augmented reality
|
||||||
@ -100,6 +100,8 @@ if __name__ == '__main__':
|
|||||||
print __doc__
|
print __doc__
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
try: video_src = sys.argv[1]
|
try:
|
||||||
except: video_src = 0
|
video_src = sys.argv[1]
|
||||||
|
except:
|
||||||
|
video_src = 0
|
||||||
App(video_src).run()
|
App(video_src).run()
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Multitarget planar tracking
|
Multitarget planar tracking
|
||||||
@ -23,7 +23,11 @@ Select a textured planar object to track by drawing a box with a mouse.
|
|||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import cv2
|
import cv2
|
||||||
|
|
||||||
|
# built-in modules
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
|
# local modules
|
||||||
import video
|
import video
|
||||||
import common
|
import common
|
||||||
|
|
||||||
@ -168,6 +172,8 @@ if __name__ == '__main__':
|
|||||||
print __doc__
|
print __doc__
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
try: video_src = sys.argv[1]
|
try:
|
||||||
except: video_src = 0
|
video_src = sys.argv[1]
|
||||||
|
except:
|
||||||
|
video_src = 0
|
||||||
App(video_src).run()
|
App(video_src).run()
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Simple "Square Detector" program.
|
Simple "Square Detector" program.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Simple example of stereo image matching and point cloud generation.
|
Simple example of stereo image matching and point cloud generation.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Texture flow direction estimation.
|
Texture flow direction estimation.
|
||||||
@ -15,10 +15,16 @@ import cv2
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
import sys
|
import sys
|
||||||
try: fn = sys.argv[1]
|
try:
|
||||||
except: fn = 'data/starry_night.jpg'
|
fn = sys.argv[1]
|
||||||
|
except:
|
||||||
|
fn = 'data/starry_night.jpg'
|
||||||
|
|
||||||
img = cv2.imread(fn)
|
img = cv2.imread(fn)
|
||||||
|
if img is None:
|
||||||
|
print 'Failed to load image file:', fn
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
|
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
|
||||||
h, w = img.shape[:2]
|
h, w = img.shape[:2]
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Multiscale Turing Patterns generator
|
Multiscale Turing Patterns generator
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Video capture sample.
|
Video capture sample.
|
||||||
@ -30,9 +30,14 @@ Keys:
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import cv2
|
|
||||||
from time import clock
|
|
||||||
from numpy import pi, sin, cos
|
from numpy import pi, sin, cos
|
||||||
|
|
||||||
|
import cv2
|
||||||
|
|
||||||
|
# built-in modules
|
||||||
|
from time import clock
|
||||||
|
|
||||||
|
# local modules
|
||||||
import common
|
import common
|
||||||
|
|
||||||
class VideoSynthBase(object):
|
class VideoSynthBase(object):
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Data matrix detector sample.
|
Data matrix detector sample.
|
||||||
@ -18,6 +18,8 @@ Keyboard shortcuts:
|
|||||||
|
|
||||||
import cv2
|
import cv2
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
|
# built-in modules
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
def data_matrix_demo(cap):
|
def data_matrix_demo(cap):
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Multithreaded video processing sample.
|
Multithreaded video processing sample.
|
||||||
@ -39,8 +39,10 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
print __doc__
|
print __doc__
|
||||||
|
|
||||||
try: fn = sys.argv[1]
|
try:
|
||||||
except: fn = 0
|
fn = sys.argv[1]
|
||||||
|
except:
|
||||||
|
fn = 0
|
||||||
cap = video.create_capture(fn)
|
cap = video.create_capture(fn)
|
||||||
|
|
||||||
|
|
||||||
|
@ -31,6 +31,9 @@ from common import Sketcher
|
|||||||
class App:
|
class App:
|
||||||
def __init__(self, fn):
|
def __init__(self, fn):
|
||||||
self.img = cv2.imread(fn)
|
self.img = cv2.imread(fn)
|
||||||
|
if self.img is None:
|
||||||
|
raise Exception('Failed to load image file: %s' % fn)
|
||||||
|
|
||||||
h, w = self.img.shape[:2]
|
h, w = self.img.shape[:2]
|
||||||
self.markers = np.zeros((h, w), np.int32)
|
self.markers = np.zeros((h, w), np.int32)
|
||||||
self.markers_vis = self.img.copy()
|
self.markers_vis = self.img.copy()
|
||||||
@ -73,7 +76,9 @@ class App:
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
import sys
|
import sys
|
||||||
try: fn = sys.argv[1]
|
try:
|
||||||
except: fn = '../cpp/fruits.jpg'
|
fn = sys.argv[1]
|
||||||
|
except:
|
||||||
|
fn = '../cpp/fruits.jpg'
|
||||||
print __doc__
|
print __doc__
|
||||||
App(fn).run()
|
App(fn).run()
|
||||||
|
Loading…
Reference in New Issue
Block a user