ShiqiYu / libfacedetection

An open source library for face detection in images. The face detection speed can reach 1000FPS.
Other
12.27k stars 3.05k forks source link

ios运行很慢 #124

Closed frostfeng closed 4 years ago

frostfeng commented 5 years ago

我在iphone6s手机上运行 demo中的440*293图片检测landmark耗时600ms,这个速度太慢了。

还有我使用iphone6s,输入摄像头采集的1280*720的画面,检测不出人脸。请帮看看是什么问题,谢谢。代码如下:

CVPixelBufferLockBaseAddress(img, 0); void *data = CVPixelBufferGetBaseAddress(img); int width = (int)CVPixelBufferGetWidth(img); int height = (int)CVPixelBufferGetHeight(img); OSType type = CVPixelBufferGetPixelFormatType(img);

vImage_Buffer src;
src.width = width;
src.height = height;
src.data = data;
src.rowBytes = CVPixelBufferGetBytesPerRow(img);

dest.width = width;
dest.height = height;
dest.rowBytes = width * 3;

vImage_Error error = vImageConvert_BGRA8888toRGB888(&src,&dest,kvImageNoFlags);

BOOL gotFace = NO;
int *pResults = NULL;
pResults = facedetect_cnn(pBuffer, (unsigned char *)dest.data, width, height, 440 * 3);
printf("%d faces detected.\n", (pResults ? *pResults : 0));
CVPixelBufferUnlockBaseAddress(img, 0);
dpmaycry commented 5 years ago

加入 -O3 cppflag 开启INT NEON OPENMP 优化

ewen1024 commented 5 years ago

@frostfeng did you find the solution for this? I know you already activated the openmp otherwise it should be over 1000ms/

ewen1024 commented 5 years ago

@dpmaycry HI, I guess I already activated the openmp . Did you have a test on any ios?

ewen1024 commented 5 years ago

@dpmaycry sry, I just misunderstood you. Without int neon openmp o3 int goes 1600ms , with neon and int -o3 goes 100ms but where to set the openmp? thx

zpfate commented 5 years ago

@dpmaycry sry, I just misunderstood you. Without int neon openmp o3 int goes 1600ms , with neon and int -o3 goes 100ms but where to set the openmp? thx

can you tell me how to open int neon openmp? Thank you very much

ShiqiYu commented 4 years ago

you can change the header file facedetectcnn.h to enable NEON.

for gcc, flag -fopenmp can enable openmp during compiling.