From 7b1a5fb3de5c05455be9863a028e8f4f2f80cb10 Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Mon, 27 Nov 2023 15:38:19 +0300 Subject: [PATCH] Migrate Android Face Detection sample to DNN. --- modules/dnn/src/dnn_read.cpp | 4 +- .../include/opencv2/objdetect/face.hpp | 25 +- modules/objdetect/src/face_detect.cpp | 47 + samples/android/face-detection/CMakeLists.txt | 16 +- .../android/face-detection/build.gradle.in | 24 - .../face-detection/gradle/AndroidManifest.xml | 2 +- samples/android/face-detection/jni/Android.mk | 23 - .../android/face-detection/jni/Application.mk | 4 - .../android/face-detection/jni/CMakeLists.txt | 23 - .../jni/DetectionBasedTracker_jni.cpp | 251 --- .../jni/DetectionBasedTracker_jni.h | 61 - .../res/raw/lbpcascade_frontalface.xml | 1505 ----------------- .../facedetect/DetectionBasedTracker.java | 41 - .../facedetect/FaceDetectActivity.java | 203 +++ .../opencv/samples/facedetect/FdActivity.java | 244 --- 15 files changed, 288 insertions(+), 2185 deletions(-) delete mode 100644 samples/android/face-detection/jni/Android.mk delete mode 100644 samples/android/face-detection/jni/Application.mk delete mode 100644 samples/android/face-detection/jni/CMakeLists.txt delete mode 100644 samples/android/face-detection/jni/DetectionBasedTracker_jni.cpp delete mode 100644 samples/android/face-detection/jni/DetectionBasedTracker_jni.h delete mode 100644 samples/android/face-detection/res/raw/lbpcascade_frontalface.xml delete mode 100644 samples/android/face-detection/src/org/opencv/samples/facedetect/DetectionBasedTracker.java create mode 100644 samples/android/face-detection/src/org/opencv/samples/facedetect/FaceDetectActivity.java delete mode 100644 samples/android/face-detection/src/org/opencv/samples/facedetect/FdActivity.java diff --git a/modules/dnn/src/dnn_read.cpp b/modules/dnn/src/dnn_read.cpp index c7eb786d01..2b02f462d3 100644 --- a/modules/dnn/src/dnn_read.cpp +++ b/modules/dnn/src/dnn_read.cpp @@ -62,7 +62,9 @@ Net readNet(const String& _framework, const std::vector& bufferModel, const std::vector& bufferConfig) { String framework = toLowerCase(_framework); - if (framework == "caffe") + if (framework == "onnx") + return readNetFromONNX(bufferModel); + else if (framework == "caffe") return readNetFromCaffe(bufferConfig, bufferModel); else if (framework == "tensorflow") return readNetFromTensorflow(bufferModel, bufferConfig); diff --git a/modules/objdetect/include/opencv2/objdetect/face.hpp b/modules/objdetect/include/opencv2/objdetect/face.hpp index d8e96b5dfd..9b53f83128 100644 --- a/modules/objdetect/include/opencv2/objdetect/face.hpp +++ b/modules/objdetect/include/opencv2/objdetect/face.hpp @@ -71,7 +71,7 @@ public: */ CV_WRAP virtual int detect(InputArray image, OutputArray faces) = 0; - /** @brief Creates an instance of this class with given parameters + /** @brief Creates an instance of face detector class with given parameters * * @param model the path to the requested model * @param config the path to the config file for compability, which is not requested for ONNX models @@ -90,6 +90,29 @@ public: int top_k = 5000, int backend_id = 0, int target_id = 0); + + /** @overload + * + * @param framework Name of origin framework + * @param bufferModel A buffer with a content of binary file with weights + * @param bufferConfig A buffer with a content of text file contains network configuration + * @param input_size the size of the input image + * @param score_threshold the threshold to filter out bounding boxes of score smaller than the given value + * @param nms_threshold the threshold to suppress bounding boxes of IoU bigger than the given value + * @param top_k keep top K bboxes before NMS + * @param backend_id the id of backend + * @param target_id the id of target device + */ + CV_WRAP static Ptr create(const String& framework, + const std::vector& bufferModel, + const std::vector& bufferConfig, + const Size& input_size, + float score_threshold = 0.9f, + float nms_threshold = 0.3f, + int top_k = 5000, + int backend_id = 0, + int target_id = 0); + }; /** @brief DNN-based face recognizer diff --git a/modules/objdetect/src/face_detect.cpp b/modules/objdetect/src/face_detect.cpp index 8da13eda45..2dc6047835 100644 --- a/modules/objdetect/src/face_detect.cpp +++ b/modules/objdetect/src/face_detect.cpp @@ -48,6 +48,35 @@ public: topK = top_k; } + FaceDetectorYNImpl(const String& framework, + const std::vector& bufferModel, + const std::vector& bufferConfig, + const Size& input_size, + float score_threshold, + float nms_threshold, + int top_k, + int backend_id, + int target_id) + :divisor(32), + strides({8, 16, 32}) + { + net = dnn::readNet(framework, bufferModel, bufferConfig); + CV_Assert(!net.empty()); + + net.setPreferableBackend(backend_id); + net.setPreferableTarget(target_id); + + inputW = input_size.width; + inputH = input_size.height; + + padW = (int((inputW - 1) / divisor) + 1) * divisor; + padH = (int((inputH - 1) / divisor) + 1) * divisor; + + scoreThreshold = score_threshold; + nmsThreshold = nms_threshold; + topK = top_k; + } + void setInputSize(const Size& input_size) override { inputW = input_size.width; @@ -264,4 +293,22 @@ Ptr FaceDetectorYN::create(const String& model, #endif } +Ptr FaceDetectorYN::create(const String& framework, + const std::vector& bufferModel, + const std::vector& bufferConfig, + const Size& input_size, + const float score_threshold, + const float nms_threshold, + const int top_k, + const int backend_id, + const int target_id) +{ +#ifdef HAVE_OPENCV_DNN + return makePtr(framework, bufferModel, bufferConfig, input_size, score_threshold, nms_threshold, top_k, backend_id, target_id); +#else + CV_UNUSED(model); CV_UNUSED(config); CV_UNUSED(input_size); CV_UNUSED(score_threshold); CV_UNUSED(nms_threshold); CV_UNUSED(top_k); CV_UNUSED(backend_id); CV_UNUSED(target_id); + CV_Error(cv::Error::StsNotImplemented, "cv::FaceDetectorYN requires enabled 'dnn' module."); +#endif +} + } // namespace cv diff --git a/samples/android/face-detection/CMakeLists.txt b/samples/android/face-detection/CMakeLists.txt index bbcfa32f08..3e246f6998 100644 --- a/samples/android/face-detection/CMakeLists.txt +++ b/samples/android/face-detection/CMakeLists.txt @@ -1,12 +1,16 @@ set(sample example-face-detection) -if(BUILD_FAT_JAVA_LIB) - set(native_deps opencv_java) -else() - set(native_deps opencv_objdetect) -endif() +ocv_download(FILENAME "face_detection_yunet_2023mar.onnx" + HASH "4ae92eeb150c82ce15ac80738b3b8167" + URL + "${OPENCV_FACE_DETECT_YN_URL}" + "$ENV{OPENCV_FACE_DETECT_YN_URL}" + "https://media.githubusercontent.com/media/opencv/opencv_zoo/main/models/face_detection_yunet/face_detection_yunet_2023mar.onnx" + DESTINATION_DIR "${CMAKE_CURRENT_LIST_DIR}/res/raw" + ID OPENCV_FACE_DETECT_YN + STATUS res) -add_android_project(${sample} "${CMAKE_CURRENT_SOURCE_DIR}" LIBRARY_DEPS "${OPENCV_ANDROID_LIB_DIR}" SDK_TARGET 11 "${ANDROID_SDK_TARGET}" NATIVE_DEPS ${native_deps}) +add_android_project(${sample} "${CMAKE_CURRENT_SOURCE_DIR}" LIBRARY_DEPS "${OPENCV_ANDROID_LIB_DIR}" SDK_TARGET 11 "${ANDROID_SDK_TARGET}") if(TARGET ${sample}) add_dependencies(opencv_android_examples ${sample}) endif() diff --git a/samples/android/face-detection/build.gradle.in b/samples/android/face-detection/build.gradle.in index 5ebf231291..6cc9d8cfb4 100644 --- a/samples/android/face-detection/build.gradle.in +++ b/samples/android/face-detection/build.gradle.in @@ -9,20 +9,6 @@ android { targetSdkVersion @ANDROID_TARGET_SDK_VERSION@ versionCode 301 versionName "3.01" - - externalNativeBuild { - cmake { - if (gradle.opencv_source == "sdk_path") { - arguments "-DOpenCV_DIR=" + project(':opencv').projectDir + "/@ANDROID_PROJECT_JNI_PATH@", - "-DOPENCV_FROM_SDK=TRUE"@OPENCV_ANDROID_CMAKE_EXTRA_ARGS@ - - } else { - arguments "-DOPENCV_VERSION_MAJOR=@OPENCV_VERSION_MAJOR@", - "-DOPENCV_FROM_SDK=FALSE"@OPENCV_ANDROID_CMAKE_EXTRA_ARGS@ - } - targets "detection_based_tracker" - } - } } buildTypes { release { @@ -38,16 +24,6 @@ android { manifest.srcFile '@ANDROID_SAMPLE_MANIFEST_PATH@' } } - externalNativeBuild { - cmake { - path '@ANDROID_SAMPLE_JNI_PATH@/CMakeLists.txt' - } - } - buildFeatures { - if (gradle.opencv_source == "maven_local" || gradle.opencv_source == "maven_cenral") { - prefab true - } - } } dependencies { diff --git a/samples/android/face-detection/gradle/AndroidManifest.xml b/samples/android/face-detection/gradle/AndroidManifest.xml index 157b318d3b..5476bcfbfb 100644 --- a/samples/android/face-detection/gradle/AndroidManifest.xml +++ b/samples/android/face-detection/gradle/AndroidManifest.xml @@ -9,7 +9,7 @@ diff --git a/samples/android/face-detection/jni/Android.mk b/samples/android/face-detection/jni/Android.mk deleted file mode 100644 index e882cac0c1..0000000000 --- a/samples/android/face-detection/jni/Android.mk +++ /dev/null @@ -1,23 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -#OPENCV_INSTALL_MODULES:=off -#OPENCV_LIB_TYPE:=SHARED -ifdef OPENCV_ANDROID_SDK - ifneq ("","$(wildcard $(OPENCV_ANDROID_SDK)/OpenCV.mk)") - include ${OPENCV_ANDROID_SDK}/OpenCV.mk - else - include ${OPENCV_ANDROID_SDK}/sdk/native/jni/OpenCV.mk - endif -else - include ../../sdk/native/jni/OpenCV.mk -endif - -LOCAL_SRC_FILES := DetectionBasedTracker_jni.cpp -LOCAL_C_INCLUDES += $(LOCAL_PATH) -LOCAL_LDLIBS += -llog -ldl - -LOCAL_MODULE := detection_based_tracker - -include $(BUILD_SHARED_LIBRARY) diff --git a/samples/android/face-detection/jni/Application.mk b/samples/android/face-detection/jni/Application.mk deleted file mode 100644 index 4fffcb2838..0000000000 --- a/samples/android/face-detection/jni/Application.mk +++ /dev/null @@ -1,4 +0,0 @@ -APP_STL := gnustl_static -APP_CPPFLAGS := -frtti -fexceptions -APP_ABI := armeabi-v7a -APP_PLATFORM := android-8 diff --git a/samples/android/face-detection/jni/CMakeLists.txt b/samples/android/face-detection/jni/CMakeLists.txt deleted file mode 100644 index 4da6e0e00e..0000000000 --- a/samples/android/face-detection/jni/CMakeLists.txt +++ /dev/null @@ -1,23 +0,0 @@ -cmake_minimum_required(VERSION 3.6) - -set(target detection_based_tracker) -project(${target} CXX) - -if (OPENCV_FROM_SDK) - message(STATUS "Using OpenCV from local SDK") - set(ANDROID_OPENCV_COMPONENTS "opencv_java" CACHE STRING "") -else() - message(STATUS "Using OpenCV from AAR (Maven repo)") - set(ANDROID_OPENCV_COMPONENTS "OpenCV::opencv_java${OPENCV_VERSION_MAJOR}" CACHE STRING "") -endif() - -message(STATUS "ANDROID_ABI=${ANDROID_ABI}") -find_package(OpenCV REQUIRED COMPONENTS ${ANDROID_OPENCV_COMPONENTS}) - -file(GLOB srcs *.cpp *.c) -file(GLOB hdrs *.hpp *.h) - -include_directories("${CMAKE_CURRENT_LIST_DIR}") -add_library(${target} SHARED ${srcs} ${hdrs}) -find_library(log_lib log) -target_link_libraries(${target} ${ANDROID_OPENCV_COMPONENTS} ${log_lib}) diff --git a/samples/android/face-detection/jni/DetectionBasedTracker_jni.cpp b/samples/android/face-detection/jni/DetectionBasedTracker_jni.cpp deleted file mode 100644 index 6ce36bc527..0000000000 --- a/samples/android/face-detection/jni/DetectionBasedTracker_jni.cpp +++ /dev/null @@ -1,251 +0,0 @@ -#include -#include -#include - -#include -#include - -#include - -#define LOG_TAG "FaceDetection/DetectionBasedTracker" -#define LOGD(...) ((void)__android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)) - -using namespace std; -using namespace cv; - -inline void vector_Rect_to_Mat(vector& v_rect, Mat& mat) -{ - mat = Mat(v_rect, true); -} - -class CascadeDetectorAdapter: public DetectionBasedTracker::IDetector -{ -public: - CascadeDetectorAdapter(cv::Ptr detector): - IDetector(), - Detector(detector) - { - LOGD("CascadeDetectorAdapter::Detect::Detect"); - CV_Assert(detector); - } - - void detect(const cv::Mat &Image, std::vector &objects) - { - LOGD("CascadeDetectorAdapter::Detect: begin"); - LOGD("CascadeDetectorAdapter::Detect: scaleFactor=%.2f, minNeighbours=%d, minObjSize=(%dx%d), maxObjSize=(%dx%d)", scaleFactor, minNeighbours, minObjSize.width, minObjSize.height, maxObjSize.width, maxObjSize.height); - Detector->detectMultiScale(Image, objects, scaleFactor, minNeighbours, 0, minObjSize, maxObjSize); - LOGD("CascadeDetectorAdapter::Detect: end"); - } - - virtual ~CascadeDetectorAdapter() - { - LOGD("CascadeDetectorAdapter::Detect::~Detect"); - } - -private: - CascadeDetectorAdapter(); - cv::Ptr Detector; -}; - -struct DetectorAgregator -{ - cv::Ptr mainDetector; - cv::Ptr trackingDetector; - - cv::Ptr tracker; - DetectorAgregator(cv::Ptr& _mainDetector, cv::Ptr& _trackingDetector): - mainDetector(_mainDetector), - trackingDetector(_trackingDetector) - { - CV_Assert(_mainDetector); - CV_Assert(_trackingDetector); - - DetectionBasedTracker::Parameters DetectorParams; - tracker = makePtr(mainDetector, trackingDetector, DetectorParams); - } -}; - -JNIEXPORT jlong JNICALL Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeCreateObject -(JNIEnv * jenv, jclass, jstring jFileName, jint faceSize) -{ - LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeCreateObject enter"); - const char* jnamestr = jenv->GetStringUTFChars(jFileName, NULL); - string stdFileName(jnamestr); - jlong result = 0; - - LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeCreateObject"); - - try - { - cv::Ptr mainDetector = makePtr( - makePtr(stdFileName)); - cv::Ptr trackingDetector = makePtr( - makePtr(stdFileName)); - result = (jlong)new DetectorAgregator(mainDetector, trackingDetector); - if (faceSize > 0) - { - mainDetector->setMinObjectSize(Size(faceSize, faceSize)); - //trackingDetector->setMinObjectSize(Size(faceSize, faceSize)); - } - } - catch(const cv::Exception& e) - { - LOGD("nativeCreateObject caught cv::Exception: %s", e.what()); - jclass je = jenv->FindClass("org/opencv/core/CvException"); - if(!je) - je = jenv->FindClass("java/lang/Exception"); - jenv->ThrowNew(je, e.what()); - } - catch (...) - { - LOGD("nativeCreateObject caught unknown exception"); - jclass je = jenv->FindClass("java/lang/Exception"); - jenv->ThrowNew(je, "Unknown exception in JNI code of DetectionBasedTracker.nativeCreateObject()"); - return 0; - } - - LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeCreateObject exit"); - return result; -} - -JNIEXPORT void JNICALL Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeDestroyObject -(JNIEnv * jenv, jclass, jlong thiz) -{ - LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeDestroyObject"); - - try - { - if(thiz != 0) - { - ((DetectorAgregator*)thiz)->tracker->stop(); - delete (DetectorAgregator*)thiz; - } - } - catch(const cv::Exception& e) - { - LOGD("nativeestroyObject caught cv::Exception: %s", e.what()); - jclass je = jenv->FindClass("org/opencv/core/CvException"); - if(!je) - je = jenv->FindClass("java/lang/Exception"); - jenv->ThrowNew(je, e.what()); - } - catch (...) - { - LOGD("nativeDestroyObject caught unknown exception"); - jclass je = jenv->FindClass("java/lang/Exception"); - jenv->ThrowNew(je, "Unknown exception in JNI code of DetectionBasedTracker.nativeDestroyObject()"); - } - LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeDestroyObject exit"); -} - -JNIEXPORT void JNICALL Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeStart -(JNIEnv * jenv, jclass, jlong thiz) -{ - LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeStart"); - - try - { - ((DetectorAgregator*)thiz)->tracker->run(); - } - catch(const cv::Exception& e) - { - LOGD("nativeStart caught cv::Exception: %s", e.what()); - jclass je = jenv->FindClass("org/opencv/core/CvException"); - if(!je) - je = jenv->FindClass("java/lang/Exception"); - jenv->ThrowNew(je, e.what()); - } - catch (...) - { - LOGD("nativeStart caught unknown exception"); - jclass je = jenv->FindClass("java/lang/Exception"); - jenv->ThrowNew(je, "Unknown exception in JNI code of DetectionBasedTracker.nativeStart()"); - } - LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeStart exit"); -} - -JNIEXPORT void JNICALL Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeStop -(JNIEnv * jenv, jclass, jlong thiz) -{ - LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeStop"); - - try - { - ((DetectorAgregator*)thiz)->tracker->stop(); - } - catch(const cv::Exception& e) - { - LOGD("nativeStop caught cv::Exception: %s", e.what()); - jclass je = jenv->FindClass("org/opencv/core/CvException"); - if(!je) - je = jenv->FindClass("java/lang/Exception"); - jenv->ThrowNew(je, e.what()); - } - catch (...) - { - LOGD("nativeStop caught unknown exception"); - jclass je = jenv->FindClass("java/lang/Exception"); - jenv->ThrowNew(je, "Unknown exception in JNI code of DetectionBasedTracker.nativeStop()"); - } - LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeStop exit"); -} - -JNIEXPORT void JNICALL Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeSetFaceSize -(JNIEnv * jenv, jclass, jlong thiz, jint faceSize) -{ - LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeSetFaceSize -- BEGIN"); - - try - { - if (faceSize > 0) - { - ((DetectorAgregator*)thiz)->mainDetector->setMinObjectSize(Size(faceSize, faceSize)); - //((DetectorAgregator*)thiz)->trackingDetector->setMinObjectSize(Size(faceSize, faceSize)); - } - } - catch(const cv::Exception& e) - { - LOGD("nativeStop caught cv::Exception: %s", e.what()); - jclass je = jenv->FindClass("org/opencv/core/CvException"); - if(!je) - je = jenv->FindClass("java/lang/Exception"); - jenv->ThrowNew(je, e.what()); - } - catch (...) - { - LOGD("nativeSetFaceSize caught unknown exception"); - jclass je = jenv->FindClass("java/lang/Exception"); - jenv->ThrowNew(je, "Unknown exception in JNI code of DetectionBasedTracker.nativeSetFaceSize()"); - } - LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeSetFaceSize -- END"); -} - - -JNIEXPORT void JNICALL Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeDetect -(JNIEnv * jenv, jclass, jlong thiz, jlong imageGray, jlong faces) -{ - LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeDetect"); - - try - { - vector RectFaces; - ((DetectorAgregator*)thiz)->tracker->process(*((Mat*)imageGray)); - ((DetectorAgregator*)thiz)->tracker->getObjects(RectFaces); - *((Mat*)faces) = Mat(RectFaces, true); - } - catch(const cv::Exception& e) - { - LOGD("nativeCreateObject caught cv::Exception: %s", e.what()); - jclass je = jenv->FindClass("org/opencv/core/CvException"); - if(!je) - je = jenv->FindClass("java/lang/Exception"); - jenv->ThrowNew(je, e.what()); - } - catch (...) - { - LOGD("nativeDetect caught unknown exception"); - jclass je = jenv->FindClass("java/lang/Exception"); - jenv->ThrowNew(je, "Unknown exception in JNI code DetectionBasedTracker.nativeDetect()"); - } - LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeDetect END"); -} diff --git a/samples/android/face-detection/jni/DetectionBasedTracker_jni.h b/samples/android/face-detection/jni/DetectionBasedTracker_jni.h deleted file mode 100644 index 7e0541d810..0000000000 --- a/samples/android/face-detection/jni/DetectionBasedTracker_jni.h +++ /dev/null @@ -1,61 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include -/* Header for class org_opencv_samples_fd_DetectionBasedTracker */ - -#ifndef _Included_org_opencv_samples_fd_DetectionBasedTracker -#define _Included_org_opencv_samples_fd_DetectionBasedTracker -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: org_opencv_samples_fd_DetectionBasedTracker - * Method: nativeCreateObject - * Signature: (Ljava/lang/String;F)J - */ -JNIEXPORT jlong JNICALL Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeCreateObject - (JNIEnv *, jclass, jstring, jint); - -/* - * Class: org_opencv_samples_fd_DetectionBasedTracker - * Method: nativeDestroyObject - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeDestroyObject - (JNIEnv *, jclass, jlong); - -/* - * Class: org_opencv_samples_fd_DetectionBasedTracker - * Method: nativeStart - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeStart - (JNIEnv *, jclass, jlong); - -/* - * Class: org_opencv_samples_fd_DetectionBasedTracker - * Method: nativeStop - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeStop - (JNIEnv *, jclass, jlong); - - /* - * Class: org_opencv_samples_fd_DetectionBasedTracker - * Method: nativeSetFaceSize - * Signature: (JI)V - */ - JNIEXPORT void JNICALL Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeSetFaceSize - (JNIEnv *, jclass, jlong, jint); - -/* - * Class: org_opencv_samples_fd_DetectionBasedTracker - * Method: nativeDetect - * Signature: (JJJ)V - */ -JNIEXPORT void JNICALL Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeDetect - (JNIEnv *, jclass, jlong, jlong, jlong); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/samples/android/face-detection/res/raw/lbpcascade_frontalface.xml b/samples/android/face-detection/res/raw/lbpcascade_frontalface.xml deleted file mode 100644 index fc7648ef51..0000000000 --- a/samples/android/face-detection/res/raw/lbpcascade_frontalface.xml +++ /dev/null @@ -1,1505 +0,0 @@ - - - - - BOOST - LBP - 24 - 24 - - GAB - 0.9950000047683716 - 0.5000000000000000 - 0.9500000000000000 - 1 - 100 - - 256 - 20 - - - <_> - 3 - -0.7520892024040222 - - - <_> - - 0 -1 46 -67130709 -21569 -1426120013 -1275125205 -21585 - -16385 587145899 -24005 - - -0.6543210148811340 0.8888888955116272 - - <_> - - 0 -1 13 -163512766 -769593758 -10027009 -262145 -514457854 - -193593353 -524289 -1 - - -0.7739216089248657 0.7278633713722229 - - <_> - - 0 -1 2 -363936790 -893203669 -1337948010 -136907894 - 1088782736 -134217726 -741544961 -1590337 - - -0.7068563103675842 0.6761534214019775 - - <_> - 4 - -0.4872078299522400 - - - <_> - - 0 -1 84 2147483647 1946124287 -536870913 2147450879 - 738132490 1061101567 243204619 2147446655 - - -0.8083735704421997 0.7685696482658386 - - <_> - - 0 -1 21 2147483647 263176079 1879048191 254749487 1879048191 - -134252545 -268435457 801111999 - - -0.7698410153388977 0.6592915654182434 - - <_> - - 0 -1 106 -98110272 1610939566 -285484400 -850010381 - -189334372 -1671954433 -571026695 -262145 - - -0.7506558895111084 0.5444605946540833 - - <_> - - 0 -1 48 -798690576 -131075 1095771153 -237144073 -65569 -1 - -216727745 -69206049 - - -0.7775990366935730 0.5465461611747742 - - <_> - 4 - -1.1592328548431396 - - - <_> - - 0 -1 47 -21585 -20549 -100818262 -738254174 -20561 -36865 - -151016790 -134238549 - - -0.5601882934570313 0.7743113040924072 - - <_> - - 0 -1 12 -286003217 183435247 -268994614 -421330945 - -402686081 1090387966 -286785545 -402653185 - - -0.6124526262283325 0.6978127956390381 - - <_> - - 0 -1 26 -50347012 970882927 -50463492 -1253377 -134218251 - -50364513 -33619992 -172490753 - - -0.6114496588706970 0.6537628173828125 - - <_> - - 0 -1 8 -273 -135266321 1877977738 -2088243418 -134217987 - 2146926575 -18910642 1095231247 - - -0.6854077577590942 0.5403239130973816 - - <_> - 5 - -0.7562355995178223 - - - <_> - - 0 -1 96 -1273 1870659519 -20971602 -67633153 -134250731 - 2004875127 -250 -150995969 - - -0.4051094949245453 0.7584033608436585 - - <_> - - 0 -1 33 -868162224 -76810262 -4262145 -257 1465211989 - -268959873 -2656269 -524289 - - -0.7388162612915039 0.5340843200683594 - - <_> - - 0 -1 57 -12817 -49 -541103378 -152950 -38993 -20481 -1153876 - -72478976 - - -0.6582943797111511 0.5339496731758118 - - <_> - - 0 -1 125 -269484161 -452984961 -319816180 -1594032130 -2111 - -990117891 -488975296 -520947741 - - -0.5981323719024658 0.5323504805564880 - - <_> - - 0 -1 53 557787431 670265215 -1342193665 -1075892225 - 1998528318 1056964607 -33570977 -1 - - -0.6498787999153137 0.4913350641727448 - - <_> - 5 - -0.8085358142852783 - - - <_> - - 0 -1 60 -536873708 880195381 -16842788 -20971521 -176687276 - -168427659 -16777260 -33554626 - - -0.5278195738792419 0.6946372389793396 - - <_> - - 0 -1 7 -1 -62981529 -1090591130 805330978 -8388827 -41945787 - -39577 -531118985 - - -0.5206505060195923 0.6329920291900635 - - <_> - - 0 -1 98 -725287348 1347747543 -852489 -16809993 1489881036 - -167903241 -1 -1 - - -0.7516061067581177 0.4232024252414703 - - <_> - - 0 -1 44 -32777 1006582562 -65 935312171 -8388609 -1078198273 - -1 733886267 - - -0.7639313936233521 0.4123568832874298 - - <_> - - 0 -1 24 -85474705 2138828511 -1036436754 817625855 - 1123369029 -58796809 -1013468481 -194513409 - - -0.5123769044876099 0.5791834592819214 - - <_> - 5 - -0.5549971461296082 - - - <_> - - 0 -1 42 -17409 -20481 -268457797 -134239493 -17473 -1 -21829 - -21846 - - -0.3763174116611481 0.7298233509063721 - - <_> - - 0 -1 6 -805310737 -2098262358 -269504725 682502698 - 2147483519 1740574719 -1090519233 -268472385 - - -0.5352765917778015 0.5659480094909668 - - <_> - - 0 -1 61 -67109678 -6145 -8 -87884584 -20481 -1073762305 - -50856216 -16849696 - - -0.5678374171257019 0.4961479902267456 - - <_> - - 0 -1 123 -138428633 1002418167 -1359008245 -1908670465 - -1346685918 910098423 -1359010520 -1346371657 - - -0.5706262588500977 0.4572288393974304 - - <_> - - 0 -1 9 -89138513 -4196353 1256531674 -1330665426 1216308261 - -36190633 33498198 -151796633 - - -0.5344601869583130 0.4672054052352905 - - <_> - 5 - -0.8776460289955139 - - - <_> - - 0 -1 105 1073769576 206601725 -34013449 -33554433 -789514004 - -101384321 -690225153 -264193 - - -0.7700348496437073 0.5943940877914429 - - <_> - - 0 -1 30 -1432340997 -823623681 -49153 -34291724 -269484035 - -1342767105 -1078198273 -1277955 - - -0.5043668746948242 0.6151274442672730 - - <_> - - 0 -1 35 -1067385040 -195758209 -436748425 -134217731 - -50855988 -129 -1 -1 - - -0.6808040738105774 0.4667325913906097 - - <_> - - 0 -1 119 832534325 -34111555 -26050561 -423659521 -268468364 - 2105014143 -2114244 -17367185 - - -0.4927591383457184 0.5401885509490967 - - <_> - - 0 -1 82 -1089439888 -1080524865 2143059967 -1114121 - -1140949004 -3 -2361356 -739516 - - -0.6445107460021973 0.4227822124958038 - - <_> - 6 - -1.1139287948608398 - - - <_> - - 0 -1 52 -1074071553 -1074003969 -1 -1280135430 -5324817 -1 - -335548482 582134442 - - -0.5307556986808777 0.6258179545402527 - - <_> - - 0 -1 99 -706937396 -705364068 -540016724 -570495027 - -570630659 -587857963 -33628164 -35848193 - - -0.5227634310722351 0.5049746036529541 - - <_> - - 0 -1 18 -2035630093 42119158 -268503053 -1671444 261017599 - 1325432815 1954394111 -805306449 - - -0.4983572661876679 0.5106441378593445 - - <_> - - 0 -1 111 -282529488 -1558073088 1426018736 -170526448 - -546832487 -5113037 -34243375 -570427929 - - -0.4990860521793366 0.5060507059097290 - - <_> - - 0 -1 92 1016332500 -606301707 915094269 -1080086049 - -1837027144 -1361600280 2147318747 1067975613 - - -0.5695009231567383 0.4460467398166657 - - <_> - - 0 -1 51 -656420166 -15413034 -141599534 -603435836 - 1505950458 -787556946 -79823438 -1326199134 - - -0.6590405106544495 0.3616424500942230 - - <_> - 7 - -0.8243625760078430 - - - <_> - - 0 -1 28 -901591776 -201916417 -262 -67371009 -143312112 - -524289 -41943178 -1 - - -0.4972776770591736 0.6027074456214905 - - <_> - - 0 -1 112 -4507851 -411340929 -268437513 -67502145 -17350859 - -32901 -71344315 -29377 - - -0.4383158981800079 0.5966237187385559 - - <_> - - 0 -1 69 -75894785 -117379438 -239063587 -12538500 1485072126 - 2076233213 2123118847 801906927 - - -0.6386105418205261 0.3977999985218048 - - <_> - - 0 -1 19 -823480413 786628589 -16876049 -1364262914 242165211 - 1315930109 -696268833 -455082829 - - -0.5512794256210327 0.4282079637050629 - - <_> - - 0 -1 73 -521411968 6746762 -1396236286 -2038436114 - -185612509 57669627 -143132877 -1041235973 - - -0.6418755054473877 0.3549866080284119 - - <_> - - 0 -1 126 -478153869 1076028979 -1645895615 1365298272 - -557859073 -339771473 1442574528 -1058802061 - - -0.4841901361942291 0.4668019413948059 - - <_> - - 0 -1 45 -246350404 -1650402048 -1610612745 -788400696 - 1467604861 -2787397 1476263935 -4481349 - - -0.5855734348297119 0.3879135847091675 - - <_> - 7 - -1.2237116098403931 - - - <_> - - 0 -1 114 -24819 1572863935 -16809993 -67108865 2146778388 - 1433927541 -268608444 -34865205 - - -0.2518476545810700 0.7088654041290283 - - <_> - - 0 -1 97 -1841359 -134271049 -32769 -5767369 -1116675 -2185 - -8231 -33603327 - - -0.4303432404994965 0.5283288359642029 - - <_> - - 0 -1 25 -1359507589 -1360593090 -1073778729 -269553812 - -809512977 1744707583 -41959433 -134758978 - - -0.4259553551673889 0.5440809130668640 - - <_> - - 0 -1 34 729753407 -134270989 -1140907329 -235200777 - 658456383 2147467263 -1140900929 -16385 - - -0.5605589151382446 0.4220733344554901 - - <_> - - 0 -1 134 -310380553 -420675595 -193005472 -353568129 - 1205338070 -990380036 887604324 -420544526 - - -0.5192656517028809 0.4399855434894562 - - <_> - - 0 -1 16 -1427119361 1978920959 -287119734 -487068946 - 114759245 -540578051 -707510259 -671660453 - - -0.5013077259063721 0.4570254683494568 - - <_> - - 0 -1 74 -738463762 -889949281 -328301948 -121832450 - -1142658284 -1863576559 2146417353 -263185 - - -0.4631414115428925 0.4790246188640595 - - <_> - 7 - -0.5544230937957764 - - - <_> - - 0 -1 113 -76228780 -65538 -1 -67174401 -148007 -33 -221796 - -272842924 - - -0.3949716091156006 0.6082032322883606 - - <_> - - 0 -1 110 369147696 -1625232112 2138570036 -1189900 790708019 - -1212613127 799948719 -4456483 - - -0.4855885505676270 0.4785369932651520 - - <_> - - 0 -1 37 784215839 -290015241 536832799 -402984963 - -1342414991 -838864897 -176769 -268456129 - - -0.4620285332202911 0.4989669024944305 - - <_> - - 0 -1 41 -486418688 -171915327 -340294900 -21938 -519766032 - -772751172 -73096060 -585322623 - - -0.6420643329620361 0.3624351918697357 - - <_> - - 0 -1 117 -33554953 -475332625 -1423463824 -2077230421 - -4849669 -2080505925 -219032928 -1071915349 - - -0.4820112884044647 0.4632140696048737 - - <_> - - 0 -1 65 -834130468 -134217476 -1349314083 -1073803559 - -619913764 -1449131844 -1386890321 -1979118423 - - -0.4465552568435669 0.5061788558959961 - - <_> - - 0 -1 56 -285249779 1912569855 -16530 -1731022870 -1161904146 - -1342177297 -268439634 -1464078708 - - -0.5190586447715759 0.4441480338573456 - - <_> - 7 - -0.7161560654640198 - - - <_> - - 0 -1 20 1246232575 1078001186 -10027057 60102 -277348353 - -43646987 -1210581153 1195769615 - - -0.4323809444904327 0.5663768053054810 - - <_> - - 0 -1 15 -778583572 -612921106 -578775890 -4036478 - -1946580497 -1164766570 -1986687009 -12103599 - - -0.4588732719421387 0.4547033011913300 - - <_> - - 0 -1 129 -1073759445 2013231743 -1363169553 -1082459201 - -1414286549 868185983 -1356133589 -1077936257 - - -0.5218553543090820 0.4111092388629913 - - <_> - - 0 -1 102 -84148365 -2093417722 -1204850272 564290299 - -67121221 -1342177350 -1309195902 -776734797 - - -0.4920000731945038 0.4326725304126740 - - <_> - - 0 -1 88 -25694458 67104495 -290216278 -168563037 2083877442 - 1702788383 -144191964 -234882162 - - -0.4494568109512329 0.4448510706424713 - - <_> - - 0 -1 59 -857980836 904682741 -1612267521 232279415 - 1550862252 -574825221 -357380888 -4579409 - - -0.5180826783180237 0.3888972699642181 - - <_> - - 0 -1 27 -98549440 -137838400 494928389 -246013630 939541351 - -1196072350 -620603549 2137216273 - - -0.6081240773200989 0.3333222270011902 - - <_> - 8 - -0.6743940711021423 - - - <_> - - 0 -1 29 -150995201 2071191945 -1302151626 536934335 - -1059008937 914128709 1147328110 -268369925 - - -0.1790193915367127 0.6605972051620483 - - <_> - - 0 -1 128 -134509479 1610575703 -1342177289 1861484541 - -1107833788 1577058173 -333558568 -136319041 - - -0.3681024610996246 0.5139749646186829 - - <_> - - 0 -1 70 -1 1060154476 -1090984524 -630918524 -539492875 - 779616255 -839568424 -321 - - -0.3217232525348663 0.6171553134918213 - - <_> - - 0 -1 4 -269562385 -285029906 -791084350 -17923776 235286671 - 1275504943 1344390399 -966276889 - - -0.4373284578323364 0.4358185231685638 - - <_> - - 0 -1 76 17825984 -747628419 595427229 1474759671 575672208 - -1684005538 872217086 -1155858277 - - -0.4404836893081665 0.4601220190525055 - - <_> - - 0 -1 124 -336593039 1873735591 -822231622 -355795238 - -470820869 -1997537409 -1057132384 -1015285005 - - -0.4294152259826660 0.4452161788940430 - - <_> - - 0 -1 54 -834212130 -593694721 -322142257 -364892500 - -951029539 -302125121 -1615106053 -79249765 - - -0.3973052501678467 0.4854526817798615 - - <_> - - 0 -1 95 1342144479 2147431935 -33554561 -47873 -855685912 -1 - 1988052447 536827383 - - -0.7054683566093445 0.2697997391223908 - - <_> - 9 - -1.2042298316955566 - - - <_> - - 0 -1 39 1431368960 -183437936 -537002499 -137497097 - 1560590321 -84611081 -2097193 -513 - - -0.5905947685241699 0.5101932883262634 - - <_> - - 0 -1 120 -1645259691 2105491231 2130706431 1458995007 - -8567536 -42483883 -33780003 -21004417 - - -0.4449204802513123 0.4490709304809570 - - <_> - - 0 -1 89 -612381022 -505806938 -362027516 -452985106 - 275854917 1920431639 -12600561 -134221825 - - -0.4693818688392639 0.4061094820499420 - - <_> - - 0 -1 14 -805573153 -161 -554172679 -530519488 -16779441 - 2000682871 -33604275 -150997129 - - -0.3600351214408875 0.5056326985359192 - - <_> - - 0 -1 67 6192 435166195 1467449341 2046691505 -1608493775 - -4755729 -1083162625 -71365637 - - -0.4459891915321350 0.4132415652275085 - - <_> - - 0 -1 86 -41689215 -3281034 1853357967 -420712635 -415924289 - -270209208 -1088293113 -825311232 - - -0.4466069042682648 0.4135067760944367 - - <_> - - 0 -1 80 -117391116 -42203396 2080374461 -188709 -542008165 - -356831940 -1091125345 -1073796897 - - -0.3394956290721893 0.5658645033836365 - - <_> - - 0 -1 75 -276830049 1378714472 -1342181951 757272098 - 1073740607 -282199241 -415761549 170896931 - - -0.5346512198448181 0.3584479391574860 - - <_> - - 0 -1 55 -796075825 -123166849 2113667055 -217530421 - -1107432194 -16385 -806359809 -391188771 - - -0.4379335641860962 0.4123645126819611 - - <_> - 10 - -0.8402050137519836 - - - <_> - - 0 -1 71 -890246622 15525883 -487690486 47116238 -1212319899 - -1291847681 -68159890 -469829921 - - -0.2670986354351044 0.6014143228530884 - - <_> - - 0 -1 31 -1361180685 -1898008841 -1090588811 -285410071 - -1074016265 -840443905 2147221487 -262145 - - -0.4149844348430634 0.4670888185501099 - - <_> - - 0 -1 40 1426190596 1899364271 2142731795 -142607505 - -508232452 -21563393 -41960001 -65 - - -0.4985891580581665 0.3719584941864014 - - <_> - - 0 -1 109 -201337965 10543906 -236498096 -746195597 - 1974565825 -15204415 921907633 -190058309 - - -0.4568729996681213 0.3965812027454376 - - <_> - - 0 -1 130 -595026732 -656401928 -268649235 -571490699 - -440600392 -133131 -358810952 -2004088646 - - -0.4770836830139160 0.3862601518630981 - - <_> - - 0 -1 66 941674740 -1107882114 1332789109 -67691015 - -1360463693 -1556612430 -609108546 733546933 - - -0.4877715110778809 0.3778986334800720 - - <_> - - 0 -1 49 -17114945 -240061474 1552871558 -82775604 -932393844 - -1308544889 -532635478 -99042357 - - -0.3721654713153839 0.4994400143623352 - - <_> - - 0 -1 133 -655906006 1405502603 -939205164 1884929228 - -498859222 559417357 -1928559445 -286264385 - - -0.3934195041656494 0.4769641458988190 - - <_> - - 0 -1 0 -335837777 1860677295 -90 -1946186226 931096183 - 251612987 2013265917 -671232197 - - -0.4323300719261169 0.4342164099216461 - - <_> - - 0 -1 103 37769424 -137772680 374692301 2002666345 -536176194 - -1644484728 807009019 1069089930 - - -0.4993278682231903 0.3665378093719482 - - <_> - 9 - -1.1974394321441650 - - - <_> - - 0 -1 43 -5505 2147462911 2143265466 -4511070 -16450 -257 - -201348440 -71333206 - - -0.3310225307941437 0.5624626278877258 - - <_> - - 0 -1 90 -136842268 -499330741 2015250980 -87107126 - -641665744 -788524639 -1147864792 -134892563 - - -0.5266560912132263 0.3704403042793274 - - <_> - - 0 -1 104 -146800880 -1780368555 2111170033 -140904684 - -16777551 -1946681885 -1646463595 -839131947 - - -0.4171888828277588 0.4540435671806335 - - <_> - - 0 -1 85 -832054034 -981663763 -301990281 -578814081 - -932319000 -1997406723 -33555201 -69206017 - - -0.4556705355644226 0.3704262077808380 - - <_> - - 0 -1 24 -118492417 -1209026825 1119023838 -1334313353 - 1112948738 -297319313 1378887291 -139469193 - - -0.4182529747486115 0.4267231225967407 - - <_> - - 0 -1 78 -1714382628 -2353704 -112094959 -549613092 - -1567058760 -1718550464 -342315012 -1074972227 - - -0.3625369668006897 0.4684656262397766 - - <_> - - 0 -1 5 -85219702 316836394 -33279 1904970288 2117267315 - -260901769 -621461759 -88607770 - - -0.4742925167083740 0.3689507246017456 - - <_> - - 0 -1 11 -294654041 -353603585 -1641159686 -50331921 - -2080899877 1145569279 -143132713 -152044037 - - -0.3666271567344666 0.4580127298831940 - - <_> - - 0 -1 32 1887453658 -638545712 -1877976819 -34320972 - -1071067983 -661345416 -583338277 1060190561 - - -0.4567637443542481 0.3894708156585693 - - <_> - 9 - -0.5733128190040588 - - - <_> - - 0 -1 122 -994063296 1088745462 -318837116 -319881377 - 1102566613 1165490103 -121679694 -134744129 - - -0.4055117964744568 0.5487945079803467 - - <_> - - 0 -1 68 -285233233 -538992907 1811935199 -369234005 -529 - -20593 -20505 -1561401854 - - -0.3787897229194641 0.4532003402709961 - - <_> - - 0 -1 58 -1335245632 1968917183 1940861695 536816369 - -1226071367 -570908176 457026619 1000020667 - - -0.4258328974246979 0.4202791750431061 - - <_> - - 0 -1 94 -1360318719 -1979797897 -50435249 -18646473 - -608879292 -805306691 -269304244 -17840167 - - -0.4561023116111755 0.4002747833728790 - - <_> - - 0 -1 87 2062765935 -16449 -1275080721 -16406 45764335 - -1090552065 -772846337 -570464322 - - -0.4314672648906708 0.4086346626281738 - - <_> - - 0 -1 127 -536896021 1080817663 -738234288 -965478709 - -2082767969 1290855887 1993822934 -990381609 - - -0.4174543321132660 0.4249868988990784 - - <_> - - 0 -1 3 -818943025 168730891 -293610428 -79249354 669224671 - 621166734 1086506807 1473768907 - - -0.4321364760398865 0.4090838730335236 - - <_> - - 0 -1 79 -68895696 -67107736 -1414315879 -841676168 - -619843344 -1180610531 -1081990469 1043203389 - - -0.5018386244773865 0.3702533841133118 - - <_> - - 0 -1 116 -54002134 -543485719 -2124882422 -1437445858 - -115617074 -1195787391 -1096024366 -2140472445 - - -0.5037505626678467 0.3564981222152710 - - <_> - 9 - -0.4892596900463104 - - - <_> - - 0 -1 132 -67113211 2003808111 1862135111 846461923 -2752 - 2002237273 -273154752 1937223539 - - -0.2448196411132813 0.5689709186553955 - - <_> - - 0 -1 62 1179423888 -78064940 -611839555 -539167899 - -1289358360 -1650810108 -892540499 -1432827684 - - -0.4633283913135529 0.3587929606437683 - - <_> - - 0 -1 23 -285212705 -78450761 -656212031 -264050110 -27787425 - -1334349961 -547662981 -135796924 - - -0.3731099069118500 0.4290455579757690 - - <_> - - 0 -1 77 341863476 403702016 -550588417 1600194541 - -1080690735 951127993 -1388580949 -1153717473 - - -0.3658909499645233 0.4556473195552826 - - <_> - - 0 -1 22 -586880702 -204831512 -100644596 -39319550 - -1191150794 705692513 457203315 -75806957 - - -0.5214384198188782 0.3221037387847900 - - <_> - - 0 -1 72 -416546870 545911370 -673716192 -775559454 - -264113598 139424 -183369982 -204474641 - - -0.4289036989212036 0.4004956185817719 - - <_> - - 0 -1 50 -1026505020 -589692154 -1740499937 -1563770497 - 1348491006 -60710713 -1109853489 -633909413 - - -0.4621542394161224 0.3832748532295227 - - <_> - - 0 -1 108 -1448872304 -477895040 -1778390608 -772418127 - -1789923416 -1612057181 -805306693 -1415842113 - - -0.3711548447608948 0.4612701535224915 - - <_> - - 0 -1 92 407905424 -582449988 52654751 -1294472 -285103725 - -74633006 1871559083 1057955850 - - -0.5180652141571045 0.3205870389938355 - - <_> - 10 - -0.5911940932273865 - - - <_> - - 0 -1 81 4112 -1259563825 -846671428 -100902460 1838164148 - -74153752 -90653988 -1074263896 - - -0.2592592537403107 0.5873016119003296 - - <_> - - 0 -1 1 -285216785 -823206977 -1085589 -1081346 1207959293 - 1157103471 2097133565 -2097169 - - -0.3801195919513702 0.4718827307224274 - - <_> - - 0 -1 121 -12465 -536875169 2147478367 2130706303 -37765492 - -866124467 -318782328 -1392509185 - - -0.3509117066860199 0.5094807147979736 - - <_> - - 0 -1 38 2147449663 -20741 -16794757 1945873146 -16710 -1 - -8406341 -67663041 - - -0.4068757295608521 0.4130136370658875 - - <_> - - 0 -1 17 -155191713 866117231 1651407483 548272812 -479201468 - -447742449 1354229504 -261884429 - - -0.4557141065597534 0.3539792001247406 - - <_> - - 0 -1 100 -225319378 -251682065 -492783986 -792341777 - -1287261695 1393643841 -11274182 -213909521 - - -0.4117803275585175 0.4118592441082001 - - <_> - - 0 -1 63 -382220122 -2002072729 -51404800 -371201558 - -923011069 -2135301457 -2066104743 -1042557441 - - -0.4008397758007050 0.4034757018089294 - - <_> - - 0 -1 101 -627353764 -48295149 1581203952 -436258614 - -105268268 -1435893445 -638126888 -1061107126 - - -0.5694189667701721 0.2964762747287750 - - <_> - - 0 -1 118 -8399181 1058107691 -621022752 -251003468 -12582915 - -574619739 -994397789 -1648362021 - - -0.3195341229438782 0.5294018983840942 - - <_> - - 0 -1 92 -348343812 -1078389516 1717960437 364735981 - -1783841602 -4883137 -457572354 -1076950384 - - -0.3365339040756226 0.5067458748817444 - - <_> - 10 - -0.7612916231155396 - - - <_> - - 0 -1 10 -1976661318 -287957604 -1659497122 -782068 43591089 - -453637880 1435470000 -1077438561 - - -0.4204545319080353 0.5165745615959168 - - <_> - - 0 -1 131 -67110925 14874979 -142633168 -1338923040 - 2046713291 -2067933195 1473503712 -789579837 - - -0.3762553930282593 0.4075302779674530 - - <_> - - 0 -1 83 -272814301 -1577073 -1118685 -305156120 -1052289 - -1073813756 -538971154 -355523038 - - -0.4253497421741486 0.3728055357933044 - - <_> - - 0 -1 135 -2233 -214486242 -538514758 573747007 -159390971 - 1994225489 -973738098 -203424005 - - -0.3601998090744019 0.4563256204128265 - - <_> - - 0 -1 115 -261031688 -1330369299 -641860609 1029570301 - -1306461192 -1196149518 -1529767778 683139823 - - -0.4034293889999390 0.4160816967487335 - - <_> - - 0 -1 64 -572993608 -34042628 -417865 -111109 -1433365268 - -19869715 -1920939864 -1279457063 - - -0.3620899617671967 0.4594142735004425 - - <_> - - 0 -1 36 -626275097 -615256993 1651946018 805366393 - 2016559730 -430780849 -799868165 -16580645 - - -0.3903816640377045 0.4381459355354309 - - <_> - - 0 -1 93 1354797300 -1090957603 1976418270 -1342502178 - -1851873892 -1194637077 -1153521668 -1108399474 - - -0.3591445386409760 0.4624078869819641 - - <_> - - 0 -1 91 68157712 1211368313 -304759523 1063017136 798797750 - -275513546 648167355 -1145357350 - - -0.4297670423984528 0.4023293554782867 - - <_> - - 0 -1 107 -546318240 -1628569602 -163577944 -537002306 - -545456389 -1325465645 -380446736 -1058473386 - - -0.5727006793022156 0.2995934784412384 - - <_> - - 0 0 3 5 - <_> - - 0 0 4 2 - <_> - - 0 0 6 3 - <_> - - 0 1 2 3 - <_> - - 0 1 3 3 - <_> - - 0 1 3 7 - <_> - - 0 4 3 3 - <_> - - 0 11 3 4 - <_> - - 0 12 8 4 - <_> - - 0 14 4 3 - <_> - - 1 0 5 3 - <_> - - 1 1 2 2 - <_> - - 1 3 3 1 - <_> - - 1 7 4 4 - <_> - - 1 12 2 2 - <_> - - 1 13 4 1 - <_> - - 1 14 4 3 - <_> - - 1 17 3 2 - <_> - - 2 0 2 3 - <_> - - 2 1 2 2 - <_> - - 2 2 4 6 - <_> - - 2 3 4 4 - <_> - - 2 7 2 1 - <_> - - 2 11 2 3 - <_> - - 2 17 3 2 - <_> - - 3 0 2 2 - <_> - - 3 1 7 3 - <_> - - 3 7 2 1 - <_> - - 3 7 2 4 - <_> - - 3 18 2 2 - <_> - - 4 0 2 3 - <_> - - 4 3 2 1 - <_> - - 4 6 2 1 - <_> - - 4 6 2 5 - <_> - - 4 7 5 2 - <_> - - 4 8 4 3 - <_> - - 4 18 2 2 - <_> - - 5 0 2 2 - <_> - - 5 3 4 4 - <_> - - 5 6 2 5 - <_> - - 5 9 2 2 - <_> - - 5 10 2 2 - <_> - - 6 3 4 4 - <_> - - 6 4 4 3 - <_> - - 6 5 2 3 - <_> - - 6 5 2 5 - <_> - - 6 5 4 3 - <_> - - 6 6 4 2 - <_> - - 6 6 4 4 - <_> - - 6 18 1 2 - <_> - - 6 21 2 1 - <_> - - 7 0 3 7 - <_> - - 7 4 2 3 - <_> - - 7 9 5 1 - <_> - - 7 21 2 1 - <_> - - 8 0 1 4 - <_> - - 8 5 2 2 - <_> - - 8 5 3 2 - <_> - - 8 17 3 1 - <_> - - 8 18 1 2 - <_> - - 9 0 5 3 - <_> - - 9 2 2 6 - <_> - - 9 5 1 1 - <_> - - 9 11 1 1 - <_> - - 9 16 1 1 - <_> - - 9 16 2 1 - <_> - - 9 17 1 1 - <_> - - 9 18 1 1 - <_> - - 10 5 1 2 - <_> - - 10 5 3 3 - <_> - - 10 7 1 5 - <_> - - 10 8 1 1 - <_> - - 10 9 1 1 - <_> - - 10 10 1 1 - <_> - - 10 10 1 2 - <_> - - 10 14 3 3 - <_> - - 10 15 1 1 - <_> - - 10 15 2 1 - <_> - - 10 16 1 1 - <_> - - 10 16 2 1 - <_> - - 10 17 1 1 - <_> - - 10 21 1 1 - <_> - - 11 3 2 2 - <_> - - 11 5 1 2 - <_> - - 11 5 3 3 - <_> - - 11 5 4 6 - <_> - - 11 6 1 1 - <_> - - 11 7 2 2 - <_> - - 11 8 1 2 - <_> - - 11 10 1 1 - <_> - - 11 10 1 2 - <_> - - 11 15 1 1 - <_> - - 11 17 1 1 - <_> - - 11 18 1 1 - <_> - - 12 0 2 2 - <_> - - 12 1 2 5 - <_> - - 12 2 4 1 - <_> - - 12 3 1 3 - <_> - - 12 7 3 4 - <_> - - 12 10 3 2 - <_> - - 12 11 1 1 - <_> - - 12 12 3 2 - <_> - - 12 14 4 3 - <_> - - 12 17 1 1 - <_> - - 12 21 2 1 - <_> - - 13 6 2 5 - <_> - - 13 7 3 5 - <_> - - 13 11 3 2 - <_> - - 13 17 2 2 - <_> - - 13 17 3 2 - <_> - - 13 18 1 2 - <_> - - 13 18 2 2 - <_> - - 14 0 2 2 - <_> - - 14 1 1 3 - <_> - - 14 2 3 2 - <_> - - 14 7 2 1 - <_> - - 14 13 2 1 - <_> - - 14 13 3 3 - <_> - - 14 17 2 2 - <_> - - 15 0 2 2 - <_> - - 15 0 2 3 - <_> - - 15 4 3 2 - <_> - - 15 4 3 6 - <_> - - 15 6 3 2 - <_> - - 15 11 3 4 - <_> - - 15 13 3 2 - <_> - - 15 17 2 2 - <_> - - 15 17 3 2 - <_> - - 16 1 2 3 - <_> - - 16 3 2 4 - <_> - - 16 6 1 1 - <_> - - 16 16 2 2 - <_> - - 17 1 2 2 - <_> - - 17 1 2 5 - <_> - - 17 12 2 2 - <_> - - 18 0 2 2 - diff --git a/samples/android/face-detection/src/org/opencv/samples/facedetect/DetectionBasedTracker.java b/samples/android/face-detection/src/org/opencv/samples/facedetect/DetectionBasedTracker.java deleted file mode 100644 index 6179f1bdc1..0000000000 --- a/samples/android/face-detection/src/org/opencv/samples/facedetect/DetectionBasedTracker.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.opencv.samples.facedetect; - -import org.opencv.core.Mat; -import org.opencv.core.MatOfRect; - -public class DetectionBasedTracker -{ - public DetectionBasedTracker(String cascadeName, int minFaceSize) { - mNativeObj = nativeCreateObject(cascadeName, minFaceSize); - } - - public void start() { - nativeStart(mNativeObj); - } - - public void stop() { - nativeStop(mNativeObj); - } - - public void setMinFaceSize(int size) { - nativeSetFaceSize(mNativeObj, size); - } - - public void detect(Mat imageGray, MatOfRect faces) { - nativeDetect(mNativeObj, imageGray.getNativeObjAddr(), faces.getNativeObjAddr()); - } - - public void release() { - nativeDestroyObject(mNativeObj); - mNativeObj = 0; - } - - private long mNativeObj = 0; - - private static native long nativeCreateObject(String cascadeName, int minFaceSize); - private static native void nativeDestroyObject(long thiz); - private static native void nativeStart(long thiz); - private static native void nativeStop(long thiz); - private static native void nativeSetFaceSize(long thiz, int size); - private static native void nativeDetect(long thiz, long inputImage, long faces); -} diff --git a/samples/android/face-detection/src/org/opencv/samples/facedetect/FaceDetectActivity.java b/samples/android/face-detection/src/org/opencv/samples/facedetect/FaceDetectActivity.java new file mode 100644 index 0000000000..f487b184ab --- /dev/null +++ b/samples/android/face-detection/src/org/opencv/samples/facedetect/FaceDetectActivity.java @@ -0,0 +1,203 @@ +package org.opencv.samples.facedetect; + +import java.lang.Math; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.Collections; +import java.util.List; + +import org.opencv.android.CameraActivity; +import org.opencv.android.CameraBridgeViewBase.CvCameraViewFrame; +import org.opencv.android.OpenCVLoader; +import org.opencv.core.Core; +import org.opencv.core.Mat; +import org.opencv.core.MatOfByte; +import org.opencv.core.Point; +import org.opencv.core.Rect; +import org.opencv.core.Scalar; +import org.opencv.core.Size; +import org.opencv.android.CameraBridgeViewBase; +import org.opencv.android.CameraBridgeViewBase.CvCameraViewListener2; +import org.opencv.objdetect.FaceDetectorYN; +import org.opencv.imgproc.Imgproc; + +import android.app.Activity; +import android.content.Context; +import android.os.Bundle; +import android.util.Log; +import android.view.Menu; +import android.view.MenuItem; +import android.view.WindowManager; +import android.widget.Toast; + +public class FaceDetectActivity extends CameraActivity implements CvCameraViewListener2 { + + private static final String TAG = "OCVSample::Activity"; + + private static final Scalar BOX_COLOR = new Scalar(0, 255, 0); + private static final Scalar RIGHT_EYE_COLOR = new Scalar(255, 0, 0); + private static final Scalar LEFT_EYE_COLOR = new Scalar(0, 0, 255); + private static final Scalar NOSE_TIP_COLOR = new Scalar(0, 255, 0); + private static final Scalar MOUTH_RIGHT_COLOR = new Scalar(255, 0, 255); + private static final Scalar MOUTH_LEFT_COLOR = new Scalar(0, 255, 255); + + private Mat mRgba; + private Mat mBgr; + private Mat mBgrScaled; + private Size mInputSize = null; + private float mScale = 2.f; + private MatOfByte mModelBuffer; + private MatOfByte mConfigBuffer; + private FaceDetectorYN mFaceDetector; + private Mat mFaces; + + private CameraBridgeViewBase mOpenCvCameraView; + + public FaceDetectActivity() { + Log.i(TAG, "Instantiated new " + this.getClass()); + } + + /** Called when the activity is first created. */ + @Override + public void onCreate(Bundle savedInstanceState) { + Log.i(TAG, "called onCreate"); + super.onCreate(savedInstanceState); + + if (OpenCVLoader.initLocal()) { + Log.i(TAG, "OpenCV loaded successfully"); + } else { + Log.e(TAG, "OpenCV initialization failed!"); + (Toast.makeText(this, "OpenCV initialization failed!", Toast.LENGTH_LONG)).show(); + return; + } + + byte[] buffer; + try { + // load cascade file from application resources + InputStream is = getResources().openRawResource(R.raw.face_detection_yunet_2023mar); + + int size = is.available(); + buffer = new byte[size]; + int bytesRead = is.read(buffer); + is.close(); + } catch (IOException e) { + e.printStackTrace(); + Log.e(TAG, "Failed to ONNX model from resources! Exception thrown: " + e); + (Toast.makeText(this, "Failed to ONNX model from resources!", Toast.LENGTH_LONG)).show(); + return; + } + + mModelBuffer = new MatOfByte(buffer); + mConfigBuffer = new MatOfByte(); + + mFaceDetector = FaceDetectorYN.create("onnx", mModelBuffer, mConfigBuffer, new Size(320, 320)); + if (mFaceDetector == null) { + Log.e(TAG, "Failed to create FaceDetectorYN!"); + (Toast.makeText(this, "Failed to create FaceDetectorYN!", Toast.LENGTH_LONG)).show(); + return; + } else + Log.i(TAG, "FaceDetectorYN initialized successfully!"); + + + getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); + + setContentView(R.layout.face_detect_surface_view); + + mOpenCvCameraView = (CameraBridgeViewBase) findViewById(R.id.fd_activity_surface_view); + mOpenCvCameraView.setVisibility(CameraBridgeViewBase.VISIBLE); + mOpenCvCameraView.setCvCameraViewListener(this); + } + + @Override + public void onPause() + { + super.onPause(); + if (mOpenCvCameraView != null) + mOpenCvCameraView.disableView(); + } + + @Override + public void onResume() + { + super.onResume(); + if (mOpenCvCameraView != null) + mOpenCvCameraView.enableView(); + } + + @Override + protected List getCameraViewList() { + return Collections.singletonList(mOpenCvCameraView); + } + + public void onDestroy() { + super.onDestroy(); + mOpenCvCameraView.disableView(); + } + + public void onCameraViewStarted(int width, int height) { + mRgba = new Mat(); + mBgr = new Mat(); + mBgrScaled = new Mat(); + mFaces = new Mat(); + } + + public void onCameraViewStopped() { + mRgba.release(); + mBgr.release(); + mBgrScaled.release(); + mFaces.release(); + } + + public void visualize(Mat rgba, Mat faces) { + + int thickness = 2; + float[] faceData = new float[faces.cols() * faces.channels()]; + + for (int i = 0; i < faces.rows(); i++) + { + faces.get(i, 0, faceData); + + Log.d(TAG, "Detected face (" + faceData[0] + ", " + faceData[1] + ", " + + faceData[2] + ", " + faceData[3] + ")"); + + // Draw bounding box + Imgproc.rectangle(rgba, new Rect(Math.round(mScale*faceData[0]), Math.round(mScale*faceData[1]), + Math.round(mScale*faceData[2]), Math.round(mScale*faceData[3])), + BOX_COLOR, thickness); + // Draw landmarks + Imgproc.circle(rgba, new Point(Math.round(mScale*faceData[4]), Math.round(mScale*faceData[5])), + 2, RIGHT_EYE_COLOR, thickness); + Imgproc.circle(rgba, new Point(Math.round(mScale*faceData[6]), Math.round(mScale*faceData[7])), + 2, LEFT_EYE_COLOR, thickness); + Imgproc.circle(rgba, new Point(Math.round(mScale*faceData[8]), Math.round(mScale*faceData[9])), + 2, NOSE_TIP_COLOR, thickness); + Imgproc.circle(rgba, new Point(Math.round(mScale*faceData[10]), Math.round(mScale*faceData[11])), + 2, MOUTH_RIGHT_COLOR, thickness); + Imgproc.circle(rgba, new Point(Math.round(mScale*faceData[12]), Math.round(mScale*faceData[13])), + 2, MOUTH_LEFT_COLOR, thickness); + } + } + + public Mat onCameraFrame(CvCameraViewFrame inputFrame) { + + mRgba = inputFrame.rgba(); + + if (mInputSize == null) { + mInputSize = new Size(Math.round(mRgba.cols()/mScale), Math.round(mRgba.rows()/mScale)); + mFaceDetector.setInputSize(mInputSize); + } + + Imgproc.cvtColor(mRgba, mBgr, Imgproc.COLOR_RGBA2BGR); + Imgproc.resize(mBgr, mBgrScaled, mInputSize); + + if (mFaceDetector != null) { + int status = mFaceDetector.detect(mBgrScaled, mFaces); + Log.d(TAG, "Detector returned status " + status); + visualize(mRgba, mFaces); + } + + return mRgba; + } +} diff --git a/samples/android/face-detection/src/org/opencv/samples/facedetect/FdActivity.java b/samples/android/face-detection/src/org/opencv/samples/facedetect/FdActivity.java deleted file mode 100644 index 2c7327fad1..0000000000 --- a/samples/android/face-detection/src/org/opencv/samples/facedetect/FdActivity.java +++ /dev/null @@ -1,244 +0,0 @@ -package org.opencv.samples.facedetect; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.Collections; -import java.util.List; - -import org.opencv.android.CameraActivity; -import org.opencv.android.CameraBridgeViewBase.CvCameraViewFrame; -import org.opencv.android.OpenCVLoader; -import org.opencv.core.Core; -import org.opencv.core.Mat; -import org.opencv.core.MatOfRect; -import org.opencv.core.Rect; -import org.opencv.core.Scalar; -import org.opencv.core.Size; -import org.opencv.android.CameraBridgeViewBase; -import org.opencv.android.CameraBridgeViewBase.CvCameraViewListener2; -import org.opencv.objdetect.CascadeClassifier; -import org.opencv.imgproc.Imgproc; - -import android.app.Activity; -import android.content.Context; -import android.os.Bundle; -import android.util.Log; -import android.view.Menu; -import android.view.MenuItem; -import android.view.WindowManager; -import android.widget.Toast; - -public class FdActivity extends CameraActivity implements CvCameraViewListener2 { - - private static final String TAG = "OCVSample::Activity"; - private static final Scalar FACE_RECT_COLOR = new Scalar(0, 255, 0, 255); - public static final int JAVA_DETECTOR = 0; - public static final int NATIVE_DETECTOR = 1; - - private MenuItem mItemFace50; - private MenuItem mItemFace40; - private MenuItem mItemFace30; - private MenuItem mItemFace20; - private MenuItem mItemType; - - private Mat mRgba; - private Mat mGray; - private File mCascadeFile; - private CascadeClassifier mJavaDetector; - private DetectionBasedTracker mNativeDetector; - - private int mDetectorType = JAVA_DETECTOR; - private String[] mDetectorName; - - private float mRelativeFaceSize = 0.2f; - private int mAbsoluteFaceSize = 0; - - private CameraBridgeViewBase mOpenCvCameraView; - - public FdActivity() { - mDetectorName = new String[2]; - mDetectorName[JAVA_DETECTOR] = "Java"; - mDetectorName[NATIVE_DETECTOR] = "Native (tracking)"; - - Log.i(TAG, "Instantiated new " + this.getClass()); - } - - /** Called when the activity is first created. */ - @Override - public void onCreate(Bundle savedInstanceState) { - Log.i(TAG, "called onCreate"); - super.onCreate(savedInstanceState); - - if (OpenCVLoader.initLocal()) { - Log.i(TAG, "OpenCV loaded successfully"); - } else { - Log.e(TAG, "OpenCV initialization failed!"); - (Toast.makeText(this, "OpenCV initialization failed!", Toast.LENGTH_LONG)).show(); - return; - } - - // Load native library after(!) OpenCV initialization - System.loadLibrary("detection_based_tracker"); - - try { - // load cascade file from application resources - InputStream is = getResources().openRawResource(R.raw.lbpcascade_frontalface); - File cascadeDir = getDir("cascade", Context.MODE_PRIVATE); - mCascadeFile = new File(cascadeDir, "lbpcascade_frontalface.xml"); - FileOutputStream os = new FileOutputStream(mCascadeFile); - - byte[] buffer = new byte[4096]; - int bytesRead; - while ((bytesRead = is.read(buffer)) != -1) { - os.write(buffer, 0, bytesRead); - } - is.close(); - os.close(); - - mJavaDetector = new CascadeClassifier(mCascadeFile.getAbsolutePath()); - if (mJavaDetector.empty()) { - Log.e(TAG, "Failed to load cascade classifier"); - mJavaDetector = null; - } else - Log.i(TAG, "Loaded cascade classifier from " + mCascadeFile.getAbsolutePath()); - - mNativeDetector = new DetectionBasedTracker(mCascadeFile.getAbsolutePath(), 0); - - cascadeDir.delete(); - - } catch (IOException e) { - e.printStackTrace(); - Log.e(TAG, "Failed to load cascade. Exception thrown: " + e); - } - - getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); - - setContentView(R.layout.face_detect_surface_view); - - mOpenCvCameraView = (CameraBridgeViewBase) findViewById(R.id.fd_activity_surface_view); - mOpenCvCameraView.setVisibility(CameraBridgeViewBase.VISIBLE); - mOpenCvCameraView.setCvCameraViewListener(this); - } - - @Override - public void onPause() - { - super.onPause(); - if (mOpenCvCameraView != null) - mOpenCvCameraView.disableView(); - } - - @Override - public void onResume() - { - super.onResume(); - if (mOpenCvCameraView != null) - mOpenCvCameraView.enableView(); - } - - @Override - protected List getCameraViewList() { - return Collections.singletonList(mOpenCvCameraView); - } - - public void onDestroy() { - super.onDestroy(); - mOpenCvCameraView.disableView(); - } - - public void onCameraViewStarted(int width, int height) { - mGray = new Mat(); - mRgba = new Mat(); - } - - public void onCameraViewStopped() { - mGray.release(); - mRgba.release(); - } - - public Mat onCameraFrame(CvCameraViewFrame inputFrame) { - - mRgba = inputFrame.rgba(); - mGray = inputFrame.gray(); - - if (mAbsoluteFaceSize == 0) { - int height = mGray.rows(); - if (Math.round(height * mRelativeFaceSize) > 0) { - mAbsoluteFaceSize = Math.round(height * mRelativeFaceSize); - } - mNativeDetector.setMinFaceSize(mAbsoluteFaceSize); - } - - MatOfRect faces = new MatOfRect(); - - if (mDetectorType == JAVA_DETECTOR) { - if (mJavaDetector != null) - mJavaDetector.detectMultiScale(mGray, faces, 1.1, 2, 2, // TODO: objdetect.CV_HAAR_SCALE_IMAGE - new Size(mAbsoluteFaceSize, mAbsoluteFaceSize), new Size()); - } - else if (mDetectorType == NATIVE_DETECTOR) { - if (mNativeDetector != null) - mNativeDetector.detect(mGray, faces); - } - else { - Log.e(TAG, "Detection method is not selected!"); - } - - Rect[] facesArray = faces.toArray(); - for (int i = 0; i < facesArray.length; i++) - Imgproc.rectangle(mRgba, facesArray[i].tl(), facesArray[i].br(), FACE_RECT_COLOR, 3); - - return mRgba; - } - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - Log.i(TAG, "called onCreateOptionsMenu"); - mItemFace50 = menu.add("Face size 50%"); - mItemFace40 = menu.add("Face size 40%"); - mItemFace30 = menu.add("Face size 30%"); - mItemFace20 = menu.add("Face size 20%"); - mItemType = menu.add(mDetectorName[mDetectorType]); - return true; - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - Log.i(TAG, "called onOptionsItemSelected; selected item: " + item); - if (item == mItemFace50) - setMinFaceSize(0.5f); - else if (item == mItemFace40) - setMinFaceSize(0.4f); - else if (item == mItemFace30) - setMinFaceSize(0.3f); - else if (item == mItemFace20) - setMinFaceSize(0.2f); - else if (item == mItemType) { - int tmpDetectorType = (mDetectorType + 1) % mDetectorName.length; - item.setTitle(mDetectorName[tmpDetectorType]); - setDetectorType(tmpDetectorType); - } - return true; - } - - private void setMinFaceSize(float faceSize) { - mRelativeFaceSize = faceSize; - mAbsoluteFaceSize = 0; - } - - private void setDetectorType(int type) { - if (mDetectorType != type) { - mDetectorType = type; - - if (type == NATIVE_DETECTOR) { - Log.i(TAG, "Detection Based Tracker enabled"); - mNativeDetector.start(); - } else { - Log.i(TAG, "Cascade detector enabled"); - mNativeDetector.stop(); - } - } - } -}