车位检测中,判断多帧图像检测出的车位是否是同一个车位.计算其IOU.

判断一个点是否在一个四边形内

Approach : Let the coordinates of four corners be A(x1, y1), B(x2, y2), C(x3, y3) and D(x4, y4). And coordinates of the given point P be (x, y)

  1. Calculate area of the given rectangle, i.e., area of the rectangle ABCD as area of triangle ABC + area of triangle ACD.

    Area A = [ x1(y2 – y3) + x2(y3 – y1) + x3(y1-y2)]/2 + [ x1(y4 – y3) + x4(y3 – y1) + x3(y1-y4)]/2
  2. Calculate area of the triangle PAB as A1.
  3. Calculate area of the triangle PBC as A2.
  4. Calculate area of the triangle PCD as A3.
  5. Calculate area of the triangle PAD as A4.
  6. If P lies inside the triangle, then A1 + A2 + A3 + A4 must be equal to A.
#include <bits/stdc++.h>
using namespace std; /* A utility function to calculate area of
triangle formed by (x1, y1), (x2, y2) and
(x3, y3) */
float area(int x1, int y1, int x2, int y2,
int x3, int y3)
{
return abs((x1 * (y2 - y3) + x2 * (y3 - y1) +
x3 * (y1 - y2)) / 2.0);
} /* A function to check whether point P(x, y)
lies inside the rectangle formed by A(x1, y1),
B(x2, y2), C(x3, y3) and D(x4, y4) */
bool check(int x1, int y1, int x2, int y2, int x3,
int y3, int x4, int y4, int x, int y)
{
/* Calculate area of rectangle ABCD */
float A = area(x1, y1, x2, y2, x3, y3) +
area(x1, y1, x4, y4, x3, y3); /* Calculate area of triangle PAB */
float A1 = area(x, y, x1, y1, x2, y2); /* Calculate area of triangle PBC */
float A2 = area(x, y, x2, y2, x3, y3); /* Calculate area of triangle PCD */
float A3 = area(x, y, x3, y3, x4, y4); /* Calculate area of triangle PAD */
float A4 = area(x, y, x1, y1, x4, y4); /* Check if sum of A1, A2, A3 and A4
is same as A */
return (A == A1 + A2 + A3 + A4);
} /* Driver program to test above function */
int main()
{
/* Let us check whether the point P(10, 15)
lies inside the rectangle formed by A(0, 10),
B(10, 0) C(0, -10) D(-10, 0) */
if (check(0, 10, 10, 0, 0, -10, -10, 0, 10, 15))
cout << "yes";
else
cout << "no";
return 0;
}

车位iou计算的更多相关文章

  1. 目标检测——IoU 计算

    Iou 的计算 我们先考虑一维的情况:令 \(A = [x_1,x_2], B = [y_1, y_2]\),若想要 \(A\) 与 \(B\) 有交集,需要满足如下情况: 简言之,要保证 \(A\) ...

  2. DDBNet:Anchor-free新训练方法,边粒度IoU计算以及更准确的正负样本 | ECCV 2020

    论文针对当前anchor-free目标检测算法的问题提出了DDBNet,该算法对预测框进行更准确地评估,包括正负样本以及IoU的判断.DDBNet的创新点主要在于box分解和重组模块(D&R) ...

  3. 两个Bounding Box的IOU计算代码

    Bounding Box的数据结构为(xmin,ymin,xmax,ymax) 输入:box1,box2 输出:IOU值 import numpy as np def iou(box1,box2): ...

  4. IOU计算python实现

    def compute_iou(rec1, rec2): """ computing IoU :param rec1: (y0, x0, y1, x1), which r ...

  5. yolov3源码分析keras(二)损失函数计算

    一.前言 损失函数计算主要分析两部分一部分是yolo_head函数的分析另一部分为ignore_mask的生成的分析. 二.重要细节分析 2.1损失函数计算具体代码及部分分析 def yolo_los ...

  6. mask-rcnn代码解读(五):mask_iou的计算

    我以为只有box能计算iou值,但我看了maskrcnn后,发现该模型对mask进行了iou的计算,该方法巧妙之处在于 mask1与mask2必须有相同的height and width,而后在同一个 ...

  7. AAAI 2020 | DIoU和CIoU:IoU在目标检测中的正确打开方式

    论文提出了IoU-based的DIoU loss和CIoU loss,以及建议使用DIoU-NMS替换经典的NMS方法,充分地利用IoU的特性进行优化.并且方法能够简单地迁移到现有的算法中带来性能的提 ...

  8. 目标检测的评价指标(TP、TN、FP、FN、Precision、Recall、IoU、mIoU、AP、mAP)

    1. TP TN FP FN ​ GroundTruth 预测结果 TP(True Positives): 真的正样本 = [正样本 被正确分为 正样本] TN(True Negatives): 真的 ...

  9. faster-rcnn系列笔记(一)

    目录: 1. 序言 2.正文 2.1  关于ROI 2.2  关于RPN 2.3 关于anchor 3. 关于数据集合制作 4. 关于参数设置 5. 参考 1.序言 叽歪一下目标检测这个模型吧,这篇笔 ...

随机推荐

  1. 从程序集加载类型,遇到 ReflectionTypeLoadException 的处理办法

    处理办法 catch ReflectionTypeLoadException ,然后从里面读取 Types 数据(成功加载的类型)就可以了. 参考 ReflectionTypeLoadExceptio ...

  2. SQL 带有output、inserted、deleted

    因需求的关系需要将修改的值返回,故查了些资料发现了OUTPUT这个好东西,现记录下来以防以后忘记 使用例子: 1.对于INSERT,可以引用inserted表以查询新行的属性.    insert i ...

  3. Springboot vue 前后分离 跨域 Activiti6 工作流 集成代码生成器 shiro权限

    官网:www.fhadmin.org 特别注意: Springboot 工作流  前后分离 + 跨域 版本 (权限控制到菜单和按钮) 后台框架:springboot2.1.2+ activiti6.0 ...

  4. CSS的border-radius 设置圆弧

    现象:将div变为有一定幅度的圆形.椭圆形等 方法:使用css的border-radius 属性进行设置CSS3 border-radius 属性:向 div 元素添加圆角边框: 一:首先建立一个di ...

  5. 【LeetCode】437. 路径总和 III

    437. 路径总和 III 给定一个二叉树,它的每个结点都存放着一个整数值. 找出路径和等于给定数值的路径总数. 路径不需要从根节点开始,也不需要在叶子节点结束,但是路径方向必须是向下的(只能从父节点 ...

  6. Redis之自问自答

    Q:Redis客户端的批处理大量数据请求时,如何优化请求速率? A:管道技术:Redis是基于客户端-服务端模型的TCP请求/响应服务,且是阻塞式的,客户端需要等待服务端处理完数据后返回状态,才能继续 ...

  7. linux下配置jdk,tomcat,mysql,redis,zookeeper

    jdk: 解压: tar zxvf jdk-8u144-linux-x64.tar.gz 执行:vi /etc/profile export JAVA_HOME=/usr/local/jdk1.8.0 ...

  8. Ingo Molnar 的实时补丁

    一.简介 Ingo Molnar 的实时补丁是完全开源的,它采用的实时实现技术完全类似于Timesys Linux,而且中断线程化的代码是基于TimeSys Linux的中断线程化代码的.这些实时实现 ...

  9. [Linux] 编写Dockerfile文件自动构建镜像

    Dockerfile是一个文本文件,按顺序包含构建给定镜像所需的所有命令Docker通过读取Dockerfile中的指令自动构建图像 . Dockerfile遵循特定的格式和指令集,您可以在Docke ...

  10. Centos7安装配置----1配置网络

    1.下载镜像安装,选择的是最小安装,设置root用户密码 (此处省略其中步骤,直到安装成功) 2.安装完成后重启,输入用户名密码进入系统 由于此时未配置网络,所以网卡什么的均未获取ip联网 输入ip ...