OpenCV - cartToPolar()

Posted zhangzhihui

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了OpenCV - cartToPolar()相关的知识,希望对你有一定的参考价值。

笛卡尔坐标转换为极坐标。

 

cartToPolar(...)
    cartToPolar(x, y[, magnitude[, angle[, angleInDegrees]]]) -> magnitude, angle
    .   @brief Calculates the magnitude and angle of 2D vectors.
    .   
    .   The function cv::cartToPolar calculates either the magnitude, angle, or both
    .   for every 2D vector (x(I),y(I)):
    .   f[egin{array}{l} 	exttt{magnitude} (I)= sqrt{	exttt{x}(I)^2+	exttt{y}(I)^2} , \ 	exttt{angle} (I)= 	exttt{atan2} ( 	exttt{y} (I), 	exttt{x} (I))[ cdot180 / pi ] end{array}f]
    .   
    .   The angles are calculated with accuracy about 0.3 degrees. For the point
    .   (0,0), the angle is set to 0.
    .   @param x array of x-coordinates; this must be a single-precision or
    .   double-precision floating-point array.
    .   @param y array of y-coordinates, that must have the same size and same type as x.
    .   @param magnitude output array of magnitudes of the same size and type as x.
    .   @param angle output array of angles that has the same size and type as
    .   x; the angles are measured in radians (from 0 to 2*Pi) or in degrees (0 to 360 degrees).
    .   @param angleInDegrees a flag, indicating whether the angles are measured
    .   in radians (which is by default), or in degrees.
    .   @sa Sobel, Scharr

cv.cartToPolar(1, 0)
(array([[1.],
        [0.],
        [0.],
        [0.]]),
 array([[0.],
        [0.],
        [0.],
        [0.]]))

cv.cartToPolar((1, 0, -1, 0), (0, 1, 0, -1))
(array([[1.],
        [1.],
        [1.],
        [1.]]),
 array([[0.        ],
        [1.57079637],
        [3.14159274],
        [4.71238899]]))

以上是关于OpenCV - cartToPolar()的主要内容,如果未能解决你的问题,请参考以下文章

OpenCV 完整例程36. 直角坐标与极坐标的转换

python opencv error “parallel_impl.cpp (240) WorkerThread 155: Can‘t spawn new thread: res = 11“(代码片

OpenCV⚠️高手勿入! 半小时学会基本操作 22⚠️ 傅里叶变换

OpenCV⚠️高手勿入! 半小时学会基本操作 22⚠️ 傅里叶变换

Opencv入门-第一回-梦牵机器视觉翼,初识Opencv域(安装Opencv)

opencv--linux下安装