人脸检测算法

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);

}

}

}

相关推荐
limingade1 小时前
手机实时提取SIM卡打电话的信令和声音-新的篇章(一、可行的方案探讨)
物联网·算法·智能手机·数据分析·信息与通信
jiao000014 小时前
数据结构——队列
c语言·数据结构·算法
迷迭所归处5 小时前
C++ —— 关于vector
开发语言·c++·算法
leon6255 小时前
优化算法(一)—遗传算法(Genetic Algorithm)附MATLAB程序
开发语言·算法·matlab
CV工程师小林5 小时前
【算法】BFS 系列之边权为 1 的最短路问题
数据结构·c++·算法·leetcode·宽度优先
Navigator_Z6 小时前
数据结构C //线性表(链表)ADT结构及相关函数
c语言·数据结构·算法·链表
Aic山鱼6 小时前
【如何高效学习数据结构:构建编程的坚实基石】
数据结构·学习·算法
天玑y6 小时前
算法设计与分析(背包问题
c++·经验分享·笔记·学习·算法·leetcode·蓝桥杯
sjsjs116 小时前
【数据结构-一维差分】力扣1893. 检查是否区域内所有整数都被覆盖
数据结构·算法·leetcode
redcocal6 小时前
地平线秋招
python·嵌入式硬件·算法·fpga开发·求职招聘