车位检测中,判断多帧图像检测出的车位是否是同一个车位.计算其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. MySQL(9)---纪录一次实际开发过程中用到的复杂存储过程

    Mysql(9)---纪录一次实际开发过程中用到的复杂存储过程 为了尽可能的还原当时为什么需要用到存储过程,下面我写了个详细的文档,我们可以从需求文档出发来分析. 有关存储过程之前也写了两篇文章来做铺 ...

  2. C#函数的参数传递方式1(值传递与地址传递)

    using System; namespace class1 { class program { static void Main(string[] args) { //值传递引用,实际参数不会变化 ...

  3. char.IsWhiteSpace(str,num),TimeSpan

    IsWhiteSpace(String, Int32) 指示指定字符串中位于指定位置处的字符是否属于空格类别. TimeSpan TimeSpan ts=new TimeSpan(4,30,0); C ...

  4. centos 7 搭建vsftp

    一.FTP简介 1.ftp 概述                                                FTP:(file  transfer  protocol文件传输协议) ...

  5. 进度更新---Responsive Web Design Certification (300 hours)

    进度更新---Responsive Web Design Certification (300 hours) 已经完成: basic html and html5 basic css applied ...

  6. 微信小程序访问webservice(wsdl)+ axis2发布服务端(Java)

    0.主要思路:使用axis2发布webservice服务端,微信小程序作为客户端访问.步骤如下: 1.服务端: 首先微信小程序仅支持访问https的url,且必须是已备案域名.因此前期的服务器端工作需 ...

  7. Angular 学习笔记(四)

    作用域和控制器的交互情况: 1.控制器通过作用域对模板暴露一些方法供其调用 2.控制器中定义的一些方法可改变注册在作用域下的数据模型 3.控制器在某些场合可能需设置监听器来监听作用域中的数据模型:这些 ...

  8. dockerfile和资源限制(五)

    镜像生成途径 dockerfile 基于容器制作 什么是dockerfile dockerfile说白就是用来构建docker 镜像的源码,大家看到源码俩字不用惊慌,所为的dockerfile源码只是 ...

  9. [Linux] 纯净ubuntu快速搭建宝塔面板

    宝塔官方建议是纯净的系统,我使用docker运行一个ubuntu容器,模拟一个纯净的系统,这样也不会影响到我的其他服务. docker run --name baota -id -p 8888:888 ...

  10. zabbix入门

    第一章 监控知识基本概述 1.1 为什么要使用监控 1.对系统不间断实时监控2.实时反馈系统当前状态3.保证服务可靠性安全性4.保证业务持续稳定运行 1.2 如何进行监控,比如我们需要监控磁盘的使用率 ...