当前位置:网站首页>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 .
边栏推荐
- 【练习-6】(PTA)分而治之
- Understand what is a programming language in a popular way
- Ball Dropping
- C language must memorize code Encyclopedia
- Research Report of peripheral venous catheter (pivc) industry - market status analysis and development prospect prediction
- 信息安全-安全专业名称|CVE|RCE|POC|VUL|0DAY
- Auto. Getting started with JS
- CEP used by Flink
- Opencv learning log 15 count the number of solder joints and output
- China exterior wall cladding (EWC) market trend report, technical dynamic innovation and market forecast
猜你喜欢

Programmers, what are your skills in code writing?

渗透测试 ( 7 ) --- 漏洞扫描工具 Nessus

Information security - threat detection - detailed design of NAT log access threat detection platform

Web based photo digital printing website

b站 實時彈幕和曆史彈幕 Protobuf 格式解析

【高老师软件需求分析】20级云班课习题答案合集

Differential (one-dimensional, two-dimensional, three-dimensional) Blue Bridge Cup three body attack

STM32 how to use stlink download program: light LED running light (Library version)

Penetration test (7) -- vulnerability scanning tool Nessus
![[teacher Gao UML software modeling foundation] collection of exercises and answers for level 20 cloud class](/img/57/bc6eda91f7263acda38b9ee8732318.png)
[teacher Gao UML software modeling foundation] collection of exercises and answers for level 20 cloud class
随机推荐
信息安全-威胁检测-flink广播流BroadcastState双流合并应用在过滤安全日志
Penetration test (2) -- penetration test system, target, GoogleHacking, Kali tool
[exercise-3] (UVA 442) matrix chain multiplication
Truck History
[exercise-5] (UVA 839) not so mobile (balance)
[exercise-6] (UVA 725) division = = violence
Opencv learning log 31 -- background difference
[teacher Gao UML software modeling foundation] collection of exercises and answers for level 20 cloud class
Interesting drink
Information security - threat detection - Flink broadcast stream broadcaststate dual stream merging application in filtering security logs
信息安全-安全编排自动化与响应 (SOAR) 技术解析
China potato slicer market trend report, technical dynamic innovation and market forecast
Determine the Photo Position
E. Breaking the Wall
D - Function(HDU - 6546)女生赛
nodejs爬虫
初入Redis
Analyse du format protobuf du rideau en temps réel et du rideau historique de la station B
【练习-5】(Uva 839)Not so Mobile(天平)
Flink 使用之 CEP