【问题标题】:How do I check if mutiple YOLO item overlap each other如何检查多个 YOLO 项目是否相互重叠
【发布时间】:2021-06-27 23:50:09
【问题描述】:

我需要你的帮助,很抱歉我的英语不好。

我使用 YOLOv4 来获取检测对象。 yolov4 可以获取汽车、摩托车、公共汽车等对象。 我想用结果来检查是否发生车祸。

我的观点: 我认为可以检查图像中的所有对象 并尝试检测两个对象是否重叠。 同时开始计算时间。 如果两个物体重叠超过一段时间,则判断为车祸。

描述问题: 有谁知道如何检查多个矩形是否相互重叠 我尝试在 C# 中使用它

for (int i = 0; i < itemRectCar.Count - 1; i++)
{
  if (itemRectCar[i].IntersectsWith(itemRectCar[i + 1]))
    {
      rectangle3 = Rectangle.Intersect(itemRectCar[i], itemRectCar[i + 1]);
      itemRectCar[i].Intersect(itemRectCar[i + 1]);
      if (!itemRectCar[i].IsEmpty)
        {
          graphics.DrawRectangle(penRed, rectangle3);
        }
    }
}

但是这种方法只能在图像中工作,不能在视频中工作

image

我需要有人来激励我。 谢谢你阅读我的问题,希望你有一个愉快的一天

【问题讨论】:

    标签: c# yolo


    【解决方案1】:

    我认为您的问题是您检查汽车 1 与汽车 2,汽车 2 与汽车 3 等等。但您不做的是检查汽车 1 与汽车 5,或汽车 2 与汽车 8

    您基本上想为阵列中的所有其他汽车检查一辆车的碰撞,然后您乘坐下一辆车,并检查与所有其他汽车的碰撞等等。

    为此,您需要一个嵌套循环:

    for (int i = 0; i < itemRectCar.Count; i++)
    {
        for (int j = 0; j < itemRectCar.Count; j++)
        {
          // A car shouldn't collect with itself, so skip this case
          if (i == j)
            continue;
        
          if (itemRectCar[i].IntersectsWith(itemRectCar[j]))
            {
              rectangle3 = Rectangle.Intersect(itemRectCar[i], itemRectCar[j]);
              itemRectCar[i].Intersect(itemRectCar[j]);
              if (!itemRectCar[i].IsEmpty)
                {
                  graphics.DrawRectangle(penRed, rectangle3);
                }
            }
    
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-27
      • 1970-01-01
      相关资源
      最近更新 更多