从图像中查找车辆的速度 [英] Find speed of vehicle from images

查看:170
本文介绍了从图像中查找车辆的速度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做一个从图像中找到车辆速度的项目。我们从车内拍摄这些图像。我们将从第一张图像中标记一些对象作为参考。使用下一图像中同一对象的属性,我们必须计算移动车辆的速度。有人能帮我一下吗???我正在使用python opencv。我已经成功,直到使用光流法找到第二图像中的标记像素。任何人都可以帮我完成剩下的工作吗?

I am doing a project to find the speed of a vehicle from images. We are taking these images from within the vehicle. We will be marking some object from the 1st image as a reference. Using the properties of the same object in the next image, we must calculate the speed of the moving vehicle. Can anyone help me here??? I am using python opencv. I have succeeded till finding the marked pixel in the 2nd image using Optical flow method. Can anyone help me with the rest?

推荐答案

知道了采集频率,你现在必须找到连续位置之间的距离。标记。

Knowing the acquisition frequency, you must now find the distance between the successive positions of the marker.

为了找到这个距离,我建议您估算每个图像的标记的姿势。简而言之,姿势是表示物体相对于相机的坐标的变换矩阵。一旦你有了这些连续的坐标,就可以计算距离,然后计算速度。

To find this distance, I suggest you estimate the pose of the marker for each image. Loosely speaking, the "pose" is the transformation matrix expressing the coordinates of an object relative to a camera. Once you have those successive coordinates, you can compute the distance, and then the speed.

姿态估计是计算已知位置和方向的过程相对于2D相机的3D对象。结果姿势是转换矩阵,用于描述对象在相机参考中的参考。

Pose estimation is the process of computing the position and orientation of a known 3D object relative to a 2D camera. The resulting pose is the transformation matrix describing the object's referential in the camera's referential.

OpenCV实现姿势估计算法: Posit 。文档说:

OpenCV implements a pose estimation algorithm: Posit. The doc says:


给定对象的一些3D点(在对象
坐标系中),最低
四个非共面点,它们在
图像中的
对应2D投影,以及
相机的焦距,算法能够
估计物体的姿势。

Given some 3D points (in object coordinate system) of the object, at least four non-coplanar points, their corresponding 2D projections in the image, and the focal length of the camera, the algorithm is able to estimate the object's pose.

这意味着:


  1. 你必须知道相机的焦距

  2. 您必须知道标记的几何形状

  3. 您必须能够在2D中匹配标记的四个已知点图片

您可能需要使用校准例程。我认为您还有其他两个必需数据。

You may have to compute the focal length of the camera using the calibration routines provided by OpenCV. I think you have the two other required data.

修改:

// Algorithm example

MarkerCoords = {Four coordinates of know 3D points}

I1 = take 1st image
F1 = focal(I1)
MarkerPixels1 = {Matching pixels in I1}
Pose1 = posit(MarkerCoords, MarkerPixels1, F1)

I2 = take 2nd image
F2 = focal(I2)
MarkerPixels2 = {Matching pixels in I2 by optical flow}
Pose2 = posit(MarkerCoords, MarkerPixels2, F2)

o1 = origin_of_camera * Pose1 // Origin of camera is
o2 = origin_of_camera * Pose2 // typically [0,0,0]
dist = euclidean_distance(o1, o2)
speed = dist/frequency

编辑2:(评论的答案)


什么是采集频率?

"What is the acquisition frequency?"

计算车辆的速度相当于计算车速标记。 (在第一种情况下,参考是连接到地球的标记,在第二种情况下,参考是连接到车辆的摄像机。)这由以下等式表示:

Computing the speed of your vehicle is equivalent to computing the speed of the marker. (In the first case, the referential is the marker attached to the earth, in the second case, the referential is the camera attached to the vehicle.) This is expressed by the following equation:

speed = D/(t2-t1)

使用:


  • D 距离 [o1 o2]

  • o1 标记在时间 t1的位置

  • o2 时刻标记的位置 t2

  • D the distance [o1 o2]
  • o1 the position of the marker at time t1
  • o2 the position of the marker at time t2

您可以通过提取 t1 和<$来检索已用时间c = c> t2 来自照片的元数据,或来自成像设备的采集频率 t2-t1 = T = 1 / F

You can retrieve the elapsed time either by extracting t1 and t2 from the metadata of your photos, or from the acquisition frequency of your imaging device: t2-t1 = T = 1/F.


标记像海报这样简单的东西不是更好吗?如果这样做可以我们认为它是一个二维物体吗?

"Won't it be better to mark simple things like posters? And if doing so can't we consider it as a 2d object?"

Posit算法无法做到这一点rithm(或据我所知的任何其他姿势估计算法):它需要四个非共面点。这意味着您无法选择嵌入3D空间的2D对象,您必须选择具有一定深度的对象。

This is not possible with the Posit algorithm (or with any other pose estimation algorithm as far as I know): it requires four non-coplanar points. This means you cannot chose a 2D object embedded in a 3D space, you have to chose an object with some depth.

另一方面,您可以使用真正简单的形状,只要它是一个体积。 (例如一个立方体。)

On the other hand, you can use a really simple shape, as far as it is a volume. (A cube for example.)

这篇关于从图像中查找车辆的速度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆