欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

OpenCV獲取鼠標(biāo)左鍵點(diǎn)擊位置圖像的像素值

 更新時(shí)間:2019年01月18日 08:50:01   作者:XAUT_ee  
這篇文章主要為大家詳細(xì)介紹了OpenCV獲取鼠標(biāo)左鍵點(diǎn)擊位置圖像的像素值,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)現(xiàn)功能:利用opencv獲取鼠標(biāo)左鍵點(diǎn)擊位置圖像的像素值(RGB像)

vs2015+opencv3.1

#include<opencv2\opencv.hpp>
#include<iostream>
using namespace std;
using namespace cv;
void on_mouse(int EVENT, int x, int y, int flags, void* userdata);
void main()
{
 namedWindow("【display】");
 Mat src;
 src = imread("F:\\lena_rgb.jpg");
 //cvtColor(src, src, COLOR_RGB2GRAY);
 setMouseCallback("【display】", on_mouse,&src);
 //以40ms刷新顯示
 while (1)
 {
  imshow("【display】", src);
  waitKey(40);
 }



}

void on_mouse(int EVENT, int x, int y, int flags, void* userdata)
 {
  Mat hh;
  hh = *(Mat*)userdata;
  Point p(x, y);
  switch (EVENT)
  {
   case EVENT_LBUTTONDOWN:
   {

    printf("b=%d\t", hh.at<Vec3b>(p)[0]);
    printf("g=%d\t", hh.at<Vec3b>(p)[1]);
    printf("r=%d\n", hh.at<Vec3b>(p)[2]);
    circle(hh, p, 2, Scalar(255),3);
   }
   break;

  }




 }

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論