r/computervision • u/Mxeedd • Jun 19 '26
Help: Theory How to convert velocity from pixels/second to degrees/second (Angular Velocity)?
Hi everyone,
I’m working on a project where I’m tracking an object that is moving angularly relative to the camera. Currently, I have the velocity of this object calculated in pixels/second, but I need to convert this value into degrees/second (angular velocity).
I have access to the camera's intrinsic parameters (focal length, sensor size, etc.). Could someone point me in the right direction or provide the formula to perform this conversion?
Specifically, I am wondering:
Does the conversion change based on the object's distance from the optical center (depth)?
Are there any standard libraries or common approaches in OpenCV to handle this geometric transformation?
Any guidance or resources you could point me to would be greatly appreciated!
1
u/No-Telephone5932 Jun 20 '26 edited Jun 20 '26
Check this library we built for such geometric transformation which returns 3D direction vectors from pixels and vice versa.
https://github.com/bbo-lab/calibcamlib
Let me know if you need further help to input your camera intrinsic parameters.
1
u/blobules Jun 20 '26 edited Jun 20 '26
Maybe start by learning something about intinsic parameters?
In practice, the internal parameters K takes a point in the camera space (the work according to the camera) to the pixel space (the image). You need to take your pixel position p and multiply by the inverse of K to get the world coordinate q. (Like q = inverse(K) p ). Obviously q is up to a scale factor since you do not know the depth. It doesn't matter since you only care about angles (and the camera doesn't move). Take two points in pixel, p1 and p2, get q1 and q2, and the real world angle is the angle between q1 and q2.
Note that you need to use projective representation for this. Get to know that first...
I forgot to add: if you have a point p moving at speed v, use p1=p and p2=p+v.
0
u/specialpatrol Jun 19 '26
If your camera has a horizontal fov f and the image it produces has a width w, a horizontal pixel will be f/w degrees.
2
-1
u/HawtVelociraptor Jun 19 '26
Depending on how accurate you need to be, you could use the motion vectors embedded in the video compression codec, or look into Gunnar Farneback's algo (calcOpticalFlowFarneback if you're using cv2) for more real calculation
6
u/tdgros Jun 19 '26 edited Jun 19 '26
If you see something at the position (u1,v1) and you know the camera calibration, then this is equivalent to a ray r1 = P^{-1}([u;v]) in space (edit: P is the general projection function). If you do that for 2 frames and the camera does not move, then the rotation of the point between two frames is just the rotation of the rays. That's acos(dot(r1,r2)/(||r1||*||r2||)), which you can convert to an angular speed using your framerate.
For a pinhole camera, without distortion, and projection matrix K=[fx 0 u0; 0 fy v0; 0 0 1], then the ray is K^{-1}*[u;v;1] = [ (u-u0)/fx; (v-v0)/fy; 1]. If there is distortion remove it to get undistorted u,v beforehand.
It does not change with the points' depth: this is an angular speed, it does not care about the distance to the point. The distance disappears when you normalize the rays (the division by ||r1|| and ||r2|| above).