python: 'cv2.' -> 'cv.' via 'import cv2 as cv'

This commit is contained in:
Alexander Alekhin
2017-12-11 12:55:03 +03:00
parent 9665dde678
commit 5560db73bf
162 changed files with 2083 additions and 2084 deletions
+9 -9
View File
@@ -18,7 +18,7 @@ gabor_threads.py [image filename]
from __future__ import print_function
import numpy as np
import cv2
import cv2 as cv
from multiprocessing.pool import ThreadPool
@@ -26,7 +26,7 @@ def build_filters():
filters = []
ksize = 31
for theta in np.arange(0, np.pi, np.pi / 16):
kern = cv2.getGaborKernel((ksize, ksize), 4.0, theta, 10.0, 0.5, 0, ktype=cv2.CV_32F)
kern = cv.getGaborKernel((ksize, ksize), 4.0, theta, 10.0, 0.5, 0, ktype=cv.CV_32F)
kern /= 1.5*kern.sum()
filters.append(kern)
return filters
@@ -34,14 +34,14 @@ def build_filters():
def process(img, filters):
accum = np.zeros_like(img)
for kern in filters:
fimg = cv2.filter2D(img, cv2.CV_8UC3, kern)
fimg = cv.filter2D(img, cv.CV_8UC3, kern)
np.maximum(accum, fimg, accum)
return accum
def process_threaded(img, filters, threadn = 8):
accum = np.zeros_like(img)
def f(kern):
return cv2.filter2D(img, cv2.CV_8UC3, kern)
return cv.filter2D(img, cv.CV_8UC3, kern)
pool = ThreadPool(processes=threadn)
for fimg in pool.imap_unordered(f, filters):
np.maximum(accum, fimg, accum)
@@ -57,7 +57,7 @@ if __name__ == '__main__':
except:
img_fn = '../data/baboon.jpg'
img = cv2.imread(img_fn)
img = cv.imread(img_fn)
if img is None:
print('Failed to load image file:', img_fn)
sys.exit(1)
@@ -70,7 +70,7 @@ if __name__ == '__main__':
res2 = process_threaded(img, filters)
print('res1 == res2: ', (res1 == res2).all())
cv2.imshow('img', img)
cv2.imshow('result', res2)
cv2.waitKey()
cv2.destroyAllWindows()
cv.imshow('img', img)
cv.imshow('result', res2)
cv.waitKey()
cv.destroyAllWindows()