• python手记(39)


    #!/usr/bin/env python
    #-*- coding: utf-8 -*-
    #code:myhaspl@qq.com
    import cv2
    import numpy as np
    
    
    fn="test1.jpg"
    print 'http://blog.csdn.net/myhaspl'
    print 'myhaspl@qq.com'
    print
    print 'loading %s ...' % fn
    print 'working',
    img = cv2.imread(fn)
    w=img.shape[1]
    h=img.shape[0]
    sz1=w
    sz0=h
    EVENTS = ['CV_EVENT_MOUSEMOVE', 'CV_EVENT_LBUTTONDOWN', 'CV_EVENT_RBUTTONDOWN',  'CV_EVENT_MBUTTONDOWN',  'CV_EVENT_LBUTTONUP',
              'CV_EVENT_RBUTTONUP', 'CV_EVENT_MBUTTONUP'  , 'CV_EVENT_LBUTTONDBLCLK','CV_EVENT_RBUTTONDBLCLK','CV_EVENT_MBUTTONDBLCLK']
    
    def callback_function(event,x,y,flag,param):
            global EVENTS
            global img
            
            if EVENTS[event]=='CV_EVENT_LBUTTONDOWN':
                    print "(%d,%d):"%(y,x)
                    print img[y,x,:]
                    cv2.imshow('img', img) 
    
               
            return
    def getdistance(color1,color2):
        return np.sqrt(sum((color1-color2)*(color1-color2)))
    
    
    
    cv2.namedWindow('img')     
    cv2.setMouseCallback('img', callback_function)
    cv2.imshow('img', img)     
    cv2.waitKey()  
    cv2.destroyAllWindows()
    
    



    python opencv 鼠标事件


  • 相关阅读:
    学了axure的感受
    axure的功能
    PS的应用
    day15-1 模块
    day14-2 模块详解
    day14-1 模块定义,导入
    day13-1 Json & pickle 数据序列化
    day12-3 内置方法
    day12-2 内置方法
    day12-1 迭代器和生成器
  • 原文地址:https://www.cnblogs.com/keanuyaoo/p/3279867.html
Copyright © 2020-2023  润新知