Giter Site home page Giter Site logo

tzutalin / dlib-android-app Goto Github PK

View Code? Open in Web Editor NEW
673.0 41.0 249.0 302.86 MB

:dragon: Android app to demo dlib-android(https://github.com/tzutalin/dlib-android). Use the prebuilt shared-lib built from dlib-android

License: Apache License 2.0

Java 99.40% Shell 0.48% Makefile 0.12%

dlib-android-app's Introduction

dlib-android-app

Build Status Download

See http://dlib.net for the main project documentation.

See dlib-android for JNI lib. Refer to dlib-android/jni/jnilib_ex

Grap the source

$ git clone https://github.com/tzutalin/dlib-android-app.git

Features

  • Support HOG detector

  • HOG Face detection

  • Facial Landmark/Expression

Demo

Demo video

Build

Android app

  • Open Android studio to build

  • Use command line to build (Optional)

On Windows platforms, type this command:

$ gradlew.bat assembleDebug

On Mac OS and Linux platforms, type these commands:

$ ./gradlew assembleDebug

or

$ make ; make install

Update shared lib (Optional)

You can build shared library from dlib-android

Copy the shared library to ./dlib/src/main/jniLibs/

Try directly

Download and install the apk

$ adb install demo/app-debug.apk

Otherwise, import the library to your build.gradle

repositories {
    maven {
        url 'https://dl.bintray.com/tzutalin/maven'
    }
}

dependencies {
    implementation 'com.tzutalin.dlib-android-app:dlib:1.0.4'
}

Sample code

Facial landmark detection

FaceDet faceDet = new FaceDet(Constants.getFaceShapeModelPath());
Bitmap bitmap = BitmapFactory.decodeFile("Image Path");
List<VisionDetRet> results = faceDet.detect(bitmap);
for (final VisionDetRet ret : results) {
    String label = ret.getLabel();
    int rectLeft = ret.getLeft();
    int rectTop = ret.getTop();
    int rectRight = ret.getRight();
    int rectBottom = ret.getBottom();
    // Get 68 landmark points
    ArrayList<Point> landmarks = ret.getFaceLandmarks();
    for (Point point : landmarks) {
        int pointX = point.x;
        int pointY = point.y;
    }
}

Pedestrian detection

Pedestrian pedestrianDet = new PedestrianDet();
List<VisionDetRet> personList = pedestrianDet.detect(imgPath);

License

License

dlib-android-app's People

Contributors

flyingzhao avatar jjjtui avatar longyany avatar mpomeroy avatar tzutalin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dlib-android-app's Issues

Nexus 6P Android 6.0.1 crashes when start CmaeraConnectionFragment

Hi Darrenl,

I always got this crash. Also not sure Not exist /sdcard/person.svm is what we expected.
Here is the full log:

05-05 13:14:36.790 5733-5733/com.tzutalin.dlibtest V/CameraConnectionFragment: ⇠ startBackgroundThread [2ms]
05-05 13:14:36.859 5733-5733/com.tzutalin.dlibtest V/CameraConnectionFragment: ⇢ openCamera(width=1440, height=2308)
05-05 13:14:36.859 5733-5733/com.tzutalin.dlibtest V/CameraConnectionFragment: ⇢ setUpCameraOutputs(width=1440, height=2308)
05-05 13:14:36.859 5733-5733/com.tzutalin.dlibtest I/CameraManagerGlobal: Connecting to camera service
05-05 13:14:36.870 5733-5733/com.tzutalin.dlibtest V/CameraConnectionFragment: ⇢ chooseOptimalSize(choices=[3264x2448, 3200x2400, 2592x1944, 2688x1512, 2048x1536, 1920x1080, 1600x1200, 1440x1080, 1280x960, 1280x768, 1280x720, 1024x768, 800x600, 864x480, 800x480, 720x480, 640x480, 640x360, 352x288, 320x240, 176x144, 160x120], width=1440, height=2308, aspectRatio=3264x2448)
05-05 13:14:36.870 5733-5733/com.tzutalin.dlibtest I/CameraConnectionFragment: Adding size: 3264x2448
05-05 13:14:36.870 5733-5733/com.tzutalin.dlibtest I/CameraConnectionFragment: Adding size: 3200x2400
05-05 13:14:36.870 5733-5733/com.tzutalin.dlibtest I/CameraConnectionFragment: Adding size: 2592x1944
05-05 13:14:36.870 5733-5733/com.tzutalin.dlibtest I/CameraConnectionFragment: Adding size: 2688x1512
05-05 13:14:36.870 5733-5733/com.tzutalin.dlibtest I/CameraConnectionFragment: Adding size: 2048x1536
05-05 13:14:36.870 5733-5733/com.tzutalin.dlibtest I/CameraConnectionFragment: Adding size: 1920x1080
05-05 13:14:36.870 5733-5733/com.tzutalin.dlibtest I/CameraConnectionFragment: Adding size: 1600x1200
05-05 13:14:36.870 5733-5733/com.tzutalin.dlibtest I/CameraConnectionFragment: Adding size: 1440x1080
05-05 13:14:36.870 5733-5733/com.tzutalin.dlibtest I/CameraConnectionFragment: Adding size: 1280x960
05-05 13:14:36.870 5733-5733/com.tzutalin.dlibtest I/CameraConnectionFragment: Adding size: 1280x768
05-05 13:14:36.870 5733-5733/com.tzutalin.dlibtest I/CameraConnectionFragment: Adding size: 1280x720
05-05 13:14:36.870 5733-5733/com.tzutalin.dlibtest I/CameraConnectionFragment: Adding size: 1024x768
05-05 13:14:36.870 5733-5733/com.tzutalin.dlibtest I/CameraConnectionFragment: Adding size: 800x600
05-05 13:14:36.871 5733-5733/com.tzutalin.dlibtest I/CameraConnectionFragment: Adding size: 864x480
05-05 13:14:36.871 5733-5733/com.tzutalin.dlibtest I/CameraConnectionFragment: Adding size: 800x480
05-05 13:14:36.871 5733-5733/com.tzutalin.dlibtest I/CameraConnectionFragment: Adding size: 720x480
05-05 13:14:36.871 5733-5733/com.tzutalin.dlibtest I/CameraConnectionFragment: Adding size: 640x480
05-05 13:14:36.871 5733-5733/com.tzutalin.dlibtest I/CameraConnectionFragment: Adding size: 640x360
05-05 13:14:36.871 5733-5733/com.tzutalin.dlibtest I/CameraConnectionFragment: Not adding size: 352x288
05-05 13:14:36.871 5733-5733/com.tzutalin.dlibtest I/CameraConnectionFragment: Not adding size: 320x240
05-05 13:14:36.871 5733-5733/com.tzutalin.dlibtest I/CameraConnectionFragment: Not adding size: 176x144
05-05 13:14:36.871 5733-5733/com.tzutalin.dlibtest I/CameraConnectionFragment: Not adding size: 160x120
05-05 13:14:36.871 5733-5733/com.tzutalin.dlibtest I/CameraConnectionFragment: Chosen size: 640x360
05-05 13:14:36.871 5733-5733/com.tzutalin.dlibtest V/CameraConnectionFragment: ⇠ chooseOptimalSize [1ms] = 640x360
05-05 13:14:36.871 5733-5733/com.tzutalin.dlibtest V/CameraConnectionFragment: ⇠ setUpCameraOutputs [12ms]
05-05 13:14:36.872 5733-5733/com.tzutalin.dlibtest V/CameraConnectionFragment: ⇢ configureTransform(viewWidth=1440, viewHeight=2308)
05-05 13:14:36.873 5733-5733/com.tzutalin.dlibtest V/CameraConnectionFragment: ⇠ configureTransform [0ms]
05-05 13:14:36.951 5733-5733/com.tzutalin.dlibtest D/CameraConnectionFragment: open Camera
05-05 13:14:36.952 5733-5733/com.tzutalin.dlibtest V/CameraConnectionFragment: ⇠ openCamera [92ms]
05-05 13:14:36.952 5733-6117/com.tzutalin.dlibtest V/CameraConnectionFragment: ⇢ createCameraPreviewSession() [Thread:"ImageListener"]
05-05 13:14:36.953 5733-6117/com.tzutalin.dlibtest I/CameraConnectionFragment: Opening camera preview: 640x360
05-05 13:14:36.964 5733-5733/com.tzutalin.dlibtest V/CameraConnectionFragment: ⇢ configureTransform(viewWidth=1298, viewHeight=2308)
05-05 13:14:36.964 5733-5733/com.tzutalin.dlibtest V/CameraConnectionFragment: ⇠ configureTransform [0ms]
05-05 13:14:36.975 5733-6117/com.tzutalin.dlibtest D/dlib: jniNativeClassInit success
05-05 13:14:36.976 5733-6117/com.tzutalin.dlibtest I/native: I/jni_face_det.cpp:145 jniInit
05-05 13:14:36.976 5733-6117/com.tzutalin.dlibtest I/native: I/detector.h:81 Model Path: /sdcard/person.svm
05-05 13:14:36.977 5733-6117/com.tzutalin.dlibtest I/native: I/detector.h:85 Not exist /sdcard/person.svm
05-05 13:14:36.977 5733-6117/com.tzutalin.dlibtest I/native: I/detector.h:149 Init mFaceDetector
05-05 13:14:37.013 5733-5775/com.tzutalin.dlibtest D/OpenGLRenderer: endAllStagingAnimators on 0x7f92eb7c00 (RippleDrawable) with handle 0x7f898456e0
05-05 13:14:39.787 5733-6117/com.tzutalin.dlibtest A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 6117 (ImageListener)```

how to get 5 points landmarks

I have run your android dlib in my project successfully. Thank you for your great work!

But I do not know how to get 5 points landmarks instead of 68 points. Is there a way to do this ?

The value of Time cost very increases when the screen is not being touched on Android 8.0 Oreo.

When not touching the screen compared to when touching the screen, the value of TimeCost is remarkably different. This issue did not occur on Android 6.0(Nexsus 7 Time cost : 100 - 90ms).

Test Envionment
device : Nexus 5X
Android version : 8.1.0
apk : https://github.com/tzutalin/dlib-android-app/blob/master/demo/app-debug.apk

When touching the screen Time cost : 55 - 45ms
When not touching the screen Time cost : 170 - 155ms

2018-03-20 1 16 14
2018-03-20 1 16 25

eye open/close detection

Hi,
How I can implement eye open/close detection as I am not able to get any java function for detecting eye separately using dlib. Only eye landmark we can set for eye open as six landmarks and eye close as 4 landmarks. But how can I set those condition using 68_facial_landmark.dat model is directly using here in this java coding.I am not able to get the information to find how landmark can be fix for eye detection.
Can someone please assist me on this.

Thanks

I cannot obtain Landmark points

I've tried to integrate this library by several ways, but none works.

Regarding gradle, the library only "works" if I use v.1.0.2 (which is not published in your git main page); otherwise I get crash: "Fatal signal 6 (SIGABRT), code -6 in tid 32077 (Thread-12710)".
From your demo, if I import the dlib module to my project, it "works".

I say "works" because I only get the bound (Rect) of the faces, the "getFaceLandmark()" method returns 0 points and I don't know why :/
However, if I copy my code (an example with hardware.camera not with camera2) to the project of your demo, everything works fine, I get all Landmark points and Bounds and no crashes... and I don't understand why.
I've checked all gradle files, if any library is missing, but no... I checked AndroidManifest too... but I don't find anything strange...
Could you help me with this?

Error:Execution failed for task ':dlib:ndkBuild'.

import to Android Studio it will show this error:

is there any thing wrong of my env.

Error:Execution failed for task ':dlib:ndkBuild'.

A problem occurred starting process 'command 'idk-build''

Gradle update error

When I open the project and update its gradle its gave me following error;

Error:Cannot choose between the following configurations of project :dlib: - debugApiElements - debugRuntimeElements - releaseApiElements - releaseRuntimeElements All of them match the consumer attributes: - Configuration 'debugApiElements': - Found com.android.build.api.attributes.BuildTypeAttr 'debug' but wasn't required. - Found com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but wasn't required. - Found com.android.build.gradle.internal.dependency.VariantAttr 'debug' but wasn't required. - Found org.gradle.api.attributes.Usage 'java-api' but wasn't required. - Configuration 'debugRuntimeElements': - Found com.android.build.api.attributes.BuildTypeAttr 'debug' but wasn't required. - Found com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but wasn't required. - Found com.android.build.gradle.internal.dependency.VariantAttr 'debug' but wasn't required. - Found org.gradle.api.attributes.Usage 'java-runtime' but wasn't required. - Configuration 'releaseApiElements': - Found com.android.build.api.attributes.BuildTypeAttr 'release' but wasn't required. - Found com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but wasn't required. - Found com.android.build.gradle.internal.dependency.VariantAttr 'release' but wasn't required. - Found org.gradle.api.attributes.Usage 'java-api' but wasn't required. - Configuration 'releaseRuntimeElements': - Found com.android.build.api.attributes.BuildTypeAttr 'release' but wasn't required. - Found com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but wasn't required. - Found com.android.build.gradle.internal.dependency.VariantAttr 'release' but wasn't required. - Found org.gradle.api.attributes.Usage 'java-runtime' but wasn't required.

Getting HOG values

Hi, how can I get the HOG values for the face detected? I see that the description says that the library includes "Support HOG detector".

Thanks

Cannot find local variable 'point' and cannot detect landmark points

If I use z3 compact to detect it, I can get the 68 points.

However, I get 0 point in other devices like nexus 5x, z5 or one plus two.

The following is the code that I use to detect the face landmark point.

private Runnable landmarkDetection = new Runnable() {

    public void run() {
        // TODO Auto-generated method stu
        try {
            Canvas canvas = new Canvas(temp);
            canvas.drawBitmap(temp, new Matrix(), null);
            if (mFaceDet == null) {
                mFaceDet = new FaceDet(Constants.getFaceShapeModelPath());
            }
            List<VisionDetRet> faceList = mFaceDet.detect(path);
            if (faceList.size() > 0) {
                for (VisionDetRet ret : faceList) {
                    float width = 1080;
                    // By ratio scale
                    float aspectRatio = originalImg.getWidth() / (float) originalImg.getHeight();
                    float resizeRatio = 1;
                    final int MAX_SIZE = 1;
                    newWidth = 1080;
                    newHeight = 1380;
                    newHeight = Math.round(newWidth / aspectRatio);

                    if (originalImg.getWidth() > MAX_SIZE && originalImg.getHeight() > MAX_SIZE) {
                        originalImg = getResizedBitmap(originalImg, newWidth, newHeight);
                        resizeRatio = (float) originalImg.getWidth() / (float) width;
                        Log.d("resizeRatio ", resizeRatio + "");
                    }

                    ArrayList<Point> landmarks = ret.getFaceLandmarks();
                    int count = 0;
                    for (Point point : landmarks) {
                        float pointX = (point.x * resizeRatio);
                        float pointY = (point.y * resizeRatio);
                            landmark_pt_x.add(pointX);
                            landmark_pt_y.add(pointY);
                        Log.d(TAG, count + " " + pointX + " : " + pointY);
                        count++;

                        drawpoint(pointX, pointY, temp, canvas);
                    }
                    Log.d(TAG + " added landmark", count + "");
                }
            } else {
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        Toast.makeText(getApplicationContext(), "No face", Toast.LENGTH_SHORT).show();
                    }
                });
            }
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    imageView.setImageBitmap(originalImg);
                    progressDialog.dismiss();
                }
            });
        } catch (Exception e) {
            Log.e(TAG, e.toString());
        }
    }
};

I use debug mode in one plus two. It got the following error when it is running

   ArrayList<Point> landmarks = ret.getFaceLandmarks();

screen shot 2017-03-27 at 2 17 36 pm

Please give me some helps. Thank you very much.

App crash on start

The application is crashing on start and displays following log:

E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.tzutalin.dlibtest, PID: 30049
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.tzutalin.dlibtest/com.tzutalin.dlibtest.MainActivity_}: android.view.InflateException: Binary XML file line #27: Binary XML file line #27: Error inflating class android.support.design.widget.FloatingActionButton
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2666)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2727)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1478)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6121)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
Caused by: android.view.InflateException: Binary XML file line #27: Binary XML file line #27: Error inflating class android.support.design.widget.FloatingActionButton
Caused by: android.view.InflateException: Binary XML file line #27: Error inflating class android.support.design.widget.FloatingActionButton
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
at android.view.LayoutInflater.createView(LayoutInflater.java:645)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:292)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.tzutalin.dlibtest.MainActivity_.setContentView(MainActivity_.java:53)
at com.tzutalin.dlibtest.MainActivity_.onCreate(MainActivity_.java:44)
at android.app.Activity.performCreate(Activity.java:6682)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2619)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2727)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1478)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6121)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
Caused by: java.lang.NoSuchMethodError: No direct method (Landroid/widget/ImageView;Landroid/support/v7/widget/AppCompatDrawableManager;)V in class Landroid/support/v7/widget/AppCompatImageHelper; or its super classes (declaration of 'android.support.v7.widget.AppCompatImageHelper' appears in /data/app/com.tzutalin.dlibtest-1/base.apk)
at android.support.design.widget.FloatingActionButton.(FloatingActionButton.java:133)
at android.support.design.widget.FloatingActionButton.(FloatingActionButton.java:110)
at java.lang.reflect.Constructor.newInstance0(Native Method) 
at java.lang.reflect.Constructor.newInstance(Constructor.java:430) 
at android.view.LayoutInflater.createView(LayoutInflater.java:645) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:858) 
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:518) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:426) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:377) 
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:292) 
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
at com.tzutalin.dlibtest.MainActivity_.setContentView(MainActivity_.java:53) 
at com.tzutalin.dlibtest.MainActivity_.onCreate(MainActivity_.java:44) 
at android.app.Activity.performCreate(Activity.java:6682) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2619) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2727) 
at android.app.ActivityThread.-wrap12(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1478) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:154) 
at android.app.ActivityThread.main(ActivityThread.java:6121) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779) 

How to Use Detector on Full Camera Image and How to Use Front-Facing Camera?

Hi,

What code do I need to change in order to use the full-size image for the face detector and also for drawing the bounding box and landmarks?

I tried changing the face detector to use the full size bitmap as so:

//results = mFaceDet.detect(mCroppedBitmap);
results = mFaceDet.detect(mRGBframeBitmap);

However, the face detector is completely unable to detect a face. Please advise.

Also, do you know how I would change the code to use the front-facing camera? I'm very new to Android but found this suggested code snippet:

Intent launchIntent = new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA); launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); launchIntent.putExtra("android.intent.extras.CAMERA_FACING", android.hardware.Camera.CameraInfo.CAMERA_FACING_FRONT); launchIntent.putExtra("android.intent.extras.LENS_FACING_FRONT", 1); launchIntent.putExtra("android.intent.extra.USE_FRONT_CAMERA", true); startActivity(launchIntent);

Would this go under line 45 in CameraActivity.java?

Can you provide an interface to process raw camera data?

Thank you for your works!
In the compiled library you provided the interface jniBitmapDetect(Bitmap bitmap) and jniDetect(String path);,but I want to work with onPreviewFrame(byte[] data, Camera camera to skip the transformation from byte[] to bitmap
Can you provide an interface to process raw camera data? Or show me how to do this?
Thanks!

how to fix the crash on miniSdkVersion 17

1 NDK_TOOLCHAIN_VERSION := 4.9
2 #APP_PLATFORM := android-21
3 APP_PLATFORM := android-17
4 APP_STL := gnustl_static
5 APP_ABI := armeabi-v7a x86 x86_64#armeabi #all
6 APP_MODULE := libdlib

@tzutalin, I set the APP_PLATFORM := android-17, as above, and rebuild the libpeople_det.so, it always crash! log is same as the previous!
#2

Face landmark Cropping

Hi every one,

i have successfully configure this application in my android studio , I need help in cropping the face landmark, i have add the OpenCV in.my project but i don't how to crop the face landmarks.

i request you people please help me out from this problem.

Thanks

Errors:no member named 'nc' in 'cv::Mat'

Hi, I use Android Studio 2.2 to integrate Dlib 19.1 and OpenCV 3.1.0,but there are so many problems, like:
Error:error: no member named 'to_string' in namespace 'std'
Error:error: reference to 'rectangle' is ambiguous
Error:error: reference to 'rectangle' is ambiguous
Error:error: implicit instantiation of undefined template 'dlib::image_traitscv::Mat'
Error:error: no member named 'nc' in 'cv::Mat'
Error:error: no member named 'nr' in 'cv::Mat'
Error:error: implicit instantiation of undefined template 'dlib::image_traitscv::Mat'
Error:error: use of undeclared identifier 'image_data'
Error:error: use of undeclared identifier 'width_step'
Error:error: use of undeclared identifier 'num_rows'
Error:error: use of undeclared identifier 'num_columns'
Error:error: implicit instantiation of undefined template 'dlib::image_traitscv::Mat'
Error:error: no matching function for call to 'num_rows'
Error:error: implicit instantiation of undefined template 'dlib::image_traitscv::Mat'
Error:error: implicit instantiation of undefined template 'dlib::image_traitscv::Mat'
Error:error: no matching function for call to 'num_columns'
Error:error: no matching function for call to 'num_rows'
Error:Execution failed for task ':app:ndkBuild'.

Process 'command 'D:/Android/SDK/ndk-bundle/ndk-build.cmd'' finished with non-zero exit value 2

Cany anyone help me?
Thanks.

Wrong initialization of VisionDetRet class

Forgot to initialize correctly ArrayList<Point> in VisionDetRet.

The default constructor should be
VisionDetRet() { mLandmarkPoints = new ArrayList<>(); } insted of being completely empty.

Alternatively you can add the initialization right into the private field declaration.
Sorry for that it slipped away!

slow facial landmarks detection

Thanks for your great work. It is very useful. However, when I tried demo app to detect facial landmarks, it took more than 10s to finish the whole process for only one picture. Is there any configurations I need to notice? Or it is the normal speed?

Could not find c++_shared in all project

You have loaded a library c++_shared
System.loadLibrary("c++_shared");

But apk does not contain this .so file, also it is not available in project anywhere. So apk is crashing with error java.lang.RuntimeException: "c++_shared" not found; check that the correct native libraries are present in the APK.

Can i remove this library loading syntax?

can't init submodules

"git submodule update --init --recursive"

And without this command , it will build failed in Android studio.

Open Front Face Camera

How to Open Front Face Camera when ever i open camera its open back camera and in code the code shows the front camera code....

Dlib together with Javacv/opencv

Hi all,

did anyone get this together working? It seems that there are several issues.

I would appreciate it, if it could be on the roadmap to allow dlib to work together with javacv on android. Testet Javacv 1.3.3 and Android-Dlib 1.0.4

thanks

adding dependency to gradel throws error

After I add dependency to to gradel like this

compile 'com.tzutalin.dlib-android-app:dlib:1.0.3'
    

in andriod studio it says

Error:(28, 13) Failed to resolve: com.tzutalin.dlib-android-app:dlib:1.0.3

detect method is taking around 40 seconds to return faclist

Hi, many thanks for the great work it has been very helpful. I have one issue with performace. I taken the demoFaceDet method into my own project and when i call this line

List faceList = mFaceDet.detect(imgPath);

It takes around 40 seconds. I have tried putting android studio in release mode but that doesnt seem to help either. Any suggestions as to how I might improve performance?

it always crash !

it always crash after I select one picture, any picture!
when I runing it as debug mode, I saw it is keep the "Person and face detection", lasting few minutes , it stop working..

Crashes for some devices with Android 9

Crashes in FaceDet.detect are reported for specific Android 9 devices:

  • Sony Xperia XZ Premium (G8141), Android 9
  • Google Pixel XL (marlin), Android 9

Looks like lib crashes here:

jniutils::ConvertBitmapToRGBAMat(_JNIEnv*, _jobject*&, cv::Mat&, bool)

Any ideas how to fix this?

  #00  pc 0000000000022034  /system/lib64/libc.so (abort+116)
  #01  pc 0000000000096fac  /data/app/com.algr.gallerai-IJju6a-yjg8_eM99p1G4ag==/lib/arm64/libandroid_dlib.so (MessageLogger::~MessageLogger()+296)
  #02  pc 00000000000cce0c  /data/app/com.algr.gallerai-IJju6a-yjg8_eM99p1G4ag==/lib/arm64/libandroid_dlib.so (jniutils::ConvertBitmapToRGBAMat(_JNIEnv*, _jobject*&, cv::Mat&, bool)+1540)
  #03  pc 0000000000099bb8  /data/app/com.algr.gallerai-IJju6a-yjg8_eM99p1G4ag==/lib/arm64/libandroid_dlib.so (Java_com_tzutalin_dlib_FaceDet_jniBitmapDetect+284)
  #04  pc 000000000001fff4  /data/app/com.algr.gallerai-IJju6a-yjg8_eM99p1G4ag==/oat/arm64/base.odex (com.tzutalin.dlib.FaceDet.jniBitmapDetect [DEDUPED]+164)
  #05  pc 0000000000555d88  /system/lib64/libart.so (art_quick_invoke_stub+584)
  #06  pc 00000000000cf8c8  /system/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+200)
  #07  pc 000000000027fac0  /system/lib64/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+344)
  #08  pc 0000000000279ac8  /system/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+968)
  #09  pc 000000000052614c  /system/lib64/libart.so (MterpInvokeDirect+296)
  #10  pc 0000000000548514  /system/lib64/libart.so (ExecuteMterpImpl+14484)
  #11  pc 00000000002d6258  /data/app/com.algr.gallerai-IJju6a-yjg8_eM99p1G4ag==/oat/arm64/base.vdex (com.tzutalin.dlib.FaceDet.detect)
  #12  pc 00000000002537cc  /system/lib64/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEb.llvm.1430790321+488)
  #13  pc 00000000002592c0  /system/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+216)
  #14  pc 0000000000279aac  /system/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+940)
  #15  pc 0000000000527e50  /system/lib64/libart.so (MterpInvokeVirtualQuick+584)
  #16  pc 000000000054c194  /system/lib64/libart.so (ExecuteMterpImpl+29972)
  #17  pc 000000000024f8b0  /data/app/com.algr.gallerai-IJju6a-yjg8_eM99p1G4ag==/oat/arm64/base.vdex (com.algr.gallerai.util.FaceUtil.detectDlibFaceConfidence+8)
   #18  pc 00000000002537cc  /system/lib64/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEb.llvm.1430790321+488)
   #19  pc 00000000002592c0  /system/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+216)
   #20  pc 0000000000279aac  /system/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+940)
   #21  pc 0000000000526310  /system/lib64/libart.so (MterpInvokeStatic+204)
   #22  pc 0000000000548594  /system/lib64/libart.so (ExecuteMterpImpl+14612)
   #23  pc 000000000024d622  /data/app/com.algr.gallerai-IJju6a-yjg8_eM99p1G4ag==/oat/arm64/base.vdex (com.algr.gallerai.scan.ScanJobService.lambda$getScanTask$0$ScanJobService+1774)
   #24  pc 00000000002537cc  /system/lib64/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEb.llvm.1430790321+488)
   #25  pc 00000000002592c0  /system/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+216)
   #26  pc 0000000000279aac  /system/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+940)
   #27  pc 0000000000527e50  /system/lib64/libart.so (MterpInvokeVirtualQuick+584)
   #28  pc 000000000054c194  /system/lib64/libart.so (ExecuteMterpImpl+29972)
   #29  pc 000000000024c4e0  /data/app/com.algr.gallerai-IJju6a-yjg8_eM99p1G4ag==/oat/arm64/base.vdex (com.algr.gallerai.scan.ScanJobService$$Lambda$0.run+8)
   #30  pc 00000000002537cc  /system/lib64/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEb.llvm.1430790321+488)
   #31  pc 00000000005156a0  /system/lib64/libart.so (artQuickToInterpreterBridge+1020)
   #32  pc 000000000055eefc  /system/lib64/libart.so (art_quick_to_interpreter_bridge+92)
   #33  pc 000000000025d128  /system/framework/arm64/boot-core-oj.oat (java.lang.Thread.run+72)
   #34  pc 0000000000555d88  /system/lib64/libart.so (art_quick_invoke_stub+584)
   #35  pc 00000000000cf8c8  /system/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+200)
   #36  pc 000000000045d04c  /system/lib64/libart.so (art::(anonymous namespace)::InvokeWithArgArray(art::ScopedObjectAccessAlreadyRunnable const&, art::ArtMethod*, art::(anonymous namespace)::ArgArray*, art::JValue*, char const*)+104)
   #37  pc 000000000045e108  /system/lib64/libart.so (art::InvokeVirtualOrInterfaceWithJValues(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jmethodID*, jvalue*)+424)
   #38  pc 0000000000488fa4  /system/lib64/libart.so (art::Thread::CreateCallback(void*)+1120)
   #39  pc 000000000009202c  /system/lib64/libc.so (__pthread_start(void*)+36)
   #40  pc 00000000000238f0  /system/lib64/libc.so (__start_thread+68)

excellent works!

I always want to port dlib to android , so that we can enjoy powerful ability of detecting person and face of dlib when driving; it can alarm by audio or flashing when detected a persion in front of the car!

I found the app havn't geting image from the camera to real time detecting;
but I am expect in C++,C not java, hope you realize the function

I have an crash with some devices(Huawei, LG G6...) also in your example

in this line:
mFaceDet = new FaceDet(Constants.getFaceShapeModelPath());

2019-04-29 20:02:52.598 10331-10390/com.tzutalin.dlibtest A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 10390 (ImageListener)
2019-04-29 20:02:52.665 10403-10403/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
2019-04-29 20:02:52.665 10403-10403/? A/DEBUG: Build fingerprint: 'HUAWEI/VTR-L29/HWVTR:7.0/HUAWEIVTR-L29/C185B151:user/release-keys'
2019-04-29 20:02:52.665 10403-10403/? A/DEBUG: Revision: '0'
2019-04-29 20:02:52.665 10403-10403/? A/DEBUG: ABI: 'arm64'
2019-04-29 20:02:52.665 10403-10403/? A/DEBUG: pid: 10331, tid: 10390, name: ImageListener >>> com.tzutalin.dlibtest <<<
2019-04-29 20:02:52.665 10403-10403/? A/DEBUG: signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
2019-04-29 20:02:52.665 10403-10403/? A/DEBUG: x0 0000000000000000 x1 0000000000002896 x2 0000000000000006 x3 0000000000000008
2019-04-29 20:02:52.665 10403-10403/? A/DEBUG: x4 ffffffffffffffff x5 0000000000000000 x6 0000008000808080 x7 7362686364716f5e
2019-04-29 20:02:52.665 10403-10403/? A/DEBUG: x8 0000000000000083 x9 ffffffffffffffdf x10 0000000000000000 x11 0000000000000001
2019-04-29 20:02:52.665 10403-10403/? A/DEBUG: x12 ffffffffffffffff x13 0000000000000000 x14 ffffffffffffffff x15 ffffffffffffffff
2019-04-29 20:02:52.665 10403-10403/? A/DEBUG: x16 000000788b2deec8 x17 000000788b287c28 x18 0000000000000068 x19 000000786b0004f8
2019-04-29 20:02:52.665 10403-10403/? A/DEBUG: x20 0000000000000006 x21 000000786b000450 x22 0000000000000000 x23 000000785582d900
2019-04-29 20:02:52.665 10403-10403/? A/DEBUG: x24 00000078519f78c0 x25 01bbc02e7ccc01ff x26 000000785192e068 x27 01bbc02e7ccc01ff
2019-04-29 20:02:52.665 10403-10403/? A/DEBUG: x28 0000000000000002 x29 000000786affd470 x30 000000788b2850d0
2019-04-29 20:02:52.665 10403-10403/? A/DEBUG: sp 000000786affd450 pc 000000788b287c30 pstate 0000000060000000
2019-04-29 20:02:52.669 10403-10403/? A/DEBUG: backtrace:
2019-04-29 20:02:52.669 10403-10403/? A/DEBUG: #00 pc 000000000006bc30 /system/lib64/libc.so (tgkill+8)
2019-04-29 20:02:52.669 10403-10403/? A/DEBUG: #1 pc 00000000000690cc /system/lib64/libc.so (pthread_kill+64)
2019-04-29 20:02:52.669 10403-10403/? A/DEBUG: #2 pc 0000000000023e68 /system/lib64/libc.so (raise+24)
2019-04-29 20:02:52.669 10403-10403/? A/DEBUG: #3 pc 000000000001c8ec /system/lib64/libc.so (abort+52)
2019-04-29 20:02:52.669 10403-10403/? A/DEBUG: #4 pc 000000000058eddc /data/app/com.tzutalin.dlibtest-2/lib/arm64/libandroid_dlib.so (_ZN9__gnu_cxx27__verbose_terminate_handlerEv+348)
2019-04-29 20:02:52.670 10403-10403/? A/DEBUG: #5 pc 000000000053c2d0 /data/app/com.tzutalin.dlibtest-2/lib/arm64/libandroid_dlib.so (_ZN10__cxxabiv111__terminateEPFvvE+8)
2019-04-29 20:02:52.670 10403-10403/? A/DEBUG: #6 pc 000000000053c33c /data/app/com.tzutalin.dlibtest-2/lib/arm64/libandroid_dlib.so (_ZSt9terminatev+12)
2019-04-29 20:02:52.670 10403-10403/? A/DEBUG: #7 pc 000000000053c478 /data/app/com.tzutalin.dlibtest-2/lib/arm64/libandroid_dlib.so (__cxa_throw+136)
2019-04-29 20:02:52.670 10403-10403/? A/DEBUG: #8 pc 00000000000c1268 /data/app/com.tzutalin.dlibtest-2/lib/arm64/libandroid_dlib.so (_ZN4dlib11deserializeERNS_15shape_predictorERSi+252)
2019-04-29 20:02:52.670 10403-10403/? A/DEBUG: #9 pc 000000000009c728 /data/app/com.tzutalin.dlibtest-2/lib/arm64/libandroid_dlib.so (_ZN19DLibHOGFaceDetectorC2ERKSs+440)
2019-04-29 20:02:52.670 10403-10403/? A/DEBUG: #10 pc 000000000009c484 /data/app/com.tzutalin.dlibtest-2/lib/arm64/libandroid_dlib.so (Java_com_tzutalin_dlib_FaceDet_jniInit+168)
2019-04-29 20:02:52.670 10403-10403/? A/DEBUG: #11 pc 000000000045dea8 /data/app/com.tzutalin.dlibtest-2/oat/arm64/base.odex (offset 0x3ee000)

Do you have a solution for this????

I have a problem when I use the package 'dlib' in my project

Cannot resolve corresponding JNI function Java_com_tzutalin_dlib_FaceDet_jniNativeClassInit
Cannot resolve corresponding JNI function Java_com_tzutalin_dlib_FaceDet_jniInit
Cannot resolve corresponding JNI function Java_com_tzutalin_dlib_FaceDet_jniDeInit
Cannot resolve corresponding JNI function Java_com_tzutalin_dlib_FaceDet_jniBitmapDetect
Cannot resolve corresponding JNI function Java_com_tzutalin_dlib_FaceDet_jniDetect

I really need some help ! thx a lot

Lips detection

Hello
I need help to just detect lips of user and than change color of lips kindly guide me where to make changes in this code.
waiting for response.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.