{"id":21174478,"url":"https://github.com/cobryan05/yolo2mqtt","last_synced_at":"2025-07-09T21:30:55.589Z","repository":{"id":101156142,"uuid":"479240174","full_name":"cobryan05/Yolo2Mqtt","owner":"cobryan05","description":"Track objects detected by YOLO and publish that info to MQTT","archived":false,"fork":false,"pushed_at":"2024-10-04T17:51:39.000Z","size":1017,"stargazers_count":23,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-05T07:11:44.377Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/cobryan05.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}},"created_at":"2022-04-08T04:11:33.000Z","updated_at":"2025-02-19T21:14:40.000Z","dependencies_parsed_at":null,"dependency_job_id":"aaca75be-1d5a-44c1-b3a5-9dec447dae85","html_url":"https://github.com/cobryan05/Yolo2Mqtt","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cobryan05/Yolo2Mqtt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cobryan05%2FYolo2Mqtt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cobryan05%2FYolo2Mqtt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cobryan05%2FYolo2Mqtt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cobryan05%2FYolo2Mqtt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cobryan05","download_url":"https://codeload.github.com/cobryan05/Yolo2Mqtt/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cobryan05%2FYolo2Mqtt/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264503949,"owners_count":23618762,"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-11-20T16:54:50.521Z","updated_at":"2025-07-09T21:30:55.339Z","avatar_url":"https://github.com/cobryan05.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Yolo2Mqtt\nTrack objects detected by YOLO and publish that info to MQTT\n\n# Description\n\nYolo2Mqtt is a collection of python scripts for running image recognition on RTSP camera streams using a Yolov5 model,\ndetecting when two objects interact, saving a video of the event, using MQTT as a communications mechanism.\n\nThis program was written to track cat feeding/drinking in a multi-cat home and to graph provide that information to Home Assistant via MQTT. Tracking both the cats and the food/water bowls allowed the bowls\nto be moved about the room, rather than designating fixed windows to trigger evnets.\n\nIt could be used for pretty much anything in which you want to run YOLO and detect if two objects are overlapping.\n\n## Running\n\nDocker is the easiest way to run this. An MQTT broker is required as well. The sample docker-compose will run an\nMQTT broker, but for Home Assistant integration the same broker must be used by HA and Yolo2Mqtt\n\nThe minimal commands to get running would are:\n\n\u003e     $ git clone --recursive https://github.com/cobryan05/Yolo2Mqtt.git\n\u003e     $ cd Yolo2Mqtt\n\u003e     Yolo2Mqtt$ docker-compose build\n\u003e     Yolo2Mqtt$ docker-compose up\n\n\nThis will build the docker container and run the default configuration.\n\n\nThe default configuration will use YoloV8 and auto-download a sample model then run sample recognitions on a static image.\nIf all goes well, you should be able to connect to the mqtt broker at \\\u003chostIp\\\u003e:1833. Detection information should be published\nto the topic /myhome/ObjectTrackers/.\n\nWith the default sample config you should soon see topics identifying a dog riding a motorcycle.\n\n## Configuration\n\nConfiguration is done by editing /config/config.yml. A default config.yml is available as config.defaults.yml. You should configure\nthe volumes in your docker-compose.yml so that so that your custom config.yml is available to it at /config/config.yml.\n\nAll settings and default values (if any) are commented in config.defaults.yml.\n\nNote: This is meant to be used with a custom-trained YOLOv5 model. The default configuration will download the base yolov5 model,\nand the example interactions are some nonsense made with default labels. Any useful interactions will require a custom model.\n\n## CUDA GPU acceleration\n\nTo enable CUDA acceleration (assuming CUDA is already working on your system):\n    * At the top of the Dockerfile change the FROM: image to the -cuda variant (then rebuild the image)\n    * In the docker-compose.yml uncomment the 'deploy' block to pass the GPU to Docker\n    * In the config.yml switch the 'yolo: device:' setting to 'cuda'\n\n## RTSP Proxy\n\nThe Docker container internally runs an RTSP Proxy on port 8554. If a port is forwarded to 8554 on Docker container, then any RTSP camera in the config.yml should be proxied at, eg \\\u003chostIp\\\u003e:8554/\\\u003ccameraName\\\u003e\n\n\n## Home Assistant Integration\n\nThere are two ways in which Yolo2Mqtt can be 'integrated' with Home Assistant.\n\n* Yolo2Mqtt's 'mediaRoot' folder can be set as a 'media_dir' in Home Assistant. This will allow browsing and playback of Yolo2Mqtt recordings via the Home Assistant 'media' browser. (See https://www.home-assistant.io/integrations/media_source/#using-custom-or-additional-media-folders)\n\n\n* When the homeAssistant 'discoveryEnabled' setting is true in config.yml then event interactions will post to the Home Assistant MQTT Discovery topic (https://www.home-assistant.io/docs/mqtt/discovery/) for autoconfiguration. Events will create new binary_sensors in Home Assistant with names such as\n\u003cbr\u003e\u003cbr\u003e\n binary_sensor.[entityPrefix]\\_[eventName]\\_[cameraName]\\_[object1]\\_[object2]\n\u003cbr\u003e\u003cbr\u003e\n\n In Home Assistant you can create 'aggregation sensors' to help process further process these events. For example, adding this template sensor to Home Assistant:\n\n\n\u003e     binary_sensor:\n\u003e      - platform: template\n\u003e        sensors:\n\u003e          cattracker_summary_sammy_eating_food:\n\u003e            friendly_name: \"Sammy Eating Food\"\n\u003e            unique_id: \"cattracker_summary_sammy_food\"\n\u003e            value_template: \u003e-\n\u003e              {% set action='cateatingfood' %}\n\u003e              {% set actor='sammy' %}\n\u003e\n\u003e              {% set re=action + '[a-z_]+' + actor %}\n\u003e              {% set ns = namespace(state='off') %}\n\u003e\n\u003e              {% for entity in states.binary_sensor if entity|regex_search( re ) and entity.state=='on'%}\n\u003e                {% set ns.state = 'on' %}\n\u003e              {% endfor %}\n\u003e              {{ ns.state }}\n\nwill create a new **binary_sensor.cattracker_summary_sammy_eating_food** which will be 'true' if any sensor matches the regex **'sammy[a-z]+cateatingfood'**.\nMultiple yolo2mqtt 'events' can be combined into one logical Home Assistant event using tricks like this.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcobryan05%2Fyolo2mqtt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcobryan05%2Fyolo2mqtt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcobryan05%2Fyolo2mqtt/lists"}