{"id":15197050,"url":"https://github.com/rubberazer/darkpaw_motion_opencv","last_synced_at":"2026-01-31T06:31:52.350Z","repository":{"id":167353915,"uuid":"343894560","full_name":"Rubberazer/Darkpaw_motion_opencv","owner":"Rubberazer","description":"A little project in C/C++ for the Adeept Darkpaw robot","archived":false,"fork":false,"pushed_at":"2024-05-25T12:49:45.000Z","size":241,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-02T21:13:19.639Z","etag":null,"topics":["adeept","csrt","mongoose","mpu-6050","opencv","opencv4","pca9685","pid-controller","pigpio","raspberry-pi-camera","robotics-programming","tracking","ultrasonic-sensor-distance","video-streaming","web-server"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Rubberazer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2021-03-02T19:51:34.000Z","updated_at":"2024-05-25T12:49:48.000Z","dependencies_parsed_at":null,"dependency_job_id":"a427036d-9324-42b9-bad3-dd7c228f70d8","html_url":"https://github.com/Rubberazer/Darkpaw_motion_opencv","commit_stats":null,"previous_names":["rubberazer/darkpaw_motion_opencv"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rubberazer%2FDarkpaw_motion_opencv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rubberazer%2FDarkpaw_motion_opencv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rubberazer%2FDarkpaw_motion_opencv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rubberazer%2FDarkpaw_motion_opencv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Rubberazer","download_url":"https://codeload.github.com/Rubberazer/Darkpaw_motion_opencv/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241570921,"owners_count":19984002,"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":["adeept","csrt","mongoose","mpu-6050","opencv","opencv4","pca9685","pid-controller","pigpio","raspberry-pi-camera","robotics-programming","tracking","ultrasonic-sensor-distance","video-streaming","web-server"],"created_at":"2024-09-28T00:40:30.344Z","updated_at":"2026-01-31T06:31:52.332Z","avatar_url":"https://github.com/Rubberazer.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Darkpaw_motion_opencv\nA little project in C/C++ for the Adeept Darkpaw robot.\n\n[Playing](https://github.com/Rubberazer/Darkpaw_motion_opencv/assets/47650457/d74e66f9-015d-43ed-9e28-c8865e67b35d)\n\nBasically replaced the original maker's python code by my own C code -with a pinch of C++ for the OpenCV thread, I am using OpenCV to first detect and then follow objects. I added an ultrasound sensor (the usual HC-SR04) as there were empty slots in the robot HAT, so it doesn't hit the walls. At the moment the robot can move: forward, backward, turn right and left totally fine, is able to detect, track and follow objects. It also incorporates a MPU6050 gyroscope \u0026 accelerometer that comes with the kit, at the moment those values are stored along with the distance measured by the ultrasound sensor in a csv file with a time stamp. Version 3 also incorporates a web server.\n\n08/03/2021: Added PID regulator to compensate drifting and to steer the robot, working with the gyroscope data as feedback to the PID. \n\n11/03/2021: Added an OpenCV MOG2 background substractor and a tracker, currently using a CSRT but it could be easily replaced, the background substractor detects movement and focuses on the biggest area to pass that rectangle to the tracker so it gets initialized, it works. FPS are rubbish but still is able to follow slow motion objects e.g passing hand.\n\n14/03/2021: The robot is finally able to follow the detected object, the magic is broken when the CSRT threshold is crossed and from that point the robot falls back to motion detection until it finds a new target to track, in the mean time the robot stops.\n\n28/03/2021: Added an embedded web server based on Mongoose, now the robot streams video straight from its camera marking (blue rectangle) the tracked object. Unfortunately the workload finally broke the camels back and it starts to show that the Rasperry 4 is just too short, future potential optimization is required, probably switch from a CSRT to a MOOSE tracker.\n\n10/04/2021: Probably last version, some cleaning, closing threads properly and tidying up in general. Kept the CSRT tracker and solved some recurrent exceptions thrown by OpenCV, mostly to do with capturing out of frame.\n\nThe robot itself can be found here: https://www.adeept.com/adeept-darkpaw-bionic-quadruped-spider-robot-kit-for-raspberry-pi-4-3-model-b-b-2b-stem-crawling-robot-opencv-tracking-self-stabilizing_p0125_s0035.html\n\nIt is a cool toy and the provided HAT supports connecting some additional stuff if you wanted too, I equipped it with a Raspberry Pi 4 with 8 Gigas so it is (almost) enough for the OpenCV stuff, as a basis to control the GPIO I am using the famous PIGPIO library wich always works first time, really good stuff that can be found here: http://abyz.me.uk/rpi/pigpio/\n\nEmbedded web server is built using the famous Mongoose, version 7.2 that can be obtained here: https://github.com/cesanta/mongoose/releases\n\nOpenCV 4.5.0 (or any other version) can be obtained here: https://github.com/opencv/opencv\n\n[\u003ch2 align=\"left\"\u003eFirst Version\u003c/h2\u003e](https://github.com/Rubberazer/Darkpaw_motion_opencv/tree/main/First_version)\n\n  Detects moving objects and once detected it tracks (and follows) them\n  \n  Files: 2_darkpaw.cpp, makefile\n  \n  Compile: type 'make', pigpio and opencv libraries should be installed previously\n  Execute: sudo ./darkpaw\n\n[\u003ch2 align=\"left\"\u003eSecond Version\u003c/h2\u003e](https://github.com/Rubberazer/Darkpaw_motion_opencv/tree/main/Second_version)\n  \n  Detects moving objects and once detected it tracks (and follows) them, this version also incorporates a web server for video streaming.\n  \n  Files: 3_darkpaw.cpp, makefile, web_root folder\n  \n  Compile: type 'make', pigpio and opencv libraries should be installed previously, also mongoose.c and mongoose.h are required \n  \n  Execute: sudo ./darkpaw\n \n [\u003ch2 align=\"left\"\u003eLatest @ main\u003c/h2\u003e](https://github.com/Rubberazer/Darkpaw_motion_opencv)\n  \n  Same functionality as 2 but terminating threads properly, cleaning up comments and tidying up a bit, all files hanging from 'main' in the repository\n  \n  Files: 4_darkpaw.cpp, makefile, web_root folder\n  \n  Compile: type 'make', pigpio and opencv libraries should be installed previously, also mongoose.c and mongoose.h are required \n  \n  Execute: sudo ./darkpaw\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubberazer%2Fdarkpaw_motion_opencv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frubberazer%2Fdarkpaw_motion_opencv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubberazer%2Fdarkpaw_motion_opencv/lists"}