OpenCV:函数参数对什么有用?

时间:2015-02-03 15:37:18

标签: python opencv

我不明白这段代码取自OpenCV documentation

import cv2
import numpy as np

# mouse callback function
def draw_circle(event,x,y,flags,param):
    if event == cv2.EVENT_LBUTTONDBLCLK:
        cv2.circle(img,(x,y),100,(255,0,0),-1)

# Create a black image, a window and bind the function to window
img = np.zeros((512,512,3), np.uint8)
cv2.namedWindow('image')
cv2.setMouseCallback('image',draw_circle)

while(1):
    cv2.imshow('image',img)

具体来说,我不明白为什么draw_circle()函数的参数是这样的,但以后从未使用过。有人可以向我解释一下这背后是什么吗?

1 个答案:

答案 0 :(得分:-3)

Bellow我的代码工作正常,请查看它..

import cv2
import numpy as np

img1=cv2.imread('Image/Desert.jpg')       
def draw(event,x,y,flage,param):
    if event==cv2.EVENT_LBUTTONDBLCLK:
        cv2.circle(img1,(x,y),4,(0,0,0),4)
        cv2.namedWindow('Image')
        cv2.setMouseCallback('Image',draw)
    while(1):
        cv2.imshow('Image',img1)
        if cv2.waitKey(20) & 0xFF ==27:
            break
    cv2.destroyAllWindows()