当前位置:网站首页>AI opencvsharp big picture to small picture (case version)
AI opencvsharp big picture to small picture (case version)
2022-07-19 03:44:00 【Dotnet cross platform】
To say with AI What does it matter , It is estimated that only the library itself , however , This big map search small map function is still good , You can try something you like . My main scene is , A specific interface is a big picture , An icon in the interface is a small figure , perhaps , The whole desktop is a big picture , A small icon is a small diagram to determine the location of a plug-in or function .
I also wrote before based on C# Code mapping , But I don't feel efficient , This time, we will make a decision based on OpenCvSharp Map finding function of , If you like, you can try .
Create a Winfrom project
Because the project example is simple , however , You also need to get the desktop size , We have to create such a project .
You want to add Nuget package
Install-Package OpenCvSharp4.Windows -Version 4.6.0.20220608Find the main business code
public static Rectangle Find(Image sourceImage, Image matchImage, double threshold = 0.8)
{
var refMat = Mat.FromImageData(ImageHelper.ImageToBytes(sourceImage), ImreadModes.AnyColor);// Big picture
var tplMat = Mat.FromImageData(ImageHelper.ImageToBytes(matchImage), ImreadModes.AnyColor);// Little picture
using (Mat res = new Mat(refMat.Rows - tplMat.Rows + 1, refMat.Cols - tplMat.Cols + 1, MatType.CV_32FC1))
{
Mat gref = refMat.CvtColor(ColorConversionCodes.BGR2GRAY);
Mat gtpl = tplMat.CvtColor(ColorConversionCodes.BGR2GRAY);
Cv2.MatchTemplate(gref, gtpl, res, TemplateMatchModes.CCoeffNormed);
Cv2.Threshold(res, res, 0.8, 1.0, ThresholdTypes.Tozero);
double minval, maxval;
Point minloc, maxloc;
Cv2.MinMaxLoc(res, out minval, out maxval, out minloc, out maxloc);
if (maxval >= threshold)
{
return new Rectangle(maxloc.X, maxloc.Y, tplMat.Width, tplMat.Height);
}
return Rectangle.Empty;
}
}Search can be realized according to similarity , In fact, if you take a screenshot directly , Similarity is 0.99, It's pretty good .
If the multi graph result returns , The boss who wants to study , You can study .
effect

You can see that the search speed is still very fast , Of course , The first time may be a little slower , near 200 The ms
summary
This case is solved , It means going WEB Page slide map unlock verification Automation is another step forward , Think about how to do this case later .
Code address
https://github.com/kesshei/SearchImageDemo.git
https://gitee.com/kesshei/SearchImageDemo.git
reading
One button three times !, Thank you for your support , Your support is my motivation !
边栏推荐
- Leetcode: 0-1 knapsack problem in dynamic programming [come and set the template directly]
- Matlab在线性代数中的应用
- 洛谷每日三题之第三天(第四天补做)
- Operator, assignment statement, structure description statement
- Simple usage and interface introduction of labelme
- Gnome boxes virtual machine creation and installation
- 第一章 绪论
- Unity解决同材质物体重叠产生Z-Fighting的问题
- leetcode:50. Pow(x, n)
- JMeter中如何实现接口之间的关联?
猜你喜欢
随机推荐
Unity solves the problem of Z-fighting caused by overlapping objects with the same material
Unity using Sqlite
【LeetCode】745. 前缀和后缀搜索
Leetcode: 0-1 knapsack problem in dynamic programming [come and set the template directly]
Method of realizing horizontal and vertical centering of unknown width and height elements
Local storage localstorage ⽤ method details
Bias and variance
options has an unknown property ‘before‘
[C语言勘误]数组长度的函数内获取方式错误
oracle 查询非自增长分区的最大分区
No, check it out
Fisher linear discriminant analysis
【Nodejs】npm/nrm无法加载文件、因为在此系统禁止执行脚本解决方式
Vs code problem: launch:program '... \ vscode\launch. exe‘ dose not exist
神经网络学习笔记2.2 ——用Matlab写一个简单的卷积神将网络图像分类器
一种鲁棒变形卷积神经网络图像去噪
10. Redis 面试常见问答
leetcode162. Looking for peak
运算符、赋值语句、结构说明语句
Detailed explanation of arrow function and this direction








