OpenCV:函数自变量有用吗? [英] OpenCV: function arguments useful for what?

查看:95
本文介绍了OpenCV:函数自变量有用吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不理解来自OpenCV的这段代码文档:

I do not understand this code taken from 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()函数的参数是这种方式,但以后不再使用.有人可以向我解释其背后的原因吗?

Specifically, I do not understand why the parameters of the draw_circle() function are that way but never used later. Can someone explain to me what's behind that, please?

推荐答案

以下我的代码运行正常,只需将其签出即可..

Bellow my code is working fine just check it out..

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()

这篇关于OpenCV:函数自变量有用吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆