{"id":19722017,"url":"https://github.com/sensoranalyticsaus/ocd---opencv-motion-detector","last_synced_at":"2026-01-24T09:31:58.611Z","repository":{"id":224468568,"uuid":"571522484","full_name":"SensorAnalyticsAus/OCD---OpenCv-motion-Detector","owner":"SensorAnalyticsAus","description":"OCD - Motion-activated recorder for RTSP and usb cameras","archived":false,"fork":false,"pushed_at":"2025-11-16T02:10:53.000Z","size":275,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-16T03:22:41.950Z","etag":null,"topics":["camera","computer-vision","motion-detection","python3","rtsp","security-tools","usb"],"latest_commit_sha":null,"homepage":"","language":"Python","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/SensorAnalyticsAus.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":"2022-11-28T10:14:24.000Z","updated_at":"2025-11-16T02:10:56.000Z","dependencies_parsed_at":"2024-02-26T06:24:27.529Z","dependency_job_id":"e71611a8-c17e-4828-8249-0c96be396c7c","html_url":"https://github.com/SensorAnalyticsAus/OCD---OpenCv-motion-Detector","commit_stats":null,"previous_names":["sensoranalyticsaus/ocd---opencv-motion-detector"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/SensorAnalyticsAus/OCD---OpenCv-motion-Detector","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SensorAnalyticsAus%2FOCD---OpenCv-motion-Detector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SensorAnalyticsAus%2FOCD---OpenCv-motion-Detector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SensorAnalyticsAus%2FOCD---OpenCv-motion-Detector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SensorAnalyticsAus%2FOCD---OpenCv-motion-Detector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SensorAnalyticsAus","download_url":"https://codeload.github.com/SensorAnalyticsAus/OCD---OpenCv-motion-Detector/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SensorAnalyticsAus%2FOCD---OpenCv-motion-Detector/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28723233,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-24T08:27:05.734Z","status":"ssl_error","status_checked_at":"2026-01-24T08:27:01.197Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["camera","computer-vision","motion-detection","python3","rtsp","security-tools","usb"],"created_at":"2024-11-11T23:16:14.522Z","updated_at":"2026-01-24T09:31:58.605Z","avatar_url":"https://github.com/SensorAnalyticsAus.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OCD Simple Motion Detection NVR\n\n## About\nOCD3 is a software network video recorder. Key features: \n* low-light motion-detection, \n* false-positive motion alert reduction,\n* AI summation of daily events (kmeans folder). \n\nIt can use any basic computer as a personal cloud for saving and displaying motion-detected images, videos etc. Outputs can also be used in custom image searching programs e.g. making event summary videos, gathering event stats \u003ca href=\"https://github.com/SensorAnalyticsAus/S-Big_Visual_Analytics\"\u003e video analytics \u003c/a\u003e and much more. \n\nTested with Tapo, Sricam, PiCam, Hiseeu, and Macbook Pro cameras. The program is quite stable once started - can run for months uninterrupted. Once the program starts up, program parameters e.g. motion sensitivity and disk use can be tailored to meet the site requirements. \n\n${\\textsf{\\color{red}NB}}$ :\nBash shell scripts in `kmeans/`folder are RaspberryPi OS/Linux specif. Also some files in it may require editing paths at the top. Using these scripts on MacOS bash will need some tweaking. Alternatively `train-km.py` and `predict-km.py` produce `ffnames.txt` containing full paths to images selected by KMeans over the user specified time window (`train-km.py` arg3 and arg4).\n\n### Demo\n* \u003ca href=\"https://youtu.be/SsAoOSjJwRs\"\u003eOCD2 night vision\u003c/a\u003e\n\n## What's New (in reverse chronological order)\n* Support for [KM-GEN](https://github.com/SensorAnalyticsAus/KM-GEN) added.\n* Support for python virtual environment added.\n* `sautils` updated to ver 3.2. A major bug in `kmeans` which restricted the use of image classification to OCD camera filename format has been relaxed. Now any filename which contains timestamp as YYYYMMDD-HHMMSS will generally work.\n* Bug fixes.\n* Version 3 has an updated motion detection scheme, which is more accurate and works better in low-light conditions.\n* A heuristic to minimise excessive frame capture.\n* `MD.log` for KMeans clustering.\n* `images_cn/` for saving contoured b/w versions of motion-detected images. Handy to know what caused motion-detection and where it occurred. \n* Option to increase motion-detection sensitivity after dark.\n* Multiple cameras can be motion-detected with suitable mods to *cam??* filenames.\n* `crtl3-cam01` can be used to control `driver3-cam01.py` with *start|stop|restart* arguments e.g. `crontab -e` with line, `@reboot /home/saauser/bin/ctrl-cam01 start`). \n* A rpi4b with internal SSD (\u003ca href=\"https://www.amazon.com/Argon-Raspberry-Support-B-Key-Compatible/dp/B08MJ3CSW7/ref=sr_1_1_sspa?crid=16TYRP9YTSGYD\u0026keywords=argon+one+m.2+case+for+raspberry+pi+4\u0026qid=1677735790\u0026sprefix=argon+one+%2Caps%2C313\u0026sr=8-1-spons\u0026psc=1\u0026spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUEzQVRBTE5DME1BQjc5JmVuY3J5cHRlZElkPUEwMTUzMzY1MVRGSlpHV0lVVU9PUyZlbmNyeXB0ZWRBZElkPUEwNzk1MzYzMjdRNDBLUUpSVDk4TyZ3aWRnZXROYW1lPXNwX2F0ZiZhY3Rpb249Y2xpY2tSZWRpcmVjdCZkb05vdExvZ0NsaWNrPXRydWU=argon\"\u003e argon one M2\u003c/a\u003e. enclosure) can support three camera streams quite easily.\n* Version 1 has even less resource requirements and almost as good (most of my less-critical cameras still use it).\n\n## Getting Started\n\n### Prerequisites\n* raspberry pi 4b or a debian linux/mac PC (windows with cygwin may work - not tested)\n* python 3.6 or higher\n* work-around for accessing a rtsp stream with udp transport only remotely, \u003ca href=\"https://github.com/SensorAnalyticsAus/remote_rtsp\"\u003eSensorAnalyticsAu/remote_rtsp\u003c/a\u003e\n\nRemember to pip install numpy before installing opencv.\n\n```\npython -m pip install -U pip\npython -m pip install -U scikit-image \npip install opencv-python\npip install shutils\npip install -U scikit-learn (for kmeans)\npip install matplotlib\n\nsudo apt update\nsudo apt upgrade\nsudo apt install screen\nsudo apt install ffmpeg\n```\n\n### Edit Settings\n\nEdit `config3.py` file according to your requirements. If in doubt retain default values where appropriate.\n\nEdit paths in the beginning of \n```\nctrl3-cam01.sh\ndriver3-cam01.py\nkmeans/predict-km.py\nkmeans/daily-driver\nmoviefrm-list\nmoviefrm-list-ni\n```\nIf using [KM-GEN](https://github.com/SensorAnalyticsAus/KM-GEN) for frame analysis (instead of `kmeans/`) then logging and gathering of additional b/w images can be turned off by setting `logg = 0` in `config3.py` as `KM-GEN` generates its own ml data for analysis.\n\n## Running the code\n```\n./ctrl3-cam01.sh start\n```\nTo stop:\n```\n./ctrl3-cam01.sh stop\n```\nTo check on program\n```\nscreen -r cam01\nctrl-a-d (to exit)\n```\n## Troubleshooting\nMain reasons for program not working. \n* A python dependency is missing.\n* Program paths are not correctly specified.\n* Incorrect camera url or camera is not working. Suggest testing camera url with VLC.\n* Captured image filenames either have no timestamp or their timestamp format does not match YYYYMMDD-HHMMSS format.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsensoranalyticsaus%2Focd---opencv-motion-detector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsensoranalyticsaus%2Focd---opencv-motion-detector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsensoranalyticsaus%2Focd---opencv-motion-detector/lists"}