標籤:影像處理 nodejs
前言
今天,東莞,天氣晴。溫度33到27度。今天天氣晴。這段時間期末,事情比較多,也很久沒有更新部落格。前幾周終於把特徵識別完成,由於最近把國外的一些網站給屏蔽了,因此暫時只能重啟csdn寫文章。
本文對特徵識別的用法簡單描述。本文你將學會使用nodeitk,
- 使用DescriptorExtractor介面尋找關鍵點對應的特徵向量
- 使用BFMatcher匹配特徵向量
- 使用drawMatches繪製特徵匹配
原始碼
var node_itk = require('./node-itk'); // 讀模數塊圖 var img_1 = node_itk.cv.imread( "./images/lena.jpg", node_itk.cv.CV_LOAD_IMAGE_GRAYSCALE ); // 讀取靶心圖表 var img_2 = node_itk.cv.imread( "./images/lena.jpg", node_itk.cv.CV_LOAD_IMAGE_GRAYSCALE ); minHessian = 400 // 設定特徵檢測方法 detector = new node_itk.cv.NodeOpenCVFeatureDetector("SURF") detector.Set("hessianThreshold", minHessian) keypoints_1 = detector.Detect( img_1 ); keypoints_2 = detector.Detect( img_2 ); // 擷取特徵描述 extractor = new node_itk.cv.NodeOpenCVDescriptorExtractor("SURF"); descriptors_1 = extractor.Compute(img_1, keypoints_1) descriptors_2 = extractor.Compute(img_2, keypoints_2) // 設定匹配方法 matcher = new node_itk.cv.NodeOpenCVDescriptorMatcher("FlannBased"); matches = matcher.Match(descriptors_1, descriptors_2); // 繪製匹配結果 img_matches = node_itk.cv.DrawMatches(img_1, keypoints_1, img_2, keypoints_2, matches); node_itk.cv.NamedWindow( "match", node_itk.cv.CV_WINDOW_AUTOSIZE ); node_itk.cv.imshow( "match", img_matches ); c = node_itk.cv.WaitKey ( 0 ); if( c >= 0 ) { return -1; }
結果
小結
nodeitk是由本人獨立開發的基於nodejs影像處理工具。它包含基本的影像處理、視頻處理還包含其它特徵匹配功能。有關它的早前介紹請參見連結。待續。