jjoe64 / android-motion-detection Goto Github PK
View Code? Open in Web Editor NEWCamera motion detector example
License: Apache License 2.0
Camera motion detector example
License: Apache License 2.0
Hi Jonas,
could you add license information for the android-motion-detection code?
Thanks and cheers,
Raimund
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.
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)
I tried to make this switch camera, but for some reasons it won't switch the camera
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.
I want to get the position of the area where the motion detected, and I found your paintDifferences(int[] data)
in Comparer.java
.
Could you explain more about that?
I would like to know the following function for what purpose:
Private long lastCheck = 0;
Is located in MotionDetector.java
What is the value of it?
Thanks.
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
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.