当前位置:网站首页>Rectangular sort....
Rectangular sort....
2022-07-18 13:57:00 【weixin_ fifty-one million two hundred and eighty-seven thousand】
bool compRECx(cv::Rect &a, cv::Rect &b)
{
return a.x < b.x;
}
bool compRECy(cv::Rect &a, cv::Rect &b)
{
return a.y < b.y;
}
void HTChipDetector::resortrecAndloop(std::vector<cv::Rect> &rec, std::vector<cv::Point> &loop, int maxHj, int maxHj1, int flag)
{
if (rec.size() > 1)
{
if (flag == 1)// First y Again x
{
std::sort(rec.begin(), rec.end(), compRECy);
int x = 1;
int y = 1;
std::vector<cv::Rect> rectemp, recres;
std::vector<std::vector<cv::Rect>> rectempV;
loop.push_back(cv::Point(x, y));
rectemp.push_back(rec[0]);
int firsty = rec[0].y;
for (int i = 1; i < rec.size(); i++)
{
if (rec[i].y - firsty > maxHj)// Too much spacing , Belongs to the next line
{
std::sort(rectemp.begin(), rectemp.end(), compRECx);//x Save after sorting
rectempV.push_back(rectemp);
rectemp.clear();
x++;
y = 0;
firsty = rec[i].y;
}
rectemp.push_back(rec[i]);
y++;
loop.push_back(cv::Point(x, y));
}
std::sort(rectemp.begin(), rectemp.end(), compRECx);//x Save after sorting
rectempV.push_back(rectemp);
for (int i = 0; i < rectempV.size(); i++)
{
if (rectempV[i].size() > 0)
{
recres.insert(recres.end(), rectempV[i].begin(), rectempV[i].end());
}
}
rec = recres;
}
else
{
std::sort(rec.begin(), rec.end(), compRECx);
int x = 1;
int y = 1;
std::vector<cv::Rect> rectemp, recres;
std::vector<std::vector<cv::Rect>> rectempV;
loop.push_back(cv::Point(x, y));
rectemp.push_back(rec[0]);
int firstx = rec[0].x;
for (int i = 1; i < rec.size(); i++)
{
if (rec[i].x - firstx > maxHj1)// Too much spacing , Belongs to the next line
{
std::sort(rectemp.begin(), rectemp.end(), compRECy);//x Save after sorting
rectempV.push_back(rectemp);
rectemp.clear();
y++;
x = 0;
firstx = rec[i].x;
}
rectemp.push_back(rec[i]);
x++;
loop.push_back(cv::Point(x, y));
}
std::sort(rectemp.begin(), rectemp.end(), compRECy);//x Save after sorting
rectempV.push_back(rectemp);
for (int i = 0; i < rectempV.size(); i++)
{
if (rectempV[i].size() > 0)
{
recres.insert(recres.end(), rectempV[i].begin(), rectempV[i].end());
}
}
rec = recres;
}
}
return;
}
边栏推荐
- 【锁相环】基于MATLAB的全数字锁相环设计与仿真
- 解道--探索术
- Quarkus 实战二:开发REST ful 服务实现简单的curd功能
- micro、M3O微服务系列(二)
- Common and practical SQL statements
- Abbyy finereader 15 standard OCR character recognition and PDF editing software tool
- MySQL window function running average
- T100自定义应用使用说明(azzi650)
- 测试/开发程序员幽默的 “自嘲“?印象流派......
- 【目标跟踪】基于背景消减的图像帧间差分法目标检测及matlab仿真
猜你喜欢

Modèles de boîtes, flux de documents, positionnement, mise en page et conception réactive

Test / develop programmers' humorous "self mockery"? Impression genre

XML文件删除掉注释

基于JSP+Servlet的高校疫情防控系统

Digital twin factory - Smart factory twin cockpit, realizing intelligent lean production management

关于XML文件(五)

Detailed steps for T100 to develop a new two gear program

MySQL window function running average
![[step on the pit] resurrect Pico go](/img/5a/434813aec233c1f62aad952fbaace8.png)
[step on the pit] resurrect Pico go

The digital transformation forum for small and medium-sized enterprises in Shandong Province was successfully held, and Jiuzhou cloud empowers small and medium-sized enterprises to upgrade their digit
随机推荐
Mysql 问题
Part of the problem solution of the 5th gxcpc Guangxi university student programming competition (without CDK)
micro、M3O微服务系列(一)
Color supplement of MATLAB scientific research drawing (special part 6) - 336 traditional French colors
Audio focus arbitration strategy
【锁相环】基于MATLAB的全数字锁相环设计与仿真
高数 | 积分中值定理的开闭区间、积分第一中值定理及其推广
leetcode 143. Rearrange linked list
T100debug operation record
Test / develop programmers' humorous "self mockery"? Impression genre
基于JSP+Servlet的高校疫情防控系统
Securities account Guotai Junan? Is it safe?
Golang --------- xiaoshiniudao gin framework file upload
腾讯员工发帖找对象,表示偏爱程序员!评论火了......丨黑马头条
What points should be paid attention to in the selection of project management system?
Idea merges dev branch code into master and so on
矩形排序。。。。
Enterprise OA system based on SSM, high-quality paper examples, attached source code, database script, project introduction and operation tutorial, Paper Writing Tutorial
Marginalization
函数的重载