├── .idea ├── .name └── workspace.xml ├── CMakeLists.txt ├── FaceAntiSpoofingX6 ├── CMakeLists.txt ├── JNIFaceAntiSpoofing.cpp ├── JNIFaceAntiSpoofing.h ├── java │ └── com │ │ └── seeta │ │ └── sdk │ │ ├── FaceAntiSpoofing.java │ │ ├── SeetaImageData.java │ │ ├── SeetaModelSetting.java │ │ ├── SeetaPointF.java │ │ └── SeetaRect.java └── jni_struct.hpp ├── FaceBoxes ├── CMakeLists.txt ├── JNIFaceDetector.cpp ├── JNIFaceDetector.h ├── java │ └── com │ │ └── seeta │ │ └── sdk │ │ ├── FaceDetector.java │ │ ├── SeetaDevice.java │ │ ├── SeetaImageData.java │ │ ├── SeetaModelSetting.java │ │ ├── SeetaRect.java │ │ └── SeetaSize.java └── jni_struct.hpp ├── FaceRecognizer6 ├── CMakeLists.txt ├── JNIFaceDatabase.cpp ├── JNIFaceDatabase.h ├── JNIFaceRecognizer.cpp ├── JNIFaceRecognizer.h ├── java │ └── com │ │ └── seeta │ │ └── sdk │ │ ├── FaceDatabase.java │ │ ├── FaceRecognizer.java │ │ ├── SeetaDevice.java │ │ ├── SeetaImageData.java │ │ ├── SeetaModelSetting.java │ │ └── SeetaPointF.java └── jni_struct.hpp ├── FaceTracker6 ├── CMakeLists.txt ├── JNIFaceTracker.cpp ├── JNIFaceTracker.h ├── java │ └── com │ │ └── seeta │ │ ├── FaceTracker.java │ │ ├── SeetaImageData.java │ │ └── SeetaTrackingFaceInfo.java └── jni_struct.hpp ├── Landmarker ├── CMakeLists.txt ├── JNIFaceLandmarker.cpp ├── JNIFaceLandmarker.h ├── java │ └── com │ │ └── seeta │ │ └── sdk │ │ ├── FaceLandmarker.java │ │ ├── SeetaDevice.java │ │ ├── SeetaImageData.java │ │ ├── SeetaModelSetting.java │ │ ├── SeetaPointF.java │ │ └── SeetaRect.java └── jni_struct.hpp ├── PoseEstimator6 ├── CMakeLists.txt ├── JNIPoseEstimator.cpp ├── JNIPoseEstimator.h ├── java │ └── com │ │ └── seeta │ │ └── sdk │ │ ├── PoseEstimator.java │ │ ├── SeetaImageData.java │ │ └── SeetaRect.java └── jni_struct.hpp ├── QualityAssessor3 ├── CMakeLists.txt ├── JNIQualityOfBrightness.cpp ├── JNIQualityOfBrightness.h ├── JNIQualityOfClarity.cpp ├── JNIQualityOfClarity.h ├── JNIQualityOfIntegrity.cpp ├── JNIQualityOfIntegrity.h ├── JNIQualityOfLBN.cpp ├── JNIQualityOfLBN.h ├── JNIQualityOfPose.cpp ├── JNIQualityOfPose.h ├── JNIQualityOfPoseEx.cpp ├── JNIQualityOfPoseEx.h ├── JNIQualityOfResolution.cpp ├── JNIQualityOfResolution.h ├── java │ └── com │ │ └── seeta │ │ └── sdk │ │ ├── QualityOfBirghtness.java │ │ ├── QualityOfClarity.java │ │ ├── QualityOfIntegrity.java │ │ ├── QualityOfLBN.java │ │ ├── QualityOfPose.java │ │ ├── QualityOfPoseEx.java │ │ ├── QualityOfResolution.java │ │ ├── SeetaDevice.java │ │ ├── SeetaImageData.java │ │ ├── SeetaModelSetting.java │ │ ├── SeetaPointF.java │ │ └── SeetaRect.java └── jni_struct.hpp ├── README.md ├── SeetaAgePredictor ├── CMakeLists.txt ├── JNIAgePredictor.cpp ├── JNIAgePredictor.h ├── java │ └── com │ │ └── seeta │ │ └── sdk │ │ ├── AgePredictor.java │ │ ├── SeetaDevice.java │ │ ├── SeetaImageData.java │ │ ├── SeetaModelSetting.java │ │ └── SeetaPointF.java └── jni_struct.hpp ├── SeetaEyeStateDetector ├── CMakeLists.txt ├── JNIEyeStateDetector.cpp ├── JNIEyeStateDetector.h ├── java │ └── com │ │ └── seeta │ │ └── sdk │ │ ├── EyeStateDetector.java │ │ ├── SeetaDevice.java │ │ ├── SeetaImageData.java │ │ ├── SeetaModelSetting.java │ │ └── SeetaPointF.java └── jni_struct.hpp ├── SeetaGenderPredictor ├── CMakeLists.txt ├── JNIGenderPredictor.cpp ├── JNIGenderPredictor.h ├── java │ └── com │ │ └── seeta │ │ └── sdk │ │ ├── GenderPredictor.java │ │ ├── SeetaDevice.java │ │ ├── SeetaImageData.java │ │ ├── SeetaModelSetting.java │ │ └── SeetaPointF.java └── jni_struct.hpp ├── SeetaMaskDetector ├── CMakeLists.txt ├── JNIMaskDetector.cpp ├── JNIMaskDetector.h ├── java │ └── com │ │ └── seeta │ │ └── sdk │ │ ├── MaskDetector.java │ │ ├── SeetaDevice.java │ │ ├── SeetaImageData.java │ │ ├── SeetaModelSetting.java │ │ └── SeetaRect.java └── jni_struct.hpp ├── include ├── SeetaLANLock.h ├── api │ ├── common.h │ ├── cpp │ │ ├── device.h │ │ ├── dtype.h │ │ ├── except.h │ │ ├── graphics2d.h │ │ ├── image_filter.h │ │ ├── intime.h │ │ ├── module.h │ │ ├── operator.h │ │ ├── operator_gpu.h │ │ ├── program.h │ │ ├── stream.h │ │ ├── tennis.h │ │ ├── tensor.h │ │ ├── tensorstack.h │ │ └── workbench.h │ ├── device.h │ ├── image_filter.h │ ├── intime.h │ ├── module.h │ ├── operator.h │ ├── operator_gpu.h │ ├── program.h │ ├── setup.h │ ├── stream.h │ ├── tennis.h │ ├── tensor.h │ ├── tensorstack.h │ └── workbench.h ├── hidden │ ├── SeetaLockFunction.h │ └── SeetaLockVerifyLAN.h ├── lock │ ├── cstamodelfilestream.h │ ├── cstastream.h │ ├── error_code.h │ ├── fast_cstastream.h │ └── fast_encryptstream.h ├── orz │ ├── codec │ │ ├── base64.h │ │ └── json.h │ ├── io │ │ ├── csv.h │ │ ├── dir.h │ │ ├── i.h │ │ ├── jug │ │ │ ├── binary.h │ │ │ ├── jug.h │ │ │ └── piece.h │ │ ├── stream │ │ │ ├── bufferedstream.h │ │ │ ├── filestream.h │ │ │ ├── filterstream.h │ │ │ ├── memorystream.h │ │ │ ├── modelfilestream.h │ │ │ └── stream.h │ │ └── walker.h │ ├── lego │ │ ├── box.h │ │ └── brick.h │ ├── mem │ │ ├── need.h │ │ ├── pot.h │ │ └── vat.h │ ├── net │ │ └── http.h │ ├── ssl │ │ ├── aes.h │ │ └── rsa.h │ ├── sync │ │ ├── backend.h │ │ ├── canyon.h │ │ ├── cartridge.h │ │ └── shotgun.h │ ├── tools │ │ ├── cpp_resources.h │ │ ├── ctxmgr_lite.h │ │ ├── ctxmgr_lite_support.h │ │ ├── fps.h │ │ ├── function.h │ │ ├── gun_with.h │ │ ├── limit.h │ │ ├── multi.h │ │ ├── option.h │ │ ├── progress_bar.h │ │ ├── range.h │ │ ├── resources.h │ │ ├── timer.h │ │ └── void_bind.h │ └── utils │ │ ├── api.h │ │ ├── except.h │ │ ├── format.h │ │ ├── log.h │ │ ├── platform.h │ │ └── random.h └── seeta │ ├── AgePredictor.h │ ├── CFaceDetector.h │ ├── CFaceInfo.h │ ├── CStream.h │ ├── CStruct.h │ ├── CTrackingFaceInfo.h │ ├── Common │ ├── CStruct.h │ └── Struct.h │ ├── EyeStateDetector.h │ ├── FaceAntiSpoofing.h │ ├── FaceDatabase.h │ ├── FaceDetector.h │ ├── FaceLandmarker.h │ ├── FaceRecognizer.h │ ├── FaceTracker.h │ ├── GenderPredictor.h │ ├── MaskDetector.h │ ├── PoseEstimator.h │ ├── QualityAssessor.h │ ├── QualityOfBrightness.h │ ├── QualityOfClarity.h │ ├── QualityOfIntegrity.h │ ├── QualityOfLBN.h │ ├── QualityOfPose.h │ ├── QualityOfPoseEx.h │ ├── QualityOfResolution.h │ ├── QualityStructure.h │ ├── SeetaFaceDetectorConfig.h │ ├── SeetaFaceLandmarkerConfig.h │ ├── SeetaFaceRecognizerConfig.h │ ├── SeetaMaskDetectorConfig.h │ ├── SeetaMaskDetectorConfig.h.in │ ├── Stream.h │ └── Struct.h └── jniLibs ├── armeabi-v7a ├── libSeetaAuthorize.so ├── libSeetaFaceDetector600.so ├── libSeetaFaceLandmarker600.so ├── libSeetaFaceRecognizer600.so ├── libTenniS.so └── libopencv_java3.so └── centos ├── libSeetaAgePredictor600.so ├── libSeetaAuthorize.so ├── libSeetaEyeStateDetector200.so ├── libSeetaFaceAntiSpoofingX600.so ├── libSeetaFaceDetector600.so ├── libSeetaFaceLandmarker600.so ├── libSeetaFaceRecognizer610.so ├── libSeetaFaceTracking600.so ├── libSeetaGenderPredictor600.so ├── libSeetaPoseEstimation600.so ├── libSeetaQualityAssessor300.so ├── libtennis.so ├── libtennis_haswell.so ├── libtennis_pentium.so └── libtennis_sandy_bridge.so /.idea/.name: -------------------------------------------------------------------------------- 1 | Seetaface6JNI -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10.2) 2 | 3 | # Declares and names the project. 4 | 5 | project("Seetaface6JNI") 6 | set(DEVICE centos) 7 | add_subdirectory(FaceAntiSpoofingX6) 8 | add_subdirectory(FaceBoxes) 9 | add_subdirectory(FaceRecognizer6) 10 | add_subdirectory(FaceTracker6) 11 | add_subdirectory(Landmarker) 12 | add_subdirectory(PoseEstimator6) 13 | add_subdirectory(QualityAssessor3) 14 | add_subdirectory(SeetaAgePredictor) 15 | add_subdirectory(SeetaEyeStateDetector) 16 | add_subdirectory(SeetaGenderPredictor) 17 | add_subdirectory(SeetaMaskDetector) -------------------------------------------------------------------------------- /FaceAntiSpoofingX6/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10.2) 2 | 3 | # Declares and names the project. 4 | 5 | project("FaceAntiSpoofingX6_java") 6 | 7 | # Creates and names a library, sets it as either STATIC 8 | # or SHARED, and provides the relative paths to its source code. 9 | # You can define multiple libraries, and CMake builds them for you. 10 | # Gradle automatically packages shared libraries with your APK. 11 | set(CMAKE_CXX_STANDARD 14) 12 | include_directories(/usr/etc/jdk1.8.0_301/include) 13 | include_directories(/usr/etc/jdk1.8.0_301/include/linux) 14 | include_directories(../include) 15 | # 搜索代码源文件存放在 project_src 变量中 16 | AUX_SOURCE_DIRECTORY(../FaceAntiSpoofingX6 project_src) 17 | add_library( # Sets the name of the library. 18 | ${PROJECT_NAME} 19 | 20 | # Sets the library as a shared library. 21 | SHARED 22 | 23 | # Provides a relative path to your source file(s). 24 | ${project_src}) 25 | 26 | add_library(TenniS SHARED IMPORTED) 27 | set_target_properties(TenniS PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/../jniLibs/centos/libtennis.so) 28 | 29 | add_library(SeetaAuthorize SHARED IMPORTED) 30 | set_target_properties(SeetaAuthorize PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/../jniLibs/centos/libSeetaAuthorize.so) 31 | 32 | add_library(FaceAntiSpoofingX6 SHARED IMPORTED) 33 | set_target_properties(FaceAntiSpoofingX6 PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/../jniLibs/centos/libSeetaFaceAntiSpoofingX600.so) 34 | 35 | 36 | target_link_libraries( # Specifies the target library. 37 | ${PROJECT_NAME} 38 | TenniS 39 | SeetaAuthorize 40 | FaceAntiSpoofingX6 41 | ) -------------------------------------------------------------------------------- /FaceAntiSpoofingX6/java/com/seeta/sdk/FaceAntiSpoofing.java: -------------------------------------------------------------------------------- 1 | package com.seeta.sdk; 2 | 3 | public class FaceAntiSpoofing 4 | { 5 | static{ 6 | System.loadLibrary("FaceAntiSpoofing600_java"); 7 | } 8 | 9 | public enum Status{ 10 | REAL, 11 | SPOOF, 12 | FUZZY, 13 | DETECTING, 14 | }; 15 | public long impl = 0; 16 | 17 | private native void construct(SeetaModelSetting setting); 18 | private native void construct(String model, String device, int id); 19 | private native void construct(String model1, String model2, String device, int id); 20 | public native void dispose(); 21 | 22 | public FaceAntiSpoofing(SeetaModelSetting setting) {this.construct(setting);} 23 | 24 | public FaceAntiSpoofing(String model, String device, int id) {this.construct(model, device, id);} 25 | 26 | public FaceAntiSpoofing(String model1, String model2, String device, int id) {this.construct(model1, model2, device, id);} 27 | protected void finalize() throws Throwable{ 28 | super.finalize(); 29 | this.dispose(); 30 | } 31 | 32 | private native int PredictCore(SeetaImageData image, SeetaRect face, SeetaPointF[] landmarks); 33 | private native int PredictVideoCore(SeetaImageData image, SeetaRect face, SeetaPointF[] landmarks); 34 | public Status Predict(SeetaImageData image, SeetaRect face, SeetaPointF[] landmarks) 35 | { 36 | int status_num = this.PredictCore(image, face, landmarks); 37 | return Status.values()[status_num]; 38 | } 39 | 40 | public Status PredictVideo(SeetaImageData image, SeetaRect face, SeetaPointF[] landmarks) 41 | { 42 | int status_num = this.PredictVideoCore(image, face, landmarks); 43 | return Status.values()[status_num]; 44 | } 45 | 46 | public native void ResetVideo(); 47 | public native void GetPreFrameScore(float[] clarity, float[] reality); 48 | public native void SetVideoFrameCount(int number); 49 | public native int GetVideoFrameCount(); 50 | public native void SetThreshold(float clarity, float reality); 51 | public native void GetThreshold(float[] clarity, float[] reality); 52 | } -------------------------------------------------------------------------------- /FaceAntiSpoofingX6/java/com/seeta/sdk/SeetaImageData.java: -------------------------------------------------------------------------------- 1 | package com.seeta.sdk; 2 | 3 | public class SeetaImageData { 4 | public SeetaImageData(int width, int height, int channels) { 5 | this.data = new byte[width * height * channels]; 6 | this.width = width; 7 | this.height = height; 8 | this.channels = channels; 9 | } 10 | 11 | public SeetaImageData(int width, int height) { 12 | this(width, height, 1); 13 | } 14 | 15 | public byte[] data; 16 | public int width; 17 | public int height; 18 | public int channels; 19 | } -------------------------------------------------------------------------------- /FaceAntiSpoofingX6/java/com/seeta/sdk/SeetaModelSetting.java: -------------------------------------------------------------------------------- 1 | package com.seeta.sdk; 2 | 3 | import com.seeta.sdk.SeetaDevice; 4 | 5 | public class SeetaModelSetting { 6 | 7 | public SeetaDevice device; 8 | public int id; // when device is GPU, id means GPU id 9 | public String [] model; 10 | 11 | public SeetaModelSetting(int id, String[] models, SeetaDevice dev) { 12 | this.id = id; 13 | this.device = dev; 14 | this.model = new String[models.length]; 15 | for(int i=0; i 3 | /* Header for class com_seeta_sdk_FaceDetector */ 4 | 5 | #ifndef _Included_com_seeta_sdk_FaceDetector 6 | #define _Included_com_seeta_sdk_FaceDetector 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | /* 11 | * Class: com_seeta_sdk_FaceDetector 12 | * Method: construct 13 | * Signature: (Lcom/seeta/sdk/SeetaModelSetting;)V 14 | */ 15 | JNIEXPORT void JNICALL Java_com_seeta_sdk_FaceDetector_construct__Lcom_seeta_sdk_SeetaModelSetting_2 16 | (JNIEnv *, jobject, jobject); 17 | 18 | /* 19 | * Class: com_seeta_sdk_FaceDetector 20 | * Method: construct 21 | * Signature: (Ljava/lang/String;Ljava/lang/String;I)V 22 | */ 23 | JNIEXPORT void JNICALL Java_com_seeta_sdk_FaceDetector_construct__Ljava_lang_String_2Ljava_lang_String_2I 24 | (JNIEnv *, jobject, jstring, jstring, jint); 25 | 26 | /* 27 | * Class: com_seeta_sdk_FaceDetector 28 | * Method: dispose 29 | * Signature: ()V 30 | */ 31 | JNIEXPORT void JNICALL Java_com_seeta_sdk_FaceDetector_dispose 32 | (JNIEnv *, jobject); 33 | 34 | /* 35 | * Class: com_seeta_sdk_FaceDetector 36 | * Method: Detect 37 | * Signature: (Lcom/seeta/sdk/SeetaImageData;)[Lcom/seeta/sdk/SeetaRect; 38 | */ 39 | JNIEXPORT jobjectArray JNICALL Java_com_seeta_sdk_FaceDetector_Detect 40 | (JNIEnv *, jobject, jobject); 41 | 42 | /* 43 | * Class: com_seeta_sdk_FaceDetector 44 | * Method: set 45 | * Signature: (Lcom/seeta/sdk/FaceDetector/Property;D)V 46 | */ 47 | JNIEXPORT void JNICALL Java_com_seeta_sdk_FaceDetector_set 48 | (JNIEnv *, jobject, jobject, jdouble); 49 | 50 | /* 51 | * Class: com_seeta_sdk_FaceDetector 52 | * Method: get 53 | * Signature: (Lcom/seeta/sdk/FaceDetector/Property;)D 54 | */ 55 | JNIEXPORT jdouble JNICALL Java_com_seeta_sdk_FaceDetector_get 56 | (JNIEnv *, jobject, jobject); 57 | 58 | #ifdef __cplusplus 59 | } 60 | #endif 61 | #endif 62 | -------------------------------------------------------------------------------- /FaceBoxes/java/com/seeta/sdk/FaceDetector.java: -------------------------------------------------------------------------------- 1 | package com.seeta.sdk; 2 | 3 | import com.seeta.sdk.SeetaModelSetting; 4 | 5 | public class FaceDetector 6 | { 7 | static { 8 | System.loadLibrary("SeetaFaceDetector600_java"); 9 | } 10 | 11 | public enum Property { 12 | PROPERTY_MIN_FACE_SIZE(0), 13 | PROPERTY_THRESHOLD(1), 14 | PROPERTY_MAX_IMAGE_WIDTH(2), 15 | PROPERTY_MAX_IMAGE_HEIGHT(3), 16 | PROPERTY_NUMBER_THREADS(4), 17 | PROPERTY_ARM_CPU_MODE(0x101); 18 | 19 | private int value; 20 | private Property(int value) { 21 | this.value = value; 22 | } 23 | 24 | public int getValue(){ 25 | return value; 26 | } 27 | } 28 | 29 | public long impl = 0; 30 | 31 | private native void construct(SeetaModelSetting setting) throws Exception; 32 | public FaceDetector(SeetaModelSetting setting) throws Exception { 33 | this.construct(setting); 34 | } 35 | 36 | public native void dispose(); 37 | protected void finalize()throws java.lang.Throwable{ 38 | super.finalize(); 39 | this.dispose(); 40 | } 41 | 42 | public native SeetaRect[] Detect(SeetaImageData image); 43 | 44 | public native void set(Property property, double value); 45 | public native double get(Property property); 46 | 47 | /* 48 | public native void SetComputingThreads(int num); 49 | public native int GetComputingThreads(); 50 | 51 | 52 | public native void SetMinFaceSize(int size); 53 | public native int GetMinFaceSize(); 54 | 55 | public native void SetThresh(float thresh); 56 | public native float GetThresh(); 57 | 58 | public native void SetMaxImageWidth(int width); 59 | public native int GetMaxImageWidth(); 60 | 61 | public native void SetMaxImageHeight(int height); 62 | public native int GetMaxImageHeight(); 63 | */ 64 | } 65 | -------------------------------------------------------------------------------- /FaceBoxes/java/com/seeta/sdk/SeetaDevice.java: -------------------------------------------------------------------------------- 1 | package com.seeta.sdk; 2 | 3 | public enum SeetaDevice 4 | { 5 | SEETA_DEVICE_AUTO(0), 6 | SEETA_DEVICE_CPU(1), 7 | SEETA_DEVICE_GPU(2); 8 | 9 | private int value; 10 | private SeetaDevice(int value) { 11 | this.value = value; 12 | } 13 | 14 | public int getValue(){ 15 | return value; 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /FaceBoxes/java/com/seeta/sdk/SeetaImageData.java: -------------------------------------------------------------------------------- 1 | package com.seeta.sdk; 2 | 3 | public class SeetaImageData { 4 | public SeetaImageData(int width, int height, int channels) { 5 | this.data = new byte[width * height * channels]; 6 | this.width = width; 7 | this.height = height; 8 | this.channels = channels; 9 | } 10 | 11 | public SeetaImageData(int width, int height) { 12 | this(width, height, 1); 13 | } 14 | 15 | public byte[] data; 16 | public int width; 17 | public int height; 18 | public int channels; 19 | } -------------------------------------------------------------------------------- /FaceBoxes/java/com/seeta/sdk/SeetaModelSetting.java: -------------------------------------------------------------------------------- 1 | package com.seeta.sdk; 2 | 3 | import com.seeta.sdk.SeetaDevice; 4 | 5 | public class SeetaModelSetting { 6 | 7 | public SeetaDevice device; 8 | public int id; // when device is GPU, id means GPU id 9 | public String [] model; 10 | 11 | public SeetaModelSetting(int id, String[] models, SeetaDevice dev) { 12 | this.id = id; 13 | this.device = dev; 14 | this.model = new String[models.length]; 15 | for(int i=0; i 3 | /* Header for class com_seeta_sdk_FaceTracker */ 4 | 5 | #ifndef _Included_com_seeta_sdk_FaceTracker 6 | #define _Included_com_seeta_sdk_FaceTracker 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | /* 11 | * Class: com_seeta_sdk_FaceTracker 12 | * Method: construct 13 | * Signature: (Ljava/lang/String;II)V 14 | */ 15 | JNIEXPORT void JNICALL Java_com_seeta_sdk_FaceTracker_construct__Ljava_lang_String_2II 16 | (JNIEnv *, jobject, jstring, jint, jint); 17 | 18 | /* 19 | * Class: com_seeta_sdk_FaceTracker 20 | * Method: construct 21 | * Signature: (Ljava/lang/String;Ljava/lang/String;III)V 22 | */ 23 | JNIEXPORT void JNICALL Java_com_seeta_sdk_FaceTracker_construct__Ljava_lang_String_2Ljava_lang_String_2III 24 | (JNIEnv *, jobject, jstring, jstring, jint, jint, jint); 25 | 26 | /* 27 | * Class: com_seeta_sdk_FaceTracker 28 | * Method: dispose 29 | * Signature: ()V 30 | */ 31 | JNIEXPORT void JNICALL Java_com_seeta_sdk_FaceTracker_dispose 32 | (JNIEnv *, jobject); 33 | 34 | /* 35 | * Class: com_seeta_sdk_FaceTracker 36 | * Method: SetSingleCalculationThreads 37 | * Signature: (I)V 38 | */ 39 | JNIEXPORT void JNICALL Java_com_seeta_sdk_FaceTracker_SetSingleCalculationThreads 40 | (JNIEnv *, jobject, jint); 41 | 42 | /* 43 | * Class: com_seeta_sdk_FaceTracker 44 | * Method: Track 45 | * Signature: (Lcom/seeta/sdk/SeetaImageData;)[Lcom/seeta/sdk/SeetaTrackingFaceInfo; 46 | */ 47 | JNIEXPORT jobjectArray JNICALL Java_com_seeta_sdk_FaceTracker_Track__Lcom_seeta_sdk_SeetaImageData_2 48 | (JNIEnv *, jobject, jobject); 49 | 50 | /* 51 | * Class: com_seeta_sdk_FaceTracker 52 | * Method: Track 53 | * Signature: (Lcom/seeta/sdk/SeetaImageData;I)[Lcom/seeta/sdk/SeetaTrackingFaceInfo; 54 | */ 55 | JNIEXPORT jobjectArray JNICALL Java_com_seeta_sdk_FaceTracker_Track__Lcom_seeta_sdk_SeetaImageData_2I 56 | (JNIEnv *, jobject, jobject, jint); 57 | 58 | /* 59 | * Class: com_seeta_sdk_FaceTracker 60 | * Method: SetMinFaceSize 61 | * Signature: (I)V 62 | */ 63 | JNIEXPORT void JNICALL Java_com_seeta_sdk_FaceTracker_SetMinFaceSize 64 | (JNIEnv *, jobject, jint); 65 | 66 | /* 67 | * Class: com_seeta_sdk_FaceTracker 68 | * Method: GetMinFaceSize 69 | * Signature: ()I 70 | */ 71 | JNIEXPORT jint JNICALL Java_com_seeta_sdk_FaceTracker_GetMinFaceSize 72 | (JNIEnv *, jobject); 73 | 74 | /* 75 | * Class: com_seeta_sdk_FaceTracker 76 | * Method: SetVideoStable 77 | * Signature: (Z)V 78 | */ 79 | JNIEXPORT void JNICALL Java_com_seeta_sdk_FaceTracker_SetVideoStable 80 | (JNIEnv *, jobject, jboolean); 81 | 82 | /* 83 | * Class: com_seeta_sdk_FaceTracker 84 | * Method: GetVideoStable 85 | * Signature: ()Z 86 | */ 87 | JNIEXPORT jboolean JNICALL Java_com_seeta_sdk_FaceTracker_GetVideoStable 88 | (JNIEnv *, jobject); 89 | 90 | #ifdef __cplusplus 91 | } 92 | #endif 93 | #endif 94 | -------------------------------------------------------------------------------- /FaceTracker6/java/com/seeta/FaceTracker.java: -------------------------------------------------------------------------------- 1 | package com.seeta.sdk; 2 | 3 | public class FaceTracker { 4 | static{ 5 | System.loadLibrary("FaceTracker600_java"); 6 | } 7 | 8 | public long impl = 0; 9 | private native void construct(String seetaModel, int videoWidth, int videoHeight); 10 | public FaceTracker(String seetaModel, int videoWidth, int videoHeight) { 11 | this.construct(seetaModel, videoWidth, videoHeight); 12 | } 13 | 14 | public native void dispose(); 15 | protected void finalize()throws Throwable{ 16 | super.finalize(); 17 | this.dispose(); 18 | } 19 | 20 | public native void SetSingleCalculationThreads(int num); 21 | 22 | public native SeetaTrackingFaceInfo[] Track(SeetaImageData image); 23 | public native SeetaTrackingFaceInfo[] Track(SeetaImageData image, int frame_no); 24 | 25 | public native void SetMinFaceSize(int size); 26 | public native int GetMinFaceSize(); 27 | 28 | public native void SetVideoStable(boolean stable); 29 | public native boolean GetVideoStable(); 30 | } 31 | -------------------------------------------------------------------------------- /FaceTracker6/java/com/seeta/SeetaImageData.java: -------------------------------------------------------------------------------- 1 | package com.seeta.sdk; 2 | 3 | public class SeetaImageData { 4 | public SeetaImageData(int width, int height, int channels) { 5 | this.data = new byte[width * height * channels]; 6 | this.width = width; 7 | this.height = height; 8 | this.channels = channels; 9 | } 10 | 11 | public SeetaImageData(int width, int height) { 12 | this(width, height, 1); 13 | } 14 | 15 | public byte[] data; 16 | public int width; 17 | public int height; 18 | public int channels; 19 | } -------------------------------------------------------------------------------- /FaceTracker6/java/com/seeta/SeetaTrackingFaceInfo.java: -------------------------------------------------------------------------------- 1 | package com.seeta.sdk; 2 | 3 | public class SeetaTrackingFaceInfo { 4 | public int x; 5 | public int y; 6 | public int width; 7 | public int height; 8 | public float score; 9 | public int frame_no; 10 | public int PID; 11 | } 12 | -------------------------------------------------------------------------------- /Landmarker/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10.2) 2 | 3 | # Declares and names the project. 4 | 5 | project("Landmarker_java") 6 | 7 | # Creates and names a library, sets it as either STATIC 8 | # or SHARED, and provides the relative paths to its source code. 9 | # You can define multiple libraries, and CMake builds them for you. 10 | # Gradle automatically packages shared libraries with your APK. 11 | set(CMAKE_CXX_STANDARD 14) 12 | include_directories(/usr/etc/jdk1.8.0_301/include) 13 | include_directories(/usr/etc/jdk1.8.0_301/include/linux) 14 | include_directories(../include) 15 | # 搜索代码源文件存放在 project_src 变量中 16 | AUX_SOURCE_DIRECTORY(../Landmarker project_src) 17 | add_library( # Sets the name of the library. 18 | ${PROJECT_NAME} 19 | 20 | # Sets the library as a shared library. 21 | SHARED 22 | 23 | # Provides a relative path to your source file(s). 24 | ${project_src}) 25 | 26 | add_library(TenniS SHARED IMPORTED) 27 | set_target_properties(TenniS PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/../jniLibs/centos/libtennis.so) 28 | 29 | add_library(SeetaAuthorize SHARED IMPORTED) 30 | set_target_properties(SeetaAuthorize PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/../jniLibs/centos/libSeetaAuthorize.so) 31 | 32 | add_library(Landmarker SHARED IMPORTED) 33 | set_target_properties(Landmarker PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/../jniLibs/centos/libSeetaFaceLandmarker600.so) 34 | 35 | 36 | target_link_libraries( # Specifies the target library. 37 | ${PROJECT_NAME} 38 | TenniS 39 | SeetaAuthorize 40 | Landmarker 41 | ) -------------------------------------------------------------------------------- /Landmarker/JNIFaceLandmarker.h: -------------------------------------------------------------------------------- 1 | /* DO NOT EDIT THIS FILE - it is machine generated */ 2 | #include 3 | /* Header for class com_seeta_sdk_FaceLandmarker */ 4 | 5 | #ifndef _Included_com_seeta_sdk_FaceLandmarker 6 | #define _Included_com_seeta_sdk_FaceLandmarker 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | /* 11 | * Class: com_seeta_sdk_FaceLandmarker 12 | * Method: construct 13 | * Signature: (Lcom/seeta/sdk/SeetaModelSetting;)V 14 | */ 15 | JNIEXPORT void JNICALL Java_com_seeta_sdk_FaceLandmarker_construct__Lcom_seeta_sdk_SeetaModelSetting_2 16 | (JNIEnv *, jobject, jobject); 17 | 18 | /* 19 | * Class: com_seeta_sdk_FaceLandmarker 20 | * Method: construct 21 | * Signature: (Ljava/lang/String;Ljava/lang/String;I)V 22 | */ 23 | JNIEXPORT void JNICALL Java_com_seeta_sdk_FaceLandmarker_construct__Ljava_lang_String_2Ljava_lang_String_2I 24 | (JNIEnv *, jobject, jstring, jstring, jint); 25 | 26 | /* 27 | * Class: com_seeta_sdk_FaceLandmarker 28 | * Method: dispose 29 | * Signature: ()V 30 | */ 31 | JNIEXPORT void JNICALL Java_com_seeta_sdk_FaceLandmarker_dispose 32 | (JNIEnv *, jobject); 33 | 34 | /* 35 | * Class: com_seeta_sdk_FaceLandmarker 36 | * Method: number 37 | * Signature: ()I 38 | */ 39 | JNIEXPORT jint JNICALL Java_com_seeta_sdk_FaceLandmarker_number 40 | (JNIEnv *, jobject); 41 | 42 | /* 43 | * Class: com_seeta_sdk_FaceLandmarker 44 | * Method: mark 45 | * Signature: (Lcom/seeta/sdk/SeetaImageData;Lcom/seeta/sdk/SeetaRect;[Lcom/seeta/sdk/SeetaPointF;)V 46 | */ 47 | JNIEXPORT void JNICALL Java_com_seeta_sdk_FaceLandmarker_mark__Lcom_seeta_sdk_SeetaImageData_2Lcom_seeta_sdk_SeetaRect_2_3Lcom_seeta_sdk_SeetaPointF_2 48 | (JNIEnv *, jobject, jobject, jobject, jobjectArray); 49 | 50 | /* 51 | * Class: com_seeta_sdk_FaceLandmarker 52 | * Method: mark 53 | * Signature: (Lcom/seeta/sdk/SeetaImageData;Lcom/seeta/sdk/SeetaRect;[Lcom/seeta/sdk/SeetaPointF;[I)V 54 | */ 55 | JNIEXPORT void JNICALL Java_com_seeta_sdk_FaceLandmarker_mark__Lcom_seeta_sdk_SeetaImageData_2Lcom_seeta_sdk_SeetaRect_2_3Lcom_seeta_sdk_SeetaPointF_2_3I 56 | (JNIEnv *, jobject, jobject, jobject, jobjectArray, jintArray); 57 | 58 | #ifdef __cplusplus 59 | } 60 | #endif 61 | #endif 62 | -------------------------------------------------------------------------------- /Landmarker/java/com/seeta/sdk/FaceLandmarker.java: -------------------------------------------------------------------------------- 1 | package com.seeta.sdk; 2 | 3 | public class FaceLandmarker { 4 | static{ 5 | System.loadLibrary("SeetaFaceLandmarker600_java"); 6 | } 7 | 8 | public long impl = 0; 9 | private native void construct(SeetaModelSetting seeting); 10 | private native void construct(String model, String device, int id); 11 | 12 | public FaceLandmarker(SeetaModelSetting setting){ 13 | this.construct(setting); 14 | } 15 | 16 | public FaceLandmarker(String model, String device, int id) 17 | { 18 | this.construct(model, device, id); 19 | } 20 | 21 | public native void dispose(); 22 | protected void finalize()throws Throwable{ 23 | super.finalize(); 24 | this.dispose(); 25 | } 26 | 27 | public native int number(); 28 | 29 | public native void mark(SeetaImageData imageData, SeetaRect seetaRect, SeetaPointF[] pointFS); 30 | 31 | public native void mark(SeetaImageData imageData, SeetaRect seetaRect, SeetaPointF[] pointFS, int[] masks); 32 | } 33 | -------------------------------------------------------------------------------- /Landmarker/java/com/seeta/sdk/SeetaDevice.java: -------------------------------------------------------------------------------- 1 | package com.seeta.sdk; 2 | 3 | public enum SeetaDevice 4 | { 5 | SEETA_DEVICE_AUTO(0), 6 | SEETA_DEVICE_CPU(1), 7 | SEETA_DEVICE_GPU(2); 8 | 9 | private int value; 10 | private SeetaDevice(int value) { 11 | this.value = value; 12 | } 13 | 14 | public int getValue(){ 15 | return value; 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /Landmarker/java/com/seeta/sdk/SeetaImageData.java: -------------------------------------------------------------------------------- 1 | package com.seeta.sdk; 2 | 3 | public class SeetaImageData { 4 | public SeetaImageData(int width, int height, int channels) { 5 | this.data = new byte[width * height * channels]; 6 | this.width = width; 7 | this.height = height; 8 | this.channels = channels; 9 | } 10 | 11 | public SeetaImageData(int width, int height) { 12 | this(width, height, 1); 13 | } 14 | 15 | public byte[] data; 16 | public int width; 17 | public int height; 18 | public int channels; 19 | } -------------------------------------------------------------------------------- /Landmarker/java/com/seeta/sdk/SeetaModelSetting.java: -------------------------------------------------------------------------------- 1 | package com.seeta.sdk; 2 | 3 | import com.seeta.sdk.SeetaDevice; 4 | 5 | public class SeetaModelSetting { 6 | 7 | public SeetaDevice device; 8 | public int id; // when device is GPU, id means GPU id 9 | public String [] model; 10 | 11 | public SeetaModelSetting(int id, String[] models, SeetaDevice dev) { 12 | this.id = id; 13 | this.device = dev; 14 | this.model = new String[models.length]; 15 | for(int i=0; i 3 | /* Header for class com_seeta_sdk_PoseEstimator */ 4 | 5 | #ifndef _Included_com_seeta_sdk_PoseEstimator 6 | #define _Included_com_seeta_sdk_PoseEstimator 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | /* 11 | * Class: com_seeta_sdk_PoseEstimator 12 | * Method: construct 13 | * Signature: (Ljava/lang/String;)V 14 | */ 15 | JNIEXPORT void JNICALL Java_com_seeta_sdk_PoseEstimator_construct__Ljava_lang_String_2 16 | (JNIEnv *, jobject, jstring); 17 | 18 | /* 19 | * Class: com_seeta_sdk_PoseEstimator 20 | * Method: construct 21 | * Signature: (Ljava/lang/String;Ljava/lang/String;I)V 22 | */ 23 | JNIEXPORT void JNICALL Java_com_seeta_sdk_PoseEstimator_construct__Ljava_lang_String_2Ljava_lang_String_2I 24 | (JNIEnv *, jobject, jstring, jstring, jint); 25 | 26 | /* 27 | * Class: com_seeta_sdk_PoseEstimator 28 | * Method: dispose 29 | * Signature: ()V 30 | */ 31 | JNIEXPORT void JNICALL Java_com_seeta_sdk_PoseEstimator_dispose 32 | (JNIEnv *, jobject); 33 | 34 | /* 35 | * Class: com_seeta_sdk_PoseEstimator 36 | * Method: Estimate 37 | * Signature: (Lcom/seeta/sdk/SeetaImageData;Lcom/seeta/sdk/SeetaRect;[F[F[F)V 38 | */ 39 | JNIEXPORT void JNICALL Java_com_seeta_sdk_PoseEstimator_Estimate 40 | (JNIEnv *, jobject, jobject, jobject, jfloatArray, jfloatArray, jfloatArray); 41 | 42 | #ifdef __cplusplus 43 | } 44 | #endif 45 | #endif 46 | -------------------------------------------------------------------------------- /PoseEstimator6/java/com/seeta/sdk/PoseEstimator.java: -------------------------------------------------------------------------------- 1 | package com.seeta.sdk; 2 | 3 | public class PoseEstimator { 4 | static{ 5 | System.loadLibrary("PoseEstimation600_java"); 6 | } 7 | 8 | public long impl = 0; 9 | private native void construct(String seetaModel); 10 | private native void construct(String model, String device, int id); 11 | 12 | public PoseEstimator(String seetaModel){ 13 | this.construct(seetaModel); 14 | } 15 | public PoseEstimator(String model, String device ,int id){this.construct(model, device, id);} 16 | 17 | public native void dispose(); 18 | protected void finalize()throws Throwable{ 19 | super.finalize(); 20 | this.dispose(); 21 | } 22 | 23 | public native void Estimate(SeetaImageData image, SeetaRect face, float[] yaw, float[] pitch, float[] roll); 24 | } 25 | -------------------------------------------------------------------------------- /PoseEstimator6/java/com/seeta/sdk/SeetaImageData.java: -------------------------------------------------------------------------------- 1 | package com.seeta.sdk; 2 | 3 | public class SeetaImageData { 4 | public SeetaImageData(int width, int height, int channels) { 5 | this.data = new byte[width * height * channels]; 6 | this.width = width; 7 | this.height = height; 8 | this.channels = channels; 9 | } 10 | 11 | public SeetaImageData(int width, int height) { 12 | this(width, height, 1); 13 | } 14 | 15 | public byte[] data; 16 | public int width; 17 | public int height; 18 | public int channels; 19 | } -------------------------------------------------------------------------------- /PoseEstimator6/java/com/seeta/sdk/SeetaRect.java: -------------------------------------------------------------------------------- 1 | package com.seeta.sdk; 2 | 3 | public class SeetaRect { 4 | public int x; 5 | public int y; 6 | public int width; 7 | public int height; 8 | } 9 | -------------------------------------------------------------------------------- /QualityAssessor3/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10.2) 2 | 3 | # Declares and names the project. 4 | 5 | project("QualityAssessor3_java") 6 | 7 | # Creates and names a library, sets it as either STATIC 8 | # or SHARED, and provides the relative paths to its source code. 9 | # You can define multiple libraries, and CMake builds them for you. 10 | # Gradle automatically packages shared libraries with your APK. 11 | set(CMAKE_CXX_STANDARD 14) 12 | include_directories(/usr/etc/jdk1.8.0_301/include) 13 | include_directories(/usr/etc/jdk1.8.0_301/include/linux) 14 | include_directories(../include) 15 | # 搜索代码源文件存放在 project_src 变量中 16 | AUX_SOURCE_DIRECTORY(../Landmarker project_src) 17 | add_library( # Sets the name of the library. 18 | ${PROJECT_NAME} 19 | 20 | # Sets the library as a shared library. 21 | SHARED 22 | 23 | # Provides a relative path to your source file(s). 24 | ${project_src}) 25 | 26 | add_library(TenniS SHARED IMPORTED) 27 | set_target_properties(TenniS PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/../jniLibs/centos/libtennis.so) 28 | 29 | add_library(SeetaAuthorize SHARED IMPORTED) 30 | set_target_properties(SeetaAuthorize PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/../jniLibs/centos/libSeetaAuthorize.so) 31 | 32 | add_library(QualityAssessor3 SHARED IMPORTED) 33 | set_target_properties(QualityAssessor3 PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/../jniLibs/centos/libSeetaQualityAssessor300.so) 34 | 35 | 36 | target_link_libraries( # Specifies the target library. 37 | ${PROJECT_NAME} 38 | TenniS 39 | SeetaAuthorize 40 | QualityAssessor3 41 | ) -------------------------------------------------------------------------------- /QualityAssessor3/JNIQualityOfBrightness.h: -------------------------------------------------------------------------------- 1 | /* DO NOT EDIT THIS FILE - it is machine generated */ 2 | #include 3 | /* Header for class com_seeta_sdk_QualityOfBrightness */ 4 | 5 | #ifndef _Included_com_seeta_sdk_QualityOfBrightness 6 | #define _Included_com_seeta_sdk_QualityOfBrightness 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | /* 11 | * Class: com_seeta_sdk_QualityOfBrightness 12 | * Method: construct 13 | * Signature: ()V 14 | */ 15 | JNIEXPORT void JNICALL Java_com_seeta_sdk_QualityOfBrightness_construct__ 16 | (JNIEnv *, jobject); 17 | 18 | /* 19 | * Class: com_seeta_sdk_QualityOfBrightness 20 | * Method: construct 21 | * Signature: (FFFF)V 22 | */ 23 | JNIEXPORT void JNICALL Java_com_seeta_sdk_QualityOfBrightness_construct__FFFF 24 | (JNIEnv *, jobject, jfloat, jfloat, jfloat, jfloat); 25 | 26 | /* 27 | * Class: com_seeta_sdk_QualityOfBrightness 28 | * Method: dispose 29 | * Signature: ()V 30 | */ 31 | JNIEXPORT void JNICALL Java_com_seeta_sdk_QualityOfBrightness_dispose 32 | (JNIEnv *, jobject); 33 | 34 | /* 35 | * Class: com_seeta_sdk_QualityOfBrightness 36 | * Method: checkCore 37 | * Signature: (Lcom/seeta/sdk/SeetaImageData;Lcom/seeta/sdk/SeetaRect;[Lcom/seeta/sdk/SeetaPointF;[F)I 38 | */ 39 | JNIEXPORT jint JNICALL Java_com_seeta_sdk_QualityOfBrightness_checkCore 40 | (JNIEnv *, jobject, jobject, jobject, jobjectArray, jfloatArray); 41 | 42 | #ifdef __cplusplus 43 | } 44 | #endif 45 | #endif 46 | -------------------------------------------------------------------------------- /QualityAssessor3/JNIQualityOfClarity.h: -------------------------------------------------------------------------------- 1 | /* DO NOT EDIT THIS FILE - it is machine generated */ 2 | #include 3 | /* Header for class com_seeta_sdk_QualityOfClarity */ 4 | 5 | #ifndef _Included_com_seeta_sdk_QualityOfClarity 6 | #define _Included_com_seeta_sdk_QualityOfClarity 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | /* 11 | * Class: com_seeta_sdk_QualityOfClarity 12 | * Method: construct 13 | * Signature: ()V 14 | */ 15 | JNIEXPORT void JNICALL Java_com_seeta_sdk_QualityOfClarity_construct__ 16 | (JNIEnv *, jobject); 17 | 18 | /* 19 | * Class: com_seeta_sdk_QualityOfClarity 20 | * Method: construct 21 | * Signature: (FF)V 22 | */ 23 | JNIEXPORT void JNICALL Java_com_seeta_sdk_QualityOfClarity_construct__FF 24 | (JNIEnv *, jobject, jfloat, jfloat); 25 | 26 | /* 27 | * Class: com_seeta_sdk_QualityOfClarity 28 | * Method: dispose 29 | * Signature: ()V 30 | */ 31 | JNIEXPORT void JNICALL Java_com_seeta_sdk_QualityOfClarity_dispose 32 | (JNIEnv *, jobject); 33 | 34 | /* 35 | * Class: com_seeta_sdk_QualityOfClarity 36 | * Method: checkCore 37 | * Signature: (Lcom/seeta/sdk/SeetaImageData;Lcom/seeta/sdk/SeetaRect;[Lcom/seeta/sdk/SeetaPointF;[F)I 38 | */ 39 | JNIEXPORT jint JNICALL Java_com_seeta_sdk_QualityOfClarity_checkCore 40 | (JNIEnv *, jobject, jobject, jobject, jobjectArray, jfloatArray); 41 | 42 | #ifdef __cplusplus 43 | } 44 | #endif 45 | #endif 46 | -------------------------------------------------------------------------------- /QualityAssessor3/JNIQualityOfIntegrity.h: -------------------------------------------------------------------------------- 1 | /* DO NOT EDIT THIS FILE - it is machine generated */ 2 | #include 3 | /* Header for class com_seeta_sdk_QualityOfIntegrity */ 4 | 5 | #ifndef _Included_com_seeta_sdk_QualityOfIntegrity 6 | #define _Included_com_seeta_sdk_QualityOfIntegrity 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | /* 11 | * Class: com_seeta_sdk_QualityOfIntegrity 12 | * Method: construct 13 | * Signature: ()V 14 | */ 15 | JNIEXPORT void JNICALL Java_com_seeta_sdk_QualityOfIntegrity_construct__ 16 | (JNIEnv *, jobject); 17 | 18 | /* 19 | * Class: com_seeta_sdk_QualityOfIntegrity 20 | * Method: construct 21 | * Signature: (FF)V 22 | */ 23 | JNIEXPORT void JNICALL Java_com_seeta_sdk_QualityOfIntegrity_construct__FF 24 | (JNIEnv *, jobject, jfloat, jfloat); 25 | 26 | /* 27 | * Class: com_seeta_sdk_QualityOfIntegrity 28 | * Method: dispose 29 | * Signature: ()V 30 | */ 31 | JNIEXPORT void JNICALL Java_com_seeta_sdk_QualityOfIntegrity_dispose 32 | (JNIEnv *, jobject); 33 | 34 | /* 35 | * Class: com_seeta_sdk_QualityOfIntegrity 36 | * Method: checkCore 37 | * Signature: (Lcom/seeta/sdk/SeetaImageData;Lcom/seeta/sdk/SeetaRect;[Lcom/seeta/sdk/SeetaPointF;[F)I 38 | */ 39 | JNIEXPORT jint JNICALL Java_com_seeta_sdk_QualityOfIntegrity_checkCore 40 | (JNIEnv *, jobject, jobject, jobject, jobjectArray, jfloatArray); 41 | 42 | #ifdef __cplusplus 43 | } 44 | #endif 45 | #endif 46 | -------------------------------------------------------------------------------- /QualityAssessor3/JNIQualityOfLBN.h: -------------------------------------------------------------------------------- 1 | /* DO NOT EDIT THIS FILE - it is machine generated */ 2 | #include 3 | /* Header for class com_seeta_sdk_QualityOfLBN */ 4 | 5 | #ifndef _Included_com_seeta_sdk_QualityOfLBN 6 | #define _Included_com_seeta_sdk_QualityOfLBN 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | /* 11 | * Class: com_seeta_sdk_QualityOfLBN 12 | * Method: construct 13 | * Signature: (Lcom/seeta/sdk/SeetaModelSetting;)V 14 | */ 15 | JNIEXPORT void JNICALL Java_com_seeta_sdk_QualityOfLBN_construct__Lcom_seeta_sdk_SeetaModelSetting_2 16 | (JNIEnv *, jobject, jobject); 17 | 18 | /* 19 | * Class: com_seeta_sdk_QualityOfLBN 20 | * Method: construct 21 | * Signature: (Ljava/lang/String;Ljava/lang/String;I)V 22 | */ 23 | JNIEXPORT void JNICALL Java_com_seeta_sdk_QualityOfLBN_construct__Ljava_lang_String_2Ljava_lang_String_2I 24 | (JNIEnv *, jobject, jstring, jstring, jint); 25 | 26 | /* 27 | * Class: com_seeta_sdk_QualityOfLBN 28 | * Method: dispose 29 | * Signature: ()V 30 | */ 31 | JNIEXPORT void JNICALL Java_com_seeta_sdk_QualityOfLBN_dispose 32 | (JNIEnv *, jobject); 33 | 34 | /* 35 | * Class: com_seeta_sdk_QualityOfLBN 36 | * Method: Detect 37 | * Signature: (Lcom/seeta/sdk/SeetaImageData;[Lcom/seeta/sdk/SeetaPointF;[I[I[I)V 38 | */ 39 | JNIEXPORT void JNICALL Java_com_seeta_sdk_QualityOfLBN_Detect 40 | (JNIEnv *, jobject, jobject, jobjectArray, jintArray, jintArray, jintArray); 41 | 42 | /* 43 | * Class: com_seeta_sdk_QualityOfLBN 44 | * Method: set 45 | * Signature: (Lcom/seeta/sdk/QualityOfLBN/Property;D)V 46 | */ 47 | JNIEXPORT void JNICALL Java_com_seeta_sdk_QualityOfLBN_set 48 | (JNIEnv *, jobject, jobject, jdouble); 49 | 50 | /* 51 | * Class: com_seeta_sdk_QualityOfLBN 52 | * Method: get 53 | * Signature: (Lcom/seeta/sdk/QualityOfLBN/Property;)D 54 | */ 55 | JNIEXPORT jdouble JNICALL Java_com_seeta_sdk_QualityOfLBN_get 56 | (JNIEnv *, jobject, jobject); 57 | 58 | #ifdef __cplusplus 59 | } 60 | #endif 61 | #endif 62 | -------------------------------------------------------------------------------- /QualityAssessor3/JNIQualityOfPose.cpp: -------------------------------------------------------------------------------- 1 | #include "JNIQualityOfPose.h" 2 | #include "seeta/QualityOfPose.h" 3 | 4 | #include "jni_struct.hpp" 5 | 6 | #include "orz/mem/need.h" 7 | 8 | 9 | #include 10 | 11 | using NativeClass = seeta::QualityOfPose; 12 | 13 | template 14 | static void delete_array(T * ptr) { 15 | delete [] ptr; 16 | } 17 | 18 | template 19 | static void delete_obj(T * ptr) { 20 | delete ptr; 21 | } 22 | 23 | JNIEXPORT void JNICALL Java_com_seeta_sdk_QualityOfPose_construct 24 | (JNIEnv *env, jobject self) 25 | { 26 | jclass self_class = env->GetObjectClass(self); 27 | jfieldID self_filed_impl = env->GetFieldID(self_class, "impl", "J"); 28 | 29 | NativeClass *native_impl = nullptr; 30 | try 31 | { 32 | native_impl = new NativeClass(); 33 | } 34 | catch (const std::exception &e) 35 | { 36 | jni_throw(env, e.what()); 37 | return; 38 | } 39 | 40 | jlong self_impl = reinterpret_cast(native_impl); 41 | 42 | env->SetLongField(self, self_filed_impl, self_impl); 43 | } 44 | 45 | JNIEXPORT void JNICALL Java_com_seeta_sdk_QualityOfPose_dispose 46 | (JNIEnv *env, jobject self) 47 | { 48 | jclass self_class = env->GetObjectClass(self); 49 | jfieldID self_filed_impl = env->GetFieldID(self_class, "impl", "J"); 50 | 51 | jlong self_impl = env->GetLongField(self, self_filed_impl); 52 | 53 | if (!self_impl) return; 54 | 55 | auto native_impl = reinterpret_cast(self_impl); 56 | delete native_impl; 57 | 58 | env->SetLongField(self, self_filed_impl, 0); 59 | } 60 | 61 | JNIEXPORT jint JNICALL Java_com_seeta_sdk_QualityOfPose_checkCore 62 | (JNIEnv *env, jobject self, jobject image, jobject info, jobjectArray landmarks, jfloatArray score) 63 | { 64 | jclass self_class = env->GetObjectClass(self); 65 | jfieldID self_filed_impl = env->GetFieldID(self_class, "impl", "J"); 66 | 67 | jlong self_impl = env->GetLongField(self, self_filed_impl); 68 | 69 | if (!self_impl) return -1; 70 | 71 | auto native_impl = reinterpret_cast(self_impl); 72 | 73 | auto native_image = jni_convert_image_data(env, image); 74 | auto native_info = jni_convert_face_info(env, info); 75 | std::vector native_points = jni_convert_landmarks(env, landmarks); 76 | 77 | seeta::QualityResult result = native_impl->check(native_image, native_info, 78 | native_points.data(), native_points.size()); 79 | 80 | env->SetFloatArrayRegion(score, 0, 1, &result.score); 81 | 82 | delete[] native_image.data; 83 | 84 | return (jint)result.level; 85 | } -------------------------------------------------------------------------------- /QualityAssessor3/JNIQualityOfPose.h: -------------------------------------------------------------------------------- 1 | /* DO NOT EDIT THIS FILE - it is machine generated */ 2 | #include 3 | /* Header for class com_seeta_sdk_QualityOfPose */ 4 | 5 | #ifndef _Included_com_seeta_sdk_QualityOfPose 6 | #define _Included_com_seeta_sdk_QualityOfPose 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | /* 11 | * Class: com_seeta_sdk_QualityOfPose 12 | * Method: construct 13 | * Signature: ()V 14 | */ 15 | JNIEXPORT void JNICALL Java_com_seeta_sdk_QualityOfPose_construct 16 | (JNIEnv *, jobject); 17 | 18 | /* 19 | * Class: com_seeta_sdk_QualityOfPose 20 | * Method: dispose 21 | * Signature: ()V 22 | */ 23 | JNIEXPORT void JNICALL Java_com_seeta_sdk_QualityOfPose_dispose 24 | (JNIEnv *, jobject); 25 | 26 | /* 27 | * Class: com_seeta_sdk_QualityOfPose 28 | * Method: checkCore 29 | * Signature: (Lcom/seeta/sdk/SeetaImageData;Lcom/seeta/sdk/SeetaRect;[Lcom/seeta/sdk/SeetaPointF;[F)I 30 | */ 31 | JNIEXPORT jint JNICALL Java_com_seeta_sdk_QualityOfPose_checkCore 32 | (JNIEnv *, jobject, jobject, jobject, jobjectArray, jfloatArray); 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | #endif 38 | -------------------------------------------------------------------------------- /QualityAssessor3/JNIQualityOfPoseEx.h: -------------------------------------------------------------------------------- 1 | /* DO NOT EDIT THIS FILE - it is machine generated */ 2 | #include 3 | /* Header for class com_seeta_sdk_QualityOfPoseEx */ 4 | 5 | #ifndef _Included_com_seeta_sdk_QualityOfPoseEx 6 | #define _Included_com_seeta_sdk_QualityOfPoseEx 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | /* 11 | * Class: com_seeta_sdk_QualityOfPoseEx 12 | * Method: construct 13 | * Signature: (Lcom/seeta/sdk/SeetaModelSetting;)V 14 | */ 15 | JNIEXPORT void JNICALL Java_com_seeta_sdk_QualityOfPoseEx_construct__Lcom_seeta_sdk_SeetaModelSetting_2 16 | (JNIEnv *, jobject, jobject); 17 | 18 | /* 19 | * Class: com_seeta_sdk_QualityOfPoseEx 20 | * Method: construct 21 | * Signature: (Ljava/lang/String;Ljava/lang/String;I)V 22 | */ 23 | JNIEXPORT void JNICALL Java_com_seeta_sdk_QualityOfPoseEx_construct__Ljava_lang_String_2Ljava_lang_String_2I 24 | (JNIEnv *, jobject, jstring, jstring, jint); 25 | 26 | /* 27 | * Class: com_seeta_sdk_QualityOfPoseEx 28 | * Method: dispose 29 | * Signature: ()V 30 | */ 31 | JNIEXPORT void JNICALL Java_com_seeta_sdk_QualityOfPoseEx_dispose 32 | (JNIEnv *, jobject); 33 | 34 | /* 35 | * Class: com_seeta_sdk_QualityOfPoseEx 36 | * Method: checkCore 37 | * Signature: (Lcom/seeta/sdk/SeetaImageData;Lcom/seeta/sdk/SeetaRect;[Lcom/seeta/sdk/SeetaPointF;[F)I 38 | */ 39 | JNIEXPORT jint JNICALL Java_com_seeta_sdk_QualityOfPoseEx_checkCore__Lcom_seeta_sdk_SeetaImageData_2Lcom_seeta_sdk_SeetaRect_2_3Lcom_seeta_sdk_SeetaPointF_2_3F 40 | (JNIEnv *, jobject, jobject, jobject, jobjectArray, jfloatArray); 41 | 42 | /* 43 | * Class: com_seeta_sdk_QualityOfPoseEx 44 | * Method: checkCore 45 | * Signature: (Lcom/seeta/sdk/SeetaImageData;Lcom/seeta/sdk/SeetaRect;[Lcom/seeta/sdk/SeetaPointF;[F[F[F)V 46 | */ 47 | JNIEXPORT void JNICALL Java_com_seeta_sdk_QualityOfPoseEx_checkCore__Lcom_seeta_sdk_SeetaImageData_2Lcom_seeta_sdk_SeetaRect_2_3Lcom_seeta_sdk_SeetaPointF_2_3F_3F_3F 48 | (JNIEnv *, jobject, jobject, jobject, jobjectArray, jfloatArray, jfloatArray, jfloatArray); 49 | 50 | /* 51 | * Class: com_seeta_sdk_QualityOfPoseEx 52 | * Method: set 53 | * Signature: (Lcom/seeta/sdk/QualityOfPoseEx/Property;D)V 54 | */ 55 | JNIEXPORT void JNICALL Java_com_seeta_sdk_QualityOfPoseEx_set 56 | (JNIEnv *, jobject, jobject, jdouble); 57 | 58 | /* 59 | * Class: com_seeta_sdk_QualityOfPoseEx 60 | * Method: get 61 | * Signature: (Lcom/seeta/sdk/QualityOfPoseEx/Property;)D 62 | */ 63 | JNIEXPORT jdouble JNICALL Java_com_seeta_sdk_QualityOfPoseEx_get 64 | (JNIEnv *, jobject, jobject); 65 | 66 | #ifdef __cplusplus 67 | } 68 | #endif 69 | #endif 70 | -------------------------------------------------------------------------------- /QualityAssessor3/JNIQualityOfResolution.h: -------------------------------------------------------------------------------- 1 | /* DO NOT EDIT THIS FILE - it is machine generated */ 2 | #include 3 | /* Header for class com_seeta_sdk_QualityOfResolution */ 4 | 5 | #ifndef _Included_com_seeta_sdk_QualityOfResolution 6 | #define _Included_com_seeta_sdk_QualityOfResolution 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | /* 11 | * Class: com_seeta_sdk_QualityOfResolution 12 | * Method: construct 13 | * Signature: ()V 14 | */ 15 | JNIEXPORT void JNICALL Java_com_seeta_sdk_QualityOfResolution_construct__ 16 | (JNIEnv *, jobject); 17 | 18 | /* 19 | * Class: com_seeta_sdk_QualityOfResolution 20 | * Method: construct 21 | * Signature: (FF)V 22 | */ 23 | JNIEXPORT void JNICALL Java_com_seeta_sdk_QualityOfResolution_construct__FF 24 | (JNIEnv *, jobject, jfloat, jfloat); 25 | 26 | /* 27 | * Class: com_seeta_sdk_QualityOfResolution 28 | * Method: dispose 29 | * Signature: ()V 30 | */ 31 | JNIEXPORT void JNICALL Java_com_seeta_sdk_QualityOfResolution_dispose 32 | (JNIEnv *, jobject); 33 | 34 | /* 35 | * Class: com_seeta_sdk_QualityOfResolution 36 | * Method: checkCore 37 | * Signature: (Lcom/seeta/sdk/SeetaImageData;Lcom/seeta/sdk/SeetaRect;[Lcom/seeta/sdk/SeetaPointF;[F)I 38 | */ 39 | JNIEXPORT jint JNICALL Java_com_seeta_sdk_QualityOfResolution_checkCore 40 | (JNIEnv *, jobject, jobject, jobject, jobjectArray, jfloatArray); 41 | 42 | #ifdef __cplusplus 43 | } 44 | #endif 45 | #endif 46 | -------------------------------------------------------------------------------- /QualityAssessor3/java/com/seeta/sdk/QualityOfBirghtness.java: -------------------------------------------------------------------------------- 1 | package com.seeta.sdk; 2 | 3 | public class QualityOfBirghtness { 4 | static { 5 | System.loadLibrary("QualityAssessor300_java"); 6 | } 7 | 8 | public enum QualityLevel 9 | { 10 | LOW ,//Quality level is low 11 | MEDIUM,//Quality level is medium 12 | HIGH,//Quality level is high 13 | } 14 | 15 | public long impl = 0; 16 | 17 | private native void construct(); 18 | public QualityOfBirghtness(){ 19 | this.construct(); 20 | } 21 | 22 | /** 23 | * 24 | * @param v0 [input] param 0 25 | * @param v1 [input] param 1 26 | * @param v2 [input] param2 27 | * @param v3 [input] param 3 28 | * [0, v0) and [v3, ~) => LOW 29 | * [v0, v1) and [v2, v3) => MEDIUM 30 | * [v1, v2) => HIGH 31 | */ 32 | private native void construct(float v0, float v1, float v2, float v3); 33 | public QualityOfBirghtness(float v0, float v1, float v2, float v3) 34 | { 35 | this.construct(v0, v1, v2,v3); 36 | } 37 | 38 | public native void dispose(); 39 | protected void finalize()throws Throwable{ 40 | super.finalize(); 41 | this.dispose(); 42 | } 43 | 44 | /** 45 | * 46 | * @param imageData [input]image data 47 | * @param face [input] face location 48 | * @param landmarks [input] face landmarks 49 | * @param score [output] quality score 50 | * @return QualityLevel quality level sorted into "LOW" , "Medium" , "HIGH" 51 | */ 52 | private native int checkCore(SeetaImageData imageData, SeetaRect face, SeetaPointF[] landmarks, float[] score); 53 | public QualityLevel check(SeetaImageData imageData, SeetaRect face, SeetaPointF[] landmarks, float[] score){ 54 | int index = this.checkCore(imageData, face, landmarks, score); 55 | 56 | QualityLevel level = QualityLevel.values()[index]; 57 | return level; 58 | } 59 | } 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /QualityAssessor3/java/com/seeta/sdk/QualityOfClarity.java: -------------------------------------------------------------------------------- 1 | package com.seeta.sdk; 2 | 3 | public class QualityOfClarity { 4 | static { 5 | System.loadLibrary("QualityAssessor300_java"); 6 | } 7 | 8 | public enum QualityLevel 9 | { 10 | LOW ,//Quality level is low 11 | MEDIUM,//Quality level is medium 12 | HIGH,//Quality level is high 13 | } 14 | 15 | public long impl = 0; 16 | 17 | private native void construct(); 18 | public QualityOfClarity(){ 19 | this.construct(); 20 | } 21 | 22 | /** 23 | *@param low [input] threshold low 24 | *@param high [input] threshold high 25 | *[0, low)=> LOW 26 | *[low, high)=> MEDIUM 27 | *[high, ~)=> HIGH 28 | */ 29 | private native void construct(float low, float high); 30 | public QualityOfClarity(float low, float high) 31 | { 32 | this.construct(low, high); 33 | } 34 | 35 | public native void dispose(); 36 | protected void finalize()throws Throwable{ 37 | super.finalize(); 38 | this.dispose(); 39 | } 40 | 41 | /** 42 | * 43 | * @param imageData [input]image data 44 | * @param face [input] face location 45 | * @param landmarks [input] face landmarks 46 | * @param score [output] quality score 47 | * @return QualityLevel quality level sorted into "LOW" , "Medium" , "HIGH" 48 | */ 49 | private native int checkCore(SeetaImageData imageData, SeetaRect face, SeetaPointF[] landmarks, float[] score); 50 | public QualityLevel check(SeetaImageData imageData, SeetaRect face, SeetaPointF[] landmarks, float[] score){ 51 | int index = this.checkCore(imageData, face, landmarks, score); 52 | 53 | QualityLevel level = QualityLevel.values()[index]; 54 | return level; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /QualityAssessor3/java/com/seeta/sdk/QualityOfIntegrity.java: -------------------------------------------------------------------------------- 1 | package com.seeta.sdk; 2 | 3 | public class QualityOfIntegrity { 4 | static { 5 | System.loadLibrary("QualityAssessor300_java"); 6 | } 7 | 8 | public enum QualityLevel 9 | { 10 | LOW ,//Quality level is low 11 | MEDIUM,//Quality level is medium 12 | HIGH,//Quality level is high 13 | } 14 | 15 | public long impl = 0; 16 | 17 | private native void construct(); 18 | public QualityOfIntegrity(){ 19 | this.construct(); 20 | } 21 | 22 | /** 23 | *@param low [input] threshold low 24 | *@param high [input] threshold high 25 | */ 26 | private native void construct(float low, float high); 27 | public QualityOfIntegrity(float low, float high) 28 | { 29 | this.construct(low, high); 30 | } 31 | 32 | public native void dispose(); 33 | protected void finalize()throws Throwable{ 34 | super.finalize(); 35 | this.dispose(); 36 | } 37 | 38 | /** 39 | * 40 | * @param imageData [input]image data 41 | * @param face [input] face location 42 | * @param landmarks [input] face landmarks 43 | * @param score [output] quality score 44 | * @return QualityLevel quality level sorted into "LOW" , "Medium" , "HIGH" 45 | */ 46 | private native int checkCore(SeetaImageData imageData, SeetaRect face, SeetaPointF[] landmarks, float[] score); 47 | public QualityLevel check(SeetaImageData imageData, SeetaRect face, SeetaPointF[] landmarks, float[] score){ 48 | int index = this.checkCore(imageData, face, landmarks, score); 49 | 50 | QualityLevel level = QualityLevel.values()[index]; 51 | return level; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /QualityAssessor3/java/com/seeta/sdk/QualityOfLBN.java: -------------------------------------------------------------------------------- 1 | package com.seeta.sdk; 2 | 3 | public class QualityOfLBN { 4 | static { 5 | System.loadLibrary("QualityAssessor300_java"); 6 | } 7 | 8 | public enum LIGHTSTATE 9 | { 10 | BRIGHT, 11 | DARK 12 | } 13 | 14 | public enum BLURSTATE 15 | { 16 | CLEAR, 17 | BLUR 18 | } 19 | 20 | public enum NOISESTATE 21 | { 22 | HAVENOISE, 23 | NONOISE 24 | } 25 | 26 | public enum Property { 27 | PROPERTY_NUMBER_THREADS(4), 28 | PROPERTY_ARM_CPU_MODE(5), 29 | PROPERTY_LIGHT_THRESH (10), 30 | PROPERTY_BLUR_THRESH (11), 31 | PROPERTY_NOISE_THRESH (12); 32 | 33 | private int value; 34 | private Property(int value) { 35 | this.value = value; 36 | } 37 | 38 | public int getValue(){ 39 | return value; 40 | } 41 | } 42 | 43 | public long impl = 0; 44 | 45 | private native void construct(SeetaModelSetting setting) throws Exception; 46 | 47 | public QualityOfLBN(SeetaModelSetting setting) throws Exception { 48 | this.construct(setting); 49 | } 50 | 51 | public native void dispose(); 52 | protected void finalize()throws Throwable{ 53 | super.finalize(); 54 | this.dispose(); 55 | } 56 | 57 | /** 58 | * 59 | * @param imageData [input] image data 60 | * @param points [input] face points 61 | * @param light [output] 0 means light is good, 1 is not [not recommend] 62 | * @param blur [output] o means face is clear, 1 means face is blur 63 | * @param noise [output] 0 means having noise ,1 not [not recommend] 64 | */ 65 | public native void Detect(SeetaImageData imageData, SeetaPointF[] points, int[] light, int[] blur, int[] noise); 66 | 67 | public native void set(Property property, double value); 68 | public native double get(Property property); 69 | } 70 | -------------------------------------------------------------------------------- /QualityAssessor3/java/com/seeta/sdk/QualityOfPose.java: -------------------------------------------------------------------------------- 1 | package com.seeta.sdk; 2 | 3 | public class QualityOfPose { 4 | static { 5 | System.loadLibrary("QualityAssessor300_java"); 6 | } 7 | 8 | public enum QualityLevel 9 | { 10 | LOW ,//Quality level is low 11 | MEDIUM,//Quality level is medium 12 | HIGH,//Quality level is high 13 | } 14 | 15 | public long impl = 0; 16 | 17 | private native void construct(); 18 | public QualityOfPose(){ 19 | this.construct(); 20 | } 21 | 22 | public native void dispose(); 23 | protected void finalize()throws Throwable{ 24 | super.finalize(); 25 | this.dispose(); 26 | } 27 | 28 | /** 29 | * 30 | * @param imageData [input]image data 31 | * @param face [input] face location 32 | * @param landmarks [input] face landmarks 33 | * @param score [output] quality score 34 | * @return QualityLevel quality level sorted into "LOW" , "Medium" , "HIGH" 35 | */ 36 | private native int checkCore(SeetaImageData imageData, SeetaRect face, SeetaPointF[] landmarks, float[] score); 37 | public QualityLevel check(SeetaImageData imageData, SeetaRect face, SeetaPointF[] landmarks, float[] score){ 38 | int index = this.checkCore(imageData, face, landmarks, score); 39 | 40 | QualityLevel level = QualityLevel.values()[index]; 41 | return level; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /QualityAssessor3/java/com/seeta/sdk/QualityOfPoseEx.java: -------------------------------------------------------------------------------- 1 | package com.seeta.sdk; 2 | 3 | public class QualityOfPoseEx { 4 | static { 5 | System.loadLibrary("QualityAssessor300_java"); 6 | } 7 | 8 | public enum QualityLevel 9 | { 10 | LOW ,//Quality level is low 11 | MEDIUM,//Quality level is medium 12 | HIGH,//Quality level is high 13 | } 14 | 15 | public enum Property { 16 | YAW_LOW_THRESHOLD(0), 17 | YAW_HIGH_THRESHOLD(1), 18 | PITCH_LOW_THRESHOLD (2), 19 | PITCH_HIGH_THRESHOLD (3), 20 | ROLL_LOW_THRESHOLD (4), 21 | ROLL_HIGH_THRESHOLD(5); 22 | 23 | private int value; 24 | private Property(int value) { 25 | this.value = value; 26 | } 27 | 28 | public int getValue(){ 29 | return value; 30 | } 31 | } 32 | 33 | public long impl = 0; 34 | 35 | private native void construct(SeetaModelSetting setting) throws Exception; 36 | 37 | public QualityOfPoseEx(SeetaModelSetting setting) throws Exception { 38 | this.construct(setting); 39 | } 40 | 41 | public native void dispose(); 42 | protected void finalize()throws Throwable{ 43 | super.finalize(); 44 | this.dispose(); 45 | } 46 | 47 | /** 48 | * 49 | * @param imageData [input]image data 50 | * @param face [input] face location 51 | * @param landmarks [input] face landmarks 52 | * @param score [output] quality score 53 | * @return QualityLevel quality level sorted into "LOW" , "Medium" , "HIGH" 54 | */ 55 | private native int checkCore(SeetaImageData imageData, SeetaRect face, SeetaPointF[] landmarks, float[] score); 56 | public QualityLevel check(SeetaImageData imageData, SeetaRect face, SeetaPointF[] landmarks, float[] score){ 57 | int index = this.checkCore(imageData, face, landmarks, score); 58 | 59 | QualityLevel level = QualityLevel.values()[index]; 60 | return level; 61 | } 62 | 63 | /** 64 | * 65 | * @param imageData [input]image data 66 | * @param face [input] face location 67 | * @param landmarks [input] face landmarks 68 | * @param yaw [output] face location in yaw 69 | * @param pitch [output] face location in pitch 70 | * @param roll [oputput] face location in roll 71 | * @return 72 | */ 73 | private native void checkCore(SeetaImageData imageData, SeetaRect face, SeetaPointF[] landmarks, float[] yaw, float[] pitch, float[] roll); 74 | public void check(SeetaImageData imageData, SeetaRect face, SeetaPointF[] landmarks, float[] yaw, float[] pitch, float[] roll){ 75 | this.checkCore(imageData, face, landmarks, yaw, pitch, roll); 76 | } 77 | 78 | public native void set(Property property, double value); 79 | public native double get(Property property); 80 | } 81 | -------------------------------------------------------------------------------- /QualityAssessor3/java/com/seeta/sdk/QualityOfResolution.java: -------------------------------------------------------------------------------- 1 | package com.seeta.sdk; 2 | 3 | public class QualityOfResolution { 4 | static { 5 | System.loadLibrary("QualityAssessor300_java"); 6 | } 7 | 8 | public enum QualityLevel 9 | { 10 | LOW ,//Quality level is low 11 | MEDIUM,//Quality level is medium 12 | HIGH,//Quality level is high 13 | } 14 | 15 | public long impl = 0; 16 | 17 | private native void construct(); 18 | public QualityOfResolution(){ 19 | this.construct(); 20 | } 21 | 22 | /** 23 | *@param low [input] threshold low 24 | *@param high [input] threshold high 25 | */ 26 | private native void construct(float low, float high); 27 | public QualityOfResolution(float low, float high) 28 | { 29 | this.construct(low, high); 30 | } 31 | 32 | public native void dispose(); 33 | protected void finalize()throws Throwable{ 34 | super.finalize(); 35 | this.dispose(); 36 | } 37 | 38 | /** 39 | * 40 | * @param imageData [input]image data 41 | * @param face [input] face location 42 | * @param landmarks [input] face landmarks 43 | * @param score [output] quality score 44 | * @return QualityLevel quality level sorted into "LOW" , "Medium" , "HIGH" 45 | */ 46 | private native int checkCore(SeetaImageData imageData, SeetaRect face, SeetaPointF[] landmarks, float[] score); 47 | public QualityLevel check(SeetaImageData imageData, SeetaRect face, SeetaPointF[] landmarks, float[] score){ 48 | int index = this.checkCore(imageData, face, landmarks, score); 49 | 50 | QualityLevel level = QualityLevel.values()[index]; 51 | return level; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /QualityAssessor3/java/com/seeta/sdk/SeetaDevice.java: -------------------------------------------------------------------------------- 1 | package com.seeta.sdk; 2 | 3 | public enum SeetaDevice 4 | { 5 | SEETA_DEVICE_AUTO(0), 6 | SEETA_DEVICE_CPU(1), 7 | SEETA_DEVICE_GPU(2); 8 | 9 | private int value; 10 | private SeetaDevice(int value) { 11 | this.value = value; 12 | } 13 | 14 | public int getValue(){ 15 | return value; 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /QualityAssessor3/java/com/seeta/sdk/SeetaImageData.java: -------------------------------------------------------------------------------- 1 | package com.seeta.sdk; 2 | 3 | public class SeetaImageData { 4 | public SeetaImageData(int width, int height, int channels) { 5 | this.data = new byte[width * height * channels]; 6 | this.width = width; 7 | this.height = height; 8 | this.channels = channels; 9 | } 10 | 11 | public SeetaImageData(int width, int height) { 12 | this(width, height, 1); 13 | } 14 | 15 | public byte[] data; 16 | public int width; 17 | public int height; 18 | public int channels; 19 | } -------------------------------------------------------------------------------- /QualityAssessor3/java/com/seeta/sdk/SeetaModelSetting.java: -------------------------------------------------------------------------------- 1 | package com.seeta.sdk; 2 | 3 | import com.seeta.sdk.SeetaDevice; 4 | 5 | public class SeetaModelSetting { 6 | 7 | public SeetaDevice device; 8 | public int id; // when device is GPU, id means GPU id 9 | public String [] model; 10 | 11 | public SeetaModelSetting(int id, String[] models, SeetaDevice dev) { 12 | this.id = id; 13 | this.device = dev; 14 | this.model = new String[models.length]; 15 | for(int i=0; i 7 | `` 记住: 优先编译出 OpenRoleZoo, SeetaAuthorize 和 TenniS,然后再进行其他 SDK 模块的编译 `` 8 | ## linux 平台编译说 9 | 以FaceAntiSpoofingX6为例: 10 | 11 | ```cd .FaceAntiSpoofingX6/craft``` 12 |
运行脚本(个人不太建议使用gpu,虽然gpu理论上效率高,但是还是有好多组建需要装,还有有好多的问题)
13 | ```sh build.linux.x64.sh``` 14 |
15 | 各个模块都编译完成之后会在build文件下产生我们所需要的so库文件把这些文件都放到```jniLibs```目录下 16 | 17 | # JNI库文件编译 18 | 以FaceAntiSpoofingX6为例:
19 | ```cd FaceAntiSpoofingX6``` 20 | 21 | ```cmake -D CMAKE_BUILD_TYPE=Debug``` 22 | 23 | ```make -j8``` 24 | 编译完成,逐个编译吧 -------------------------------------------------------------------------------- /SeetaAgePredictor/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10.2) 2 | 3 | # Declares and names the project. 4 | 5 | project("SeetaAgePredictor_java") 6 | 7 | # Creates and names a library, sets it as either STATIC 8 | # or SHARED, and provides the relative paths to its source code. 9 | # You can define multiple libraries, and CMake builds them for you. 10 | # Gradle automatically packages shared libraries with your APK. 11 | set(CMAKE_CXX_STANDARD 14) 12 | include_directories(/usr/etc/jdk1.8.0_301/include) 13 | include_directories(/usr/etc/jdk1.8.0_301/include/linux) 14 | include_directories(../include) 15 | # 搜索代码源文件存放在 project_src 变量中 16 | AUX_SOURCE_DIRECTORY(../Landmarker project_src) 17 | add_library( # Sets the name of the library. 18 | ${PROJECT_NAME} 19 | 20 | # Sets the library as a shared library. 21 | SHARED 22 | 23 | # Provides a relative path to your source file(s). 24 | ${project_src}) 25 | 26 | add_library(TenniS SHARED IMPORTED) 27 | set_target_properties(TenniS PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/../jniLibs/centos/libtennis.so) 28 | 29 | add_library(SeetaAuthorize SHARED IMPORTED) 30 | set_target_properties(SeetaAuthorize PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/../jniLibs/centos/libSeetaAuthorize.so) 31 | 32 | add_library(SeetaAgePredictor SHARED IMPORTED) 33 | set_target_properties(SeetaAgePredictor PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/../jniLibs/centos/libSeetaAgePredictor600.so) 34 | 35 | 36 | target_link_libraries( # Specifies the target library. 37 | ${PROJECT_NAME} 38 | TenniS 39 | SeetaAuthorize 40 | SeetaAgePredictor 41 | ) -------------------------------------------------------------------------------- /SeetaAgePredictor/JNIAgePredictor.h: -------------------------------------------------------------------------------- 1 | /* DO NOT EDIT THIS FILE - it is machine generated */ 2 | #include 3 | /* Header for class com_seeta_sdk_AgePredictor */ 4 | 5 | #ifndef _Included_com_seeta_sdk_AgePredictor 6 | #define _Included_com_seeta_sdk_AgePredictor 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | /* 11 | * Class: com_seeta_sdk_AgePredictor 12 | * Method: construct 13 | * Signature: (Lcom/seeta/sdk/SeetaModelSetting;)V 14 | */ 15 | JNIEXPORT void JNICALL Java_com_seeta_sdk_AgePredictor_construct 16 | (JNIEnv *, jobject, jobject); 17 | 18 | /* 19 | * Class: com_seeta_sdk_AgePredictor 20 | * Method: dispose 21 | * Signature: ()V 22 | */ 23 | JNIEXPORT void JNICALL Java_com_seeta_sdk_AgePredictor_dispose 24 | (JNIEnv *, jobject); 25 | 26 | /* 27 | * Class: com_seeta_sdk_AgePredictor 28 | * Method: GetCropFaceWidth 29 | * Signature: ()I 30 | */ 31 | JNIEXPORT jint JNICALL Java_com_seeta_sdk_AgePredictor_GetCropFaceWidth 32 | (JNIEnv *, jobject); 33 | 34 | /* 35 | * Class: com_seeta_sdk_AgePredictor 36 | * Method: GetCropFaceHeight 37 | * Signature: ()I 38 | */ 39 | JNIEXPORT jint JNICALL Java_com_seeta_sdk_AgePredictor_GetCropFaceHeight 40 | (JNIEnv *, jobject); 41 | 42 | /* 43 | * Class: com_seeta_sdk_AgePredictor 44 | * Method: GetCropFaceChannels 45 | * Signature: ()I 46 | */ 47 | JNIEXPORT jint JNICALL Java_com_seeta_sdk_AgePredictor_GetCropFaceChannels 48 | (JNIEnv *, jobject); 49 | 50 | /* 51 | * Class: com_seeta_sdk_AgePredictor 52 | * Method: CropFace 53 | * Signature: (Lcom/seeta/sdk/SeetaImageData;[Lcom/seeta/sdk/SeetaPointF;Lcom/seeta/sdk/SeetaImageData;)Z 54 | */ 55 | JNIEXPORT jboolean JNICALL Java_com_seeta_sdk_AgePredictor_CropFace 56 | (JNIEnv *, jobject, jobject, jobjectArray, jobject); 57 | 58 | /* 59 | * Class: com_seeta_sdk_AgePredictor 60 | * Method: PredictAge 61 | * Signature: (Lcom/seeta/sdk/SeetaImageData;[I)Z 62 | */ 63 | JNIEXPORT jboolean JNICALL Java_com_seeta_sdk_AgePredictor_PredictAge 64 | (JNIEnv *, jobject, jobject, jintArray); 65 | 66 | /* 67 | * Class: com_seeta_sdk_AgePredictor 68 | * Method: PredictAgeWithCrop 69 | * Signature: (Lcom/seeta/sdk/SeetaImageData;[Lcom/seeta/sdk/SeetaPointF;[I)Z 70 | */ 71 | JNIEXPORT jboolean JNICALL Java_com_seeta_sdk_AgePredictor_PredictAgeWithCrop 72 | (JNIEnv *, jobject, jobject, jobjectArray, jintArray); 73 | 74 | /* 75 | * Class: com_seeta_sdk_AgePredictor 76 | * Method: set 77 | * Signature: (Lcom/seeta/sdk/AgePredictor/Property;D)V 78 | */ 79 | JNIEXPORT void JNICALL Java_com_seeta_sdk_AgePredictor_set 80 | (JNIEnv *, jobject, jobject, jdouble); 81 | 82 | /* 83 | * Class: com_seeta_sdk_AgePredictor 84 | * Method: get 85 | * Signature: (Lcom/seeta/sdk/AgePredictor/Property;)D 86 | */ 87 | JNIEXPORT jdouble JNICALL Java_com_seeta_sdk_AgePredictor_get 88 | (JNIEnv *, jobject, jobject); 89 | 90 | #ifdef __cplusplus 91 | } 92 | #endif 93 | #endif 94 | -------------------------------------------------------------------------------- /SeetaAgePredictor/java/com/seeta/sdk/AgePredictor.java: -------------------------------------------------------------------------------- 1 | package com.seeta.sdk; 2 | 3 | public class AgePredictor { 4 | static{ 5 | System.loadLibrary("SeetaAgePredictor600_java"); 6 | } 7 | 8 | public enum Property { 9 | PROPERTY_NUMBER_THREADS(4), 10 | PROPERTY_ARM_CPU_MODE(5); 11 | 12 | private int value; 13 | private Property(int value) { 14 | this.value = value; 15 | } 16 | 17 | public int getValue(){ 18 | return value; 19 | } 20 | } 21 | 22 | public long impl = 0; 23 | 24 | private native void construct(SeetaModelSetting setting); 25 | 26 | public AgePredictor(SeetaModelSetting setting) { 27 | this.construct(setting); 28 | } 29 | 30 | public native void dispose(); 31 | protected void finalize()throws Throwable{ 32 | super.finalize(); 33 | this.dispose(); 34 | } 35 | 36 | public native int GetCropFaceWidth(); 37 | public native int GetCropFaceHeight(); 38 | public native int GetCropFaceChannels(); 39 | 40 | public native boolean CropFace(SeetaImageData image, SeetaPointF[] points, SeetaImageData face); 41 | 42 | public native boolean PredictAge(SeetaImageData face, int[] age); 43 | public native boolean PredictAgeWithCrop(SeetaImageData image, SeetaPointF[] points, int[] age); 44 | 45 | public native void set(Property property, double value); 46 | public native double get(Property property); 47 | } 48 | -------------------------------------------------------------------------------- /SeetaAgePredictor/java/com/seeta/sdk/SeetaDevice.java: -------------------------------------------------------------------------------- 1 | package com.seeta.sdk; 2 | 3 | public enum SeetaDevice 4 | { 5 | SEETA_DEVICE_AUTO(0), 6 | SEETA_DEVICE_CPU(1), 7 | SEETA_DEVICE_GPU(2); 8 | 9 | private int value; 10 | private SeetaDevice(int value) { 11 | this.value = value; 12 | } 13 | 14 | public int getValue(){ 15 | return value; 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /SeetaAgePredictor/java/com/seeta/sdk/SeetaImageData.java: -------------------------------------------------------------------------------- 1 | package com.seeta.sdk; 2 | 3 | public class SeetaImageData { 4 | public SeetaImageData(int width, int height, int channels) { 5 | this.data = new byte[width * height * channels]; 6 | this.width = width; 7 | this.height = height; 8 | this.channels = channels; 9 | } 10 | 11 | public SeetaImageData(int width, int height) { 12 | this(width, height, 1); 13 | } 14 | 15 | public byte[] data; 16 | public int width; 17 | public int height; 18 | public int channels; 19 | } -------------------------------------------------------------------------------- /SeetaAgePredictor/java/com/seeta/sdk/SeetaModelSetting.java: -------------------------------------------------------------------------------- 1 | package com.seeta.sdk; 2 | 3 | import com.seeta.sdk.SeetaDevice; 4 | 5 | public class SeetaModelSetting { 6 | 7 | public SeetaDevice device; 8 | public int id; // when device is GPU, id means GPU id 9 | public String [] model; 10 | 11 | public SeetaModelSetting(int id, String[] models, SeetaDevice dev) { 12 | this.id = id; 13 | this.device = dev; 14 | this.model = new String[models.length]; 15 | for(int i=0; i 3 | /* Header for class com_seeta_sdk_EyeStateDetector */ 4 | 5 | #ifndef _Included_com_seeta_sdk_EyeStateDetector 6 | #define _Included_com_seeta_sdk_EyeStateDetector 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | /* 11 | * Class: com_seeta_sdk_EyeStateDetector 12 | * Method: construct 13 | * Signature: (Lcom/seeta/sdk/SeetaModelSetting;)V 14 | */ 15 | JNIEXPORT void JNICALL Java_com_seeta_sdk_EyeStateDetector_construct 16 | (JNIEnv *, jobject, jobject); 17 | 18 | /* 19 | * Class: com_seeta_sdk_EyeStateDetector 20 | * Method: dispose 21 | * Signature: ()V 22 | */ 23 | JNIEXPORT void JNICALL Java_com_seeta_sdk_EyeStateDetector_dispose 24 | (JNIEnv *, jobject); 25 | 26 | /* 27 | * Class: com_seeta_sdk_EyeStateDetector 28 | * Method: DetectCore 29 | * Signature: (Lcom/seeta/sdk/SeetaImageData;[Lcom/seeta/sdk/SeetaPointF;[I)V 30 | */ 31 | JNIEXPORT void JNICALL Java_com_seeta_sdk_EyeStateDetector_DetectCore 32 | (JNIEnv *, jobject, jobject, jobjectArray, jintArray); 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | #endif 38 | -------------------------------------------------------------------------------- /SeetaEyeStateDetector/java/com/seeta/sdk/EyeStateDetector.java: -------------------------------------------------------------------------------- 1 | package com.seeta.sdk; 2 | 3 | public class EyeStateDetector { 4 | static{ 5 | System.loadLibrary("SeetaEyeStateDetector200_java"); 6 | } 7 | 8 | public long impl = 0; 9 | public enum EYE_STATE{ 10 | EYE_CLOSE, 11 | EYE_OPEN, 12 | EYE_RANDOM, 13 | EYE_UNKNOWN 14 | } 15 | 16 | private native void construct(SeetaModelSetting setting) throws Exception; 17 | public EyeStateDetector(SeetaModelSetting setting) throws Exception { 18 | this.construct(setting); 19 | } 20 | 21 | public native void dispose(); 22 | protected void finalize()throws Throwable{ 23 | super.finalize(); 24 | this.dispose(); 25 | } 26 | 27 | public void Detect(SeetaImageData imageData, SeetaPointF[] points, EYE_STATE[] eyeStatus) 28 | { 29 | if(eyeStatus.length < 2) return; 30 | 31 | int[] eyeStateIndexs = new int[2]; 32 | DetectCore(imageData, points, eyeStateIndexs); 33 | 34 | eyeStatus[0] = EYE_STATE.values()[eyeStateIndexs[0]]; 35 | eyeStatus[1] = EYE_STATE.values()[eyeStateIndexs[1]]; 36 | 37 | eyeStateIndexs = null; 38 | } 39 | 40 | private native void DetectCore(SeetaImageData imageData, SeetaPointF[] points, int[] eyeStateIndexs); 41 | } 42 | -------------------------------------------------------------------------------- /SeetaEyeStateDetector/java/com/seeta/sdk/SeetaDevice.java: -------------------------------------------------------------------------------- 1 | package com.seeta.sdk; 2 | 3 | public enum SeetaDevice 4 | { 5 | SEETA_DEVICE_AUTO(0), 6 | SEETA_DEVICE_CPU(1), 7 | SEETA_DEVICE_GPU(2); 8 | 9 | private int value; 10 | private SeetaDevice(int value) { 11 | this.value = value; 12 | } 13 | 14 | public int getValue(){ 15 | return value; 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /SeetaEyeStateDetector/java/com/seeta/sdk/SeetaImageData.java: -------------------------------------------------------------------------------- 1 | package com.seeta.sdk; 2 | 3 | public class SeetaImageData { 4 | public SeetaImageData(int width, int height, int channels) { 5 | this.data = new byte[width * height * channels]; 6 | this.width = width; 7 | this.height = height; 8 | this.channels = channels; 9 | } 10 | 11 | public SeetaImageData(int width, int height) { 12 | this(width, height, 1); 13 | } 14 | 15 | public byte[] data; 16 | public int width; 17 | public int height; 18 | public int channels; 19 | } -------------------------------------------------------------------------------- /SeetaEyeStateDetector/java/com/seeta/sdk/SeetaModelSetting.java: -------------------------------------------------------------------------------- 1 | package com.seeta.sdk; 2 | 3 | import com.seeta.sdk.SeetaDevice; 4 | 5 | public class SeetaModelSetting { 6 | 7 | public SeetaDevice device; 8 | public int id; // when device is GPU, id means GPU id 9 | public String [] model; 10 | 11 | public SeetaModelSetting(int id, String[] models, SeetaDevice dev) { 12 | this.id = id; 13 | this.device = dev; 14 | this.model = new String[models.length]; 15 | for(int i=0; i 3 | /* Header for class com_seeta_sdk_GenderPredictor */ 4 | 5 | #ifndef _Included_com_seeta_sdk_GenderPredictor 6 | #define _Included_com_seeta_sdk_GenderPredictor 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | /* 11 | * Class: com_seeta_sdk_GenderPredictor 12 | * Method: construct 13 | * Signature: (Lcom/seeta/sdk/SeetaModelSetting;)V 14 | */ 15 | JNIEXPORT void JNICALL Java_com_seeta_sdk_GenderPredictor_construct 16 | (JNIEnv *, jobject, jobject); 17 | 18 | /* 19 | * Class: com_seeta_sdk_GenderPredictor 20 | * Method: dispose 21 | * Signature: ()V 22 | */ 23 | JNIEXPORT void JNICALL Java_com_seeta_sdk_GenderPredictor_dispose 24 | (JNIEnv *, jobject); 25 | 26 | /* 27 | * Class: com_seeta_sdk_GenderPredictor 28 | * Method: GetCropFaceWidth 29 | * Signature: ()I 30 | */ 31 | JNIEXPORT jint JNICALL Java_com_seeta_sdk_GenderPredictor_GetCropFaceWidth 32 | (JNIEnv *, jobject); 33 | 34 | /* 35 | * Class: com_seeta_sdk_GenderPredictor 36 | * Method: GetCropFaceHeight 37 | * Signature: ()I 38 | */ 39 | JNIEXPORT jint JNICALL Java_com_seeta_sdk_GenderPredictor_GetCropFaceHeight 40 | (JNIEnv *, jobject); 41 | 42 | /* 43 | * Class: com_seeta_sdk_GenderPredictor 44 | * Method: GetCropFaceChannels 45 | * Signature: ()I 46 | */ 47 | JNIEXPORT jint JNICALL Java_com_seeta_sdk_GenderPredictor_GetCropFaceChannels 48 | (JNIEnv *, jobject); 49 | 50 | /* 51 | * Class: com_seeta_sdk_GenderPredictor 52 | * Method: CropFace 53 | * Signature: (Lcom/seeta/sdk/SeetaImageData;[Lcom/seeta/sdk/SeetaPointF;Lcom/seeta/sdk/SeetaImageData;)Z 54 | */ 55 | JNIEXPORT jboolean JNICALL Java_com_seeta_sdk_GenderPredictor_CropFace 56 | (JNIEnv *, jobject, jobject, jobjectArray, jobject); 57 | 58 | /* 59 | * Class: com_seeta_sdk_GenderPredictor 60 | * Method: PredictGenderCore 61 | * Signature: (Lcom/seeta/sdk/SeetaImageData;[I)Z 62 | */ 63 | JNIEXPORT jboolean JNICALL Java_com_seeta_sdk_GenderPredictor_PredictGenderCore 64 | (JNIEnv *, jobject, jobject, jintArray); 65 | 66 | /* 67 | * Class: com_seeta_sdk_GenderPredictor 68 | * Method: PredictGenderWithCropCore 69 | * Signature: (Lcom/seeta/sdk/SeetaImageData;[Lcom/seeta/sdk/SeetaPointF;[I)Z 70 | */ 71 | JNIEXPORT jboolean JNICALL Java_com_seeta_sdk_GenderPredictor_PredictGenderWithCropCore 72 | (JNIEnv *, jobject, jobject, jobjectArray, jintArray); 73 | 74 | /* 75 | * Class: com_seeta_sdk_GenderPredictor 76 | * Method: set 77 | * Signature: (Lcom/seeta/sdk/GenderPredictor/Property;D)V 78 | */ 79 | JNIEXPORT void JNICALL Java_com_seeta_sdk_GenderPredictor_set 80 | (JNIEnv *, jobject, jobject, jdouble); 81 | 82 | /* 83 | * Class: com_seeta_sdk_GenderPredictor 84 | * Method: get 85 | * Signature: (Lcom/seeta/sdk/GenderPredictor/Property;)D 86 | */ 87 | JNIEXPORT jdouble JNICALL Java_com_seeta_sdk_GenderPredictor_get 88 | (JNIEnv *, jobject, jobject); 89 | 90 | #ifdef __cplusplus 91 | } 92 | #endif 93 | #endif 94 | -------------------------------------------------------------------------------- /SeetaGenderPredictor/java/com/seeta/sdk/GenderPredictor.java: -------------------------------------------------------------------------------- 1 | package com.seeta.sdk; 2 | 3 | public class GenderPredictor { 4 | static{ 5 | System.loadLibrary("SeetaGenderPredictor600_java"); 6 | } 7 | 8 | public enum Property { 9 | PROPERTY_NUMBER_THREADS(4), 10 | PROPERTY_ARM_CPU_MODE(5); 11 | 12 | private int value; 13 | private Property(int value) { 14 | this.value = value; 15 | } 16 | 17 | public int getValue(){ 18 | return value; 19 | } 20 | } 21 | 22 | public enum GENDER 23 | { 24 | MALE, 25 | FEMALE 26 | } 27 | 28 | public long impl = 0; 29 | 30 | private native void construct(SeetaModelSetting setting); 31 | 32 | public GenderPredictor(SeetaModelSetting setting) { 33 | this.construct(setting); 34 | } 35 | 36 | 37 | public native void dispose(); 38 | protected void finalize()throws Throwable{ 39 | super.finalize(); 40 | this.dispose(); 41 | } 42 | 43 | public native int GetCropFaceWidth(); 44 | public native int GetCropFaceHeight(); 45 | public native int GetCropFaceChannels(); 46 | 47 | public native boolean CropFace(SeetaImageData image, SeetaPointF[] points, SeetaImageData face); 48 | 49 | private native boolean PredictGenderCore(SeetaImageData face, int[] gender_index); 50 | private native boolean PredictGenderWithCropCore(SeetaImageData image, SeetaPointF[] points, int[] gender_index); 51 | 52 | public boolean PredictGender(SeetaImageData face, GENDER[] gender) 53 | { 54 | int[] gender_index = new int[1]; 55 | boolean result = PredictGenderCore(face, gender_index); 56 | if(gender.length > 0) 57 | { 58 | gender[0] = GENDER.values()[gender_index[0]]; 59 | } 60 | 61 | return result; 62 | } 63 | 64 | public boolean PredictGenderWithCrop(SeetaImageData image, SeetaPointF[] points, GENDER[] gender) 65 | { 66 | int[] gender_index = new int[1]; 67 | boolean result = PredictGenderWithCropCore(image, points, gender_index); 68 | if(gender.length > 0) 69 | { 70 | gender[0] = GENDER.values()[gender_index[0]]; 71 | } 72 | 73 | return result; 74 | } 75 | 76 | public native void set(Property property, double value); 77 | public native double get(Property property); 78 | } 79 | -------------------------------------------------------------------------------- /SeetaGenderPredictor/java/com/seeta/sdk/SeetaDevice.java: -------------------------------------------------------------------------------- 1 | package com.seeta.sdk; 2 | 3 | public enum SeetaDevice 4 | { 5 | SEETA_DEVICE_AUTO(0), 6 | SEETA_DEVICE_CPU(1), 7 | SEETA_DEVICE_GPU(2); 8 | 9 | private int value; 10 | private SeetaDevice(int value) { 11 | this.value = value; 12 | } 13 | 14 | public int getValue(){ 15 | return value; 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /SeetaGenderPredictor/java/com/seeta/sdk/SeetaImageData.java: -------------------------------------------------------------------------------- 1 | package com.seeta.sdk; 2 | 3 | public class SeetaImageData { 4 | public SeetaImageData(int width, int height, int channels) { 5 | this.data = new byte[width * height * channels]; 6 | this.width = width; 7 | this.height = height; 8 | this.channels = channels; 9 | } 10 | 11 | public SeetaImageData(int width, int height) { 12 | this(width, height, 1); 13 | } 14 | 15 | public byte[] data; 16 | public int width; 17 | public int height; 18 | public int channels; 19 | } -------------------------------------------------------------------------------- /SeetaGenderPredictor/java/com/seeta/sdk/SeetaModelSetting.java: -------------------------------------------------------------------------------- 1 | package com.seeta.sdk; 2 | 3 | import com.seeta.sdk.SeetaDevice; 4 | 5 | public class SeetaModelSetting { 6 | 7 | public SeetaDevice device; 8 | public int id; // when device is GPU, id means GPU id 9 | public String [] model; 10 | 11 | public SeetaModelSetting(int id, String[] models, SeetaDevice dev) { 12 | this.id = id; 13 | this.device = dev; 14 | this.model = new String[models.length]; 15 | for(int i=0; i 3 | /* Header for class com_seeta_sdk_MaskDetector */ 4 | 5 | #ifndef _Included_com_seeta_sdk_MaskDetector 6 | #define _Included_com_seeta_sdk_MaskDetector 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | /* 11 | * Class: com_seeta_sdk_MaskDetector 12 | * Method: construct 13 | * Signature: (Lcom/seeta/sdk/SeetaModelSetting;)V 14 | */ 15 | JNIEXPORT void JNICALL Java_com_seeta_sdk_MaskDetector_construct 16 | (JNIEnv *, jobject, jobject); 17 | 18 | /* 19 | * Class: com_seeta_sdk_MaskDetector 20 | * Method: dispose 21 | * Signature: ()V 22 | */ 23 | JNIEXPORT void JNICALL Java_com_seeta_sdk_MaskDetector_dispose 24 | (JNIEnv *, jobject); 25 | 26 | /* 27 | * Class: com_seeta_sdk_MaskDetector 28 | * Method: detect 29 | * Signature: (Lcom/seeta/sdk/SeetaImageData;Lcom/seeta/sdk/SeetaRect;[F)Z 30 | */ 31 | JNIEXPORT jboolean JNICALL Java_com_seeta_sdk_MaskDetector_detect 32 | (JNIEnv *, jobject, jobject, jobject, jfloatArray); 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | #endif 38 | -------------------------------------------------------------------------------- /SeetaMaskDetector/java/com/seeta/sdk/MaskDetector.java: -------------------------------------------------------------------------------- 1 | package com.seeta.sdk; 2 | 3 | public class MaskDetector { 4 | static { 5 | System.loadLibrary("SeetaMaksDetector200_java"); 6 | } 7 | 8 | public long impl = 0; 9 | 10 | private native void construct(SeetaModelSetting setting) throws Exception; 11 | public MaskDetector(SeetaModelSetting setting) throws Exception { 12 | this.construct(setting); 13 | } 14 | 15 | public native void dispose(); 16 | protected void finalize()throws Throwable{ 17 | super.finalize(); 18 | this.dispose(); 19 | } 20 | 21 | public native boolean detect(SeetaImageData imageData, SeetaRect face, float[] score); 22 | } 23 | -------------------------------------------------------------------------------- /SeetaMaskDetector/java/com/seeta/sdk/SeetaDevice.java: -------------------------------------------------------------------------------- 1 | package com.seeta.sdk; 2 | 3 | public enum SeetaDevice 4 | { 5 | SEETA_DEVICE_AUTO(0), 6 | SEETA_DEVICE_CPU(1), 7 | SEETA_DEVICE_GPU(2); 8 | 9 | private int value; 10 | private SeetaDevice(int value) { 11 | this.value = value; 12 | } 13 | 14 | public int getValue(){ 15 | return value; 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /SeetaMaskDetector/java/com/seeta/sdk/SeetaImageData.java: -------------------------------------------------------------------------------- 1 | package com.seeta.sdk; 2 | 3 | public class SeetaImageData { 4 | public SeetaImageData(int width, int height, int channels) { 5 | this.data = new byte[width * height * channels]; 6 | this.width = width; 7 | this.height = height; 8 | this.channels = channels; 9 | } 10 | 11 | public SeetaImageData(int width, int height) { 12 | this(width, height, 1); 13 | } 14 | 15 | public byte[] data; 16 | public int width; 17 | public int height; 18 | public int channels; 19 | } -------------------------------------------------------------------------------- /SeetaMaskDetector/java/com/seeta/sdk/SeetaModelSetting.java: -------------------------------------------------------------------------------- 1 | package com.seeta.sdk; 2 | 3 | import com.seeta.sdk.SeetaDevice; 4 | 5 | public class SeetaModelSetting { 6 | 7 | public SeetaDevice device; 8 | public int id; // when device is GPU, id means GPU id 9 | public String [] model; 10 | 11 | public SeetaModelSetting(int id, String[] models, SeetaDevice dev) { 12 | this.id = id; 13 | this.device = dev; 14 | this.model = new String[models.length]; 15 | for(int i=0; i= 4 16 | # define TENNIS_DLL_IMPORT __attribute__((visibility("default"))) 17 | # define TENNIS_DLL_EXPORT __attribute__((visibility("default"))) 18 | # define TENNIS_DLL_LOCAL __attribute__((visibility("hidden"))) 19 | # else 20 | # define TENNIS_DLL_IMPORT 21 | # define TENNIS_DLL_EXPORT 22 | # define TENNIS_DLL_LOCAL 23 | # endif 24 | #endif 25 | 26 | #if defined(BUILDING_TENNIS) 27 | #define TENNIS_API TENNIS_DLL_EXPORT 28 | #else 29 | #define TENNIS_API TENNIS_DLL_IMPORT 30 | #endif 31 | 32 | #ifdef __cplusplus 33 | # define TENNIS_C_API TENNIS_EXTERN_C TENNIS_API 34 | #else 35 | # define TENNIS_C_API TENNIS_API 36 | #endif 37 | 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | 42 | #include 43 | 44 | typedef int32_t ts_bool; 45 | 46 | /** 47 | * Get last error message in current thread. 48 | * @return last error message. 49 | * @note Return NULL if failed. 50 | */ 51 | TENNIS_C_API const char *ts_last_error_message(); 52 | 53 | /** 54 | * Set error message in current thread. 55 | * @param message error message. 56 | */ 57 | TENNIS_C_API void ts_set_error_message(const char *message); 58 | 59 | #ifdef __cplusplus 60 | } 61 | #endif 62 | 63 | #endif //TENNIS_API_COMMON_H 64 | -------------------------------------------------------------------------------- /include/api/cpp/device.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by kier on 2019/3/16. 3 | // 4 | 5 | #ifndef TENNIS_API_CPP_DEVICE_H 6 | #define TENNIS_API_CPP_DEVICE_H 7 | 8 | #include "../device.h" 9 | 10 | #include 11 | #include 12 | 13 | namespace ts { 14 | namespace api { 15 | /** 16 | * @see ts_Device 17 | */ 18 | class Device { 19 | public: 20 | using self = Device; 21 | using raw = ts_Device; 22 | 23 | using shared = std::shared_ptr; 24 | using shared_raw = std::shared_ptr; 25 | 26 | Device(const self &) = default; 27 | 28 | Device &operator=(const self &) = default; 29 | 30 | const raw *get_raw() const { 31 | return &m_raw; 32 | } 33 | 34 | Device() : self("cpu", 0) {} 35 | 36 | Device(const std::string &type, int id = 0) { 37 | m_type = type; 38 | m_raw.id = id; 39 | m_raw.type = m_type.c_str(); 40 | } 41 | 42 | const std::string &type() const { return m_type; } 43 | 44 | int id() const { return m_raw.id; } 45 | 46 | private: 47 | Device(raw *ptr) { 48 | m_type = ptr->type; 49 | m_raw.id = ptr->id; 50 | m_raw.type = m_type.c_str(); 51 | } 52 | 53 | raw m_raw; 54 | 55 | std::string m_type; 56 | }; 57 | } 58 | } 59 | 60 | #endif //TENNIS_API_CPP_DEVICE_H 61 | -------------------------------------------------------------------------------- /include/api/cpp/except.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by kier on 2019/3/16. 3 | // 4 | 5 | #ifndef TENNIS_API_CPP_EXCEPT_H 6 | #define TENNIS_API_CPP_EXCEPT_H 7 | 8 | #include "../common.h" 9 | #include 10 | #include 11 | 12 | #if defined(_MSC_VER) && _MSC_VER < 1900 // lower then VS2015 13 | #define TS_API_NOEXCEPT 14 | #else 15 | #define TS_API_NOEXCEPT noexcept 16 | #endif 17 | 18 | namespace ts { 19 | namespace api { 20 | class Exception : public std::exception { 21 | public: 22 | using self = Exception; 23 | 24 | Exception() : Exception(ts_last_error_message()) {} 25 | 26 | explicit Exception(const std::string &message) : m_message(message) {} 27 | 28 | const char *what() const TS_API_NOEXCEPT override { return m_message.c_str(); } 29 | 30 | private: 31 | std::string m_message; 32 | }; 33 | } 34 | } 35 | 36 | #define TS_API_AUTO_CHECK(condition) \ 37 | if (!(condition)) { throw ts::api::Exception(); } 38 | 39 | #endif //TENNIS_API_CPP_EXCEPT_H 40 | -------------------------------------------------------------------------------- /include/api/cpp/operator_gpu.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by kier on 19-5-18. 3 | // 4 | 5 | #ifndef TENNIS_API_CPP_OPERATOR_GPU_H 6 | #define TENNIS_API_CPP_OPERATOR_GPU_H 7 | 8 | #include "operator.h" 9 | #include "../operator_gpu.h" 10 | 11 | #endif //TENNIS_API_CPP_OPERATOR_GPU_H 12 | -------------------------------------------------------------------------------- /include/api/cpp/tennis.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by kier on 2019/1/24. 3 | // 4 | 5 | #ifndef TENNIS_API_CPP_TENNIS_H 6 | #define TENNIS_API_CPP_TENNIS_H 7 | 8 | #include "except.h" 9 | #include "dtype.h" 10 | #include "device.h" 11 | #include "tensor.h" 12 | #include "module.h" 13 | #include "image_filter.h" 14 | #include "workbench.h" 15 | #include "intime.h" 16 | 17 | #endif //TENNIS_API_CPP_TENNIS_H 18 | -------------------------------------------------------------------------------- /include/api/cpp/tensorstack.h: -------------------------------------------------------------------------------- 1 | #ifndef TENNIS_API_CPP_TENSORSTACK_H 2 | #define TENNIS_API_CPP_TENSORSTACK_H 3 | 4 | #pragma message("Using decrepted header, please use #include \"api/cpp/tennis.h\" instead") 5 | 6 | #include "tennis.h" 7 | 8 | #endif //TENNIS_API_CPP_TENSORSTACK_H 9 | -------------------------------------------------------------------------------- /include/api/device.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by keir on 2019/3/16. 3 | // 4 | 5 | #ifndef TENNIS_API_DEVICE_H 6 | #define TENNIS_API_DEVICE_H 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | #include 13 | 14 | /** 15 | * Device description 16 | */ 17 | struct ts_Device { 18 | const char *type; ///< device type, like cpu or gpu 19 | int32_t id; ///< device id 20 | }; 21 | typedef struct ts_Device ts_Device; 22 | 23 | #ifdef __cplusplus 24 | } 25 | #endif 26 | 27 | #endif //TENNIS_API_DEVICE_H 28 | -------------------------------------------------------------------------------- /include/api/module.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by keir on 2019/3/16. 3 | // 4 | 5 | #ifndef TENNIS_API_MODULE_H 6 | #define TENNIS_API_MODULE_H 7 | 8 | #include "common.h" 9 | #include "stream.h" 10 | #include "device.h" 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | /** 17 | * Module contains struct and input, output of networks. 18 | */ 19 | struct ts_Module; 20 | typedef struct ts_Module ts_Module; 21 | 22 | /** 23 | * Serialized module format 24 | */ 25 | enum ts_SerializationFormat { 26 | TS_BINARY = 0, // BINARY file format 27 | TS_TEXT = 1, // TEXT file format 28 | }; 29 | typedef enum ts_SerializationFormat ts_SerializationFormat; 30 | 31 | // Module's API 32 | 33 | /** 34 | * Load module from given filename. 35 | * @param filename 36 | * @param format @sa ts_SerializationFormat, only support TS_BINARY in this version. 37 | * @return New reference. Return NULL if failed. 38 | * @note call @see ts_free_Module to free ts_Module 39 | */ 40 | TENNIS_C_API ts_Module *ts_Module_Load(const char *filename, ts_SerializationFormat format); 41 | 42 | /** 43 | * Load module from given stream. 44 | * @param obj object pointer pass to reader 45 | * @param reader stream reader 46 | * @param format @sa ts_SerializationFormat, only support TS_BINARY in this version. 47 | * @return New reference. Return NULL if failed. 48 | * @note call @see ts_free_Module to free ts_Module 49 | */ 50 | TENNIS_C_API ts_Module *ts_Module_LoadFromStream(void *obj, ts_stream_read *reader, ts_SerializationFormat format); 51 | 52 | /** 53 | * Free module. 54 | * @param module the return value of ts_Module_Load 55 | * Happen nothing if failed. 56 | */ 57 | TENNIS_C_API void ts_free_Module(const ts_Module *module); 58 | 59 | /** 60 | * Fusion two modules to one. 61 | * @param in input module 62 | * @param in_out_slot input module's output slot 63 | * @param out output module 64 | * @param in_out_slot output module's input slot 65 | * @return New reference. Return NULL if failed. 66 | * @note call @see ts_free_Module to free ts_Module 67 | * @note new module's input and output is sorted all `in` and `out` modules left input and output nodes 68 | */ 69 | TENNIS_C_API ts_Module *ts_Module_Fusion(const ts_Module *in, int32_t in_out_slot, const ts_Module *out, int32_t out_in_slot); 70 | 71 | 72 | #ifdef __cplusplus 73 | } 74 | #endif 75 | 76 | #endif //TENNIS_API_MODULE_H 77 | -------------------------------------------------------------------------------- /include/api/operator_gpu.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by kier on 19-5-18. 3 | // 4 | 5 | #ifndef TENNIS_API_OPERATOR_GPU_H 6 | #define TENNIS_API_OPERATOR_GPU_H 7 | 8 | #include "operator.h" 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | #include 15 | 16 | /** 17 | * get cuda stream in gpu operator 18 | * @param context instance of ts_OperatorContext 19 | * @raturn pointer value of cudaStream_t @sa TS_CUDA_STREAM 20 | */ 21 | TENNIS_C_API void *ts_OperatorContext_cuda_stream(ts_OperatorContext *context); 22 | 23 | /** 24 | * get cuda stream in gpu operator 25 | * @param context instance of ts_OperatorContext 26 | */ 27 | #define TS_CUDA_STREAM(context) ((cudaStream_t)(ts_OperatorContext_cuda_stream(context))) 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | 33 | #endif //TENNIS_API_OPERATOR_GPU_H 34 | -------------------------------------------------------------------------------- /include/api/setup.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by keir on 2019/3/16. 3 | // 4 | 5 | #ifndef TENNIS_API_SETUP_H 6 | #define TENNIS_API_SETUP_H 7 | 8 | #include "common.h" 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | /** 15 | * @return ts_true if succeed. 16 | * @note Happen nothing if failed. 17 | */ 18 | TENNIS_C_API ts_bool ts_setup(); 19 | 20 | #ifdef __cplusplus 21 | } 22 | #endif 23 | 24 | #endif //TENNIS_API_SETUP_H 25 | -------------------------------------------------------------------------------- /include/api/stream.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by kier on 19-4-25. 3 | // 4 | 5 | #ifndef TENNIS_API_STREAM_H 6 | #define TENNIS_API_STREAM_H 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | #include 13 | #include 14 | 15 | /** 16 | * Callback function of stream writing. 17 | * @param obj stream object 18 | * @param data buffer to write 19 | * @param length length of buffer 20 | * @return actually write size 21 | */ 22 | typedef uint64_t ts_stream_write(void *obj, const char *data, uint64_t length); 23 | 24 | /** 25 | * Callback function of stream reading. 26 | * @param obj stream object 27 | * @param data buffer to read 28 | * @param length length of buffer 29 | * @return actually read size 30 | */ 31 | typedef uint64_t ts_stream_read(void *obj, char *data, uint64_t length); 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | 37 | #endif //TENNIS_API_STREAM_H 38 | -------------------------------------------------------------------------------- /include/api/tennis.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by kier on 2019/1/24. 3 | // 4 | 5 | #ifndef TENNIS_API_TENNIS_H 6 | #define TENNIS_API_TENNIS_H 7 | 8 | // version 01.00.00.00 9 | #define TS_VERSION 1000000 10 | 11 | #include "setup.h" 12 | #include "common.h" 13 | #include "device.h" 14 | #include "tensor.h" 15 | #include "module.h" 16 | #include "image_filter.h" 17 | #include "workbench.h" 18 | #include "intime.h" 19 | 20 | #endif //TENNIS_API_TENNIS_H 21 | -------------------------------------------------------------------------------- /include/api/tensorstack.h: -------------------------------------------------------------------------------- 1 | #ifndef TENNIS_API_TENSORSTACK_H 2 | #define TENNIS_API_TENSORSTACK_H 3 | 4 | #pragma message("Using decrepted header, please use #include \"api/tennis.h\" instead") 5 | 6 | #include "tennis.h" 7 | 8 | #endif //TENNIS_API_TENSORSTACK_H 9 | -------------------------------------------------------------------------------- /include/hidden/SeetaLockVerifyLAN.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "SeetaLANLock.h" 4 | #include "SeetaLockFunction.h" 5 | #include 6 | 7 | static inline void VerifyLAN() 8 | { 9 | SeetaLock_VerifyLANParallel verify; 10 | 11 | if (!SeetaLockSafe_call(&verify)) 12 | { 13 | orz::Log(orz::FATAL) << "Lock module hijacked" << orz::crash; 14 | } 15 | 16 | if (verify.out.errcode != 0) 17 | { 18 | SeetaLock_ErrorMessage error_message(verify.out.errcode); 19 | SeetaLockSafe_call(&error_message); 20 | orz::Log(orz::FATAL) << "SeetaLANLock failed(" << verify.out.errcode << "): " << error_message.out.message << orz::crash; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /include/lock/cstastream.h: -------------------------------------------------------------------------------- 1 | #ifndef ORZ_CSTASTREAM_H 2 | #define ORZ_CSTASTREAM_H 3 | 4 | #include 5 | #include 6 | #include "orz/io/stream/filterstream.h" 7 | 8 | namespace orz 9 | { 10 | 11 | /** 12 | * This class transform csta type to sta type 13 | */ 14 | class CstaInputStream : public FilterInputStream { 15 | public: 16 | /** 17 | * @param in the input stream that contain csta model data 18 | * CstaInputStream skip four bytes mask at the input stream header 19 | */ 20 | CstaInputStream( std::shared_ptr in ); 21 | }; 22 | 23 | /** 24 | * This class transform sta type to csta type 25 | */ 26 | class CstaOutputStream : public FilterOutputStream { 27 | public: 28 | 29 | /** 30 | * @param out the output stream that contain sta model data 31 | * CstaOutputStream add four bytes mask at the output stream header 32 | */ 33 | CstaOutputStream( std::shared_ptr out ); 34 | }; 35 | 36 | 37 | } 38 | #endif 39 | -------------------------------------------------------------------------------- /include/lock/error_code.h: -------------------------------------------------------------------------------- 1 | #ifndef ERROR_CODE_H_ 2 | #define ERROR_CODE_H_ 3 | 4 | #include 5 | 6 | 7 | std::string error_str( int error_code ); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /include/lock/fast_cstastream.h: -------------------------------------------------------------------------------- 1 | #ifndef ORZ_FAST_CSTASTREAM_H 2 | #define ORZ_FAST_CSTASTREAM_H 3 | 4 | #include 5 | #include 6 | #include "orz/io/stream/filterstream.h" 7 | 8 | namespace orz 9 | { 10 | 11 | /** 12 | * This class transform csta type to sta type 13 | */ 14 | class Fast_CstaInputStream : public FilterInputStream { 15 | public: 16 | /** 17 | * @param in the input stream that contain csta model data 18 | * Fast_CstaInputStream skip four bytes mask at the input stream header 19 | */ 20 | Fast_CstaInputStream( std::shared_ptr in ); 21 | }; 22 | 23 | /** 24 | * This class transform sta type to csta type 25 | */ 26 | class Fast_CstaOutputStream : public FilterOutputStream { 27 | public: 28 | 29 | /** 30 | * @param out the output stream that contain sta model data 31 | * Fast_CstaOutputStream add four bytes mask at the output stream header 32 | */ 33 | Fast_CstaOutputStream( std::shared_ptr out ); 34 | }; 35 | 36 | 37 | } 38 | #endif 39 | -------------------------------------------------------------------------------- /include/orz/codec/base64.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by lby on 2018/1/10. 3 | // 4 | 5 | #ifndef ORZ_CODEC_BASE64_H 6 | #define ORZ_CODEC_BASE64_H 7 | 8 | #include 9 | 10 | namespace orz { 11 | std::string base64_encode(const std::string &bin); 12 | std::string base64_decode(const std::string &codes); 13 | } 14 | 15 | #endif //ORZ_CODEC_BASE64_H 16 | -------------------------------------------------------------------------------- /include/orz/codec/json.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by lby on 2018/1/10. 3 | // 4 | 5 | #ifndef ORZ_CODEC_JSON_H 6 | #define ORZ_CODEC_JSON_H 7 | 8 | #include "orz/io/jug/jug.h" 9 | 10 | namespace orz 11 | { 12 | orz::jug json2jug(const std::string &json); 13 | /** 14 | * 15 | * @param json 16 | * @param root must be fullpath to json, or path to root end with '/' 17 | * @return 18 | * Note: root work with root change 19 | */ 20 | orz::jug json2jug(const std::string &json, const std::string &root); 21 | std::string jug2json(const orz::jug &obj); 22 | std::string form_encode(const orz::jug &obj); 23 | } 24 | 25 | 26 | #endif //ORZ_CODEC_JSON_H 27 | -------------------------------------------------------------------------------- /include/orz/io/csv.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Lby on 2017/7/31. 3 | // 4 | 5 | #ifndef ORZ_IO_CSV_H 6 | #define ORZ_IO_CSV_H 7 | 8 | #include 9 | #include 10 | 11 | namespace orz { 12 | static const char CSVSeparator = ','; 13 | 14 | std::vector > CSVRead(const std::string &filename, char sep = CSVSeparator); 15 | 16 | void CSVWrite(const std::string &filename, const std::vector > &csv, char sep = CSVSeparator); 17 | 18 | std::string CSVBuild(const std::vector &line, char sep = CSVSeparator); 19 | 20 | std::vector CSVParse(const std::string &line, char sep = CSVSeparator); 21 | 22 | std::string CSVBuildItem(const std::string &item, char sep = CSVSeparator); 23 | } 24 | 25 | #endif //ORZ_IO_CSV_H 26 | -------------------------------------------------------------------------------- /include/orz/io/dir.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Lby on 2017/8/7. 3 | // 4 | 5 | #ifndef ORZ_IO_DIR_H 6 | #define ORZ_IO_DIR_H 7 | 8 | #include 9 | #include 10 | 11 | namespace orz { 12 | const std::string FileSeparator(); 13 | 14 | bool mkdir(const std::string &dir); 15 | 16 | bool access(const std::string &path); 17 | 18 | bool isdir(const std::string &path); 19 | 20 | bool isfile(const std::string &path); 21 | 22 | std::string join_path(const std::vector &paths); 23 | 24 | /*** 25 | * @brief Remove a file for now 26 | * @param filename File to remove 27 | * @return Return 0 only if succeed. 28 | */ 29 | bool remove(const std::string &filename); 30 | 31 | /*** 32 | * @brief Rename a file 33 | * @param oldname File's old name 34 | * @param newname File's new name 35 | * @return Return 0 only if succeed. 36 | */ 37 | bool rename(const std::string &oldname, const std::string &newname); 38 | 39 | /** 40 | * \brief copy file 41 | * \param fromfile source file 42 | * \param tofile dest file, or dir 43 | * \param force if false, 44 | * \return return true only if success 45 | */ 46 | bool copy(const std::string &fromfile, const std::string &tofile, bool force = true); 47 | 48 | /** 49 | * \brief Get current working directory 50 | * \return return current working directory 51 | */ 52 | std::string getcwd(); 53 | 54 | /** 55 | * \brief Get current executing filename 56 | * \return return current executing filename 57 | */ 58 | std::string getself(); 59 | 60 | /** 61 | * \brief Get current executing directory 62 | * \return return current executing directory 63 | */ 64 | std::string getexed(); 65 | 66 | /** 67 | * \brief Change current working directory 68 | * \return return true only if succeed 69 | */ 70 | bool cd(const std::string &path); 71 | 72 | /** 73 | * \brief Cut file path, like /path/to/file => [/path/to, file] 74 | * \return return path without tail directory 75 | */ 76 | std::string cut_path_tail(const std::string &path); 77 | 78 | /** 79 | * \brief Cut file path, like /path/to/file => [/path/to, file] 80 | * \param [out] tail return tail directory 81 | * \return return path without tail directory 82 | */ 83 | std::string cut_path_tail(const std::string &path, std::string &tail); 84 | 85 | /** 86 | * \brief cut filename and ext, like name.ext => [name, ext] 87 | * \param [out] filename return ext 88 | * \return return filename without ext 89 | */ 90 | std::string cut_name_ext(const std::string &name_ext, std::string &ext); 91 | } 92 | 93 | #endif //ORZ_IO_DIR_H 94 | -------------------------------------------------------------------------------- /include/orz/io/i.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by lby on 2018/1/15. 3 | // 4 | 5 | #ifndef ORZ_IO_I_H 6 | #define ORZ_IO_I_H 7 | 8 | #include "jug/binary.h" 9 | 10 | #include 11 | 12 | namespace orz { 13 | binary read_file(const std::string &filename); 14 | 15 | std::string read_txt_file(const std::string &filename); 16 | 17 | class imemorystream : public std::istream { 18 | public: 19 | imemorystream(const void *data, size_t size); 20 | 21 | private: 22 | class imemorybuffer : public std::streambuf { 23 | 24 | public: 25 | imemorybuffer(const void *data, size_t size); 26 | 27 | protected: 28 | int_type overflow(int_type c) override; 29 | 30 | std::streambuf *setbuf(char *s, std::streamsize n) override; 31 | 32 | int_type underflow() override; 33 | 34 | int_type uflow() override; 35 | 36 | streampos seekoff(streamoff off, ios_base::seekdir way, 37 | ios_base::openmode which) override; 38 | 39 | streampos seekpos(streampos sp, ios_base::openmode which) override; 40 | 41 | private: 42 | const void *m_data; 43 | size_t m_size; 44 | }; 45 | 46 | imemorybuffer m_buffer; 47 | }; 48 | 49 | class MemoryFILE { 50 | public: 51 | using self = MemoryFILE; 52 | 53 | explicit MemoryFILE(::FILE *file); 54 | 55 | MemoryFILE(void *data, size_t size); 56 | 57 | friend size_t fread(void *ptr, size_t size, size_t count, MemoryFILE *stream); 58 | 59 | friend size_t fwrite(const void *ptr, size_t size, size_t count, MemoryFILE *stream); 60 | 61 | friend int fseek(MemoryFILE *stream, long int offset, int origin); 62 | 63 | friend long int ftell(MemoryFILE *stream); 64 | 65 | friend void rewind(MemoryFILE *stream); 66 | 67 | friend int ferror(MemoryFILE *stream); 68 | 69 | friend int feof(MemoryFILE *stream); 70 | 71 | private: 72 | ::FILE *m_file = nullptr; 73 | char *m_data = nullptr; 74 | size_t m_size = 0; 75 | size_t m_index = 0; 76 | }; 77 | 78 | using FILE = MemoryFILE; 79 | } 80 | 81 | #endif //ORZ_IO_I_H 82 | -------------------------------------------------------------------------------- /include/orz/io/stream/filterstream.h: -------------------------------------------------------------------------------- 1 | #ifndef ORZ_IO_STREAM_FILTERSTREAM_H 2 | #define ORZ_IO_STREAM_FILTERSTREAM_H 3 | 4 | #include "orz/io/stream/stream.h" 5 | #include 6 | 7 | namespace orz { 8 | 9 | 10 | /** 11 | * A FilterInputStream contains some other input stream, which it uses as its basic 12 | * source of data, possibly transforming the data along the way or providing additional functionality. 13 | */ 14 | class FilterInputStream : public InputStream { 15 | public: 16 | /** 17 | * reads up to len char of data from this input stream into a char array. 18 | * This method blocks until some input is available. 19 | * @param buf, Pointer to an array where the read characters are stored. 20 | * @param len, Number of characters to read. 21 | * @return return the number of characters read, If no char is available because 22 | * the end of the stream has been reached, the 0 is returned. an exception happen will return -1. 23 | */ 24 | int64_t read(char *buf, int64_t len) override; 25 | 26 | protected: 27 | /** 28 | * Creates a FilterInputStream by assigning the argument in to the field this.m_in so 29 | * as to remember it for later use 30 | * @param in the underlying input stream 31 | */ 32 | FilterInputStream(std::shared_ptr in); 33 | 34 | 35 | protected: 36 | /** 37 | * The input stream to be filtered 38 | */ 39 | std::shared_ptr m_in; 40 | 41 | }; 42 | 43 | /** 44 | * This class is the superclass of all classes that filter output streams. 45 | * These strreams sit on top of an already existing output stream which it uses 46 | * as its basic sink of data, buf possibly transforming the data along the way 47 | * or providing additional functionality. 48 | */ 49 | class FilterOutputStream : public OutputStream { 50 | public: 51 | /** 52 | @param buf, Pointer to an array of at least len characters.. 53 | @param len, Number of characters to insert. 54 | @return return the number of characters written, an exception happen will return -1. 55 | */ 56 | int64_t write(const char *buf, int64_t len) override; 57 | 58 | protected: 59 | 60 | /** 61 | * Creates a FilterOutputStream by assigning the argument out to the field this.m_out so 62 | * as to remember it for later use 63 | * @param in the underlying output stream 64 | */ 65 | FilterOutputStream(std::shared_ptr out); 66 | 67 | 68 | protected: 69 | 70 | /** 71 | * The output stream to be filtered 72 | */ 73 | std::shared_ptr m_out; 74 | 75 | }; 76 | 77 | 78 | } 79 | 80 | 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /include/orz/io/stream/stream.h: -------------------------------------------------------------------------------- 1 | #ifndef ORZ_IO_STREAM_STREAM_H 2 | #define ORZ_IO_STREAM_STREAM_H 3 | 4 | #include 5 | 6 | namespace orz { 7 | 8 | /** 9 | *This abstract class is the superclass of all classes representing an input stream of bytes. 10 | */ 11 | 12 | class InputStream { 13 | public: 14 | 15 | /** 16 | @param buf, Pointer to an array where the extracted characters are stored. 17 | @param len, Number of characters to extract. 18 | @return return the number of characters extracted. 19 | */ 20 | virtual int64_t read(char *buf, int64_t len) = 0; 21 | virtual ~InputStream() {} 22 | 23 | /** 24 | @return return the inputstream work path. 25 | */ 26 | virtual const char * getworkpath() { return ""; } 27 | }; 28 | 29 | 30 | class OutputStream { 31 | public: 32 | 33 | /** 34 | @param buf, Pointer to an array of at least len characters.. 35 | @param len, Number of characters to insert. 36 | @return return the number of characters inserted. 37 | */ 38 | virtual int64_t write(const char *buf, int64_t len) = 0; 39 | virtual ~OutputStream() {} 40 | 41 | /** 42 | @return return the outputstream work path. 43 | */ 44 | virtual const char * getworkpath() { return ""; } 45 | }; 46 | 47 | 48 | } 49 | 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /include/orz/io/walker.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Lby on 2017/7/31. 3 | // 4 | 5 | #ifndef ORZ_IO_WALKER_H 6 | #define ORZ_IO_WALKER_H 7 | 8 | #include 9 | #include 10 | 11 | namespace orz { 12 | std::vector FindFiles(const std::string &path); 13 | 14 | std::vector FindFiles(const std::string &path, std::vector &dirs); 15 | 16 | std::vector FindFilesRecursively(const std::string &path, int depth = -1); 17 | 18 | std::vector FindFlodersRecursively(const std::string &path, int depth = -1); 19 | } 20 | 21 | #endif //ORZ_IO_WALKER_H 22 | -------------------------------------------------------------------------------- /include/orz/lego/box.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Lby on 2017/10/11. 3 | // 4 | 5 | #ifndef ORZ_BOX_H 6 | #define ORZ_BOX_H 7 | 8 | 9 | class box { 10 | 11 | }; 12 | 13 | 14 | #endif //ORZ_BOX_H 15 | -------------------------------------------------------------------------------- /include/orz/mem/need.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Lby on 2017/10/9. 3 | // 4 | 5 | #ifndef ORZ_MEM_NEED_H 6 | #define ORZ_MEM_NEED_H 7 | 8 | #include "orz/tools/void_bind.h" 9 | 10 | namespace orz { 11 | 12 | class need { 13 | public: 14 | 15 | template 16 | need(FUNC func) { 17 | task = void_bind(func); 18 | } 19 | 20 | template 21 | need(FUNC func, Args &&... args) { 22 | task = void_bind(func, std::forward(args)...); 23 | } 24 | 25 | ~need() { task(); } 26 | 27 | private: 28 | need(const need &that) = delete; 29 | 30 | need &operator=(const need &that) = delete; 31 | 32 | VoidOperator task; 33 | }; 34 | } 35 | 36 | #endif //ORZ_NEED_H 37 | -------------------------------------------------------------------------------- /include/orz/mem/pot.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Lby on 2017/8/12. 3 | // 4 | 5 | #ifndef ORZ_MEM_POT_H 6 | #define ORZ_MEM_POT_H 7 | 8 | #include 9 | #include 10 | 11 | namespace orz { 12 | 13 | class Pot { 14 | public: 15 | using allocator = std::function(size_t)>; 16 | 17 | Pot(); 18 | Pot(const allocator &ator); 19 | 20 | void *malloc(size_t _size); 21 | 22 | void *relloc(size_t _size); 23 | 24 | template 25 | T *calloc(size_t _count, bool copy = false) { 26 | if (copy) 27 | return reinterpret_cast(this->relloc(sizeof(T) * _count)); 28 | else 29 | return reinterpret_cast(this->malloc(sizeof(T) * _count)); 30 | } 31 | 32 | void *data() const; 33 | 34 | size_t capacity() const; 35 | 36 | size_t size() const; 37 | 38 | void dispose(); 39 | 40 | private: 41 | allocator m_allocator; 42 | 43 | private: 44 | size_t m_capacity; 45 | size_t m_size; 46 | std::shared_ptr m_data; 47 | }; 48 | } 49 | 50 | #endif //ORZ_MEM_POT_H 51 | -------------------------------------------------------------------------------- /include/orz/mem/vat.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Lby on 2017/8/23. 3 | // 4 | 5 | #ifndef ORZ_MEM_VAT_H 6 | #define ORZ_MEM_VAT_H 7 | 8 | #include "pot.h" 9 | #include 10 | #include 11 | 12 | namespace orz { 13 | 14 | class Vat { 15 | public: 16 | Vat(); 17 | 18 | void *malloc(size_t _size); 19 | 20 | template 21 | T *calloc(size_t _count) { 22 | return reinterpret_cast(this->malloc(sizeof(T) * _count)); 23 | } 24 | 25 | template 26 | std::shared_ptr calloc_shared(size_t _count) { 27 | return std::shared_ptr(calloc(_count), [this](T*ptr){this->free(ptr); }); 28 | } 29 | 30 | void free(const void *ptr); 31 | 32 | /** 33 | * @brief doing like free all malloc ptrs 34 | */ 35 | void reset(); 36 | 37 | void dispose(); 38 | 39 | void swap(Vat &that); 40 | 41 | Vat(Vat &&that); 42 | 43 | Vat &operator=(Vat &&that); 44 | 45 | private: 46 | Vat(const Vat &that) = delete; 47 | 48 | Vat &operator=(const Vat &that) = delete; 49 | 50 | // std::vector m_list; 51 | std::map m_dict; ///< save pair of pointer and index 52 | std::vector m_heap; ///< save all free memory, small fisrt sort 53 | }; 54 | 55 | } 56 | 57 | 58 | #endif //ORZ_MEM_VAT_H 59 | -------------------------------------------------------------------------------- /include/orz/net/http.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by lby on 2018/1/11. 3 | // 4 | 5 | #ifndef ORZ_NET_HTTP_H 6 | #define ORZ_NET_HTTP_H 7 | 8 | #include 9 | 10 | namespace orz { 11 | namespace http { 12 | enum VERB { 13 | POST, 14 | GET 15 | }; 16 | } 17 | 18 | namespace header { 19 | enum TYPE { 20 | JSON, ///< "Content-Type:application/json; charset=utf-8"; 21 | FORM, ///< "Content-Type:application/x-www-form-urlencoded; charset=utf-8"; 22 | }; 23 | } 24 | 25 | class URL { 26 | public: 27 | using self = URL; 28 | 29 | URL(const std::string &url); 30 | 31 | const std::string &url() const { return m_url; } 32 | 33 | const std::string &protocol() const { return m_protocol; } 34 | 35 | const std::string &host() const { return m_host; } 36 | 37 | int port() const { return m_port; } 38 | 39 | const std::string &target() const { return m_target; } 40 | 41 | bool valid() const { return m_valid; } 42 | 43 | private: 44 | std::string m_url; // http://www.localhost.com:8090/index.html?lang=zh_CN 45 | std::string m_protocol; // http 46 | std::string m_host; // www.web.com 47 | int m_port; // 8090 48 | std::string m_target; // /index.html?lang=zh_CN 49 | bool m_valid; 50 | }; 51 | 52 | std::string http_request(const URL &url, http::VERB verb, const std::string &data = ""); 53 | std::string http_request(const URL &url, http::VERB verb, const std::string &data, header::TYPE header); 54 | std::string http_request(const URL &url, http::VERB verb, const std::string &data, const std::string &header); 55 | } 56 | 57 | 58 | #endif //ORZ_NET_HTTP_H 59 | -------------------------------------------------------------------------------- /include/orz/ssl/aes.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by lby on 2018/1/15. 3 | // 4 | 5 | #ifndef ORZ_CODEC_AES_H 6 | #define ORZ_CODEC_AES_H 7 | 8 | #include 9 | #include "orz/io/jug/binary.h" 10 | 11 | namespace orz { 12 | enum CRYPTO_MODE { 13 | CBC 14 | }; 15 | 16 | std::string 17 | aes128_encode_block(const std::string &key, CRYPTO_MODE mode, const std::string &data, const std::string &iv = ""); 18 | 19 | std::string 20 | aes128_decode_block(const std::string &key, CRYPTO_MODE mode, const std::string &data, const std::string &iv = ""); 21 | 22 | // encode with PKCS7_PADDING 23 | std::string 24 | aes128_encode(const std::string &key, CRYPTO_MODE mode, const std::string &data, const std::string &iv = ""); 25 | 26 | // decode with PKCS7_PADDING 27 | std::string 28 | aes128_decode(const std::string &key, CRYPTO_MODE mode, const std::string &data, const std::string &iv = ""); 29 | 30 | void aes128_PKCS7_add_padding(std::string &data); 31 | 32 | void aes128_PKCS7_reamove_padding(std::string &data); 33 | 34 | // TODO: more general binary support 35 | binary 36 | aes128_encode_block(const std::string &key, CRYPTO_MODE mode, const binary &data, const std::string &iv = ""); 37 | 38 | binary 39 | aes128_decode_block(const std::string &key, CRYPTO_MODE mode, const binary &data, const std::string &iv = ""); 40 | 41 | // encode with PKCS7_PADDING 42 | binary 43 | aes128_encode(const std::string &key, CRYPTO_MODE mode, const binary &data, const std::string &iv = ""); 44 | 45 | // decode with PKCS7_PADDING 46 | binary 47 | aes128_decode(const std::string &key, CRYPTO_MODE mode, const binary &data, const std::string &iv = ""); 48 | 49 | void aes128_PKCS7_add_padding(binary &data); 50 | 51 | void aes128_PKCS7_reamove_padding(binary &data); 52 | } 53 | 54 | 55 | #endif //ORZ_CODEC_AES_H 56 | -------------------------------------------------------------------------------- /include/orz/ssl/rsa.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by lby on 2018/1/16. 3 | // 4 | 5 | #ifndef ORZ_RSA_H 6 | #define ORZ_RSA_H 7 | 8 | #include 9 | 10 | namespace orz { 11 | class rsa_key; 12 | 13 | rsa_key *load_public_rsa_key(const std::string &filename); 14 | 15 | rsa_key *load_private_rsa_key(const std::string &filename); 16 | 17 | rsa_key *load_mem_public_rsa_key(const std::string &buffer); 18 | 19 | rsa_key *load_mem_private_rsa_key(const std::string &buffer); 20 | 21 | void free_rsa_key(const rsa_key *key); 22 | 23 | // encode with OPENSSL_PKCS1_PADDING, data length can not greater than 117 24 | std::string rsa_encode_block(rsa_key *key, const std::string &data); 25 | 26 | // decode with OPENSSL_PKCS1_PADDING, data length should be 128 27 | std::string rsa_decode_block(rsa_key *key, const std::string &data); 28 | 29 | std::string rsa_private_encode(rsa_key *key, const std::string &data); 30 | 31 | std::string rsa_public_decode(rsa_key *key, const std::string &data); 32 | 33 | std::string rsa_public_encode(rsa_key *keye, const std::string &data); 34 | 35 | std::string rsa_private_decode(rsa_key *key, const std::string &data); 36 | 37 | std::string rsa_private_encode(const std::string &filename, const std::string &data); 38 | 39 | std::string rsa_public_decode(const std::string &filename, const std::string &data); 40 | 41 | std::string rsa_public_encode(const std::string &filename, const std::string &data); 42 | 43 | std::string rsa_private_decode(const std::string &filename, const std::string &data); 44 | 45 | std::string rsa_mem_private_encode(const std::string &buffer, const std::string &data); 46 | 47 | std::string rsa_mem_public_decode(const std::string &buffer, const std::string &data); 48 | 49 | std::string rsa_mem_public_encode(const std::string &buffer, const std::string &data); 50 | 51 | std::string rsa_mem_private_decode(const std::string &buffer, const std::string &data); 52 | } 53 | 54 | #endif //ORZ_RSA_H 55 | -------------------------------------------------------------------------------- /include/orz/sync/backend.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by lby on 2018/6/5. 3 | // 4 | 5 | #ifndef ORZ_SYNC_BACKEND_H 6 | #define ORZ_SYNC_BACKEND_H 7 | 8 | #include "cartridge.h" 9 | 10 | namespace orz { 11 | template 12 | class Backend { 13 | public: 14 | using self = Backend; 15 | using Mission = std::function; 16 | 17 | Backend() 18 | : m_busy(false) { 19 | } 20 | 21 | explicit Backend(const T &value) 22 | : m_busy(false), m_future(value) { 23 | } 24 | 25 | T fire(const Mission &mission) { 26 | this->put(mission); 27 | return this->get(); 28 | } 29 | 30 | template 31 | T bind(FUNC func, Args &&... args) { 32 | return this->fire(std::bind(func, std::forward(args)...)); 33 | }; 34 | 35 | bool busy() const { return this->m_busy; } 36 | 37 | void put(const Mission &mission) { 38 | if (!this->m_busy) { 39 | this->m_busy = true; 40 | this->m_cart.fire(0, [this, mission](int) { 41 | T a = mission(); 42 | std::unique_lock _locker(this->m_mutex); 43 | this->m_future = std::move(a); 44 | }, [this](int) { 45 | this->m_busy = false; 46 | }); 47 | } 48 | } 49 | 50 | T get() const { 51 | std::unique_lock _locker(this->m_mutex); 52 | return this->m_future; 53 | } 54 | 55 | void set(const T &value) { 56 | std::unique_lock _locker(this->m_mutex); 57 | this->m_future = value; 58 | } 59 | 60 | private: 61 | mutable std::mutex m_mutex; 62 | T m_future; 63 | orz::Cartridge m_cart; 64 | mutable std::atomic m_busy; 65 | }; 66 | } 67 | 68 | 69 | #endif //ORZ_SYNC_BACKEND_H 70 | -------------------------------------------------------------------------------- /include/orz/sync/canyon.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Lby on 2017/8/11. 3 | // 4 | 5 | #ifndef ORZ_SYNC_CANYON_H 6 | #define ORZ_SYNC_CANYON_H 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #include "orz/tools/void_bind.h" 17 | 18 | namespace orz { 19 | 20 | class Canyon { 21 | public: 22 | enum Action { 23 | DISCARD, 24 | WAITING 25 | }; 26 | 27 | explicit Canyon(int size = -1, Action act = WAITING); 28 | 29 | ~Canyon(); 30 | 31 | template 32 | void operator()(FUNC func) const { 33 | auto op = [=]() -> void { func(); }; 34 | this->push(void_bind(func)); 35 | } 36 | 37 | template 38 | void operator()(FUNC func, Args &&... args) const { 39 | this->push(void_bind(func, std::forward(args)...)); 40 | } 41 | 42 | void join() const; 43 | 44 | private: 45 | Canyon(const Canyon &that) = delete; 46 | 47 | const Canyon &operator=(const Canyon &that) = delete; 48 | 49 | void push(const VoidOperator &op) const; 50 | 51 | void operating() const; 52 | 53 | mutable std::queue _task; 54 | mutable std::mutex _mutex; 55 | mutable std::condition_variable _cond; 56 | std::atomic _work; 57 | int _size; 58 | Action _act; 59 | 60 | std::thread _core; 61 | }; 62 | 63 | } 64 | 65 | #endif //ORZ_SYNC_CANYON_H 66 | -------------------------------------------------------------------------------- /include/orz/sync/cartridge.h: -------------------------------------------------------------------------------- 1 | #ifndef ORZ_SYNC_BULLET_H 2 | #define ORZ_SYNC_BULLET_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | namespace orz { 11 | 12 | class Cartridge { 13 | public: 14 | Cartridge(); 15 | 16 | ~Cartridge(); 17 | 18 | using bullet_type = std::function; 19 | using shell_type = std::function; 20 | 21 | /** 22 | * @brief fire Asynchronous build and fire bullet, first calls the bullet, then calls the shell. 23 | * @param signet the index to call `bullet(signet)` and `shell(signet)` 24 | * @param bullet the function call in thread 25 | * @param shell call it after bullet called 26 | */ 27 | void fire(int signet, const bullet_type &bullet, const shell_type &shell = nullptr); 28 | 29 | bool busy(); 30 | 31 | void join(); 32 | 33 | private: 34 | Cartridge(const Cartridge &that) = delete; 35 | const Cartridge &operator=(const Cartridge &that) = delete; 36 | 37 | void operating(); 38 | 39 | std::mutex fire_mutex; ///< mutex control each fire 40 | std::condition_variable fire_cond; ///< condition to tell if fire finished 41 | std::atomic dry; ///< object only work when dry is true 42 | 43 | int signet; ///< the argument to call `bullet(signet)` and `shell(signet)` 44 | bullet_type bullet = nullptr; ///< main function call in thread 45 | shell_type shell = nullptr; ///< side function call after `bullet` called 46 | 47 | std::thread powder; ///< working thread 48 | 49 | }; 50 | 51 | } 52 | 53 | #endif // ORZ_SYNC_BULLET_H 54 | -------------------------------------------------------------------------------- /include/orz/sync/shotgun.h: -------------------------------------------------------------------------------- 1 | #ifndef ORZ_SYNC_SHOTGUN_H 2 | #define ORZ_SYNC_SHOTGUN_H 3 | 4 | #include "cartridge.h" 5 | 6 | #include 7 | #include 8 | 9 | namespace orz { 10 | 11 | /** 12 | * @brief The Shotgun class the thread pool 13 | */ 14 | class Shotgun { 15 | public: 16 | /** 17 | * @brief Shotgun 18 | * @param clip_size The cartridge number in clip. Number of threads 19 | */ 20 | Shotgun(size_t clip_size); 21 | 22 | ~Shotgun(); 23 | 24 | /** 25 | * @brief fire Find ready cartridge, build bullet and fire. 26 | * @param bullet the work ready to run 27 | * @return The cartridge running bullet 28 | */ 29 | Cartridge *fire(const Cartridge::bullet_type &bullet); 30 | 31 | /** 32 | * @brief fire Find ready cartridge, build bullet and fire. 33 | * @param bullet the work ready to run 34 | * @param shell the work after bullet finished 35 | * @return The cartridge running bullet 36 | */ 37 | Cartridge *fire(const Cartridge::bullet_type &bullet, const Cartridge::shell_type &shell); 38 | 39 | /** 40 | * @brief join Wait all cartridge working finish. 41 | */ 42 | void join(); 43 | 44 | /** 45 | * @brief busy Return if there are work running in thread 46 | * @return True if busy 47 | */ 48 | bool busy(); 49 | 50 | /** 51 | * @brief size Get number of threads 52 | * @return Number of threads 53 | */ 54 | size_t size() const; 55 | 56 | private: 57 | Shotgun(const Shotgun &that) = delete; 58 | const Shotgun &operator=(const Shotgun &that) = delete; 59 | 60 | /** 61 | * @brief load Get cartridge ready to fire 62 | * @return Get ready cartridge 63 | */ 64 | int load(); 65 | 66 | /** 67 | * @brief recycling_cartridge Recycle cartridge 68 | * @param signet cartridge index 69 | */ 70 | void recycling_cartridge(int signet); 71 | 72 | std::vector clip; ///< all cartridges 73 | 74 | std::mutex chest_mutex; ///< mutex to get cartridges 75 | std::condition_variable chest_cond; ///< active when cartridge pushed in chest 76 | std::deque chest; ///< save all cartridge ready to fire 77 | }; 78 | 79 | } 80 | 81 | #endif // ORZ_SYNC_SHOTGUN_H 82 | -------------------------------------------------------------------------------- /include/orz/tools/cpp_resources.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by kier on 2019/3/19. 3 | // 4 | 5 | #ifndef ORZ_TOOLS_CPP_RESOURCES_H 6 | #define ORZ_TOOLS_CPP_RESOURCES_H 7 | 8 | #include 9 | #include 10 | 11 | namespace orz { 12 | namespace resources { 13 | class BinaryFileInfo { 14 | public: 15 | int line = 0; 16 | std::string url; 17 | std::string path; 18 | std::string root; 19 | }; 20 | 21 | class OutputFileInfo { 22 | public: 23 | std::string path; 24 | std::string root; 25 | }; 26 | 27 | class CPPCompiler { 28 | public: 29 | static const char annotation; 30 | static const char *const header_name; 31 | static const char *const header_ext; 32 | static const char *const source_name; 33 | static const char *const source_ext; 34 | 35 | void set_split(int split) { m_split = split; } 36 | 37 | bool compile(const std::string &working_root, 38 | const std::string &resources_path, 39 | const std::string &binary_files_root, 40 | const std::string &output_root, 41 | std::string &header, std::vector &source); 42 | 43 | bool compile(const std::string &working_root, 44 | const std::vector &input_binaries, 45 | const std::string &output_root, 46 | std::string &header, std::vector &source); 47 | 48 | const std::string &last_error_message() const { 49 | return m_last_error_message; 50 | } 51 | 52 | private: 53 | int m_split = 10; 54 | std::string m_last_error_message; 55 | }; 56 | } 57 | } 58 | 59 | #endif //ORZ_TOOLS_CPP_RESOURCES_H 60 | -------------------------------------------------------------------------------- /include/orz/tools/ctxmgr_lite_support.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by kier on 2018/11/11. 3 | // 4 | 5 | #ifndef ORZ_TOOLS_CTXMGR_LITE_SUPPORT_HPP 6 | #define ORZ_TOOLS_CTXMGR_LITE_SUPPORT_HPP 7 | 8 | #include "ctxmgr_lite.h" 9 | 10 | namespace orz { 11 | 12 | template 13 | ORZ_LITE_THREAD_LOCAL 14 | typename __thread_local_lite_context::context 15 | __thread_local_lite_context::m_ctx = nullptr; 16 | 17 | template 18 | typename __thread_local_lite_context::context 19 | __thread_local_lite_context::swap(typename __thread_local_lite_context::context ctx) { 20 | auto pre_ctx = m_ctx; 21 | m_ctx = ctx; 22 | return pre_ctx; 23 | } 24 | 25 | template 26 | void __thread_local_lite_context::set(typename __thread_local_lite_context::context ctx) { 27 | m_ctx = ctx; 28 | } 29 | 30 | template 31 | typename __thread_local_lite_context::context const __thread_local_lite_context::get() { 32 | if (m_ctx == nullptr) throw NoLiteContextException(); 33 | return m_ctx; 34 | } 35 | 36 | template 37 | typename __thread_local_lite_context::context const __thread_local_lite_context::try_get() { 38 | return m_ctx; 39 | } 40 | 41 | template 42 | __lite_context::__lite_context(typename __lite_context::context ctx) { 43 | this->m_now_ctx = ctx; 44 | this->m_pre_ctx = __thread_local_lite_context::swap(ctx); 45 | } 46 | 47 | template 48 | __lite_context::~__lite_context() { 49 | __thread_local_lite_context::set(this->m_pre_ctx); 50 | } 51 | 52 | template 53 | void __lite_context::set(typename __lite_context::context ctx) { 54 | __thread_local_lite_context::set(ctx); 55 | } 56 | 57 | template 58 | typename __lite_context::context __lite_context::get() { 59 | return __thread_local_lite_context::get(); 60 | } 61 | 62 | template 63 | typename __lite_context::context __lite_context::try_get() { 64 | return __thread_local_lite_context::try_get(); 65 | } 66 | 67 | template 68 | typename __lite_context::context __lite_context::ctx() { 69 | return m_now_ctx; 70 | } 71 | 72 | template 73 | typename __lite_context::context const __lite_context::ctx() const { 74 | return m_now_ctx; 75 | } 76 | } 77 | 78 | #define ORZ_LITE_CONTEXT(T) \ 79 | template class orz::__thread_local_lite_context; \ 80 | template class orz::__lite_context; 81 | 82 | #endif // ORZ_TOOLS_CTXMGR_LITE_SUPPORT_HPP -------------------------------------------------------------------------------- /include/orz/tools/fps.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by lby on 2018/6/10. 3 | // 4 | 5 | #ifndef ORZ_TOOLS_FPS_H 6 | #define ORZ_TOOLS_FPS_H 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | namespace orz { 13 | class FPS { 14 | public: 15 | using system_clock = std::chrono::system_clock; 16 | using time_point = decltype(system_clock::now()); 17 | using microseconds = std::chrono::microseconds; 18 | using milliseconds = std::chrono::milliseconds; 19 | using seconds = std::chrono::seconds; 20 | 21 | explicit FPS(seconds range = seconds(1)) : m_range(range) {} 22 | 23 | void rewind() { 24 | this->m_every_time_point.clear(); 25 | } 26 | 27 | FPS &tick() { 28 | auto now = system_clock::now(); 29 | double now_fps = 0; 30 | if (this->m_every_time_point.empty()) { 31 | this->m_every_time_point.push_back(now); 32 | } else { 33 | this->m_every_time_point.push_back(now); 34 | 35 | now_fps = m_range.count() * double(1000000) 36 | / std::chrono::duration_cast( 37 | this->m_every_time_point.back() - this->m_every_time_point.front()).count() 38 | * (this->m_every_time_point.size() - 1); 39 | while (this->m_every_time_point.size() > 1 && 40 | (now - this->m_every_time_point.front()) > this->m_range) // seconds over m_range will be ignored 41 | this->m_every_time_point.pop_front(); 42 | } 43 | this->m_fps = static_castm_fps)>(now_fps); 44 | return *this; 45 | } 46 | 47 | double fps() const { 48 | return this->m_fps; 49 | } 50 | 51 | operator double() const { return static_cast(this->fps()); } 52 | 53 | operator float() const { return static_cast(this->fps()); } 54 | 55 | operator int() const { return static_cast(lround(this->fps() + 0.5)); } 56 | 57 | operator long() const { return static_cast(lround(this->fps() + 0.5)); } 58 | 59 | operator unsigned int() const { return static_cast(lround(this->fps() + 0.5)); } 60 | 61 | operator unsigned long() const { return static_cast(lround(this->fps() + 0.5)); } 62 | 63 | private: 64 | seconds m_range = seconds(1); 65 | std::deque m_every_time_point; 66 | double m_fps = 0; 67 | }; 68 | } 69 | 70 | 71 | 72 | #endif //ORZ_TOOLS_FPS_H 73 | -------------------------------------------------------------------------------- /include/orz/tools/gun_with.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by seeta on 2018/7/30. 3 | // 4 | 5 | #ifndef ORZ_TOOLS_GUN_WITH_H 6 | #define ORZ_TOOLS_GUN_WITH_H 7 | 8 | #include "multi.h" 9 | #include "orz/sync/shotgun.h" 10 | 11 | namespace orz { 12 | template 13 | class GunWithMulti : public Multi { 14 | public: 15 | using self = GunWithMulti; 16 | using supper = Multi; 17 | 18 | using Mission = std::function; 19 | 20 | template 21 | explicit GunWithMulti(size_t N, Args &&... args) 22 | : supper(N, std::forward(args)...), m_gun(N) { 23 | } 24 | 25 | void fire(const Mission &mission) { 26 | this->m_gun.fire([this, mission](int id) { mission(this->core(id)); }); 27 | } 28 | 29 | template 30 | void bind(FUNC func, Args &&... args) { 31 | this->m_gun.fire(this->bind_core(func, std::forward(args)...)); 32 | } 33 | 34 | void join() { 35 | this->m_gun.join(); 36 | } 37 | 38 | private: 39 | template 40 | void fire_core(int id, FUNC func, Args &&... args) { 41 | std::bind(func, &this->core(id), std::forward(args)...)(); 42 | } 43 | 44 | template 45 | orz::Cartridge::bullet_type bind_core(FUNC func, Args &&... args) { 46 | // no errors here 47 | return std::bind(&self::fire_core, this, std::placeholders::_1, func, std::forward(args)...); 48 | } 49 | 50 | orz::Shotgun m_gun; 51 | }; 52 | } 53 | 54 | #endif //ORZ_TOOLS_GUN_WITH_H 55 | -------------------------------------------------------------------------------- /include/orz/tools/limit.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Lby on 2017/10/19. 3 | // 4 | 5 | #ifndef ORZ_TOOLS_LIMIT_H 6 | #define ORZ_TOOLS_LIMIT_H 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | namespace orz 13 | { 14 | template 15 | class limit { 16 | public: 17 | limit() { 18 | ++_instance_count; 19 | if (_instance_count > N) throw std::logic_error( 20 | std::string("Can not create more the ") + 21 | std::to_string(N) + 22 | std::string(" instances.") 23 | ); 24 | } 25 | virtual ~limit() { 26 | --_instance_count; 27 | } 28 | private: 29 | static std::atomic _instance_count; 30 | }; 31 | 32 | template 33 | std::atomic limit::_instance_count; 34 | } 35 | 36 | #endif //ORZ_TOOLS_LIMIT_H 37 | -------------------------------------------------------------------------------- /include/orz/tools/multi.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by seeta on 2018/7/30. 3 | // 4 | 5 | #ifndef ORZ_TOOLS_MULTI_H 6 | #define ORZ_TOOLS_MULTI_H 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | namespace orz { 13 | template 14 | class Multi { 15 | public: 16 | using self = Multi; 17 | 18 | using Clazz = T; 19 | 20 | template 21 | explicit Multi(size_t N, Args &&... args) 22 | : m_cores(N) { 23 | for (auto &core : this->m_cores) core = std::make_shared(std::forward(args)...); 24 | } 25 | 26 | T &operator[](size_t _index) { return *this->m_cores[_index]; } 27 | 28 | const T &operator[](size_t _index) const { return *this->m_cores[_index]; } 29 | 30 | T &core(size_t _index) { return *this->m_cores[_index]; } 31 | 32 | const T &core(size_t _index) const { return *this->m_cores[_index]; } 33 | 34 | T &operator*() { return *this->m_cores[0]; } 35 | 36 | const T &operator*() const { return *this->m_cores[0]; } 37 | 38 | T *operator->() { return &*this->m_cores[0]; } 39 | 40 | const T *operator->() const { return &*this->m_cores[0]; } 41 | 42 | size_t size() const { return this->m_cores.size(); } 43 | 44 | /** 45 | * call function on each object 46 | * @tparam FUNC function type, should be Ret(T*, Args...) or Ret(T::*)(Args...) 47 | * @tparam Args the params of FUNC 48 | * @param func instance of FUNC 49 | * @param args instances of Args 50 | * @note FUNC can be Ret(T&, Args...) 51 | */ 52 | template 53 | void each(FUNC func, Args &&... args) { 54 | for (auto &core : this->m_cores) std::bind(func, &*core, std::forward(args)...)(); 55 | } 56 | 57 | private: 58 | using ptr = std::shared_ptr; 59 | std::vector m_cores; 60 | }; 61 | } 62 | 63 | #endif //ORZ_TOOLS_MULTI_H 64 | -------------------------------------------------------------------------------- /include/orz/tools/progress_bar.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by lby on 2018/1/23. 3 | // 4 | 5 | #ifndef ORZ_TOOLS_PROGRESS_BAR_H 6 | #define ORZ_TOOLS_PROGRESS_BAR_H 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | namespace orz { 13 | using system_clock = std::chrono::system_clock; 14 | using time_point = decltype(system_clock::now()); 15 | using microseconds = std::chrono::microseconds; 16 | using milliseconds = std::chrono::milliseconds; 17 | using seconds = std::chrono::seconds; 18 | using std::chrono::duration_cast; 19 | 20 | std::string to_string(microseconds us, size_t limit = 8); 21 | 22 | class progress_bar { 23 | public: 24 | using self = progress_bar; 25 | 26 | enum status { 27 | WAITING, 28 | RUNNING, 29 | PAUSED, 30 | STOPPED, 31 | }; 32 | 33 | progress_bar(int min, int max, int value); 34 | 35 | progress_bar(int min, int max); 36 | 37 | progress_bar(int max); 38 | 39 | progress_bar(); 40 | 41 | status stat() const; 42 | 43 | void start(); 44 | 45 | void stop(); 46 | 47 | void pause(); 48 | 49 | void autostop(bool flag); 50 | 51 | bool autostop() const; 52 | 53 | int value() const; 54 | 55 | int max() const; 56 | 57 | int min() const; 58 | 59 | void set_value(int value); 60 | 61 | void set_min(int min); 62 | 63 | void set_max(int max); 64 | 65 | int next(); 66 | 67 | int next(int step); 68 | 69 | microseconds used_time() const; 70 | 71 | microseconds left_time() const; 72 | 73 | int percent() const; 74 | 75 | std::ostream &show(std::ostream &out) const; 76 | 77 | std::ostream &wait_show(int ms, std::ostream &out) const; 78 | 79 | private: 80 | // reset sample 81 | void reset(); 82 | 83 | // sample value and time point, calculate speed 84 | void sample(); 85 | 86 | int m_min; 87 | int m_max; 88 | int m_value; 89 | int m_step = 1; 90 | 91 | bool m_autostop = true; 92 | 93 | status m_stat = WAITING; 94 | 95 | time_point m_start_time_point; 96 | time_point m_stop_time_point; 97 | time_point m_pause_time_point; 98 | microseconds m_paused_duration; 99 | 100 | mutable int m_show_count = 0; 101 | 102 | int m_sample_value; 103 | time_point m_sample_time_point; 104 | double m_vpus; // values per microseconds 105 | 106 | mutable time_point m_last_show_time_point; 107 | }; 108 | } 109 | 110 | 111 | 112 | #endif //ORZ_TOOLS_PROGRESS_BAR_H 113 | -------------------------------------------------------------------------------- /include/orz/tools/resources.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by kier on 2018/9/25. 3 | // 4 | 5 | #ifndef ORZ_TOOLS_RESOURCES_H 6 | #define ORZ_TOOLS_RESOURCES_H 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | namespace orz { 14 | 15 | namespace resources { 16 | struct resources { 17 | public: 18 | resources() = default; 19 | explicit resources(const std::string &url, const std::string &path, size_t line = 0) 20 | : line(line), url(url), path(path) {} 21 | 22 | size_t line = 0; 23 | std::string url; 24 | std::string path; 25 | }; 26 | 27 | class compiler { 28 | public: 29 | static const char annotation = '#'; 30 | 31 | compiler(); 32 | 33 | bool compile(const std::vector &in_resources, std::ostream &out_header, std::ostream &out_source, 34 | const std::string &val_header_path = "orz_resources.h"); 35 | 36 | bool compile(std::istream &in_source, std::ostream &out_header, std::ostream &out_source, 37 | const std::string &val_header_path = "orz_resources.h"); 38 | 39 | bool compile(std::istream &in_source, 40 | const std::string &header_filename, 41 | const std::string &source_filename); 42 | 43 | bool compile(const std::string &path, const std::string &header_filename, const std::string &source_filename); 44 | 45 | bool up2date_header(const std::string &header_filename); 46 | 47 | bool up2date_header(const std::string &header_filename, const std::string &content); 48 | 49 | const std::string &last_error_message() const { 50 | return m_last_error_message; 51 | } 52 | 53 | void set_working_directory(const std::string &path) { m_working_directory = path; } 54 | void set_output_directory(const std::string &path) { m_output_directory = path; } 55 | void set_input_directory(const std::string &path) { m_input_directory = path; } 56 | void set_mark(const std::string &mark) { m_mark = mark; } 57 | 58 | private: 59 | std::string m_last_error_message; 60 | 61 | // path to load orc file 62 | std::string m_working_directory; 63 | 64 | // path to output generated files 65 | std::string m_output_directory; 66 | 67 | // path to input resources file 68 | std::string m_input_directory; 69 | 70 | std::string m_mark; 71 | }; 72 | } 73 | } 74 | 75 | 76 | #endif //ORZ_TOOLS_RESOURCES_H 77 | -------------------------------------------------------------------------------- /include/orz/tools/timer.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by seeta on 2018/8/3. 3 | // 4 | 5 | #ifndef ORZ_TOOLS_TIMER_H 6 | #define ORZ_TOOLS_TIMER_H 7 | 8 | #include 9 | 10 | namespace orz { 11 | 12 | /** 13 | * using microseconds for timer 14 | */ 15 | class Timer { 16 | public: 17 | using duration = std::chrono::microseconds; 18 | using time_point = std::chrono::system_clock::time_point; 19 | using system_clock = std::chrono::system_clock; 20 | 21 | Timer() { 22 | m_start = system_clock::now(); 23 | } 24 | 25 | duration reset() { 26 | auto now = system_clock::now(); 27 | auto count = std::chrono::duration_cast(now - m_start); 28 | m_start = now; 29 | return count; 30 | } 31 | 32 | duration count() const { 33 | auto now = system_clock::now(); 34 | return std::chrono::duration_cast(now - m_start); 35 | } 36 | 37 | time_point start() const { 38 | return m_start; 39 | } 40 | 41 | time_point now() const { 42 | return system_clock::now(); 43 | } 44 | 45 | private: 46 | time_point m_start; 47 | }; 48 | } 49 | 50 | #endif //ORZ_TOOLS_TIMER_H 51 | -------------------------------------------------------------------------------- /include/orz/tools/void_bind.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by lby on 2018/1/23. 3 | // 4 | 5 | #ifndef ORZ_TOOLS_VOID_BIND_H 6 | #define ORZ_TOOLS_VOID_BIND_H 7 | 8 | #include 9 | 10 | namespace orz { 11 | using VoidOperator = std::function; 12 | 13 | // for error C3848 in MSVC 14 | 15 | template 16 | class _Operator { 17 | public: 18 | static VoidOperator bind(FUNC func) { 19 | return [func]() -> void { 20 | // for error C3848 in MSVC 21 | FUNC non_const_func = func; 22 | non_const_func(); 23 | }; 24 | } 25 | }; 26 | 27 | template 28 | class _Operator { 29 | public: 30 | static VoidOperator bind(FUNC func) { return func; } 31 | }; 32 | 33 | template 34 | inline VoidOperator void_bind(FUNC func, Args &&... args) { 35 | auto inner_func = std::bind(func, std::forward(args)...); 36 | using Ret = decltype(inner_func()); 37 | using RetOperator = _Operator; 38 | return RetOperator::bind(inner_func); 39 | } 40 | 41 | template 42 | inline void void_call(FUNC func, Args &&... args) { 43 | std::bind(func, std::forward(args)...)(); 44 | }; 45 | } 46 | 47 | #endif //ORZ_TOOLS_VOID_BIND_H 48 | -------------------------------------------------------------------------------- /include/orz/utils/api.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Lby on 2017/8/7. 3 | // 4 | 5 | #ifndef ORZ_UTILS_API_H 6 | #define ORZ_UTILS_API_H 7 | 8 | #include "platform.h" 9 | 10 | #define ORZ_EXTERN_C extern "C" 11 | 12 | #if ORZ_PLATFORM_OS_WINDOWS 13 | # define ORZ_DLL_IMPORT __declspec(dllimport) 14 | # define ORZ_DLL_EXPORT __declspec(dllexport) 15 | # define ORZ_DLL_LOCAL 16 | #else 17 | # if defined(__GNUC__) && __GNUC__ >= 4 18 | # define ORZ_DLL_IMPORT __attribute__((visibility("default"))) 19 | # define ORZ_DLL_EXPORT __attribute__((visibility("default"))) 20 | # define ORZ_DLL_LOCAL __attribute__((visibility("hidden"))) 21 | # else 22 | # define ORZ_DLL_IMPORT 23 | # define ORZ_DLL_EXPORT 24 | # define ORZ_DLL_LOCAL 25 | # endif 26 | #endif 27 | 28 | #define ORZ_API ORZ_DLL_EXPORT 29 | 30 | #ifdef __cplusplus 31 | # define ORZ_C_API ORZ_EXTERN_C ORZ_API 32 | #else 33 | # define ORZ_C_API ORZ_API 34 | #endif 35 | 36 | #ifndef ORZ_UNUSED 37 | # define ORZ_UNUSED(x) ((void)x) 38 | #endif 39 | 40 | #endif //ORZ_UTILS_API_H 41 | -------------------------------------------------------------------------------- /include/orz/utils/except.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Lby on 2017/6/6. 3 | // 4 | 5 | #ifndef ORZ_UTILS_EXCEPT_H 6 | #define ORZ_UTILS_EXCEPT_H 7 | 8 | #include 9 | #include 10 | 11 | #include "platform.h" 12 | 13 | #if ORZ_PLATFORM_CC_MSVC 14 | #define ORZ_NOEXCEPT 15 | #else 16 | #define ORZ_NOEXCEPT noexcept 17 | #endif 18 | 19 | namespace orz { 20 | class Exception : public std::exception { 21 | public: 22 | Exception(const std::string &message); 23 | 24 | virtual const char *what() const ORZ_NOEXCEPT override; 25 | 26 | private: 27 | std::string m_message; 28 | }; 29 | } 30 | 31 | #endif //ORZ_UTILS_EXCEPT_H 32 | -------------------------------------------------------------------------------- /include/orz/utils/format.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Lby on 2017/6/1. 3 | // 4 | 5 | #ifndef ORZ_UTILS_FORMAT_H 6 | #define ORZ_UTILS_FORMAT_H 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #ifndef UNUSED 14 | #define UNUSED(val) (void)(val) 15 | #endif 16 | 17 | namespace orz { 18 | using time_point = decltype(std::chrono::system_clock::now()); 19 | 20 | static inline void _Concat_str(std::ostream &out) { (decltype(_Concat_str(out))()); } 21 | 22 | template 23 | static inline void _Concat_str(std::ostream &out, T &&t, Args&&... args) { _Concat_str(out << std::forward(t), std::forward(args)...); } 24 | 25 | template 26 | static inline const std::string Concat(Args&&... args) { 27 | std::ostringstream oss; 28 | _Concat_str(oss, std::forward(args)...); 29 | return oss.str(); 30 | } 31 | 32 | const std::string Format(const std::string &f); 33 | 34 | std::vector Split(const std::string &str, char ch = ' ', size_t _size = 0); 35 | 36 | std::vector Split(const std::string &str, const std::string sep = " ", size_t _size = 0); 37 | 38 | std::string Join(const std::vector &list, const std::string &sep); 39 | 40 | template 41 | static inline std::ostream &operator<<(std::ostream &out, const std::vector &vec) { 42 | out << "["; 43 | for (size_t i = 0; i < vec.size(); ++i) { 44 | if (i) out << ", "; 45 | out << vec[i]; 46 | } 47 | out << "]"; 48 | return out; 49 | } 50 | 51 | std::string to_string(time_point tp, const std::string &format = "%Y-%m-%d %H:%M:%S"); 52 | 53 | /** 54 | * return format now time string 55 | * @param format same as strftime 56 | * @return string contains now time 57 | * @see strftime 58 | */ 59 | std::string now_time(const std::string &format = "%Y-%m-%d %H:%M:%S"); 60 | } 61 | 62 | #endif //ORZ_UTILS_FORMAT_H 63 | -------------------------------------------------------------------------------- /include/orz/utils/random.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by kier on 2018/7/19. 3 | // 4 | 5 | #ifndef ORZ_UTILS_RANDOM_H 6 | #define ORZ_UTILS_RANDOM_H 7 | 8 | namespace orz { 9 | class MT19937 { 10 | public: 11 | MT19937(); 12 | 13 | explicit MT19937(int __seed); 14 | 15 | void srand(int __seed); 16 | 17 | int rand(); 18 | 19 | static const int MAX = 0x7fffffff; // 2 ^ 31 - 1 20 | private: 21 | static const int N = 624; //624 * 32 - 31 = 19937 22 | int MT[N]; 23 | int m_i = 0; 24 | int m_seed; 25 | }; 26 | 27 | class Random { 28 | public: 29 | 30 | Random(); 31 | 32 | explicit Random(int __seed); 33 | 34 | // Set seed of random serial 35 | void seed(int __seed); 36 | 37 | // Uniformly distributed integer in [0, MT19937::MAX] 38 | int next(); 39 | 40 | // Uniformly distributed integer in [min, max] 41 | int next(int min, int max); 42 | 43 | // Uniformly distributed number in [0, 1] 44 | double u(); 45 | 46 | // Binomial distributed boolean(p) 47 | bool binomial(double p); 48 | 49 | // Exponential distribution 50 | double exp(double beta); 51 | 52 | // Ray distribution 53 | double ray(double mu); 54 | 55 | // Weibull distribution 56 | double weibull(double alpha, double beta); 57 | 58 | // Normal distribution: N(0, 1) 59 | double normal(); 60 | 61 | // Normal distribution: N(mu, delta^2) 62 | double normal(double mu, double delta); 63 | 64 | private: 65 | MT19937 mt; 66 | }; 67 | 68 | extern Random random; 69 | } 70 | 71 | 72 | #endif //ORZ_UTILS_RANDOM_H 73 | -------------------------------------------------------------------------------- /include/seeta/AgePredictor.h: -------------------------------------------------------------------------------- 1 | #ifndef SEETA_AGE_PREDICTOR_H 2 | #define SEETA_AGE_PREDICTOR_H 3 | 4 | #include "seeta/Common/Struct.h" 5 | 6 | #define SEETA_AGE_PREDICTOR_MAJOR_VERSION 6 7 | #define SEETA_AGE_PREDICTOR_MINOR_VERSION 0 8 | #define SEETA_AGE_PREDICTOR_SINOR_VERSION 0 9 | 10 | namespace seeta { 11 | namespace v6 { 12 | class AgePredictor { 13 | public: 14 | 15 | enum Property { 16 | PROPERTY_NUMBER_THREADS = 4, 17 | PROPERTY_ARM_CPU_MODE = 5 18 | }; 19 | 20 | SEETA_API explicit AgePredictor(const SeetaModelSetting &setting); 21 | SEETA_API ~AgePredictor(); 22 | 23 | SEETA_API int GetCropFaceWidth() const; 24 | SEETA_API int GetCropFaceHeight() const; 25 | SEETA_API int GetCropFaceChannels() const; 26 | SEETA_API bool CropFace(const SeetaImageData &image, const SeetaPointF *points, SeetaImageData &face) const; 27 | 28 | SEETA_API bool PredictAge(const SeetaImageData &image, int &age) const; 29 | 30 | SEETA_API bool PredictAgeWithCrop(const SeetaImageData &image, const SeetaPointF *points, int &age) const; 31 | 32 | SEETA_API void set(Property property, double value); 33 | 34 | SEETA_API double get(Property property) const; 35 | 36 | private: 37 | AgePredictor(const AgePredictor &) = delete; 38 | const AgePredictor &operator=(const AgePredictor&) = delete; 39 | 40 | private: 41 | class Implement; 42 | Implement *m_impl; 43 | }; 44 | } 45 | using namespace v6; 46 | } 47 | 48 | #endif //SEETA_AGE_PREDICTOR_H 49 | -------------------------------------------------------------------------------- /include/seeta/CFaceDetector.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by kier on 19-8-30. 3 | // 4 | 5 | #ifndef INC_SEETA_C_FACEDETECTOR_H 6 | #define INC_SEETA_C_FACEDETECTOR_H 7 | 8 | #include "seeta/Common/CStruct.h" 9 | #include "CFaceInfo.h" 10 | 11 | struct SeetaFaceDetector; 12 | 13 | enum seeta_v6_FaceDetector_Property { 14 | SEETA_PROPERTY_MIN_FACE_SIZE = 0, 15 | SEETA_PROPERTY_THRESHOLD = 1, 16 | SEETA_PROPERTY_MAX_IMAGE_WIDTH = 2, 17 | SEETA_PROPERTY_MAX_IMAGE_HEIGHT = 3, 18 | SEETA_PROPERTY_NUMBER_THREADS = 4, 19 | 20 | /* 21 | * -1 for default, 0 for big core, 1 for little core, 2 for all cores 22 | * @note **ONLY** work in ARM arch. 23 | */ 24 | SEETA_PROPERTY_ARM_CPU_MODE = 0x101, 25 | }; 26 | 27 | SEETA_C_API const char *seeta_v6_FaceDetector_error(); 28 | 29 | SEETA_C_API SeetaFaceDetector *seeta_v6_FaceDetector_new(const SeetaModelSetting *setting); 30 | 31 | SEETA_C_API void seeta_v6_FaceDetector_delete(const SeetaFaceDetector *object); 32 | 33 | SEETA_C_API SeetaFaceDetector *seeta_v6_FaceDetector_clone(const SeetaFaceDetector *object); 34 | 35 | SEETA_C_API SeetaFaceInfoArray seeta_v6_FaceDetector_detect(const SeetaFaceDetector *object, 36 | const SeetaImageData *image); 37 | 38 | SEETA_C_API void seeta_v6_FaceDetector_set(SeetaFaceDetector *object, 39 | seeta_v6_FaceDetector_Property property, 40 | double value); 41 | 42 | SEETA_C_API double seeta_v6_FaceDetector_get(const SeetaFaceDetector *object, 43 | seeta_v6_FaceDetector_Property property); 44 | 45 | #endif //INC_SEETA_C_FACEDETECTOR_H 46 | -------------------------------------------------------------------------------- /include/seeta/CFaceInfo.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "seeta/Common/CStruct.h" 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | struct SeetaFaceInfo 10 | { 11 | SeetaRect pos; 12 | float score; 13 | }; 14 | 15 | struct SeetaFaceInfoArray 16 | { 17 | struct SeetaFaceInfo *data; 18 | int size; 19 | }; 20 | 21 | #ifdef __cplusplus 22 | } 23 | #endif 24 | -------------------------------------------------------------------------------- /include/seeta/CStream.h: -------------------------------------------------------------------------------- 1 | #ifndef INC_SEETA_C_STREAM_H 2 | #define INC_SEETA_C_STREAM_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | #include 10 | 11 | typedef size_t SeetaStreamWrite(void *obj, const char *data, size_t length); 12 | typedef size_t SeetaStreamRead(void *obj, char *data, size_t length); 13 | 14 | #ifdef __cplusplus 15 | } 16 | #endif 17 | 18 | #endif // INC_SEETA_C_STREAM_H 19 | -------------------------------------------------------------------------------- /include/seeta/CStruct.h: -------------------------------------------------------------------------------- 1 | #ifndef INC_SEETA_C_STRUCT_H 2 | #define INC_SEETA_C_STRUCT_H 3 | 4 | #ifdef _MSC_VER 5 | #ifdef SEETA_EXPORTS 6 | #define SEETA_API __declspec(dllexport) 7 | #else 8 | #define SEETA_API __declspec(dllimport) 9 | #endif 10 | #else 11 | #define SEETA_API __attribute__ ((visibility("default"))) 12 | #endif 13 | 14 | #define SEETA_C_API extern "C" SEETA_API 15 | 16 | #define INCLUDED_SEETA_CSTRUCT 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | #include 23 | 24 | struct SeetaImageData 25 | { 26 | int width; 27 | int height; 28 | int channels; 29 | unsigned char *data; 30 | }; 31 | 32 | struct SeetaPoint 33 | { 34 | int x; 35 | int y; 36 | }; 37 | 38 | struct SeetaPointF 39 | { 40 | double x; 41 | double y; 42 | }; 43 | 44 | struct SeetaSize 45 | { 46 | int width; 47 | int height; 48 | }; 49 | 50 | struct SeetaRect 51 | { 52 | int x; 53 | int y; 54 | int width; 55 | int height; 56 | }; 57 | 58 | struct SeetaRegion 59 | { 60 | int top; 61 | int bottom; 62 | int left; 63 | int right; 64 | }; 65 | 66 | enum SeetaDevice 67 | { 68 | SEETA_DEVICE_AUTO = 0, 69 | SEETA_DEVICE_CPU = 1, 70 | SEETA_DEVICE_GPU = 2, 71 | }; 72 | 73 | struct SeetaModelSetting 74 | { 75 | enum SeetaDevice device; 76 | int id; // when device is GPU, id means GPU id 77 | const char **model; // model string terminate with nullptr 78 | }; 79 | 80 | struct SeetaBuffer 81 | { 82 | void *buffer; 83 | int64_t size; 84 | }; 85 | 86 | struct SeetaModelBuffer 87 | { 88 | enum SeetaDevice device; 89 | int id; // when device is GPU, id means GPU id 90 | const SeetaBuffer *buffer; // input buffers, terminate with empty buffer(buffer=nullptr, size=0) 91 | }; 92 | 93 | #ifdef __cplusplus 94 | } 95 | #endif 96 | 97 | #endif // INC_SEETA_C_STRUCT_H 98 | -------------------------------------------------------------------------------- /include/seeta/CTrackingFaceInfo.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "seeta/Common/Struct.h" 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | struct SeetaTrackingFaceInfo 10 | { 11 | SeetaRect pos; 12 | float score; 13 | 14 | int frame_no; 15 | int PID; 16 | int step; 17 | }; 18 | 19 | struct SeetaTrackingFaceInfoArray 20 | { 21 | struct SeetaTrackingFaceInfo *data; 22 | int size; 23 | }; 24 | 25 | #ifdef __cplusplus 26 | } 27 | #endif 28 | -------------------------------------------------------------------------------- /include/seeta/Common/CStruct.h: -------------------------------------------------------------------------------- 1 | #ifndef INC_SEETA_C_STRUCT_H 2 | #define INC_SEETA_C_STRUCT_H 3 | 4 | #ifdef _MSC_VER 5 | #ifdef SEETA_EXPORTS 6 | #define SEETA_API __declspec(dllexport) 7 | #else 8 | #define SEETA_API __declspec(dllimport) 9 | #endif 10 | #else 11 | #define SEETA_API __attribute__ ((visibility("default"))) 12 | #endif 13 | 14 | #define SEETA_C_API extern "C" SEETA_API 15 | 16 | #define INCLUDED_SEETA_CSTRUCT 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | #include 23 | 24 | struct SeetaImageData 25 | { 26 | int width; 27 | int height; 28 | int channels; 29 | unsigned char *data; 30 | }; 31 | 32 | struct SeetaPoint 33 | { 34 | int x; 35 | int y; 36 | }; 37 | 38 | struct SeetaPointF 39 | { 40 | double x; 41 | double y; 42 | }; 43 | 44 | struct SeetaSize 45 | { 46 | int width; 47 | int height; 48 | }; 49 | 50 | struct SeetaRect 51 | { 52 | int x; 53 | int y; 54 | int width; 55 | int height; 56 | }; 57 | 58 | struct SeetaRegion 59 | { 60 | int top; 61 | int bottom; 62 | int left; 63 | int right; 64 | }; 65 | 66 | enum SeetaDevice 67 | { 68 | SEETA_DEVICE_AUTO = 0, 69 | SEETA_DEVICE_CPU = 1, 70 | SEETA_DEVICE_GPU = 2, 71 | }; 72 | 73 | struct SeetaModelSetting 74 | { 75 | enum SeetaDevice device; 76 | int id; // when device is GPU, id means GPU id 77 | const char **model; // model string terminate with nullptr 78 | }; 79 | 80 | struct SeetaBuffer 81 | { 82 | void *buffer; 83 | int64_t size; 84 | }; 85 | 86 | struct SeetaModelBuffer 87 | { 88 | enum SeetaDevice device; 89 | int id; // when device is GPU, id means GPU id 90 | const SeetaBuffer *buffer; // input buffers, terminate with empty buffer(buffer=nullptr, size=0) 91 | }; 92 | 93 | #ifdef __cplusplus 94 | } 95 | #endif 96 | 97 | #endif // INC_SEETA_C_STRUCT_H 98 | -------------------------------------------------------------------------------- /include/seeta/EyeStateDetector.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by kier on 19-4-24. 3 | // 4 | 5 | #ifndef SEETA_EyeStateDetector_H 6 | #define SEETA_EyeStateDetector_H 7 | 8 | #include "seeta/Common/Struct.h" 9 | 10 | namespace seeta { 11 | namespace v6 { 12 | class EyeStateDetector { 13 | public: 14 | enum EYE_STATE {EYE_CLOSE, EYE_OPEN, EYE_RANDOM, EYE_UNKNOWN}; 15 | 16 | SEETA_API explicit EyeStateDetector(const seeta::ModelSetting &setting); 17 | SEETA_API ~EyeStateDetector(); 18 | 19 | 20 | SEETA_API void Detect(const SeetaImageData &image, const SeetaPointF *points, EYE_STATE &leftstate, EYE_STATE &rightstate); 21 | 22 | 23 | enum Property { 24 | PROPERTY_NUMBER_THREADS = 4, 25 | PROPERTY_ARM_CPU_MODE = 5 26 | }; 27 | 28 | SEETA_API void set(Property property, double value); 29 | 30 | SEETA_API double get(Property property) const; 31 | 32 | 33 | private: 34 | EyeStateDetector(const EyeStateDetector &) = delete; 35 | const EyeStateDetector &operator=(const EyeStateDetector&) = delete; 36 | 37 | private: 38 | class Implement; 39 | Implement *m_impl; 40 | }; 41 | } 42 | using namespace v6; 43 | } 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /include/seeta/FaceAntiSpoofing.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/watt1010/Seetaface6JNI_cmake/2af06e354675f67c67d8b4d14968d8b6c1938518/include/seeta/FaceAntiSpoofing.h -------------------------------------------------------------------------------- /include/seeta/FaceDetector.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by kier on 19-4-24. 3 | // 4 | 5 | #ifndef INC_SEETA_FACEDETECTOR_H 6 | #define INC_SEETA_FACEDETECTOR_H 7 | 8 | #include "seeta/Common/Struct.h" 9 | #include "seeta/CFaceInfo.h" 10 | #include "seeta/SeetaFaceDetectorConfig.h" 11 | 12 | namespace seeta { 13 | namespace SEETA_FACE_DETECTOR_NAMESPACE_VERSION { 14 | class FaceDetector { 15 | public: 16 | using self = FaceDetector; 17 | 18 | enum Property { 19 | PROPERTY_MIN_FACE_SIZE, 20 | PROPERTY_THRESHOLD, 21 | PROPERTY_MAX_IMAGE_WIDTH, 22 | PROPERTY_MAX_IMAGE_HEIGHT, 23 | PROPERTY_NUMBER_THREADS, 24 | 25 | PROPERTY_ARM_CPU_MODE = 0x101, 26 | }; 27 | 28 | SEETA_API explicit FaceDetector(const SeetaModelSetting &setting); 29 | 30 | SEETA_API ~FaceDetector(); 31 | 32 | SEETA_API explicit FaceDetector(const self *other); 33 | 34 | SEETA_API SeetaFaceInfoArray detect(const SeetaImageData &image) const; 35 | 36 | std::vector detect_v2(const SeetaImageData &image) const { 37 | auto faces = this->detect(image); 38 | return std::vector(faces.data, faces.data + faces.size); 39 | } 40 | 41 | SEETA_API void set(Property property, double value); 42 | 43 | SEETA_API double get(Property property) const; 44 | 45 | private: 46 | FaceDetector(const FaceDetector &) = delete; 47 | 48 | const FaceDetector &operator=(const FaceDetector &) = delete; 49 | 50 | private: 51 | class Implement; 52 | 53 | Implement *m_impl; 54 | }; 55 | } 56 | using namespace SEETA_FACE_DETECTOR_NAMESPACE_VERSION; 57 | } 58 | 59 | #endif //INC_SEETA_FACEDETECTOR_H 60 | -------------------------------------------------------------------------------- /include/seeta/FaceLandmarker.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by kier on 19-7-16. 3 | // 4 | 5 | #ifndef SEETA_FACELANDMARKER_FACELANDMARKER_H 6 | #define SEETA_FACELANDMARKER_FACELANDMARKER_H 7 | 8 | #include "seeta/Common/Struct.h" 9 | #include "seeta/SeetaFaceLandmarkerConfig.h" 10 | 11 | namespace seeta { 12 | namespace SEETA_FACE_LANDMARKER_NAMESPACE_VERSION { 13 | class FaceLandmarker { 14 | public: 15 | using self = FaceLandmarker; 16 | 17 | SEETA_API explicit FaceLandmarker(const SeetaModelSetting &setting); 18 | SEETA_API ~FaceLandmarker(); 19 | 20 | SEETA_API FaceLandmarker(const self *other); 21 | 22 | SEETA_API int number() const; 23 | 24 | SEETA_API void mark(const SeetaImageData &image, const SeetaRect &face, SeetaPointF *points) const; 25 | 26 | SEETA_API void mark(const SeetaImageData &image, const SeetaRect &face, SeetaPointF *points, int32_t *mask) const; 27 | 28 | std::vector mark(const SeetaImageData &image, const SeetaRect &face) const { 29 | std::vector points(this->number()); 30 | mark(image, face, points.data()); 31 | return points; 32 | } 33 | 34 | class PointWithMask { 35 | public: 36 | SeetaPointF point; 37 | bool mask; 38 | }; 39 | 40 | std::vector mark_v2(const SeetaImageData &image, const SeetaRect &face) const { 41 | std::vector points(this->number()); 42 | std::vector masks(this->number()); 43 | mark(image, face, points.data(), masks.data()); 44 | std::vector point_with_masks(this->number()); 45 | for (int i = 0; i < this->number(); ++i) { 46 | point_with_masks[i].point = points[i]; 47 | point_with_masks[i].mask = masks[i]; 48 | } 49 | return point_with_masks; 50 | } 51 | 52 | private: 53 | FaceLandmarker(const FaceLandmarker &) = delete; 54 | const FaceLandmarker &operator=(const FaceLandmarker&) = delete; 55 | 56 | private: 57 | class Implement; 58 | Implement *m_impl; 59 | }; 60 | } 61 | using namespace SEETA_FACE_LANDMARKER_NAMESPACE_VERSION; 62 | } 63 | 64 | #endif //SEETA_FACELANDMARKER_FACELANDMARKER_H 65 | -------------------------------------------------------------------------------- /include/seeta/GenderPredictor.h: -------------------------------------------------------------------------------- 1 | #ifndef SEETA_GENDER_PREDICTOR_H 2 | #define SEETA_GENDER_PREDICTOR_H 3 | 4 | #include "seeta/Common/Struct.h" 5 | 6 | #define SEETA_AGE_PREDICTOR_MAJOR_VERSION 6 7 | #define SEETA_AGE_PREDICTOR_MINOR_VERSION 0 8 | #define SEETA_AGE_PREDICTOR_SINOR_VERSION 0 9 | 10 | namespace seeta { 11 | namespace v6 { 12 | class GenderPredictor { 13 | public: 14 | 15 | enum Property { 16 | PROPERTY_NUMBER_THREADS = 4, 17 | PROPERTY_ARM_CPU_MODE = 5 18 | }; 19 | 20 | enum GENDER 21 | { 22 | MALE, 23 | FEMALE 24 | }; 25 | 26 | SEETA_API explicit GenderPredictor(const SeetaModelSetting &setting); 27 | SEETA_API ~GenderPredictor(); 28 | 29 | SEETA_API int GetCropFaceWidth() const; 30 | SEETA_API int GetCropFaceHeight() const; 31 | SEETA_API int GetCropFaceChannels() const; 32 | SEETA_API bool CropFace(const SeetaImageData &image, const SeetaPointF *points, SeetaImageData &face) const; 33 | 34 | SEETA_API bool PredictGender(const SeetaImageData &image, GENDER &gender) const; 35 | 36 | SEETA_API bool PredictGenderWithCrop(const SeetaImageData &image, const SeetaPointF *points, GENDER &gender) const; 37 | 38 | SEETA_API void set(Property property, double value); 39 | 40 | SEETA_API double get(Property property) const; 41 | 42 | private: 43 | GenderPredictor(const GenderPredictor &) = delete; 44 | const GenderPredictor &operator=(const GenderPredictor&) = delete; 45 | 46 | private: 47 | class Implement; 48 | Implement *m_impl; 49 | }; 50 | } 51 | using namespace v6; 52 | } 53 | 54 | #endif //SEETA_GENDER_PREDICTOR_H 55 | -------------------------------------------------------------------------------- /include/seeta/MaskDetector.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "seeta/Common/Struct.h" 4 | #include 5 | #include 6 | 7 | namespace seeta 8 | { 9 | namespace v2 10 | { 11 | class MaskDetector { 12 | public: 13 | /** 14 | * \brief initialize `MaskDetector` 15 | * \param setting one specifc model, or zero model 16 | */ 17 | SEETA_API explicit MaskDetector(const seeta::ModelSetting &setting = seeta::ModelSetting() ); 18 | 19 | SEETA_API ~MaskDetector(); 20 | 21 | /** 22 | * detect if face with mask 23 | * @param image original image 24 | * @param face position of face 25 | * @param score mask confidence 26 | * @return true for with mask (score >= 0.5) 27 | */ 28 | SEETA_API bool detect(const SeetaImageData &image, const SeetaRect &face, float *score = nullptr); 29 | 30 | private: 31 | MaskDetector(const MaskDetector &other ) = delete; 32 | const MaskDetector &operator=(const MaskDetector &other ) = delete; 33 | 34 | private: 35 | class Implement; 36 | Implement *m_impl; 37 | }; 38 | } 39 | using namespace v2; 40 | } 41 | 42 | -------------------------------------------------------------------------------- /include/seeta/PoseEstimator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "seeta/Common/Struct.h" 4 | #include 5 | #include 6 | 7 | #define SEETA_POSE_ESTIMATOR_MAJOR_VERSION 6 8 | #define SEETA_POSE_ESTIMATOR_MINOR_VERSION 0 9 | #define SEETA_POSE_ESTIMATOR_SINOR_VERSION 0 10 | 11 | namespace seeta 12 | { 13 | namespace v6 14 | { 15 | class PoseEstimator { 16 | public: 17 | enum Axis 18 | { 19 | YAW = 0, 20 | PITCH = 1, 21 | ROLL = 2, 22 | }; 23 | 24 | enum Property { 25 | PROPERTY_NUMBER_THREADS = 4, 26 | PROPERTY_ARM_CPU_MODE = 5 27 | }; 28 | 29 | /** 30 | * \brief initialize `PoseEstimator` 31 | * \param setting one specifc model, or zero model 32 | */ 33 | SEETA_API explicit PoseEstimator( const seeta::ModelSetting &setting = seeta::ModelSetting() ); 34 | 35 | SEETA_API ~PoseEstimator(); 36 | 37 | 38 | /** 39 | * \brief Feed image to `PoseEstimator` 40 | * \param image The orginal image 41 | * \param face The face location 42 | */ 43 | SEETA_API void Feed( const SeetaImageData &image, const SeetaRect &face ) const; 44 | 45 | /** 46 | * \brief get angle on given axis 47 | * \param axis \sa `Axis`: YAW, PITCH, or ROLL 48 | * \return angle on given axis 49 | * \note Must `Feed` image and face first. 50 | */ 51 | SEETA_API float Get( Axis axis ) const; 52 | 53 | /** 54 | * \brief Get angle from given face on image 55 | * \param image The orginal image 56 | * \param face The face location 57 | * \param [out] yaw angle on axis yaw 58 | * \param [out] pitch angle on axis pitch 59 | * \param [out] roll angle on axis roll 60 | * \note yaw, pitch or roll can be nullptr 61 | */ 62 | SEETA_API void Estimate( const SeetaImageData &image, const SeetaRect &face, float *yaw, float *pitch, float *roll ) const; 63 | 64 | 65 | SEETA_API void set(Property property, double value); 66 | 67 | SEETA_API double get(Property property) const; 68 | 69 | 70 | private: 71 | PoseEstimator( const PoseEstimator &other ) = delete; 72 | const PoseEstimator &operator=( const PoseEstimator &other ) = delete; 73 | 74 | private: 75 | class Implement; 76 | Implement *m_impl; 77 | }; 78 | } 79 | using namespace v6; 80 | } 81 | 82 | -------------------------------------------------------------------------------- /include/seeta/QualityOfBrightness.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by kier on 2019-07-24. 3 | // 4 | 5 | #ifndef SEETA_QUALITYEVALUATOR_QUALITYOFBRIGHTNESS_H 6 | #define SEETA_QUALITYEVALUATOR_QUALITYOFBRIGHTNESS_H 7 | 8 | #include "QualityStructure.h" 9 | 10 | namespace seeta { 11 | namespace v3 { 12 | class QualityOfBrightness : public QualityRule { 13 | public: 14 | using self = QualityOfBrightness; 15 | using supper = QualityRule; 16 | 17 | /** 18 | * Construct with recommend parameters 19 | */ 20 | SEETA_API QualityOfBrightness(); 21 | /** 22 | * 23 | * @param v0 24 | * @param v1 25 | * @param v2 26 | * @param v3 27 | * [0, v0) and [v3, ~) => LOW 28 | * [v0, v1) and [v2, v3) => MEDIUM 29 | * [v1, v2) => HIGH 30 | */ 31 | SEETA_API QualityOfBrightness(float v0, float v1, float v2, float v3); 32 | 33 | SEETA_API ~QualityOfBrightness() override; 34 | 35 | SEETA_API QualityResult check( 36 | const SeetaImageData &image, 37 | const SeetaRect &face, 38 | const SeetaPointF *points, 39 | const int32_t N) override; 40 | 41 | private: 42 | QualityOfBrightness(const QualityOfBrightness &) = delete; 43 | QualityOfBrightness &operator=(const QualityOfBrightness &) = delete; 44 | 45 | private: 46 | void *m_data; 47 | }; 48 | } 49 | using namespace v3; 50 | } 51 | 52 | #endif //SEETA_QUALITYEVALUATOR_QUALITYOFBRIGHTNESS_H 53 | -------------------------------------------------------------------------------- /include/seeta/QualityOfClarity.h: -------------------------------------------------------------------------------- 1 | #ifndef SEETA_QUALITYEVALUATOR_QUALITYOFCLARITY_H 2 | #define SEETA_QUALITYEVALUATOR_QUALITYOFCLARITY_H 3 | #include "QualityStructure.h" 4 | 5 | namespace seeta { 6 | namespace v3 { 7 | class QualityOfClarity : public QualityRule { 8 | public: 9 | using self = QualityOfClarity; 10 | using supper = QualityRule; 11 | 12 | /** 13 | * Construct with recommanded parameters 14 | */ 15 | SEETA_API QualityOfClarity(); 16 | 17 | /* 18 | *@param low 19 | *@param high 20 | *[0, low)=> LOW 21 | *[low, high)=> MEDIUM 22 | *[high, ~)=> HIGH 23 | */ 24 | SEETA_API QualityOfClarity(float low, float high); 25 | 26 | SEETA_API ~QualityOfClarity() override; 27 | 28 | SEETA_API QualityResult check( 29 | const SeetaImageData &image, 30 | const SeetaRect &face, 31 | const SeetaPointF* points, 32 | const int32_t num) override; 33 | 34 | private: 35 | QualityOfClarity(const QualityOfClarity &) = delete; 36 | QualityOfClarity &operator=(const QualityOfClarity &) = delete; 37 | private: 38 | void* m_data; 39 | 40 | }; 41 | } 42 | using namespace v3; 43 | } 44 | #endif -------------------------------------------------------------------------------- /include/seeta/QualityOfIntegrity.h: -------------------------------------------------------------------------------- 1 | #ifndef SEETA_QUALITYEVALUATOR_QUALITYOFINTEGRITY_H 2 | #define SEETA_QUALITYEVALUATOR_QUALITYOFINTEGRITY_H 3 | #include "QualityStructure.h" 4 | 5 | namespace seeta { 6 | namespace v3 { 7 | class QualityOfIntegrity : public QualityRule { 8 | public: 9 | using self = QualityOfIntegrity; 10 | using supper = QualityRule; 11 | 12 | SEETA_API QualityOfIntegrity(); 13 | 14 | /* 15 | * shift_thresh image outside to inner's ratio 16 | * face inner high => HIGH 17 | * face between low and high => MEDIUM 18 | * face beyond low => LOW 19 | */ 20 | SEETA_API QualityOfIntegrity(float low, float high); 21 | 22 | SEETA_API ~QualityOfIntegrity() override; 23 | 24 | SEETA_API QualityResult check( 25 | const SeetaImageData &image, 26 | const SeetaRect &face, 27 | const SeetaPointF* points, 28 | const int32_t num) override; 29 | 30 | private: 31 | QualityOfIntegrity(const QualityOfIntegrity &) = delete; 32 | QualityOfIntegrity &operator=(const QualityOfIntegrity &) = delete; 33 | private: 34 | void* m_data; 35 | 36 | }; 37 | } 38 | using namespace v3; 39 | } 40 | #endif -------------------------------------------------------------------------------- /include/seeta/QualityOfLBN.h: -------------------------------------------------------------------------------- 1 | #ifndef SEETA_QUALITYEVALUATOR_QUALITYOFLBN_H 2 | #define SEETA_QUALITYEVALUATOR_QUALITYOFLBN_H 3 | 4 | 5 | #include "seeta/Common/Struct.h" 6 | #include 7 | #include 8 | 9 | #define SEETA_POSE_ESTIMATOR_MAJOR_VERSION 6 10 | #define SEETA_POSE_ESTIMATOR_MINOR_VERSION 0 11 | #define SEETA_POSE_ESTIMATOR_SINOR_VERSION 0 12 | 13 | namespace seeta 14 | { 15 | namespace v6 16 | { 17 | class QualityOfLBN { 18 | public: 19 | enum LIGHTSTATE 20 | { 21 | BRIGHT = 0, 22 | DARK = 1 23 | //NORMAL = 2 24 | }; 25 | 26 | enum BLURSTATE 27 | { 28 | CLEAR = 0, 29 | BLUR = 1 30 | //SERIOUSBLUR = 2 31 | }; 32 | 33 | enum NOISESTATE 34 | { 35 | HAVENOISE = 0, 36 | NONOISE = 1 37 | }; 38 | 39 | enum Property { 40 | PROPERTY_NUMBER_THREADS = 4, 41 | PROPERTY_ARM_CPU_MODE = 5, 42 | PROPERTY_LIGHT_THRESH = 10, 43 | PROPERTY_BLUR_THRESH = 11, 44 | PROPERTY_NOISE_THRESH = 12 45 | }; 46 | 47 | /** 48 | * \brief initialize `QualityOfLBN` 49 | * \param setting one specifc model, or zero model 50 | */ 51 | SEETA_API explicit QualityOfLBN( const seeta::ModelSetting &setting = seeta::ModelSetting() ); 52 | 53 | SEETA_API ~QualityOfLBN(); 54 | 55 | 56 | /** 57 | * \brief Get angle from given face on image 58 | * \param image The orginal image 59 | * \param points face location array,size must is 68 60 | * \param [out] LIGHTSTATE 61 | * \param [out] BLURSTATE 62 | * \param [out] NOISESTATE 63 | * \note light, blur or noise can be nullptr 64 | */ 65 | SEETA_API void Detect( const SeetaImageData &image, const SeetaPointF *points, int *light, int *blur, int *noise ) const; 66 | 67 | 68 | SEETA_API void set(Property property, double value); 69 | SEETA_API double get(Property property) const; 70 | 71 | 72 | private: 73 | QualityOfLBN( const QualityOfLBN &other ) = delete; 74 | const QualityOfLBN &operator=( const QualityOfLBN &other ) = delete; 75 | 76 | private: 77 | class Implement; 78 | Implement *m_impl; 79 | }; 80 | } 81 | using namespace v6; 82 | } 83 | 84 | #endif 85 | -------------------------------------------------------------------------------- /include/seeta/QualityOfPose.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by kier on 2019-07-24. 3 | // 4 | 5 | #ifndef SEETA_QUALITYEVALUATOR_QUALITYOFPOSE_H 6 | #define SEETA_QUALITYEVALUATOR_QUALITYOFPOSE_H 7 | 8 | #include "QualityStructure.h" 9 | 10 | namespace seeta { 11 | namespace v3 { 12 | class QualityOfPose : public QualityRule { 13 | public: 14 | using self = QualityOfPose; 15 | using supper = QualityRule; 16 | 17 | /** 18 | * Construct with recommend parameters 19 | */ 20 | SEETA_API QualityOfPose(); 21 | 22 | SEETA_API ~QualityOfPose() override; 23 | 24 | SEETA_API QualityResult check( 25 | const SeetaImageData &image, 26 | const SeetaRect &face, 27 | const SeetaPointF *points, 28 | const int32_t N) override; 29 | 30 | private: 31 | QualityOfPose(const QualityOfPose &) = delete; 32 | QualityOfPose &operator=(const QualityOfPose &) = delete; 33 | 34 | private: 35 | void *m_data; 36 | }; 37 | } 38 | using namespace v3; 39 | } 40 | 41 | #endif //SEETA_QUALITYEVALUATOR_QUALITYOFPOSE_H 42 | -------------------------------------------------------------------------------- /include/seeta/QualityOfPoseEx.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by kier on 2019-07-24. 3 | // 4 | 5 | #ifndef SEETA_QUALITYEVALUATOR_QUALITYOFPOSEEX_H 6 | #define SEETA_QUALITYEVALUATOR_QUALITYOFPOSEEX_H 7 | 8 | #include "QualityStructure.h" 9 | 10 | namespace seeta { 11 | namespace v3 { 12 | 13 | class QualityOfPoseEx : public QualityRule { 14 | public: 15 | 16 | enum PROPERTY 17 | { 18 | YAW_LOW_THRESHOLD = 0, 19 | YAW_HIGH_THRESHOLD = 1, 20 | PITCH_LOW_THRESHOLD = 2, 21 | PITCH_HIGH_THRESHOLD = 3, 22 | ROLL_LOW_THRESHOLD = 4, 23 | ROLL_HIGH_THRESHOLD = 5 24 | }; 25 | 26 | using self = QualityOfPoseEx; 27 | using supper = QualityRule; 28 | 29 | /** 30 | * Construct with recommend parameters 31 | */ 32 | SEETA_API QualityOfPoseEx(const SeetaModelSetting &setting); 33 | 34 | SEETA_API ~QualityOfPoseEx() override; 35 | 36 | SEETA_API QualityResult check( 37 | const SeetaImageData &image, 38 | const SeetaRect &face, 39 | const SeetaPointF *points, 40 | const int32_t N) override; 41 | 42 | SEETA_API bool check( 43 | const SeetaImageData &image, 44 | const SeetaRect &face, 45 | const SeetaPointF *points, 46 | const int32_t N, 47 | float &yaw, 48 | float &pitch, 49 | float &roll); 50 | 51 | 52 | SEETA_API float get(PROPERTY property); 53 | 54 | SEETA_API void set(PROPERTY property, float value); 55 | private: 56 | QualityOfPoseEx(const QualityOfPoseEx &) = delete; 57 | QualityOfPoseEx &operator=(const QualityOfPoseEx &) = delete; 58 | 59 | private: 60 | void *m_data; 61 | float m_yaw_low; 62 | float m_pitch_low; 63 | float m_roll_low; 64 | 65 | float m_yaw_high; 66 | float m_pitch_high; 67 | float m_roll_high; 68 | }; 69 | } 70 | using namespace v3; 71 | } 72 | 73 | #endif //SEETA_QUALITYEVALUATOR_QUALITYOFPOSEEX_H 74 | -------------------------------------------------------------------------------- /include/seeta/QualityOfResolution.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by kier on 2019-07-24. 3 | // 4 | 5 | #ifndef SEETA_QUALITYEVALUATOR_QUALITYOFRESOLUTION_H 6 | #define SEETA_QUALITYEVALUATOR_QUALITYOFRESOLUTION_H 7 | 8 | #include "QualityStructure.h" 9 | 10 | namespace seeta { 11 | namespace v3 { 12 | class QualityOfResolution : public QualityRule { 13 | public: 14 | using self = QualityOfResolution; 15 | using supper = QualityRule; 16 | 17 | /** 18 | * Construct with recommend parameters 19 | */ 20 | SEETA_API QualityOfResolution(); 21 | 22 | /** 23 | * 24 | * @param low 25 | * @param high 26 | * [0, low) and [v3, ~) => LOW 27 | * [low, high) and [v2, v3) => MEDIUM 28 | * [high, ~) => HIGH 29 | */ 30 | SEETA_API QualityOfResolution(float low, float high); 31 | 32 | SEETA_API ~QualityOfResolution() override; 33 | 34 | SEETA_API QualityResult check( 35 | const SeetaImageData &image, 36 | const SeetaRect &face, 37 | const SeetaPointF *points, 38 | const int32_t N) override; 39 | 40 | private: 41 | QualityOfResolution(const QualityOfResolution &) = delete; 42 | QualityOfResolution &operator=(const QualityOfResolution &) = delete; 43 | 44 | private: 45 | void *m_data; 46 | }; 47 | } 48 | using namespace v3; 49 | } 50 | 51 | #endif //SEETA_QUALITYEVALUATOR_QUALITYOFRESOLUTION_H 52 | -------------------------------------------------------------------------------- /include/seeta/QualityStructure.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by kier on 19-7-24. 3 | // 4 | 5 | #ifndef SEETA_QULITY_EVALUATOR_QULITY_STRUCTURE_H 6 | #define SEETA_QULITY_EVALUATOR_QULITY_STRUCTURE_H 7 | 8 | #include "seeta/Common/Struct.h" 9 | 10 | namespace seeta { 11 | namespace v3 { 12 | enum QualityLevel { 13 | LOW = 0, 14 | MEDIUM = 1, 15 | HIGH = 2, 16 | }; 17 | 18 | class QualityResult { 19 | public: 20 | using self = QualityResult; 21 | 22 | QualityResult() = default; 23 | 24 | QualityResult(QualityLevel level, float score = 0) 25 | : level(level), score(score) {} 26 | 27 | QualityLevel level = LOW; ///< quality level 28 | float score = 0; ///< greater means better, no range limit 29 | }; 30 | 31 | struct QualityResultEx { 32 | int attr; 33 | QualityLevel level; ///< quality level 34 | float score; ///< greater means better, no range limit 35 | }; 36 | 37 | struct QualityResultExArray { 38 | int size; 39 | QualityResultEx *data; 40 | }; 41 | 42 | class QualityRule { 43 | public: 44 | using self = QualityRule; 45 | 46 | virtual ~QualityRule() = default; 47 | 48 | /** 49 | * 50 | * @param image original image 51 | * @param face face location 52 | * @param points landmark on face 53 | * @param N how many landmark on face given, normally 5 54 | * @return Quality result 55 | */ 56 | virtual QualityResult check( 57 | const SeetaImageData &image, 58 | const SeetaRect &face, 59 | const SeetaPointF *points, 60 | int32_t N) = 0; 61 | }; 62 | } 63 | using namespace v3; 64 | } 65 | 66 | #endif //SEETA_QULITY_EVALUATOR_QULITY_STRUCTURE_H 67 | -------------------------------------------------------------------------------- /include/seeta/SeetaFaceDetectorConfig.h: -------------------------------------------------------------------------------- 1 | #ifndef _INC_SEETA_FACE_DETECTOR_V6_ 2 | #define _INC_SEETA_FACE_DETECTOR_V6_ 3 | 4 | #define SEETA_FACE_DETECTOR_MAJOR_VERSION 6 5 | #define SEETA_FACE_DETECTOR_MINOR_VERSION 0 6 | #define SEETA_FACE_DETECTOR_SINOR_VERSION 0 7 | 8 | #define SEETA_FACE_DETECTOR_LIBRARY_NAME "SeetaFaceDetector" 9 | 10 | #define SEETA_FACE_DETECTOR_NAMESPACE_VERSION v6 11 | 12 | #endif // _INC_SEETA_FACE_DETECTOR_V6_ 13 | -------------------------------------------------------------------------------- /include/seeta/SeetaFaceLandmarkerConfig.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define SEETA_FACE_LANDMARKER_MAJOR_VERSION 6 4 | #define SEETA_FACE_LANDMARKER_MINOR_VERSION 0 5 | #define SEETA_FACE_LANDMARKER_SINOR_VERSION 0 6 | 7 | #define SEETA_FACE_LANDMARKER_LIBRARY_NAME "SeetaFaceLandmarker" 8 | 9 | #define SEETA_FACE_LANDMARKER_NAMESPACE_VERSION v6 10 | -------------------------------------------------------------------------------- /include/seeta/SeetaFaceRecognizerConfig.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define SEETA_FACE_RECOGNIZER_MAJOR_VERSION 6 4 | #define SEETA_FACE_RECOGNIZER_MINOR_VERSION 1 5 | #define SEETA_FACE_RECOGNIZER_SINOR_VERSION 0 6 | 7 | #define SEETA_FACE_RECOGNIZE_LIBRARY_NAME "SeetaFaceRecognizer" 8 | 9 | #define SEETA_FACE_RECOGNIZE_NAMESPACE_VERSION v6 10 | -------------------------------------------------------------------------------- /include/seeta/SeetaMaskDetectorConfig.h: -------------------------------------------------------------------------------- 1 | #ifndef _INC_SEETA_MASK_DETECTOR_V2_ 2 | #define _INC_SEETA_MASK_DETECTOR_V2_ 3 | 4 | #define SEETA_POSE_ESTIMATOR_MAJOR_VERSION 2 5 | #define SEETA_POSE_ESTIMATOR_MINOR_VERSION 0 6 | #define SEETA_POSE_ESTIMATOR_SINOR_VERSION 0 7 | 8 | #define SEETA_POSE_ESTIMATOR_LIBRARY_NAME "SeetaMaskDetector" 9 | 10 | #define SEETA_POSE_ESTIMATOR_NAMESPACE_VERSION v2 11 | 12 | #endif // _INC_SEETA_MASK_DETECTOR_V2_ 13 | -------------------------------------------------------------------------------- /include/seeta/SeetaMaskDetectorConfig.h.in: -------------------------------------------------------------------------------- 1 | #ifndef _INC_SEETA_MASK_DETECTOR_V@SeetaMaskDetector_VERSION_MAJOR@_ 2 | #define _INC_SEETA_MASK_DETECTOR_V@SeetaMaskDetector_VERSION_MAJOR@_ 3 | 4 | #define SEETA_POSE_ESTIMATOR_MAJOR_VERSION @SeetaMaskDetector_VERSION_MAJOR@ 5 | #define SEETA_POSE_ESTIMATOR_MINOR_VERSION @SeetaMaskDetector_VERSION_MINOR@ 6 | #define SEETA_POSE_ESTIMATOR_SINOR_VERSION @SeetaMaskDetector_VERSION_SINOR@ 7 | 8 | #define SEETA_POSE_ESTIMATOR_LIBRARY_NAME "@SeetaMaskDetector_NAME@" 9 | 10 | #define SEETA_POSE_ESTIMATOR_NAMESPACE_VERSION v@SeetaMaskDetector_VERSION_MAJOR@ 11 | 12 | #endif // _INC_SEETA_MASK_DETECTOR_V@SeetaMaskDetector_VERSION_MAJOR@_ -------------------------------------------------------------------------------- /jniLibs/armeabi-v7a/libSeetaAuthorize.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/watt1010/Seetaface6JNI_cmake/2af06e354675f67c67d8b4d14968d8b6c1938518/jniLibs/armeabi-v7a/libSeetaAuthorize.so -------------------------------------------------------------------------------- /jniLibs/armeabi-v7a/libSeetaFaceDetector600.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/watt1010/Seetaface6JNI_cmake/2af06e354675f67c67d8b4d14968d8b6c1938518/jniLibs/armeabi-v7a/libSeetaFaceDetector600.so -------------------------------------------------------------------------------- /jniLibs/armeabi-v7a/libSeetaFaceLandmarker600.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/watt1010/Seetaface6JNI_cmake/2af06e354675f67c67d8b4d14968d8b6c1938518/jniLibs/armeabi-v7a/libSeetaFaceLandmarker600.so -------------------------------------------------------------------------------- /jniLibs/armeabi-v7a/libSeetaFaceRecognizer600.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/watt1010/Seetaface6JNI_cmake/2af06e354675f67c67d8b4d14968d8b6c1938518/jniLibs/armeabi-v7a/libSeetaFaceRecognizer600.so -------------------------------------------------------------------------------- /jniLibs/armeabi-v7a/libTenniS.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/watt1010/Seetaface6JNI_cmake/2af06e354675f67c67d8b4d14968d8b6c1938518/jniLibs/armeabi-v7a/libTenniS.so -------------------------------------------------------------------------------- /jniLibs/armeabi-v7a/libopencv_java3.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/watt1010/Seetaface6JNI_cmake/2af06e354675f67c67d8b4d14968d8b6c1938518/jniLibs/armeabi-v7a/libopencv_java3.so -------------------------------------------------------------------------------- /jniLibs/centos/libSeetaAgePredictor600.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/watt1010/Seetaface6JNI_cmake/2af06e354675f67c67d8b4d14968d8b6c1938518/jniLibs/centos/libSeetaAgePredictor600.so -------------------------------------------------------------------------------- /jniLibs/centos/libSeetaAuthorize.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/watt1010/Seetaface6JNI_cmake/2af06e354675f67c67d8b4d14968d8b6c1938518/jniLibs/centos/libSeetaAuthorize.so -------------------------------------------------------------------------------- /jniLibs/centos/libSeetaEyeStateDetector200.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/watt1010/Seetaface6JNI_cmake/2af06e354675f67c67d8b4d14968d8b6c1938518/jniLibs/centos/libSeetaEyeStateDetector200.so -------------------------------------------------------------------------------- /jniLibs/centos/libSeetaFaceAntiSpoofingX600.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/watt1010/Seetaface6JNI_cmake/2af06e354675f67c67d8b4d14968d8b6c1938518/jniLibs/centos/libSeetaFaceAntiSpoofingX600.so -------------------------------------------------------------------------------- /jniLibs/centos/libSeetaFaceDetector600.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/watt1010/Seetaface6JNI_cmake/2af06e354675f67c67d8b4d14968d8b6c1938518/jniLibs/centos/libSeetaFaceDetector600.so -------------------------------------------------------------------------------- /jniLibs/centos/libSeetaFaceLandmarker600.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/watt1010/Seetaface6JNI_cmake/2af06e354675f67c67d8b4d14968d8b6c1938518/jniLibs/centos/libSeetaFaceLandmarker600.so -------------------------------------------------------------------------------- /jniLibs/centos/libSeetaFaceRecognizer610.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/watt1010/Seetaface6JNI_cmake/2af06e354675f67c67d8b4d14968d8b6c1938518/jniLibs/centos/libSeetaFaceRecognizer610.so -------------------------------------------------------------------------------- /jniLibs/centos/libSeetaFaceTracking600.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/watt1010/Seetaface6JNI_cmake/2af06e354675f67c67d8b4d14968d8b6c1938518/jniLibs/centos/libSeetaFaceTracking600.so -------------------------------------------------------------------------------- /jniLibs/centos/libSeetaGenderPredictor600.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/watt1010/Seetaface6JNI_cmake/2af06e354675f67c67d8b4d14968d8b6c1938518/jniLibs/centos/libSeetaGenderPredictor600.so -------------------------------------------------------------------------------- /jniLibs/centos/libSeetaPoseEstimation600.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/watt1010/Seetaface6JNI_cmake/2af06e354675f67c67d8b4d14968d8b6c1938518/jniLibs/centos/libSeetaPoseEstimation600.so -------------------------------------------------------------------------------- /jniLibs/centos/libSeetaQualityAssessor300.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/watt1010/Seetaface6JNI_cmake/2af06e354675f67c67d8b4d14968d8b6c1938518/jniLibs/centos/libSeetaQualityAssessor300.so -------------------------------------------------------------------------------- /jniLibs/centos/libtennis.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/watt1010/Seetaface6JNI_cmake/2af06e354675f67c67d8b4d14968d8b6c1938518/jniLibs/centos/libtennis.so -------------------------------------------------------------------------------- /jniLibs/centos/libtennis_haswell.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/watt1010/Seetaface6JNI_cmake/2af06e354675f67c67d8b4d14968d8b6c1938518/jniLibs/centos/libtennis_haswell.so -------------------------------------------------------------------------------- /jniLibs/centos/libtennis_pentium.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/watt1010/Seetaface6JNI_cmake/2af06e354675f67c67d8b4d14968d8b6c1938518/jniLibs/centos/libtennis_pentium.so -------------------------------------------------------------------------------- /jniLibs/centos/libtennis_sandy_bridge.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/watt1010/Seetaface6JNI_cmake/2af06e354675f67c67d8b4d14968d8b6c1938518/jniLibs/centos/libtennis_sandy_bridge.so --------------------------------------------------------------------------------