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
+15 -15
View File
@@ -18,7 +18,7 @@ Keys:
from __future__ import print_function
import numpy as np
import cv2
import cv2 as cv
if __name__ == '__main__':
import sys
@@ -28,7 +28,7 @@ if __name__ == '__main__':
fn = '../data/fruits.jpg'
print(__doc__)
img = cv2.imread(fn, True)
img = cv.imread(fn, True)
if img is None:
print('Failed to load image file:', fn)
sys.exit(1)
@@ -41,32 +41,32 @@ if __name__ == '__main__':
def update(dummy=None):
if seed_pt is None:
cv2.imshow('floodfill', img)
cv.imshow('floodfill', img)
return
flooded = img.copy()
mask[:] = 0
lo = cv2.getTrackbarPos('lo', 'floodfill')
hi = cv2.getTrackbarPos('hi', 'floodfill')
lo = cv.getTrackbarPos('lo', 'floodfill')
hi = cv.getTrackbarPos('hi', 'floodfill')
flags = connectivity
if fixed_range:
flags |= cv2.FLOODFILL_FIXED_RANGE
cv2.floodFill(flooded, mask, seed_pt, (255, 255, 255), (lo,)*3, (hi,)*3, flags)
cv2.circle(flooded, seed_pt, 2, (0, 0, 255), -1)
cv2.imshow('floodfill', flooded)
flags |= cv.FLOODFILL_FIXED_RANGE
cv.floodFill(flooded, mask, seed_pt, (255, 255, 255), (lo,)*3, (hi,)*3, flags)
cv.circle(flooded, seed_pt, 2, (0, 0, 255), -1)
cv.imshow('floodfill', flooded)
def onmouse(event, x, y, flags, param):
global seed_pt
if flags & cv2.EVENT_FLAG_LBUTTON:
if flags & cv.EVENT_FLAG_LBUTTON:
seed_pt = x, y
update()
update()
cv2.setMouseCallback('floodfill', onmouse)
cv2.createTrackbar('lo', 'floodfill', 20, 255, update)
cv2.createTrackbar('hi', 'floodfill', 20, 255, update)
cv.setMouseCallback('floodfill', onmouse)
cv.createTrackbar('lo', 'floodfill', 20, 255, update)
cv.createTrackbar('hi', 'floodfill', 20, 255, update)
while True:
ch = cv2.waitKey()
ch = cv.waitKey()
if ch == 27:
break
if ch == ord('f'):
@@ -77,4 +77,4 @@ if __name__ == '__main__':
connectivity = 12-connectivity
print('connectivity =', connectivity)
update()
cv2.destroyAllWindows()
cv.destroyAllWindows()