mirror of
https://gitcode.com/gh_mirrors/es/esp32-opencv.git
synced 2025-08-15 03:01:04 +08:00
initial commit
This commit is contained in:
@ -0,0 +1,34 @@
|
||||
from __future__ import print_function
|
||||
import cv2 as cv
|
||||
import argparse
|
||||
|
||||
max_lowThreshold = 100
|
||||
window_name = 'Edge Map'
|
||||
title_trackbar = 'Min Threshold:'
|
||||
ratio = 3
|
||||
kernel_size = 3
|
||||
|
||||
def CannyThreshold(val):
|
||||
low_threshold = val
|
||||
img_blur = cv.blur(src_gray, (3,3))
|
||||
detected_edges = cv.Canny(img_blur, low_threshold, low_threshold*ratio, kernel_size)
|
||||
mask = detected_edges != 0
|
||||
dst = src * (mask[:,:,None].astype(src.dtype))
|
||||
cv.imshow(window_name, dst)
|
||||
|
||||
parser = argparse.ArgumentParser(description='Code for Canny Edge Detector tutorial.')
|
||||
parser.add_argument('--input', help='Path to input image.', default='fruits.jpg')
|
||||
args = parser.parse_args()
|
||||
|
||||
src = cv.imread(cv.samples.findFile(args.input))
|
||||
if src is None:
|
||||
print('Could not open or find the image: ', args.input)
|
||||
exit(0)
|
||||
|
||||
src_gray = cv.cvtColor(src, cv.COLOR_BGR2GRAY)
|
||||
|
||||
cv.namedWindow(window_name)
|
||||
cv.createTrackbar(title_trackbar, window_name , 0, max_lowThreshold, CannyThreshold)
|
||||
|
||||
CannyThreshold(0)
|
||||
cv.waitKey()
|
Reference in New Issue
Block a user