【问题标题】:How to determine angular velocity from a video?如何从视频中确定角速度?
【发布时间】:2019-05-24 09:29:08
【问题描述】:

考虑一个旋转轮子的视频,该视频已被读取为灰度。在此视频中,我标记了一个感兴趣的区域:

在 ROI 内,我对像素强度设置了一个阈值:强度小于 50 的每个像素都降为 0,强度大于 50 的每个像素都缩放到 255。

根据这些信息,我创建了一个包含两列的 .txt 文件:一列包含时间戳,另一列包含 ROI 内像素强度的平均值:here

应该可以根据这些信息确定车轮的角速度。但我不确定如何做到这一点。有人有想法吗?

这是我迄今为止尝试过的:

import numpy as np
import pandas as pd
from matplotlib import pyplot as plt 


VideoData = pd.read_csv('myData.txt', sep='\t')
VideoPixelMean = VideoData.iloc[:,1].values.tolist()
VideoTimestamp = VideoData.iloc[:,0].values.tolist()

SpokeList = []
for idx,el in enumerate(VideoPixelMean):
    if el >= 150:
        SpokeList.append(idx)
VideoVelocity=[]
VelocityTime = [0]
for idx,el in enumerate(SpokeList):
    if idx == 0:
        VideoVelocity.append(0)
    else:
        framesPassed = SpokeList[idx] - SpokeList[idx-1]
        if framesPassed > 2:
            velocity = 2*np.pi/360 * 72 * 50 * 30/framesPassed #each wheel has 5 spokes (the angle between two spokes is 72°) and a radius of 50mm; fps = 30
        else:
            velocity = 0
        VideoVelocity.append(velocity)
        velocityTime = VideoTimestamp[el]
        VelocityTime.append(velocityTime)  

我很确定结果不正确。

【问题讨论】:

  • 速度是否恒定并且您打算在整个时间内取平均值?还是您希望它动态变化?
  • @MarkSetchell:速度大约每 5 秒变化一次。

标签: python image-processing video-processing


【解决方案1】:

有趣的问题!信守承诺。

对于我们的固定 ROI,速度可以通过以下方式确定:

测量到达下一个辐条所需的时间。为此,您可以在遇到暗像素后测量第一次出现的亮像素和下一次出现的亮像素。

D-L-L-L-L-D-D-D.....D-L-L-L-L
  ^                   ^

确定这些点后,以秒为单位获取时间差(t) 以获取经过的时间。

您计算的距离:

2π(r)(θ/360)

您可以通过以下方式获得垂直速度:

v_perp = 2π(r)(θ/360) / t

现在你可以将它除以r 得到角速度:

v_angular = 2πθ/360t
spoke_start_time, spoke_end_time = None, None

for idx, pixel in enumerate(VideoPixelMean):
     if pixel > 150 and VideoPixelMean[idx-1] < 150:
            if not spoke_start_time:
                spoke_start_time = VideoTimestamp[idx]
            else:
                spoke_end_time = VideoTimestamp[idx]
                break
     else:
        last_pixel = 0

t = spoke_end_time - spoke_start_time # This should be in seconds

THETA = 72
v_angular = (2 * np.pi * THETA) / (360 * t)

【讨论】:

  • 非常感谢您的回答!我觉得你的想法和我的很相似。事实证明,我的想法一直在奏效。我只是输入了错误的车轮半径。
  • Samaksh,你知道如何跟踪其中一根辐条从一帧到下一帧的运动吗?由此,应该可以计算出辐条的角位移。但我不知道如何跟踪它..
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-01-29
  • 2015-08-03
  • 2020-10-22
  • 1970-01-01
相关资源
最近更新 更多