You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

172 lines
5.0 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#ifndef ARITH_UTILS_H
#define ARITH_UTILS_H
#pragma once
#include "Arith_SysStruct.h"
// 使用哈希表来记录每个非零数字的出现次数
typedef struct tagHashEntry
{
int key;
int count;
} HashEntry;
typedef struct tagHashMap
{
HashEntry* entries;
int capacity;
int size;
} HashMap;
// 矩阵加法
void AddMat(double* A, double* B, int mn, double* AaddB);
// 矩阵乘法
void MultiMat(double* A, double* B, double* AB, int m, int n, int p);
// M1(3*3) * M2(3*3)
void MultiMat33(double* A, double* B, double* AB);
// M1(3*3) * M2(3*3) * M3(3*3)
void MultiMat333(double* A, double* B, double* C, double* ABC);
// 标量乘以矩阵
void MultiMatScalar(double scalar, double* A, double* sA, int mn);
// 矩阵转置
void TransposeMat(double* A, int m, int n, double* AT);
// 3阶矩阵逆不判断逆是否存在
void invMat3(double* A, double* invA);
// 获得三阶单位阵
void eye3(double* M);
// 绕X轴旋转矩阵
void Rx(double omega, double* Opp);
// 绕Y轴旋转矩阵
void Ry(double omega, double* Opp);
// 绕Z轴旋转矩阵
void Rz(double omega, double* Opp);
// 镜面反射矩阵
void RMirror(PointXYZ normalVec, double* Opp);
// 坐标(矢量)旋转: M1(3*3) * M2(3,1)
PointXYZ RtPoint(double* M, PointXYZ Point);
// 坐标(矢量)归一化
PointXYZ NormPoint(PointXYZ Point);
// 罗得里格公式
void rotationVectorToMatrix(PointXYZ rotaVec_One, float rotaAgl, double* Mat);
/*************************************
* Method: findMostFrequentNonZero()
* Function Description:
* CreateData: 2025/1/8
* Input Param: int arr[]:输入数组
* Input Param: int size:数组长度
* Input Param: int clsMaxNum:频率最高的类别出现的次数
* Input Param: float * MostFrequentratio:频率最高的类别出现的频率
* Output Param:
* Return: int:出现次数最多的目标类别
* Call Relation:
* Other Description:
*************************************/
int findMostFrequentNonZero(int arr[], int size, int *clsMaxNum, float* MostFrequentratio);
/*************************************
* Method: count2To0Transitions()
* Function Description: 统计序列2变成1的次数
* CreateData: 2025/1/8
* Input Param: int arr[]
* Input Param: int size
* Output Param:
* Return: int
* Call Relation:
* Other Description:
*************************************/
int count2To0Transitions(int arr[], int size);
/*************************************
* Method: checkCondition()
* Function Description: 一维数组当中判断相邻数字2变成11连续出现的次数大于frmThresh是否存在
* CreateData: 2025/1/8
* Input Param: int arr[]
* Input Param: int size
* Input Param: int frmThresh
* Output Param:
* Return: bool
* Call Relation:
* Other Description:
*************************************/
bool checkXToYCondition(int arr[], int size, int x, int y, int frmThresh);
/*************************************
* Method: countNumberFreq()
* Function Description: 统计一维数组当中number出现的次数
* CreateData: 2025/1/8
* Input Param: int arr[]
* Input Param: int size
* Input Param: int number
* Output Param:
* Return: int
* Call Relation:
* Other Description:
*************************************/
int countNumberFreq(int arr[], int size, int number);
/*************************************
* Method: Cosine_Similarity()
* Function Description: 计算两个size长度一维数组的余弦相似度
* CreateData: 2025/2/7
* Input Param: float * A
* Input Param: float * B
* Input Param: int size
* Output Param:
* Return: float
* Call Relation:
* Other Description:
*************************************/
float Cosine_Similarity(float* A, float* B, int size);
// 获取动态库所在路径
std::string GetDynamicLibraryPath();
/*************************************
* Method: Save_RunImg()
* Function Description: 保存一帧调用算法的图像数据
* CreateData: 2025/3/11
* Input Param: GD_VIDEO_FRAME_S img:输入图像
* Input Param: SINT32 nControlerFrmNum:当前算法已处理的帧数
* Output Param:
* Return: void
* Call Relation:
* Other Description:
*************************************/
void Save_RunImg(GD_VIDEO_FRAME_S img, SINT32 nControlerFrmNum);
/**********************************************************
* 函数名称SERVO_CorrectAngleScale()
* 功能描述处理伺服信息校正角度值到0°360°范围
* 输入参数FLOAT32 fAngle -- 输入角度值
* 输出参数:无
* 返 回 值FLOAT32 fAngleCorrect -- 校正后的角度值
* 调用关系:
* 其它说明:实际伺服角度范围为:-180°180°(= -180°)180°
**********************************************************/
FLOAT32 SERVO_CorrectAngleScale(FLOAT32 fAngle);
#endif