asp.net-mvc – Accord.NET比较两个图像以确定相似性
发布时间:2020-05-23 21:24:24 所属栏目:asp.Net 来源:互联网
导读:我希望您的建议是为什么代码可能会变得无法响应以及如何解决它. 我正在使用Accord.NET来比较图像.我的项目的第一阶段是比较两个图像,一个观察图像和一个模型图像,并确定它们有多相似;第二种方法是将观察到的图像与我的整个数据库进行比较,以根据模型的分类方
|
我希望您的建议是为什么代码可能会变得无法响应以及如何解决它. 我正在使用Accord.NET来比较图像.我的项目的第一阶段是比较两个图像,一个观察图像和一个模型图像,并确定它们有多相似;第二种方法是将观察到的图像与我的整个数据库进行比较,以根据模型的分类方式确定观察到的图像最有可能是什么.现在我专注于第一个.我最初尝试使用ExhaustiveTemplateMatching.ProcessImage()但它不符合我的需要.现在,我正在使用SURF.这是我的代码: public class ProcessImage
{
public static void Similarity(System.IO.Stream model,System.IO.Stream observed,out float similPercent)
{
Bitmap bitModel = new Bitmap(model);
Bitmap bitObserved = new Bitmap(observed);
// For method Difference,see http://www.aforgenet.com/framework/docs/html/673023f7-799a-2ef6-7933-31ef09974dde.htm
// Inspiration for this process: https://www.youtube.com/watch?v=YHT46f2244E
// Greyscale class http://www.aforgenet.com/framework/docs/html/d7196dc6-8176-4344-a505-e7ade35c1741.htm
// Convert model and observed to greyscale
Grayscale filter = new Grayscale(0.2125,0.7154,0.0721);
// apply the filter to the model
Bitmap greyModel = filter.Apply(bitModel);
// Apply the filter to the observed image
Bitmap greyObserved = filter.Apply(bitObserved);
int modelPoints = 0,matchingPoints = 0;
/*
* This doesn't work. Images can have different sizes
// For an example,https://thecsharper.com/?p=94
// Match
var tm = new ExhaustiveTemplateMatching(similarityThreshold);
// Process the images
var results = tm.ProcessImage(greyModel,greyObserved);
*/
using (SpeededUpRobustFeaturesDetector detector = new SpeededUpRobustFeaturesDetector())
{
List<SpeededUpRobustFeaturePoint> surfModel = detector.ProcessImage(greyModel);
modelPoints = surfModel.Count();
List<SpeededUpRobustFeaturePoint> surfObserved = detector.ProcessImage(greyObserved);
KNearestNeighborMatching matcher = new KNearestNeighborMatching(5);
var results = matcher.Match(surfModel,surfObserved);
matchingPoints = results.Length;
}
// Determine if they represent the same points
// Obtain the pairs of associated points,we determine the homography matching all these pairs
// Compare the results,0 indicates no match so return false
if (matchingPoints <= 0)
{
similPercent = 0.0f;
}
similPercent = (matchingPoints * 100) / modelPoints;
}
}
到目前为止,我得到了点列表,但是当匹配代码时似乎没有响应. 我在用户发布位图后从ASP.NET网页调用上面的代码.这是代码,如果它可能有所帮助: public ActionResult Compare(int id)
{
ViewData["SampleID"] = id;
return View();
}
[HttpPost]
public ActionResult Compare(int id,HttpPostedFileBase uploadFile)
{
Sample model = _db.Sample_Read(id);
System.IO.Stream modelStream = null;
float result = 0;
_db.Sample_Stream(model.FileId,out modelStream);
ImgProc.ProcessImage.Similarity(modelStream,uploadFile.InputStream,out result);
ViewData["SampleID"] = id;
ViewData["match"] = result;
return View();
}
页面本身相当简单,隐藏字段,文件类型输入和提交. 解决方法问题是我的电脑.经过一段时间处理后,计算结束.谢谢, (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net – AsyncPostBackTrigger找不到LinkButton
- asp.net – 任何类似于蚂蚁分析器和免费的工具?
- asp.net-mvc – Asp.Net MVC中的JQuery UI datepicker
- asp.net-mvc – 如何下载Razor View引擎
- asp.net-mvc-3 – ASP.NET MVC视图模型不绑定在HTTP Post与
- asp.net-mvc – .Net 4内存缓存类和用户会话
- asp.net – 从两个表(join)获取数据,并使用linq返回结果
- 在ASP.NET中将MS Word文档转换为PDF
- asp.net-mvc-3 – ASP.NET MVC3 Razor:没有@if或@foreach可
- asp.net – 如何在隐藏字段(TextBox)上触发RequiredFieldVa
推荐文章
站长推荐
- asp.net – 网页中的电子签名[已关闭]
- asp.net – 如何禁用viewstate的aspx页面?
- asp.net-mvc – 将表单提交为JSON(无AJAX)
- 我可以使用ASP.NET Core仅针对.NET 4.6.1吗?
- asp.net – 是否可以根据用户角色隐藏/显示Kendo
- 在Asp.Net中使用Office365 SMTP时出错
- asp.net-mvc – asp.net MVC:禁用一个TextBox
- asp.net-core – 从与xproj相同的解决方案引用cs
- asp.net-mvc – 我如何使用一个新的Phil的路由网
- asp.net-mvc – ASP.NET MVC – 如何获取一个URL
热点阅读
