人脸检测算法

public unsafe static void GenerateProposal(int inpHeight, int inpWidth, int reg_max, int num_class, float score_threshold, int feat_h, int feat_w, Mat output, List<Rect> position_boxes, List<float> confidences, List<List<Point>> landmarks, int imgh, int imgw, float ratioh, float ratiow, int padh, int padw)

{

int num = (int)Math.Ceiling((double)(inpHeight / feat_h));

int num2 = feat_h * feat_w;

float* ptr = (float*)(void*)output.DataStart;

float* ptr2 = ptr + num2 * reg_max * 4;

float* ptr3 = ptr + num2 * (reg_max * 4 + num_class);

for (int i = 0; i < feat_h; i++)

{

for (int j = 0; j < feat_w; j++)

{

int num3 = -1;

float num4 = -10000f;

int num5 = i * feat_w + j;

for (int k = 0; k < num_class; k++)

{

float num6 = ptr2[k * num2 + num5];

if (num6 > num4)

{

num4 = num6;

num3 = k;

}

}

float num7 = sigmoid_x(num4);

if (!(num7 > score_threshold))

{

continue;

}

float[] array = new float[4];

float[] x = new float[reg_max];

float[] y = new float[reg_max];

for (int l = 0; l < 4; l++)

{

for (int m = 0; m < reg_max; m++)

{

x[m] = ptr[(l * reg_max + m) * num2 + num5];

}

softmax_(ref x, ref y, reg_max);

float num8 = 0f;

for (int n = 0; n < reg_max; n++)

{

num8 += (float)n * y[n];

}

array[l] = num8 * (float)num;

}

float num9 = ((float)j + 0.5f) * (float)num;

float num10 = ((float)i + 0.5f) * (float)num;

float num11 = Math.Max((num9 - array[0] - (float)padw) * ratiow, 0f);

float num12 = Math.Max((num10 - array[1] - (float)padh) * ratioh, 0f);

float num13 = Math.Min((num9 + array[2] - (float)padw) * ratiow, imgw - 1);

float num14 = Math.Min((num10 + array[3] - (float)padh) * ratioh, imgh - 1);

Rect item = new Rect((int)num11, (int)num12, (int)(num13 - num11), (int)(num14 - num12));

position_boxes.Add(item);

confidences.Add(num7);

List<Point> list = new List<Point>();

for (int num15 = 0; num15 < 5; num15++)

{

float num16 = ((ptr3[num15 * 3 * num2 + num5] * 2f + (float)j) * (float)num - (float)padw) * ratiow;

float num17 = ((ptr3[(num15 * 3 + 1) * num2 + num5] * 2f + (float)i) * (float)num - (float)padh) * ratioh;

list.Add(new Point((int)num16, (int)num17));

}

landmarks.Add(list);

}

}

}

相关推荐
hh随便起个名2 分钟前
力扣二叉树的三种遍历
javascript·数据结构·算法·leetcode
Dingdangcat861 小时前
城市交通多目标检测系统:YOLO11-MAN-FasterCGLU算法优化与实战应用_3
算法·目标检测·目标跟踪
tang&2 小时前
滑动窗口:双指针的优雅舞步,征服连续区间问题的利器
数据结构·算法·哈希算法·滑动窗口
拼命鼠鼠2 小时前
【算法】矩阵链乘法的动态规划算法
算法·矩阵·动态规划
LYFlied2 小时前
【每日算法】LeetCode 17. 电话号码的字母组合
前端·算法·leetcode·面试·职场和发展
式5163 小时前
线性代数(八)非齐次方程组的解的结构
线性代数·算法·机器学习
橘颂TA4 小时前
【剑斩OFFER】算法的暴力美学——翻转对
算法·排序算法·结构与算法
叠叠乐4 小时前
robot_state_publisher 参数
java·前端·算法
hweiyu004 小时前
排序算法:冒泡排序
算法·排序算法
brave and determined4 小时前
CANN训练营 学习(day9)昇腾AscendC算子开发实战:从零到性能冠军
人工智能·算法·机器学习·ai·开发环境·算子开发·昇腾ai