Files
open-cv-experiment/test/2024,9,23/homework.py
T
2024-09-23 22:03:17 +08:00

22 lines
491 B
Python

import cv2 as cv
# 1
img=cv.imread("sample.jpg",cv.IMREAD_GRAYSCALE)
# 2
def draw_circle(event,x,y,flags,param):
if event==cv.EVENT_LBUTTONDOWN:
cv.circle(img,(x,y),10,0,-1)
#3
cv.namedWindow('modify_sample')
cv.setMouseCallback('modify_sample',draw_circle)
#4
alpha=0.3
beta=80
while(1):
cv.imshow('modify_sample',img)
pressedKey=cv.waitKey(5)
# 5
if pressedKey==ord('q'):
break
if pressedKey==ord('s'):
cv.imwrite('modified_sample.jpg',img)