{"id":19055975,"url":"https://github.com/redisgrafana/redis-camera-ai","last_synced_at":"2025-08-03T16:32:29.366Z","repository":{"id":47691886,"uuid":"370809730","full_name":"RedisGrafana/redis-camera-ai","owner":"RedisGrafana","description":"Analyzing camera feed using @RedisAI, OpenCV, and Redis plugins for @Grafana ","archived":false,"fork":false,"pushed_at":"2022-01-24T17:06:43.000Z","size":76408,"stargazers_count":26,"open_issues_count":0,"forks_count":10,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-18T12:19:19.902Z","etag":null,"topics":["grafana","redis","redisai","redisgears"],"latest_commit_sha":null,"homepage":"https://demo.volkovlabs.io","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/RedisGrafana.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-05-25T19:43:29.000Z","updated_at":"2025-03-12T08:57:04.000Z","dependencies_parsed_at":"2022-09-23T16:51:25.641Z","dependency_job_id":null,"html_url":"https://github.com/RedisGrafana/redis-camera-ai","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RedisGrafana%2Fredis-camera-ai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RedisGrafana%2Fredis-camera-ai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RedisGrafana%2Fredis-camera-ai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RedisGrafana%2Fredis-camera-ai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RedisGrafana","download_url":"https://codeload.github.com/RedisGrafana/redis-camera-ai/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250564429,"owners_count":21451002,"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":["grafana","redis","redisai","redisgears"],"created_at":"2024-11-08T23:47:38.175Z","updated_at":"2025-04-24T04:30:04.729Z","avatar_url":"https://github.com/RedisGrafana.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Analyzing camera feed using RedisAI, OpenCV and Grafana\n\n![Redis-Camera-AI](https://raw.githubusercontent.com/RedisGrafana/redis-camera-ai/main/images/batman-ai.gif)\n\n[![Grafana 8](https://img.shields.io/badge/Grafana-8-orange)](https://www.grafana.com)\n[![Redis Data Source](https://img.shields.io/badge/dynamic/json?color=blue\u0026label=Redis%20Data%20Source\u0026query=%24.version\u0026url=https%3A%2F%2Fgrafana.com%2Fapi%2Fplugins%2Fredis-datasource)](https://grafana.com/grafana/plugins/redis-datasource)\n[![Redis Application plug-in](https://img.shields.io/badge/dynamic/json?color=blue\u0026label=Redis%20Application%20plug-in\u0026query=%24.version\u0026url=https%3A%2F%2Fgrafana.com%2Fapi%2Fplugins%2Fredis-app)](https://grafana.com/grafana/plugins/redis-app)\n[![Docker](https://github.com/RedisGrafana/redis-camera-ai/actions/workflows/docker.yml/badge.svg)](https://github.com/RedisGrafana/redis-camera-ai/actions/workflows/docker.yml)\n\n## Introduction\n\nThis project demonstrates how to analyze camera feed stored as [Redis Streams](https://redis.io/topics/streams-intro) using serverless engine [RedisGears](https://oss.redislabs.com/redisgears/), [RedisAI](https://redisai.io/) and display analyzed frames with metrics in Grafana.\n\n![Redis-Camera-AI](https://raw.githubusercontent.com/RedisGrafana/redis-camera-ai/main/images/redis-camera-ai.png)\n\n## Demo\n\nDemo is available on [demo.volkovlabs.io](https://demo.volkovlabs.io):\n\n- [Redis Overview dashboard](https://demo.volkovlabs.io/d/TgibHBv7z/redis-overview?orgId=1\u0026refresh=1h)\n- [Camera Feed dashboard](https://demo.volkovlabs.io/d/DtsbVE3Mk/analyzing-camera-feed-with-ai?orgId=1)\n\n## Requirements\n\n- [Docker](https://docker.com) to start Redis and Grafana.\n- [Python](https://www.python.org/) to run scripts.\n\n## Redis with OpenCV Docker image\n\nThis project provides Docker image with Redis, RedisTimeSeries, RedisGears, RedisAI and installed [OpenCV for Python](https://docs.opencv.org/master/d6/d00/tutorial_py_root.html) library.\n\n```bash\ndocker run -p 6379:6379 --name=redis-opencv ghcr.io/redisgrafana/redis-opencv:latest\n```\n\n## OpenCV requirements\n\nCheck that OpenCV with dependencies downloaded, installed and registered in the RedisGears requirements:\n\n```bash\ncluster.remote:6379\u003e rg.pydumpreqs\n1)  1) \"GearReqVersion\"\n    2) (integer) 1\n    3) \"Name\"\n    4) \"Pillow\"\n    5) \"IsDownloaded\"\n    6) \"yes\"\n    7) \"IsInstalled\"\n    8) \"yes\"\n    9) \"CompiledOs\"\n   10) \"linux-buster-x64\"\n   11) \"Wheels\"\n   12) 1) \"Pillow-8.2.0-cp37-cp37m-manylinux1_x86_64.whl\"\n2)  1) \"GearReqVersion\"\n    2) (integer) 1\n    3) \"Name\"\n    4) \"opencv-python\"\n    5) \"IsDownloaded\"\n    6) \"yes\"\n    7) \"IsInstalled\"\n    8) \"yes\"\n    9) \"CompiledOs\"\n   10) \"linux-buster-x64\"\n   11) \"Wheels\"\n   12) 1) \"numpy-1.20.3-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl\"\n       2) \"opencv_python-4.5.2.52-cp37-cp37m-manylinux2014_x86_64.whl\"\n3)  1) \"GearReqVersion\"\n    2) (integer) 1\n    3) \"Name\"\n    4) \"numpy\"\n    5) \"IsDownloaded\"\n    6) \"yes\"\n    7) \"IsInstalled\"\n    8) \"yes\"\n    9) \"CompiledOs\"\n   10) \"linux-buster-x64\"\n   11) \"Wheels\"\n   12) 1) \"numpy-1.20.3-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl\"\n```\n\n## Import AI model and script\n\nTo load AI model and [PyTorch](https://pytorch.org/) script to the Redis database run:\n\n```bash\ncd ai/\ncat tiny-yolo-voc.pb | redis-cli -h redis -x AI.MODELSTORE yolo:model TF CPU INPUTS 1 input OUTPUTS 1 output BLOB\ncat ai-yolo-script.py| redis-cli -h redis -x AI.SCRIPTSET yolo:script CPU SOURCE\n```\n\n## Start Grafana\n\nGrafana can be started using Docker Compose or installed locally with [Redis plug-ins for Grafana](https://redisgrafana.github.io) and [Volkov Labs Image panel](https://github.com/VolkovLabs/grafana-image-panel).\n\n```bash\ndocker-compose pull\ndocker-compose up\n```\n\nWhen starting using Docker Compose, dashboard and plug-ins will be auto-provisioned and available in Grafana.\n\n## Register RedisGears script\n\nSelect `Camera Processing` dashboard and copy-paste `gears-yolo.py` script to RedisGears Script editor panel.\n\n![RedisGears Script Editor](https://raw.githubusercontent.com/RedisGrafana/redis-camera-ai/main/images/gears-script-editor.png)\n\nClick on the `Run script` button and you should see registered script `StreamReader` in the Registrations panel.\n\n![Camera AI](https://raw.githubusercontent.com/RedisGrafana/redis-camera-ai/main/images/camera-ai.png)\n\n## Start Camera\n\nCopy script `edge-camera.py` and `requirements.txt` to IoT or any device with camera. Run script by specifying Redis URL, number of frames per second and rotate camera if required.\n\n```bash\ncd camera/\npip3 install -r requirements.txt\npython3 edge-camera.py -u redis://redis:6379 --fps 6 --rotate-90-clockwise true\n```\n\nYou should see output with Stream's Id and size of the jpeg file.\n\n```bash\n# python3 camera.py -u redis://red:6379 --fps 6 --rotate-90-clockwise true\nConnected to Redis: ParseResult(scheme='redis', netloc='redis:6379', path='', params='', query='', fragment='')\nid: b'1622145939609-0', size: 5479\nid: b'1622145939769-0', size: 10006\nid: b'1622145939928-0', size: 6709\nid: b'1622145940100-0', size: 6037\nid: b'1622145940266-0', size: 6468\nid: b'1622145940435-0', size: 11607\nid: b'1622145940597-0', size: 5577\nid: b'1622145940768-0', size: 6041\nid: b'1622145940926-0', size: 5570\nid: b'1622145941098-0', size: 5916\n```\n\n## Learn more\n\n- Redis plug-ins for Grafana [Documentation](https://redisgrafana.github.io/)\n- [My Other Stack Is RedisEdge](https://redislabs.com/blog/my-other-stack-is-redisedge/)\n- [RedisEdge Real-time Video Analytics](https://github.com/RedisGears/EdgeRealtimeVideoAnalytics)\n\n## Contributing\n\n- Fork the repository.\n- Find an issue to work on and submit a pull request.\n- Could not find an issue? Look for documentation, bugs, typos, and missing features.\n\n## License\n\n- Apache License Version 2.0, see [LICENSE](https://github.com/RedisGrafana/redis-camera-ai/blob/main/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredisgrafana%2Fredis-camera-ai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fredisgrafana%2Fredis-camera-ai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredisgrafana%2Fredis-camera-ai/lists"}