【发布时间】: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