当前位置:网站首页>Opencv learning log 27 -- chip positioning
Opencv learning log 27 -- chip positioning
2022-07-06 16:07:00 【@Spring sauce】
Preface
This article focuses on opencv Application of chip positioning in image processing .
One 、 Chip positioning
// Chip positioning
#include <opencv2/opencv.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main()
{
cv::Mat dst;
cv::Mat dstbin;
cv::Mat dsttemp;
cv::Mat resMat;
cv::Mat Matstate;
cv::Mat center;
cv::Mat src = imread("C://Users//john//Desktop//1.jpg");
cv::Mat srcgray = imread("C://Users//john//Desktop//1.jpg", 0);
threshold(srcgray, dstbin, 100, 255, THRESH_OTSU); // Dajin law
cv::imshow("dstbin", dstbin);
src.copyTo(dst);
//bitwise_not(dstbin, dsttemp);
vector<vector<Point>> contours;
vector<Vec4i> hirearchy;
findContours(dstbin, contours, CV_RETR_LIST, CV_CHAIN_APPROX_NONE);
int num = contours.size();
//cout << num << endl;
Point2f rect[4];
for (int i = 0; i < num; i++)
{
RotatedRect rbox = minAreaRect(contours[i]);
///cout << rbox << endl;
int area = contourArea(contours[i]);// Calculate the contour area
rbox.points(rect); // Copy the four ends of the smallest circumscribed rectangle to rect Array
if (fabs(rbox.size.width * 1.0 / rbox.size.height - 1) < 0.2&&area>=100)
{
drawContours(dst, contours, i, Scalar(255, 0, 0), -1, 8);
for (int j = 0; j<4; j++)
{
line(dst, rect[j], rect[(j + 1) % 4], Scalar(255, 255, 255), 2, 8); // Draw the smallest outer edge of each rectangle
}
}
}
cv::imshow("dsttemp", dstbin);
cv::imshow("dst", dst);
waitKey(0);
}
summary
1. The code can run directly , If you don't understand, please leave a message .
2. Missing material pictures , Follow up, thank you .
边栏推荐
- Path problem before dynamic planning
- 【练习-8】(Uva 246)10-20-30==模拟
- Penetration test (3) -- Metasploit framework (MSF)
- socket通讯
- [analysis of teacher Gao's software needs] collection of exercises and answers for level 20 cloud class
- b站 實時彈幕和曆史彈幕 Protobuf 格式解析
- The most complete programming language online API document
- Nodejs+vue online fresh flower shop sales information system express+mysql
- Determine the Photo Position
- 信息安全-安全专业名称|CVE|RCE|POC|VUL|0DAY
猜你喜欢
Determine the Photo Position
D - Function(HDU - 6546)女生赛
Penetration test (3) -- Metasploit framework (MSF)
Information security - Analysis of security orchestration automation and response (soar) technology
渗透测试 2 --- XSS、CSRF、文件上传、文件包含、反序列化漏洞
渗透测试 ( 2 ) --- 渗透测试系统、靶机、GoogleHacking、kali工具
Web based photo digital printing website
[exercise-4] (UVA 11988) broken keyboard = = (linked list)
b站 實時彈幕和曆史彈幕 Protobuf 格式解析
信息安全-威胁检测引擎-常见规则引擎底座性能比较
随机推荐
Borg Maze (BFS+最小生成树)(解题报告)
HDU - 6024 Building Shops(女生赛)
Write web games in C language
Determine the Photo Position
E. Breaking the Wall
[exercise-7] (UVA 10976) fractions again?! (fraction split)
【练习-6】(PTA)分而治之
MySQL grants the user the operation permission of the specified content
Perform general operations on iptables
【高老师软件需求分析】20级云班课习题答案合集
Penetration test (8) -- official document of burp Suite Pro
渗透测试 ( 2 ) --- 渗透测试系统、靶机、GoogleHacking、kali工具
Interesting drink
C basic grammar
The concept of C language array
Research Report of exterior wall insulation system (ewis) industry - market status analysis and development prospect prediction
【练习-9】Zombie’s Treasure Chest
Opencv learning log 19 skin grinding
想应聘程序员,您的简历就该这样写【精华总结】
B - 代码派对(女生赛)