亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

OpenCV實(shí)現(xiàn)圖像角點(diǎn)檢測(cè)

 更新時(shí)間:2019年01月12日 13:33:07   作者:lindamtd  
這篇文章主要為大家詳細(xì)介紹了OpenCV實(shí)現(xiàn)圖像角點(diǎn)檢測(cè),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

歷時(shí)一個(gè)多月,于今天上午終于將項(xiàng)目交上去了,這期間雖很辛苦,但是成長(zhǎng)了不少,在此將項(xiàng)目中涉及到的知識(shí)點(diǎn)進(jìn)行整理,本文主要介紹圖像的角點(diǎn)檢測(cè):

一、代碼部分:

// Detect_Corners.cpp : 定義控制臺(tái)應(yīng)用程序的入口點(diǎn)。
//
#include "stdafx.h"
#include "opencv2/opencv.hpp"  
#include <opencv2/imgproc/imgproc.hpp> 
#include <iostream>
#include "opencv2/highgui/highgui.hpp"   
#include <stdio.h> 
#include <stdlib.h> 
using namespace std;
using namespace cv;
//全局變量 
Mat src, src_gray; 
int thresh = 200; 
int max_thresh = 255; 

char* source_window = "Source image"; 
//char* corners_window = "Corners detected";
//函數(shù)聲明 
void cornerHarris_demo(int, void*); 

int _tmain(int argc, _TCHAR* argv[])
{ 
  //Load source image and convert it to gray
  char *img_name="..\\image\\71254.png";
  src=imread(img_name);
  imshow(source_window,src);
  cvtColor(src, src_gray, CV_BGR2GRAY); 
  createTrackbar("Threshold: ", source_window, &thresh, max_thresh, cornerHarris_demo);
  waitKey(0);
  //角點(diǎn)檢測(cè)
  cornerHarris_demo(0,0); 
  return 0;
}
/** 函數(shù) cornerHarris_demo */  
void cornerHarris_demo( int, void*) 
{ 
  Mat dst, dst_norm,dst_norm_scaled; 
  dst = Mat::zeros(src.size(), CV_32FC1 ); 
  // Detector parameters 
  int blockSize = 2; 
  int apertureSize = 3; 
  double k = 0.04; 
  // Detecting corners 
  cornerHarris( src_gray, dst, blockSize, apertureSize, k, BORDER_DEFAULT ); 
  // Normalizing 
  normalize( dst, dst_norm, 0, 255, NORM_MINMAX, CV_32FC1, Mat() ); 
  convertScaleAbs( dst_norm, dst_norm_scaled );  
  // Drawing a circle around corners 
  for( int j = 0; j < dst_norm.rows ; j++ ) 
   { for( int i = 0; i < dst_norm.cols; i++ ) 
     { 
      if( (int) dst_norm.at<float>(j,i) > thresh ) 
       {  
        circle( dst_norm_scaled, Point(i, j), 5, Scalar(0), 2, 8, 0 );  
        circle(src,Point( i, j ), 5, Scalar(255,0,0), -1, 8, 0 ); 
       } 
     }  
   }   
 // Showing the result 
  imshow( source_window, src); 
} 

二、檢測(cè)效果圖:

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

相關(guān)文章

最新評(píng)論