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. }    
  • 相关阅读:
    模拟器分辨率收集
    6. 蜂鳴器
    5. 伺服馬達
    4. 流水燈
    3. 序列埠的輸出以及按鈕消抖
    2. 沒有按鈕的電路是沒有靈魂的
    1. 點亮一個LED燈
    ARDUINO準備工作
    vritualenvwrapper的基本操作
    蠻力法兌換零錢及其優化
  • 原文地址:https://www.cnblogs.com/stevenxiu/p/5641099.html
Copyright © 2011-2022 走看看