The SCRFD face detection, depends on ncnn library and opencv

Overview

ncnn-android-scrfd

The SCRFD face detection

This is a sample ncnn android project, it depends on ncnn library and opencv

https://github.com/Tencent/ncnn

https://github.com/nihui/opencv-mobile

android apk file download

https://github.com/nihui/ncnn-android-scrfd/releases/download/v1/com.tencent.scrfdncnn-release.apk

how to build and run

step1

https://github.com/Tencent/ncnn/releases

  • Download ncnn-YYYYMMDD-android-vulkan.zip or build ncnn for android yourself
  • Extract ncnn-YYYYMMDD-android-vulkan.zip into app/src/main/jni and change the ncnn_DIR path to yours in app/src/main/jni/CMakeLists.txt

step2

https://github.com/nihui/opencv-mobile

  • Download opencv-mobile-XYZ-android.zip
  • Extract opencv-mobile-XYZ-android.zip into app/src/main/jni and change the OpenCV_DIR path to yours in app/src/main/jni/CMakeLists.txt

step3

  • Open this project with Android Studio, build it and enjoy!

some notes

  • Android ndk camera is used for best efficiency
  • Crash may happen on very old devices for lacking HAL3 camera interface
  • All models are manually modified to accept dynamic input shape
  • Most small models run slower on GPU than on CPU, this is common
  • FPS may be lower in dark environment because of longer camera exposure time

screenshot

You might also like...
This is the code of our paper An Efficient Training Approach for Very Large Scale Face Recognition or F²C for simplicity.
This is the code of our paper An Efficient Training Approach for Very Large Scale Face Recognition or F²C for simplicity.

Fast Face Classification (F²C) This is the code of our paper An Efficient Training Approach for Very Large Scale Face Recognition or F²C for simplicit

Face tracking plugin for OBS Studio

OBS Face Tracker Plugin Introduction This plugin provide a filter for face detection and face tracking for mainly a speaking person. This plugin emplo

Chunky pixel watch face for SQFMI's Watchy

pxl999 Pxl999 is a chunky pixel watch face for SQFMI's Watchy. This watch face features live weather updates every 30 minutes and NTP syncing twice a

Mixed reality VR laser tag using Oculus Quest 2 and OAK-D depth cameras. First prize winner for North America region in OpenCV AI Competition 2021.
Mixed reality VR laser tag using Oculus Quest 2 and OAK-D depth cameras. First prize winner for North America region in OpenCV AI Competition 2021.

Mixed Reality Laser Tag Copyright 2021 Bart Trzynadlowski Overview This is the source code to my Mixed Reality Laser Tag project, which won first priz

Example of using  ultralytics YOLO V5 with OpenCV 4.5.4, C++ and Python
Example of using ultralytics YOLO V5 with OpenCV 4.5.4, C++ and Python

yolov5-opencv-cpp-python Example of performing inference with ultralytics YOLO V5, OpenCV 4.5.4 DNN, C++ and Python Looking for YOLO V4 OpenCV C++/Pyt

Example of using YOLO v4 with OpenCV, C++ and Python
Example of using YOLO v4 with OpenCV, C++ and Python

yolov4-opencv-cpp-python Example of performing inference with Darknet YOLO V4, OpenCV 4.4.0 DNN, C++ and Python Looking for YOLO V5 OpenCV C++/Python

cvnp: pybind11 casts between numpy and OpenCV, possibly with shared memory

cvnp: pybind11 casts and transformers between numpy and OpenCV, possibly with shared memory Explicit transformers between cv::Mat / cv::Matx and numpy

GPU PyTorch TOP in TouchDesigner with CUDA-enabled OpenCV

PyTorchTOP This project demonstrates how to use OpenCV with CUDA modules and PyTorch/LibTorch in a TouchDesigner Custom Operator. Building this projec

A simple facial recognition script using OpenCV's FaceRecognizer module implemented in C++
A simple facial recognition script using OpenCV's FaceRecognizer module implemented in C++

Local Binary Patterns Histogram Recognizer A proyect that implements the LBPHRecognizer class of the OpenCV library to determine if a detected face co

Comments
  • imwrite fail on android

    imwrite fail on android

    undefined reference to `cv::imwrite(std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator > const&, cv::_InputArray const&, std::__ndk1::vector<int, std::__ndk1::allocator > const&)' clang++: error: linker command failed with exit code 1 (use -v to see invocation)

    I am using your opencvmobile sdk.

    opened by soham24 2
  • How to change the size of the anchor

    How to change the size of the anchor

    Hi nihui,

    I see that in generate_anchors, the largest anchor is 512*512 (base size=256, scale=2.f).

    I want to change the size of the anchor to detect larger faces.

    But I can't detect a larger face by increasing base_size or scale.

    What should I do to detect larger face sizes?

    BR

    opened by Ijustakid 1
  • Frames dropping and slowness

    Frames dropping and slowness

    The problem

    Actually this is not a problem with your code or ncnn model it just a generic problem when it comes to face heavy operations. Slowness and image frame cuttering because you detect faces in every camera frame

    So

    Well actually phones cpus and gpus aren't much power than our desktops or laptops. It needs a different treatment and workaround to get the best results so far I have used many workarounds and really get some good results overall but still need much smoothness between frames, So far I tried

    • Resizing an image before getting into processing
    • Do the process task in a standalone thread
    • Trackers ?
    • If you know any workaround please mention it

    How to get more good results

    I believe using trackers play a powerful role in this problem but in myself didn't find a good resource to start implement that and see what the output. Did you ever tried to solve this problem using trackers? and if you have a good repos for trackers to use please mention them below

    Thanks!

    opened by aboozaid 1
  • /ncnn-android-scrfd/app/src/main/jni/scrfd.h:29: error: undefined reference to 'ncnn::Net::Net()'

    /ncnn-android-scrfd/app/src/main/jni/scrfd.h:29: error: undefined reference to 'ncnn::Net::Net()'

    @nihui 大佬好,感谢大佬的代码,我已经按照设置把ncnn_dir 和 opencv_dir设置为自己的了,并且所有的ZIP下载下来解压后都放在了jni下,我的cmakelists像这样:

    project(scrfdncnn)
    
    cmake_minimum_required(VERSION 3.10)
    
    set(OpenCV_DIR ./sdk/native/jni)
    find_package(OpenCV REQUIRED core imgproc)
    
    set(ncnn_DIR ./arm64-v8a/lib/cmake/ncnn)
    find_package(ncnn REQUIRED)
    
    add_library(scrfdncnn SHARED scrfdncnn.cpp scrfd.cpp ndkcamera.cpp)
    
    target_link_libraries(scrfdncnn ncnn ${OpenCV_LIBS} camera2ndk mediandk)
    

    但是在编译项目的时候还是找不到ncnn,想问下错在哪里了~感激不尽

    opened by chaotianjiao 0
Owner
マジやばくね
null
This is a sample ncnn android project, it depends on ncnn library and opencv

This is a sample ncnn android project, it depends on ncnn library and opencv

null 248 Jan 6, 2023
GFPGAN-ncnn - a naive NCNN implementation of GFPGAN aims at developing Practical Algorithms for Real-world Face Restoration

GFPGAN-ncnn a naive ncnn implementation of GFPGAN aims at developing Practical Algorithms for Real-world Face Restoration model support: 1.GFPGANClean

FeiGeChuanShu 42 Dec 10, 2022
Swapping face using Face Mesh with TensorFlow Lite

demo.mp4 Aiine Transform (アイン変換) Swapping face using FaceMesh. (could be used to unveil masked faces) Tested Environment Computer Windows 10 (x64) + V

iwatake 17 Apr 26, 2022
Android face detect and segmentation by ncnn

Android face detect and segmentation by ncnn

null 118 Dec 29, 2022
OpenPose: Real-time multi-person keypoint detection library for body, face, hands, and foot estimation

Build Type Linux MacOS Windows Build Status OpenPose has represented the first real-time multi-person system to jointly detect human body, hand, facia

null 25.6k Dec 29, 2022
Helper Class for Deep Learning Inference Frameworks: TensorFlow Lite, TensorRT, OpenCV, ncnn, MNN, SNPE, Arm NN, NNAbla

InferenceHelper This is a helper class for deep learning frameworks especially for inference This class provides an interface to use various deep lear

iwatake 192 Dec 26, 2022
RealSR-NCNN-Android is a simple Android application that based on Realsr-NCNN & Real-ESRGAN.

RealSR-NCNN-Android Real-ESRGAN is a Practical Algorithms for General Image Restoration. RealSR-NCNN-Android is a simple Android application that base

null 272 Jan 3, 2023
Fast and robust face tracking addon for openFrameworks based on YOLO5Face

ofxFaceTracker3 Working in progress Fast and robust face tracking addon for openFrameworks based on YOLO5Face and ONNX Runtime. Features Fast and robu

Yuya Hanai 13 Nov 6, 2022
fast face classification

Fast Face Classification (F²C)—— An Efficient Training Approach for Very Large Scale Face Recognition Training on ultra-large-scale datasets is time-c

null 70 Jan 4, 2023