OpenCV實(shí)現(xiàn)圖像角點(diǎn)檢測(cè)
歷時(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í)有所幫助,也希望大家多多支持腳本之家。
- Python使用Opencv實(shí)現(xiàn)圖像特征檢測(cè)與匹配的方法
- python opencv檢測(cè)目標(biāo)顏色的實(shí)例講解
- 10個(gè)步驟Opencv輕松檢測(cè)出圖片中條形碼
- Python 使用Opencv實(shí)現(xiàn)目標(biāo)檢測(cè)與識(shí)別的示例代碼
- Python Opencv實(shí)現(xiàn)單目標(biāo)檢測(cè)的示例代碼
- Opencv Hough算法實(shí)現(xiàn)圖片中直線檢測(cè)
- 使用OpenCV檢測(cè)圖像中的矩形
- opencv?canny邊緣檢測(cè)算法詳解
- 基于OpenCV的路面質(zhì)量檢測(cè)的實(shí)現(xiàn)
- opencv實(shí)現(xiàn)礦石圖片檢測(cè)礦石數(shù)量
相關(guān)文章
C語(yǔ)言實(shí)現(xiàn)簡(jiǎn)單酒店管理系統(tǒng)
這篇文章主要為大家詳細(xì)介紹了C語(yǔ)言實(shí)現(xiàn)簡(jiǎn)單酒店管理系統(tǒng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-03-03C++深度優(yōu)先搜索的實(shí)現(xiàn)方法
這篇文章主要介紹了C++深度優(yōu)先搜索的實(shí)現(xiàn)方法,是數(shù)據(jù)結(jié)構(gòu)中非常重要的一種算法,需要的朋友可以參考下2014-08-08makefile如何調(diào)用靜態(tài)庫(kù)的方法實(shí)現(xiàn)
這篇文章主要介紹了makefile如何調(diào)用靜態(tài)庫(kù)的方法實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-12-12c語(yǔ)言輸出字符串中最大對(duì)稱子串長(zhǎng)度的3種解決方案
這篇文章主要介紹了c語(yǔ)言輸出字符串中最大對(duì)稱子串長(zhǎng)度的3種解決方案,需要的朋友可以參考下2014-03-03