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
@@ -3,12 +3,12 @@
@brief Sample code showing how to detect edges using the Laplace operator
"""
import sys
import cv2
import cv2 as cv
def main(argv):
# [variables]
# Declare the variables we are going to use
ddepth = cv2.CV_16S
ddepth = cv.CV_16S
kernel_size = 3
window_name = "Laplace Demo"
# [variables]
@@ -16,7 +16,7 @@ def main(argv):
# [load]
imageName = argv[0] if len(argv) > 0 else "../data/lena.jpg"
src = cv2.imread(imageName, cv2.IMREAD_COLOR) # Load an image
src = cv.imread(imageName, cv.IMREAD_COLOR) # Load an image
# Check if image is loaded fine
if src is None:
@@ -27,30 +27,30 @@ def main(argv):
# [reduce_noise]
# Remove noise by blurring with a Gaussian filter
src = cv2.GaussianBlur(src, (3, 3), 0)
src = cv.GaussianBlur(src, (3, 3), 0)
# [reduce_noise]
# [convert_to_gray]
# Convert the image to grayscale
src_gray = cv2.cvtColor(src, cv2.COLOR_BGR2GRAY)
src_gray = cv.cvtColor(src, cv.COLOR_BGR2GRAY)
# [convert_to_gray]
# Create Window
cv2.namedWindow(window_name, cv2.WINDOW_AUTOSIZE)
cv.namedWindow(window_name, cv.WINDOW_AUTOSIZE)
# [laplacian]
# Apply Laplace function
dst = cv2.Laplacian(src_gray, ddepth, kernel_size)
dst = cv.Laplacian(src_gray, ddepth, kernel_size)
# [laplacian]
# [convert]
# converting back to uint8
abs_dst = cv2.convertScaleAbs(dst)
abs_dst = cv.convertScaleAbs(dst)
# [convert]
# [display]
cv2.imshow(window_name, abs_dst)
cv2.waitKey(0)
cv.imshow(window_name, abs_dst)
cv.waitKey(0)
# [display]
return 0