{"id":17219002,"url":"https://github.com/jjoe64/android-motion-detection","last_synced_at":"2025-06-11T23:03:58.927Z","repository":{"id":49148461,"uuid":"72941951","full_name":"jjoe64/android-motion-detection","owner":"jjoe64","description":"Camera motion detector example ","archived":false,"fork":false,"pushed_at":"2024-06-02T12:55:03.000Z","size":107,"stargazers_count":66,"open_issues_count":10,"forks_count":31,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-11T11:52:02.583Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jjoe64.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2016-11-05T17:24:36.000Z","updated_at":"2025-03-24T02:22:48.000Z","dependencies_parsed_at":"2025-04-11T11:26:01.891Z","dependency_job_id":null,"html_url":"https://github.com/jjoe64/android-motion-detection","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jjoe64/android-motion-detection","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jjoe64%2Fandroid-motion-detection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jjoe64%2Fandroid-motion-detection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jjoe64%2Fandroid-motion-detection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jjoe64%2Fandroid-motion-detection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jjoe64","download_url":"https://codeload.github.com/jjoe64/android-motion-detection/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jjoe64%2Fandroid-motion-detection/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259360795,"owners_count":22845818,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-15T03:48:52.988Z","updated_at":"2025-06-11T23:03:58.911Z","avatar_url":"https://github.com/jjoe64.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Android Motion Detector\n\n## functional description\n\nThe preview of the camera will be drawn on a 1x1 pixel surface. At this point the preview input of the camera will be analysed at a given interval.\nTo detect a movement the picture will be dived into tiles. For each tile the average brightness will be calculated. If a average value of a single tile differs from the previous value, a motion is registered.\n\n## integration\n\n1. Copy all classes of the subpackge `motiondetection` into your project. Adapt the package names.\n2. There must be a `SurfaceView` in your layout:\n```\n\u003cSurfaceView\n    android:layout_width=\"1dp\"\n    android:layout_height=\"1dp\"\n    android:id=\"@+id/surfaceView\" /\u003e\n```\n3. create instance of `MotionDetector`\n```\nmotionDetector = new MotionDetector(this, (SurfaceView) findViewById(R.id.surfaceView));\n```\n4. call lifecycle methods: `motionDetector.onResume() and .onPause()`\n5. register callbacks\n```\nmotionDetector.setMotionDetectorCallback(new MotionDetectorCallback() {\n    @Override\n    public void onMotionDetected() {\n        txtStatus.setText(\"Bewegung erkannt\");\n    }\n\n    @Override\n    public void onTooDark() {\n        txtStatus.setText(\"Zu dunkel hier\");\n    }\n});\n```\n\n## customize parameters\n\nthere are some important parameters that can be adjusted at runtime.\n\n| Method | Description | Default |\n| --- | --- | --- |\n| motionDetector.setCheckInterval(500); | milliseconds between pictures to compare. less = less energy cos t | 500 |\n| motionDetector.setLeniency(20); | maximal tolerence of difference in pictures. less = more sensible | 20 |\n| motionDetector.setMinLuma(1000); | minimum brightness. if lower the callback onTooDark is called | 1000 |\n\n## notice\n\n1. Permissions must be given in the AndroidManifest.xml\n```\n\u003cuses-feature android:name=\"android.hardware.camera\" /\u003e\n\u003cuses-permission android:name=\"android.permission.CAMERA\"/\u003e\n```\n2. if `targetSdkVersion` is greater than 21 you have to implement Runtime Permissions\n3. the detection is only running while the activity is active. It may make sense to build in a Wake-Lock.\n4. Parts of the code is taken from https://github.com/phishman3579/android-motion-detection\n\n## license\n\nJonas Gehring\nApache license 2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjjoe64%2Fandroid-motion-detection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjjoe64%2Fandroid-motion-detection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjjoe64%2Fandroid-motion-detection/lists"}