zoukankan      html  css  js  c++  java
  • Get a specific pixel coordinates where your mouse on (cc)

    1. #include <cv.h>    
    2. #include <highgui.h>    
    3. #include <stdio.h>    
    4.   
    5. IplImage* src=0;    
    6.   
    7. void on_mouse( int event, int x, int y, int flags, void* ustc)    
    8. {    
    9.     CvFont font;    
    10.     cvInitFont(&font, CV_FONT_HERSHEY_SIMPLEX, 0.5, 0.5, 0, 1, CV_AA);    
    11.     if( event == CV_EVENT_LBUTTONDOWN )    
    12.     {    
    13.         CvPoint pt = cvPoint(x,y);    
    14.         char temp[16];    
    15.         sprintf(temp,"(%d,%d)",pt.x,pt.y);    
    16.         cvPutText(src,temp, pt, &font, cvScalar(255, 255, 255, 0));    
    17.         cvCircle( src, pt, 2,cvScalar(255,0,0,0) ,CV_FILLED, CV_AA, 0 );    
    18.         cvShowImage( "src", src );    
    19.     }     
    20. }    
    21.   
    22. int main()    
    23. {    
    24.     src=cvLoadImage("lena.jpg",1);    
    25.     cvNamedWindow("src",1);    
    26.     cvSetMouseCallback( "src", on_mouse, 0 );    
    27.   
    28.     cvShowImage("src",src);    
    29.   
    30.     cvWaitKey(0);     
    31.     cvDestroyAllWindows();    
    32.     cvReleaseImage(&src);    
    33.   
    34.     return 0;    
    35. }    
  • 相关阅读:
    POI使用介绍
    Git的使用简介
    SOA架构搭建---duboo+zookeeper+SSM实现
    分布式事务介绍
    兼容安卓微信调用摄像头
    cookie
    js对手机软键盘的监听
    input 改变placeholder默认样式
    VisualVm使用JMX的方式连接远程JVM
    update批量根据条件更新
  • 原文地址:https://www.cnblogs.com/stevenxiu/p/5641099.html
Copyright © 2011-2022 走看看