From e2cc9c8e6ddea90744d3d5e65822443a7b5dc9f0 Mon Sep 17 00:00:00 2001 From: zhaoxi <535394140@qq.com> Date: Fri, 8 Nov 2024 15:59:10 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20=E4=BF=AE=E5=A4=8D=20binary=20?= =?UTF-8?q?=E5=87=BD=E6=95=B0=E4=BC=A0=E5=85=A5=E5=8D=95=E9=80=9A=E9=81=93?= =?UTF-8?q?=E5=9B=BE=E5=83=8F=E6=97=B6=EF=BC=8C=E4=BC=9A=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=8E=9F=E5=9B=BE=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/core/include/rmvl/core/math.hpp | 24 ++++++++++++------------ modules/core/src/pretreat.cpp | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/modules/core/include/rmvl/core/math.hpp b/modules/core/include/rmvl/core/math.hpp index 47db8a4b..237b26b2 100644 --- a/modules/core/include/rmvl/core/math.hpp +++ b/modules/core/include/rmvl/core/math.hpp @@ -236,13 +236,12 @@ constexpr auto getDistance(const cv::Vec &vec_1, const cv::Vec & } /** - * @brief 点到直线距离 - * @note 点 \f$P=(x_0,y_0)\f$ 到直线 \f$l:Ax+By+C=0\f$ 距离公式为 - * \f[D(P,l)=\frac{Ax_0+By_0+C}{\sqrt{A^2+B^2}}\f] + * @brief 点到直线距离,其中 \f$P=(x_0,y_0)\f$ 到直线 \f$l:Ax+By+C=0\f$ 距离公式为 + * \f[D(P,l)=\frac{Ax_0+By_0+C}{\sqrt{A^2+B^2}}\f] * * @tparam Tp1 直线方程数据类型 * @tparam Tp2 平面点的数据类型 - * @param[in] line 用 `cv::Vec4_` 表示的直线方程 (vx, vy, x0, y0) + * @param[in] line 用 `cv::Vec4_` 表示的直线方程 \f$(v_x, v_y, x_0, y_0)\f$ * @param[in] pt 平面点 * @param[in] direc 是否区分距离的方向 * @note @@ -262,9 +261,10 @@ constexpr auto getDistance(const cv::Vec &line, const cv::Point_ &p } /** - * @brief 获取与水平方向的夹角,以平面直角坐标系 x 轴为分界线, - * 逆时针为正方向,范围: (-180°, 180°],默认返回弧度制 - * + * @brief 获取与水平方向的夹角,以平面直角坐标系 \f$x\f$ 轴为分界线, **逆时针** 为正方向,范围: \f$(-180°,180°]\f$ ,默认返回弧度制 + * @note 与像素(图像)坐标系不同,像素(图像)坐标系中 \f$y\f$ 轴向下为正方向,而此函数将 \f$y\f$ + * 轴向上设置为正方向,因此才能将逆时针表示为旋转的正方向 + * * @tparam Tp1 平面点 1 的数据类型 * @tparam Tp2 平面点 2 的数据类型 * @param[in] start 像素坐标系下的起点 @@ -280,8 +280,8 @@ constexpr auto getHAngle(const cv::Point_ &start, const cv::Point_ &en } /** - * @brief 获取与垂直方向的夹角,以平面直角坐标系 y 轴为分界线, - * 顺时针为正方向,范围: (-180°, 180°],默认返回弧度制 + * @brief 获取与垂直方向的夹角,以平面直角坐标系 \f$y\f$ 轴为分界线, + * **顺时针** 为正方向,范围: \f$(-180°,180°]\f$ ,默认返回弧度制 * * @tparam Tp1 平面点 1 的数据类型 * @tparam Tp2 平面点 2 的数据类型 @@ -303,7 +303,7 @@ constexpr auto getVAngle(const cv::Point_ &start, const cv::Point_ &en * @tparam Tp 角度的数据类型 * @param[in] angle_1 第 1 个角度 * @param[in] angle_2 第 2 个角度 - * @return 夹角,角度的范围是 (-180°, 180°] + * @return 夹角,角度的范围是 \f$(-180°,180°]\f$ */ template constexpr Tp getDeltaAngle(Tp angle_1, Tp angle_2) @@ -385,7 +385,7 @@ constexpr Tp sigmoid(Tp x, Tp k = 1, Tp Kp = 1, Tp mu = 0) { return Kp / (1 + st * @tparam Tp 向量数据类型 * @param[in] a 向量 A * @param[in] b 向量 B - * @return 外积,若 retval = 0,则共线 + * @return 外积,若 \f$\texttt{res} = 0\f$ 则共线,\f$\texttt{res} > 0\f$ 则方向向内,\f$\texttt{res} < 0\f$ 则方向向外 */ template constexpr Tp cross2D(const cv::Vec &a, const cv::Vec &b) { return a(0) * b(1) - a(1) * b(0); } @@ -396,7 +396,7 @@ constexpr Tp cross2D(const cv::Vec &a, const cv::Vec &b) { return * @tparam Tp Point_数据类型 * @param[in] a 向量 A * @param[in] b 向量 B - * @return 外积,若 retval = 0,则共线 + * @return 外积,若 \f$\texttt{res} = 0\f$ 则共线,\f$\texttt{res} > 0\f$ 则方向向内,\f$\texttt{res} < 0\f$ 则方向向外 */ template constexpr Tp cross2D(const cv::Point_ &a, const cv::Point_ &b) { return a.x * b.y - a.y * b.x; } diff --git a/modules/core/src/pretreat.cpp b/modules/core/src/pretreat.cpp index c18db54c..138a04ad 100644 --- a/modules/core/src/pretreat.cpp +++ b/modules/core/src/pretreat.cpp @@ -46,7 +46,7 @@ cv::Mat binary(cv::Mat src, uint8_t thresh) if (src.type() == CV_8UC3) cvtColor(src, bin, cv::COLOR_BGR2GRAY); else - bin = src; + bin = src.clone(); threshold(bin, bin, thresh, 255, cv::THRESH_BINARY); return bin; }