人脸检测算法

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 = ptr2k \* num2 + num5;

if (num6 > num4)

{

num4 = num6;

num3 = k;

}

}

float num7 = sigmoid_x(num4);

if (!(num7 > score_threshold))

{

continue;

}

float\[\] array = new float4;

float\[\] x = new floatreg_max;

float\[\] y = new floatreg_max;

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

{

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

{

xm = 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 * yn;

}

arrayl = num8 * (float)num;

}

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

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

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

float num12 = Math.Max((num10 - array1 - (float)padh) * ratioh, 0f);

float num13 = Math.Min((num9 + array2 - (float)padw) * ratiow, imgw - 1);

float num14 = Math.Min((num10 + array3 - (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 = ((ptr3num15 \* 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);

}

}

}

相关推荐
ZhengEnCi9 分钟前
同样的模型,为什么本地和云 API 差别那么大:量化精度、聊天模板与采样参数的三大元凶
人工智能·算法·llm
Flynn Liang29 分钟前
RAG 答非所问/幻觉怎么破?Spring AI QuestionAnswerAdvisor 召回优化实战(TopK/重排/混合检索)
人工智能·算法·spring·rag·幻觉·springai
liminla!1 小时前
SQL 从入门到进阶:语法速查与实战练习(完整优化版)
数据库·sql·算法
维克兜率天2 小时前
【维克】指数调整:哪些股票会被“强制买入“?
人工智能·python·算法
罗西的思考3 小时前
【轻量化复刻大模型】线性注意力交互式演示
人工智能·算法·机器学习
神也畏惧菠萝3 小时前
Day08 Python流程控制从入门到上瘾:if/match/while/for四件套,从B站登录一路打到猜数字游戏
python·算法·数据存储·for·while·if·ifelse
揽星河..3 小时前
【C语言】分支和循环
c语言·c++·算法
Fuyo_11195 小时前
C++ AVL树保姆级详解:从平衡因子到四大旋转机制
java·c++·算法
jktantan5 小时前
每个节点 41 字节:把一棵百万节点树拆进 14 个 typed array
前端·javascript·vue.js·算法·typescript