前言
今天,东莞,天气晴。温度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图像处理工具。它包含基本的图像处理、视频处理还包含其它特征匹配功能。有关它的早前介绍请参见链接。待续。