GithubHelp home page GithubHelp logo

android-motion-detection's People

Contributors

jjoe64 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-motion-detection's Issues

Missing License

Hi Jonas,
could you add license information for the android-motion-detection code?

Thanks and cheers,
Raimund

Exception while using images instead of camera

An indexOutofBounds Exception is thrown if the detector is fed with continuous images instead of camera as the input source.
consume(bitmap,bitmap.width,bitmap.height) results in an indexoutofbounds exception at
int y = (0xff & (yuv420sp[yp])) - 16; in decodeYUV420SPtoLuma method
Are the width and height related to camera instead of the bitmap.

Crash: NullPointerException

Just wanted to log this crash I'm seeing on my 10" Fire Tablet (running Lineage OS)

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'android.hardware.Camera$Parameters android.hardware.Camera.getParameters()' on a null object reference
       at com.jjoe64.motiondetection.motiondetection.MotionDetector$2.surfaceChanged(MotionDetector.java:194)
       at android.view.SurfaceView.updateWindow(SurfaceView.java:630)
       at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:161)
       at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:944)
       at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2205)
       at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1254)
       at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6344)
       at android.view.Choreographer$CallbackRecord.run(Choreographer.java:874)
       at android.view.Choreographer.doCallbacks(Choreographer.java:686)
       at android.view.Choreographer.doFrame(Choreographer.java:621)
       at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:860)
       at android.os.Handler.handleCallback(Handler.java:751)
       at android.os.Handler.dispatchMessage(Handler.java:95)
       at android.os.Looper.loop(Looper.java:154)
       at android.app.ActivityThread.main(ActivityThread.java:6186)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)

Camera Switch

I tried to make this switch camera, but for some reasons it won't switch the camera

Detect motion for long distance.

Hello,

I am using this library for motion detection. It is work fine. But I am facing issue related to distance of motion detection. Also I have tried for different Leniency values .This library not cover enough long distance for motion detection.
Is there any why to detect motion for long distance. Could you please tell me motion detection depends of which feature of camera.

On Capturing picture app is crashing

on calling : camera.takePicture(null, null, pictureCallback);
the app is crashing
04-17 11:57:35.281 25292-25292/com.jjoe64.motiondetection E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.jjoe64.motiondetection, PID: 25292
java.lang.RuntimeException: takePicture failed
at android.hardware.Camera.native_takePicture(Native Method)
at android.hardware.Camera.takePicture(Camera.java:1865)
at android.hardware.Camera.takePicture(Camera.java:1810)
at com.jjoe64.motiondetection.MainActivity.captureImageOnMotionDetected(MainActivity.java:73)
at com.jjoe64.motiondetection.MainActivity$1.onMotionDetected(MainActivity.java:52)
at com.jjoe64.motiondetection.motiondetection.MotionDetector$MotionDetectorThread$2.run(MotionDetector.java:55)
at android.os.Handler.handleCallback(Handler.java:822)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5811)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:681)
04-17 11:57:39.875 25292-25308/com.jjoe64.motiondetection W/art: Suspending all threads took: 13.631ms
04-17 11:57:44.306 25292-25306/com.jjoe64.motiondetection I/System: FinalizerDaemon: finalize objects = 161

Motion detector callback working only in debug mode

Hi, need some help... i need to capture video recording on every motion detected, this is my relevant code:

void motionDetectorCallback(){
        motionDetector.setMotionDetectorCallback(new MotionDetectorCallback() {
            @RequiresApi(api = Build.VERSION_CODES.KITKAT)
            @Override    public void onMotionDetected() {
                try {
                    initRoutine();
                }catch(NullPointerException ignored){}   Log.w(TAG,"Motion detected");
            }
            @Override
            public void onTooDark() {    Log.w(TAG,"Too dark here"    ); }  })  ;}


    @RequiresApi(api = Build.VERSION_CODES.KITKAT)
    void initRoutine() {
        if (!firstRun) {
            enoughTimeHasPassed = false;
            long now = System.currentTimeMillis();
            if ( (now -lastRecordingTime) > 500 )
                enoughTimeHasPassed = true;
        }
        if (smbConnection.isConnected() & !recording & serviceRunning & enoughTimeHasPassed)
{            textRecordingStatus.setText("RECORDING");
            textRecordingStatus.setTextColor(Color.GREEN);
            firstRun = false;
            Log.w(TAG,"RECORD STARTED");
            record();  }}


    @RequiresApi(api = Build.VERSION_CODES.KITKAT)
    private void record() {
        if (!recording) {
            recording = true;
            prepareVideoRecorder();
            recorder.start();
            Handler handler = new Handler();
            handler.postDelayed(new Runnable() {
                @Override
                public void run() { stopRecorder(); }  }, time*1000);  }   }

What is happening is that if i run the app normally the first cycle the app uses the callback correctly and record is launched, after x time the recording autostops trough stopRecorder() function. Here the motion detector callback is not running anymore, while if i'm testing the app in debug mode everything works perfectly.
I have the same problem if i start the app in debug mode and then disconnect the phone
What is the problem? O.o

edit: testing the problem i implemented a callback to log the callback, and i can see that the service is running, the only problem is that nextData is always null on MotionDetector after the first run, maybe is MediaRecorder overwriting access to the camera? why is it working in debug mode then? I even tried disabling proguard

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.