1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-28 23:03:03 +04:00

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
+12 -12
View File
@@ -9,7 +9,7 @@ Keys:
'''
import numpy as np
import cv2
import cv2 as cv
# built-in modules
import sys
@@ -24,16 +24,16 @@ if __name__ == '__main__':
hsv_map[:,:,0] = h
hsv_map[:,:,1] = s
hsv_map[:,:,2] = 255
hsv_map = cv2.cvtColor(hsv_map, cv2.COLOR_HSV2BGR)
cv2.imshow('hsv_map', hsv_map)
hsv_map = cv.cvtColor(hsv_map, cv.COLOR_HSV2BGR)
cv.imshow('hsv_map', hsv_map)
cv2.namedWindow('hist', 0)
cv.namedWindow('hist', 0)
hist_scale = 10
def set_scale(val):
global hist_scale
hist_scale = val
cv2.createTrackbar('scale', 'hist', hist_scale, 32, set_scale)
cv.createTrackbar('scale', 'hist', hist_scale, 32, set_scale)
try:
fn = sys.argv[1]
@@ -43,20 +43,20 @@ if __name__ == '__main__':
while True:
flag, frame = cam.read()
cv2.imshow('camera', frame)
cv.imshow('camera', frame)
small = cv2.pyrDown(frame)
small = cv.pyrDown(frame)
hsv = cv2.cvtColor(small, cv2.COLOR_BGR2HSV)
hsv = cv.cvtColor(small, cv.COLOR_BGR2HSV)
dark = hsv[...,2] < 32
hsv[dark] = 0
h = cv2.calcHist([hsv], [0, 1], None, [180, 256], [0, 180, 0, 256])
h = cv.calcHist([hsv], [0, 1], None, [180, 256], [0, 180, 0, 256])
h = np.clip(h*0.005*hist_scale, 0, 1)
vis = hsv_map*h[:,:,np.newaxis] / 255.0
cv2.imshow('hist', vis)
cv.imshow('hist', vis)
ch = cv2.waitKey(1)
ch = cv.waitKey(1)
if ch == 27:
break
cv2.destroyAllWindows()
cv.destroyAllWindows()