视频中的速度和加速度测量
Velocity and acceleration measurement in a video
我正在尝试找到一种方法来计算被跟踪对象的速度和加速度,比方说一个球落下。我正在使用Processing 2制作这个程序,我知道从相机到物体的距离,它可以计算它在运动过程中每一帧的位置。
为了计算速度,我使用了这个公式(全部以像素计算):VelocityX=(PositionX - LastPositionX)/delta time
与加速度类似:AccelerationX=(VelocityX - LastVelocityX)/delta time
然后,我用帧改变了增量时间。所以现在我有每帧像素的速度和加速度,但我的问题是如何将每帧像素单位转换为 mm/s 例如?更直观的单位。
我也计算了以像素为单位的位置,但之后我将其转换为毫米,但我对如何计算速度和加速度有点困惑。
// Get the current time
currTime = frameCount;
deltaTime = (currTime - prevTime);
// Remember current time for the next frame
prevTime = currTime;
// Calculate velocity in X and Y directions (pixels / frame)
if (lastMovingX != Float.MAX_VALUE) {
velX = (PX - lastMovingX) / deltaTime;
velY = (PY - lastMovingY) / deltaTime;
}
// Save the current frame position for the next calculation
lastMovingX = PX;
lastMovingY = PY;
if (lastVelX != Float.MAX_VALUE) {
accelX = (velX - lastVelX) / deltaTime;
accelY = (velY - lastVelY) / deltaTime;
}
lastVelX = velX;
lastVelY = velY;
如果知道物体的大小,就可以提取pixels/mm的比例。如果你知道你的帧速率,你可以将帧转换为秒。
查找 pixels/mm = 对象大小(像素)/对象大小(毫米)
(pixels/frame) / (pixels/mm) = mm/frame
mm/frame * frames/second = 毫米/秒
这是您要找的吗?
我正在尝试找到一种方法来计算被跟踪对象的速度和加速度,比方说一个球落下。我正在使用Processing 2制作这个程序,我知道从相机到物体的距离,它可以计算它在运动过程中每一帧的位置。
为了计算速度,我使用了这个公式(全部以像素计算):VelocityX=(PositionX - LastPositionX)/delta time
与加速度类似:AccelerationX=(VelocityX - LastVelocityX)/delta time
然后,我用帧改变了增量时间。所以现在我有每帧像素的速度和加速度,但我的问题是如何将每帧像素单位转换为 mm/s 例如?更直观的单位。
我也计算了以像素为单位的位置,但之后我将其转换为毫米,但我对如何计算速度和加速度有点困惑。
// Get the current time
currTime = frameCount;
deltaTime = (currTime - prevTime);
// Remember current time for the next frame
prevTime = currTime;
// Calculate velocity in X and Y directions (pixels / frame)
if (lastMovingX != Float.MAX_VALUE) {
velX = (PX - lastMovingX) / deltaTime;
velY = (PY - lastMovingY) / deltaTime;
}
// Save the current frame position for the next calculation
lastMovingX = PX;
lastMovingY = PY;
if (lastVelX != Float.MAX_VALUE) {
accelX = (velX - lastVelX) / deltaTime;
accelY = (velY - lastVelY) / deltaTime;
}
lastVelX = velX;
lastVelY = velY;
如果知道物体的大小,就可以提取pixels/mm的比例。如果你知道你的帧速率,你可以将帧转换为秒。
查找 pixels/mm = 对象大小(像素)/对象大小(毫米)
(pixels/frame) / (pixels/mm) = mm/frame
mm/frame * frames/second = 毫米/秒
这是您要找的吗?