当前位置:网站首页>Detailed explanation of rect class
Detailed explanation of rect class
2022-06-30 08:48:00 【Chasing foot dream】
If you create a Rect object rect(100, 50, 50, 100), that rect There will be the following functions :
rect.area(); // return rect The area of 5000
rect.size(); // return rect The size of the [50 × 100]
rect.tl(); // return rect The coordinates of the upper left vertex of [100, 50]
rect.br(); // return rect The coordinates of the lower right vertex of [150, 150]
rect.width(); // return rect Width 50
rect.height(); // return rect Height 100
rect.x
rect.contains(Point(x, y)); // Returns a boolean variable , Judge rect Does it include Point(x, y) spot
// You can also find the intersection and union of two rectangles
rect = rect1 & rect2;
rect = rect1 | rect2;
// You can also pan and zoom the rectangle
rect = rect + Point(-100, 100); // translation , That is, the top left vertex x coordinate -100,y coordinate +100
rect = rect + Size(-100, 100); // The zoom , Top left vertex unchanged , Width -100, Height +100
// You can also compare rectangles , Returns a boolean variable
rect1 == rect2;
rect1 != rect2;
//OpenCV There seems to be no judgment in rect1 Whether in rect2 The function inside , So write one yourself
bool isInside(Rect rect1, Rect rect2)
{
return (rect1 == (rect1&rect2));
}
//OpenCV It seems that there is no function to obtain the center point of the rectangle , Or write one by yourself
Point getCenterPoint(Rect rect)
{
Point cpt;
cpt.x = rect.x + cvRound(rect.width/2.0);
cpt.y = rect.y + cvRound(rect.height/2.0);
return cpt;
}
// Scale around the center of the rectangle
Rect rectCenterScale(Rect rect, Size size)
{
rect = rect + size;
Point pt;
pt.x = cvRound(size.width/2.0);
pt.y = cvRound(size.height/2.0);
return (rect-pt);
}
边栏推荐
- Unity简单shader
- Redis design and Implementation (V) | sentinel sentry
- C#访问MongoDB并执行CRUD操作
- CUDA implements matrix replication
- mysql基础入门 day4 动力节点[老杜]课堂笔记
- Rew acoustic test (V): equipment required for test
- Bind threads to run on a specific CPU logical kernel
- C#访问SQL Server数据库两种方式的比较(SqlDataReader vs SqlDataAdapter)
- Unity basic lighting model
- How can I get the discount for opening a securities account? Is online account opening safe?
猜你喜欢

A troubleshooting of CPU bottom falling

我们如何拿到自己满意的薪资呢?这些套路还是需要掌握的

Mmcv expanding CUDA operator beginner level chapter

Rew acoustic test (II): offline test

一次cpu 跌底排查

电流探头电路分析
![[nvme2.0b 14-8] set features (Part 2)](/img/fe/67fd4f935237f9aa835e132e696b98.png)
[nvme2.0b 14-8] set features (Part 2)

Swagger use

将线程绑定在某个具体的CPU逻辑内核上运行

Tidb v6.0.0 (DMR): initial test of cache table - tidb Book rush
随机推荐
【kotlin 协程】万字协程 一篇完成kotlin 协程进阶
Sort (simple description)
Tidb 6.0: making Tso more efficient tidb Book rush
[untitled]
Redis design and Implementation (IV) | master-slave replication
QT connection to Shentong database
我们如何拿到自己满意的薪资呢?这些套路还是需要掌握的
Unity 基础光照模型
Axure make menu bar effect
Rew acoustic test (IV): test principle of rew
How can we get a satisfactory salary? These routines still need to be mastered
Redis design and Implementation (VII) | publish & subscribe
Circuit analysis of current probe
Redis design and Implementation (II) | database (deletion strategy & expiration elimination strategy)
Influencing factors of echo cancellation for smart speakers
Flink sql -- No factory implements ‘org.apache.flink.table.delegation.ExecutorFactory‘.
基于Svelte3.x桌面端UI组件库Svelte UI
CUDA implements matrix replication
2021-02-22
Alcohol tester scheme: what principle does the alcohol tester measure alcohol solubility based on?