Giter Site home page Giter Site logo

my-dlib-experiment's Introduction

alt text

It's a sample project running DLib in the Android app. For the details, please check out my blog, part 1, part 2 and part 3. Feel free to discuss it with me.

TL;DR

slide

my-dlib-experiment's People

Contributors

tcw165 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

Watchers

 avatar  avatar  avatar  avatar

my-dlib-experiment's Issues

listView null object reference

Attempt to invoke virtual method 'void android.widget.ListView.setAdapter(android.widget.ListAdapter)' on a null object reference

Could not find requested camera

Hi,
Thank for your article on medium, it helped me a lot.
But I have a problem when testing the demo app on android virtual devices:

  • When I choose the first function Detection using DLib, it can download and initialize the detector but after that it says: "Could not find the requested camera" (It's happened the same for the second function Detection using GoogleVision and Dlib but in Camera2 it can show one frame only)
    Note: I can use the camera (webcam) in camera app on this avd.

Can you give me some suggestions? Thanks!

Fatal signal 11 error

After face detection am getting the following error.
libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 10588 (Thread-4)
dont know what is the reason because am just now learning integration of dlib with your code. Please post the cause?

And this is the Logcat:

07-31 11:37:52.556 9845-9845/my.demo.dlib I/CameraSource: Camera auto focus is not supported on this device.
07-31 11:37:52.713 9845-9845/my.demo.dlib I/Choreographer: Skipped 40 frames! The application may be doing too much work on its main thread.
07-31 11:37:52.801 9845-10588/my.demo.dlib D/xyz: frame (w=320, h=240), preview (w=240, h=320)
07-31 11:37:52.801 9845-10588/my.demo.dlib D/skia: onFlyCompress
07-31 11:37:52.821 9845-10588/my.demo.dlib D/xyz: Extract bitmap (w=240, h=320) from YUV frame (took 19.569 ms)
07-31 11:37:52.821 9845-10588/my.demo.dlib I/dlib-jni:: L63: info.width=240, info.height=320
07-31 11:37:52.837 9845-10588/my.demo.dlib I/dlib-jni:: L407: input image (w=240.000000, h=320.000000) is read (took 16.133 ms)
07-31 11:37:59.448 9845-10588/my.demo.dlib I/dlib-jni:: L420: Number of faces detected: 0 (took 6610.470 ms)
L469: Convert faces to protobuf message (took 0.044 ms)
07-31 11:37:59.473 9845-10588/my.demo.dlib D/xyz: Detect 0 face with landmarks (took 6652.268 ms)
Process of detecting faces and landmarks done (took 6673.464 ms)
07-31 11:37:59.474 9845-10588/my.demo.dlib D/xyz: Ready to render 0 faces
frame (w=320, h=240), preview (w=240, h=320)
07-31 11:37:59.475 9845-10588/my.demo.dlib D/skia: onFlyCompress
07-31 11:37:59.483 9845-10588/my.demo.dlib D/xyz: Extract bitmap (w=240, h=320) from YUV frame (took 8.306 ms)
07-31 11:37:59.483 9845-10588/my.demo.dlib I/dlib-jni:: L63: info.width=240, info.height=320
07-31 11:37:59.515 9845-10588/my.demo.dlib I/dlib-jni:: L407: input image (w=240.000000, h=320.000000) is read (took 32.091 ms)
07-31 11:38:06.169 9845-10588/my.demo.dlib I/dlib-jni:: L420: Number of faces detected: 1 (took 6654.046 ms)
07-31 11:38:06.171 9845-10588/my.demo.dlib A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 10588 (Thread-4)

face recognition

have you tried dlib_face_recognition_resnet_model_v1 this model to get 128 vector dimension to perform face recognition?

Errors during application compilation

On mac, app dont want to compile.

It seems that is it berried somewhere in cache files. Any idea how to resolve this issue?

/Users/xxx/.gradle/caches/transforms-1/files-1.1/lib-widget-release.aar/dae56a7f680c0ce1e1f86cd366ad0946/res/drawable/bg_oval_white.xml
Error:error: resource color/white (aka my.demo.dlib.test:color/white) not found.
Error:resource color/white (aka my.demo.dlib.test:color/white) not found.
/Users/xxx/.gradle/caches/transforms-1/files-1.1/lib-widget-release.aar/dae56a7f680c0ce1e1f86cd366ad0946/res/drawable/bg_round_rect_accent.xml
Error:error: resource color/colorAccent (aka my.demo.dlib.test:color/colorAccent) not found.
Error:resource color/colorAccent (aka my.demo.dlib.test:color/colorAccent) not found.
/Users/xxx/.gradle/caches/transforms-1/files-1.1/lib-widget-release.aar/dae56a7f680c0ce1e1f86cd366ad0946/res/drawable/icon_arrow_down.xml
Error:error: resource color/colorAccent (aka my.demo.dlib.test:color/colorAccent) not found.
Error:resource color/colorAccent (aka my.demo.dlib.test:color/colorAccent) not found.
/Users/xxx/.gradle/caches/transforms-1/files-1.1/lib-widget-release.aar/dae56a7f680c0ce1e1f86cd366ad0946/res/drawable/icon_arrow_up.xml
Error:error: resource color/colorAccent (aka my.demo.dlib.test:color/colorAccent) not found.
Error:resource color/colorAccent (aka my.demo.dlib.test:color/colorAccent) not found.
/Users/xxx/.gradle/caches/transforms-1/files-1.1/lib-widget-release.aar/dae56a7f680c0ce1e1f86cd366ad0946/res/drawable/icon_list_black_24px.xml
Error:error: resource color/colorAccent (aka my.demo.dlib.test:color/colorAccent) not found.
Error:resource color/colorAccent (aka my.demo.dlib.test:color/colorAccent) not found.
/Users/xxx/.gradle/caches/transforms-1/files-1.1/lib-widget-release.aar/dae56a7f680c0ce1e1f86cd366ad0946/res/drawable/icon_settings.xml
Error:error: resource color/colorAccent (aka my.demo.dlib.test:color/colorAccent) not found.
Error:resource color/colorAccent (aka my.demo.dlib.test:color/colorAccent) not found.
/Users/xxx/.gradle/caches/transforms-1/files-1.1/lib-widget-release.aar/dae56a7f680c0ce1e1f86cd366ad0946/res/drawable/icon_toolbar_camera.xml
Error:error: resource color/colorAccent (aka my.demo.dlib.test:color/colorAccent) not found.
Error:resource color/colorAccent (aka my.demo.dlib.test:color/colorAccent) not found.
/Users/xxx/.gradle/caches/transforms-1/files-1.1/lib-widget-release.aar/dae56a7f680c0ce1e1f86cd366ad0946/res/drawable/icon_toolbar_close.xml
Error:error: resource color/colorAccent (aka my.demo.dlib.test:color/colorAccent) not found.
Error:resource color/colorAccent (aka my.demo.dlib.test:color/colorAccent) not found.
/Users/xxx/.gradle/caches/transforms-1/files-1.1/lib-widget-release.aar/dae56a7f680c0ce1e1f86cd366ad0946/res/layout/sample_card_menu_item.xml
Error:error: resource color/colorPrimary (aka my.demo.dlib.test:color/colorPrimary) not found.
Error:error: resource color/textColorPrimary (aka my.demo.dlib.test:color/textColorPrimary) not found.
Error:error: resource color/textColorSecondary (aka my.demo.dlib.test:color/textColorSecondary) not found.
Error:resource color/colorPrimary (aka my.demo.dlib.test:color/colorPrimary) not found.
Error:resource color/textColorPrimary (aka my.demo.dlib.test:color/textColorPrimary) not found.
Error:resource color/textColorSecondary (aka my.demo.dlib.test:color/textColorSecondary) not found.
/Users/xxx/.gradle/caches/transforms-1/files-1.1/lib-widget-release.aar/dae56a7f680c0ce1e1f86cd366ad0946/res/layout/view_drop_down_menu.xml
Error:error: resource color/bg_translucent_black (aka my.demo.dlib.test:color/bg_translucent_black) not found.
Error:resource color/bg_translucent_black (aka my.demo.dlib.test:color/bg_translucent_black) not found.
/Users/xxx/.gradle/caches/transforms-1/files-1.1/lib-widget-release.aar/dae56a7f680c0ce1e1f86cd366ad0946/res/layout/view_numbered_button.xml
Error:error: resource color/colorAccent (aka my.demo.dlib.test:color/colorAccent) not found.
Error:resource color/colorAccent (aka my.demo.dlib.test:color/colorAccent) not found.
/Users/xxx/.gradle/caches/transforms-1/files-1.1/lib-widget-release.aar/dae56a7f680c0ce1e1f86cd366ad0946/res/layout/view_spinner_album_item.xml
Error:error: resource color/colorAccent (aka my.demo.dlib.test:color/colorAccent) not found.
Error:resource color/colorAccent (aka my.demo.dlib.test:color/colorAccent) not found.
Error:failed linking file resources.
Error:java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:Execution failed for task ':demo-dlib:processDebugAndroidTestResources'.
> Failed to execute aapt

Not able to compile the project (Rxjava problem).

Hi:
I am not able to compile the java part of the project.
Error says:

method compose in class Observable cannot be applied to given types;
required: ObservableTransformer<CAP#1,R>
found: ObservableTransformer<Object,CAP#2>
reason: cannot infer type-variable(s) R
(argument mismatch; ObservableTransformer<Object,CAP#2> cannot be converted to ObservableTransformer<CAP#1,R>)
where R,T are type-variables:
R extends Object declared in method compose(ObservableTransformer<T,R>)
T extends Object declared in class Observable
where CAP#1,CAP#2 are fresh type-variables:
CAP#1 extends Object from capture of ?
CAP#2 extends Object from capture of ?

The error comes from CompositeDisposable compose function.

       mDisposables.add(
           grantPermission()
                .compose(waitForTextureSurfaceReady())
               .compose(openCameraToGetCameraDevice())
               .compose(createCaptureSession())
               .compose(setCaptureRequestAndObserveAvailableImage())
               .onErrorReturn(new Function<Throwable, Object>() {
                   @Override
                   public Object apply(Throwable throwable) throws Exception {
                       return UiModel.failed(throwable);
                   }
               })
               .ofType(UiModel.class)
               .subscribe(new Consumer<UiModel>() {
                   @Override
                   public void accept(UiModel viewModel)
                       throws Exception {
                       // Error handling.
                       if (viewModel.error != null) {
                           showAlertDialog(viewModel.error);
                       }
                   }
               }));

I see the function waitForTextureSurfaceReady():

    private ObservableTransformer<?, Object> waitForTextureSurfaceReady() {
        return new ObservableTransformer<Object, Object>() {
            @Override
            public ObservableSource<Object> apply(Observable<Object> upstream) {
                return upstream
                    .ofType(Boolean.class)
                    .flatMap(new Function<Boolean, ObservableSource<Object>>() {
                        @Override
                        public ObservableSource<Object> apply(Boolean granted)
                            throws Exception {
                            if (granted) {
                                return new TextureViewObservable(mCameraView).ofType(Object.class);
                            } else {
                                throw new IllegalStateException("Permission is not granted.");
                            }
                        }
                    });
            }
        };
    }

The gradle configuration is the same of the repository, and I installed the build tools that you are using.
I am very new in MVP patterns and with rxjava. I see that you use this functions for granting the runtime permissions.

So, is there any way to solve this easily?

Thanks in advance.
Unai.

could not resolve all dependencies for configuration.

Hi,
the demo project in tech-pic-collage series helped me a lot to learn about face detection to get landmarks and dlib integration but when i tried to integrate the sample app it shows me the following error.

org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':demo-dlib'.
org.gradle.api.artifacts.ResolveException: Could not resolve all dependencies for configuration ':demo-dlib:_debugCompile'.

org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':lib-dlib'.

Expected NDK STL shared object file at C:\Users{username}\AppData\Local\Android\Sdk\ndk-bundle\sources\cxx-stl\llvm-libc++\libs\armeabi\libc++_shared.so

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.