当前位置:网站首页>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 .
边栏推荐
- Information security - Epic vulnerability log4j vulnerability mechanism and preventive measures
- TCP's three handshakes and four waves
- [exercise-9] Zombie's Treasury test
- 【练习-3】(Uva 442)Matrix Chain Multiplication(矩阵链乘)
- Opencv learning log 16 paperclip count
- [exercise-6] (UVA 725) division = = violence
- Differential (one-dimensional, two-dimensional, three-dimensional) Blue Bridge Cup three body attack
- 渗透测试 ( 2 ) --- 渗透测试系统、靶机、GoogleHacking、kali工具
- Flink 使用之 CEP
- Penetration test (3) -- Metasploit framework (MSF)
猜你喜欢
Penetration test 2 --- XSS, CSRF, file upload, file inclusion, deserialization vulnerability
信息安全-威胁检测引擎-常见规则引擎底座性能比较
PySide6 信号、槽
渗透测试 ( 8 ) --- Burp Suite Pro 官方文档
1010 things that college students majoring in it must do before graduation
Ball Dropping
STM32 how to use stlink download program: light LED running light (Library version)
洛谷P1102 A-B数对(二分,map,双指针)
Penetration test (4) -- detailed explanation of meterpreter command
mysql导入数据库报错 [Err] 1273 – Unknown collation: ‘utf8mb4_0900_ai_ci’
随机推荐
树莓派CSI/USB摄像头使用mjpg实现网页摄像头监控
Interesting drink
Penetration test (4) -- detailed explanation of meterpreter command
China's peripheral catheter market trend report, technological innovation and market forecast
Research Report on surgical fluid treatment industry - market status analysis and development prospect prediction
Differential (one-dimensional, two-dimensional, three-dimensional) Blue Bridge Cup three body attack
【练习-8】(Uva 246)10-20-30==模拟
Information security - Epic vulnerability log4j vulnerability mechanism and preventive measures
Ball Dropping
The concept of C language array
TCP's three handshakes and four waves
Nodejs+vue网上鲜花店销售信息系统express+mysql
[exercise-4] (UVA 11988) broken keyboard = = (linked list)
socket通讯
D - Function(HDU - 6546)女生赛
Flink 使用之 CEP
[exercise-2] (UVA 712) s-trees
[exercise-3] (UVA 442) matrix chain multiplication
PySide6 信号、槽
Opencv learning log 32 edge extraction