资源简介
基于seetaface的android实现,包含检测、对齐、比对,采用NEON优化提高处理速度,提高人脸旋转角度roll,pitch,yaw,带自动遍历比对人脸
代码片段和文件信息
#include “CMImgProc.h“
#define CV_DESCALE(xn) (((x) + (1 << ((n) - 1))) >> (n))
// 双线性插值图像缩放注意:缩放只改变宽高不改变通道数
// src 源图像指针
// swshsc 分别表示源图像的宽高及通道数
// dst 缩放后图像指针
// dwdh 缩放后图像宽高
void CMImgProc::ResizeLinear(unsigned char *src int sw int sh int sc unsigned char *dst int dw int dh)
{
//LOGD(“native ResizeLinear 1sw=%d sh=%d dw=%d dh=%d“ sw sh dw dh);
unsigned char *dataDst = dst;
int stepDst = dw * sc;
unsigned char *dataSrc = src;
int stepSrc = sw * sc;
int iWidthSrc = sw;
int iHiehgtSrc = sh;
double scale_x = (double)sw / dw;
double scale_y = (double)sh / dh;
//LOGD(“native ResizeLinear 2 scale_x=%f scale_y=%f“ scale_x scale_y);
for (int j = 0; j < dh; ++j)
{
float fy = (float)((j + 0.5) * scale_y - 0.5);
int sy = (int)floor(fy);// 向下取整
fy -= sy;
sy = std::min(sy iHiehgtSrc - 2);
sy = std::max(0 sy);
int cbufy[2];
cbufy[0] = (int)((1.f - fy) * 2048 + 0.5);
cbufy[1] = 2048 - cbufy[0];
for (int i = 0; i < dw; ++i)
{
float fx = (float)((i + 0.5) * scale_x - 0.5);
int sx = (int)floor(fx);
fx -= sx;
if (sx < 0) {
fx = 0 sx = 0;
}
if (sx >= iWidthSrc - 1) {
fx = 0 sx = iWidthSrc - 2;
}
short cbufx[2];
cbufx[0] = (int)((1.f - fx) * 2048 + 0.5);
cbufx[1] = 2048 - cbufx[0];
// 对每个通道进行计算
for (int k = 0; k < sc; k++)
{
*(dataDst+ j*stepDst + sc*i + k) = (*(dataSrc + sy*stepSrc + sc*sx + k) * cbufx[0] * cbufy[0] +
*(dataSrc + (sy+1)*stepSrc + sc*sx + k) * cbufx[0] * cbufy[1] +
*(dataSrc + sy*stepSrc + sc*(sx+1) + k) * cbufx[1] * cbufy[0] +
*(dataSrc + (sy+1)*stepSrc + sc*(sx+1) + k) * cbufx[1] * cbufy[1]) >> 22;
}
}
}
}
/**
* RGBA的图像转为RGB图像
*/
void CMImgProc::RGBA2RGB(const unsigned char *src unsigned char *dst int w int h)
{
//LOGD(“native RGBA2GRAY 1......“);
const unsigned char *pSrc;
unsigned char *pDst;
for(int j = 0; j < h; j++)
{
pSrc = src + j * w * 4;
pDst = dst + j * w * 3;
for(int i = 0; i < w; i++)
{
pDst[2] = pSrc[2];
pDst[1] = pSrc[1];
pDst[0] = pSrc[0];
pSrc += 4;
pDst += 3;
}
}
}
// RGBA格式转GRAY采用公式如下
// Y = 0.299 * R + 0.587 * G + 0.114 * B
// Cr = (R - Y) * 0.713 + delta
// Cb = (B - Y) * 0.564 + delta
// src 源数据4通道RGBA
// dst 结果数据3通道YCrCb
// w 图像的宽度
// h 图像的高度
// sc 源图像的通道数一般为4
void CMImgProc::RGBA2GRAY(const unsigned char *src unsigned char *dst int w int h int sc)
{
LOGD(“native RGBA2GRAY 1......“);
static int yuv_shift = 14;
static int c0 = 4899c1 = 9617c2 = 1868;//RGB
size_t len = strlen((char*)src);
size_t t_sc = len/(w*h);
LOGD(“native RGBA2GRAY 2.....len=%d w=%d h=%d sc=%d t_sc=%d“ len w h sc t_sc);
const unsigned char *pSrc;
unsigned char *pDst;
for(int j = 0; j < h; j++)
{
pSrc = src + j * w * sc;
pDst = dst + j *
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
I.A.... 1182 2016-11-30 07:04 .project
I.A.... 1115 2016-11-30 07:04 AndroidManifest.xm
I.A.... 781 2016-11-30 07:04 proguard-project.txt
I.A.... 563 2016-11-30 07:04 project.properties
I.A.... 2117 2016-11-30 07:03 jni\Android.mk
I.A.... 400 2016-12-03 01:43 jni\Application.mk
I.A.... 6752 2016-12-03 06:43 jni\CMImgProc.cpp
I.A.... 1073 2016-11-30 07:03 jni\CMImgProc.h
I.A.... 14246 2016-11-30 07:03 jni\FaceAlignment\cfan.cpp
I.A.... 3124 2016-11-30 07:03 jni\FaceAlignment\face_alignment.cpp
I.A.... 4697 2016-11-30 07:03 jni\FaceAlignment\include\cfan.h
I.A.... 2735 2016-11-30 07:03 jni\FaceAlignment\include\common.h
I.A.... 2467 2016-11-30 10:17 jni\FaceAlignment\include\face_alignment.h
I.A.... 3448 2016-11-30 07:03 jni\FaceAlignment\include\face_detection.h
I.A.... 3720 2016-11-30 07:03 jni\FaceAlignment\include\sift.h
I.A.... 13422 2016-11-30 07:03 jni\FaceAlignment\sift.cpp
I.A.... 265 2016-11-30 07:04 jni\FaceDetection\CMakeLists.txt
I.A.... 3361 2016-11-30 07:03 jni\FaceDetection\include\classifier\lab_boosted_classifier.h
I.A.... 3593 2016-11-30 07:03 jni\FaceDetection\include\classifier\mlp.h
I.A.... 2503 2016-11-30 07:03 jni\FaceDetection\include\classifier\surf_mlp.h
I.A.... 1880 2016-11-30 07:03 jni\FaceDetection\include\classifier.h
I.A.... 2491 2016-11-30 07:03 jni\FaceDetection\include\common.h
I.A.... 1932 2016-11-30 07:03 jni\FaceDetection\include\detector.h
I.A.... 3494 2016-11-30 07:03 jni\FaceDetection\include\face_detection.h
I.A.... 3057 2016-11-30 07:03 jni\FaceDetection\include\feat\lab_feature_map.h
I.A.... 5399 2016-11-30 07:03 jni\FaceDetection\include\feat\surf_feature_map.h
I.A.... 1890 2016-11-30 07:03 jni\FaceDetection\include\feature_map.h
I.A.... 3262 2016-11-30 07:03 jni\FaceDetection\include\fust.h
I.A.... 2073 2016-11-30 07:03 jni\FaceDetection\include\io\lab_boost_model_reader.h
I.A.... 1868 2016-11-30 07:03 jni\FaceDetection\include\io\surf_mlp_model_reader.h
............此处省略128个文件信息
- 上一篇:基于JSP的驾校考试系统
- 下一篇:dbcp Jar包135339
评论
共有 条评论