如何从计算机视觉相机计算像素的水平角 [英] how to compute horizontal angle of a pixel from a computer vision camera

查看:26
本文介绍了如何从计算机视觉相机计算像素的水平角的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的程序需要从具有 120 度水平视野、640 像素宽和 480 像素高的分辨率的计算机视觉相机计算像素的角度.

My program needs to compute the angle of a pixel from a computer vision camera that has 120 degrees horizontal field of view, and resolution of 640 pixels wide and 480 pixels high.

程序从相机接收每个图像帧的 X,Y 像素数组.对于最左边的像素,X 为 0,角度为 -60 度.对于最右边的像素,X 为 639,角度为 60 度.对于中心像素,X 为 320,角度为 0.

Program receives an X,Y array of pixels for each image frame from camera. For left-most pixel, X would be 0 and angle would be -60 degrees. For right-most pixel, X would be 639 and angle 60 degrees. For center pixel, X would be 320 and angle 0.

当 (X is > 0 and < 320) and (>320 and <640) 时,角度如何计算?

How is angle computed when (X is > 0 and < 320) and (>320 and <640)?

推荐答案

// In pseudocode.

// Compute focal length in pixels from FOV
double f = (0.5 * image_width) / tan(0.5 * fov_radians);

// Vectors subtending image center and pixel from optical center
// in camera coordinates.
Vector3D center(0, 0, f), pixel(x - center_x, y - center_y, f);

// angle between vector (0, 0, f) and pixel
double dot = dot_product(center, pixel)
double alpha = acos(dot / (center.length() * pixel.length()));

这篇关于如何从计算机视觉相机计算像素的水平角的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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