{"id":18541283,"url":"https://github.com/fernaper/cv2-tools","last_synced_at":"2025-06-27T11:37:19.591Z","repository":{"id":37602766,"uuid":"169968871","full_name":"fernaper/cv2-tools","owner":"fernaper","description":"v2.4.0 - Library to help the drawing process with OpenCV. Thought to add labels to the images. Classification of images and much more.","archived":false,"fork":false,"pushed_at":"2023-10-03T23:08:03.000Z","size":9215,"stargazers_count":12,"open_issues_count":11,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-18T01:40:29.996Z","etag":null,"topics":["artificial-intelligence","constraints","cv2","library","opencv","python","python3","tools"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fernaper.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2019-02-10T11:02:56.000Z","updated_at":"2024-05-14T17:31:47.000Z","dependencies_parsed_at":"2025-04-09T18:42:44.983Z","dependency_job_id":"e543371b-ae37-4759-8c04-3adc37ce7ca3","html_url":"https://github.com/fernaper/cv2-tools","commit_stats":null,"previous_names":["fernaper/opencv-draw-tools"],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/fernaper/cv2-tools","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fernaper%2Fcv2-tools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fernaper%2Fcv2-tools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fernaper%2Fcv2-tools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fernaper%2Fcv2-tools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fernaper","download_url":"https://codeload.github.com/fernaper/cv2-tools/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fernaper%2Fcv2-tools/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260838503,"owners_count":23070602,"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":["artificial-intelligence","constraints","cv2","library","opencv","python","python3","tools"],"created_at":"2024-11-06T20:04:33.002Z","updated_at":"2025-06-27T11:37:19.552Z","avatar_url":"https://github.com/fernaper.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cv2_tools\n\n[![PyPI version](https://badge.fury.io/py/cv2-tools.svg)](https://pypi.org/project/cv2-tools/) [![Downloads](https://pepy.tech/badge/cv2-tools)](https://pypi.org/project/cv2-tools/) [![Downloads](https://pepy.tech/badge/cv2-tools/month)](https://pypi.org/project/cv2-tools/)\n\nLibrary to help the drawing process with OpenCV. Thought to add labels to the images. Classification of images, etc.\n\n![cv2-tools](https://user-images.githubusercontent.com/18369529/56097027-839fe680-5eef-11e9-9c35-9d20f92b595e.png)\n\n**Image generated with face_recognition and drawed with cv2-tools version 2.0.2**\n\n## Installation\n\n### Pre-requisites\n\nYou will need to install:\n\n* opencv \u003e= 3.6.2\n* numpy \u003e= 1.13.3\n* python-constraint \u003e= 1.4.0\n\nYou can simply execute:\n`pip install -r requirements.txt`\n\nFinally you can install the library with:\n\n`pip install cv2-tools`\n\nWhen you install `cv2-tools`, it will automatically download `numpy` but not opencv becouse in some cases you will need another version.\n\n## Test\n\n```\nimport cv2_tools\n\nprint('Name: {}\\nVersion:{}\\nHelp:{}'.format(cv2_tools.name,cv2_tools.__version__,cv2_tools.help))\nwebcam_test()\n```\n\n## Ussage and Important classes\n\n### ManagerCV2\n\n```\nfrom cv2_tools.Management import ManagerCV2\n```\n\nIf you want to work with video or stream, this class will help you mantain your code cleaner while you get more features.\n\nFor example:\n - Open a a stream (your webcam).\n - Reproduce it on real time with max FPS equals to 24.\n - Press `esc` to finish the program.\n - At the end print average FPS.\n\n```\nfrom cv2_tools.Managment import ManagerCV2\nimport cv2\n\n# keystroke=27 is the button `esc`\nmanager_cv2 = ManagerCV2(cv2.VideoCapture(0), is_stream=True, keystroke=27, wait_key=1, fps_limit=60)\n\n  # This for will manage file descriptor for you\n  for frame in manager_cv2:\n      cv2.imshow('Example easy manager', frame)\n  cv2.destroyAllWindows()\n  print(manager_cv2.get_fps())\n```\n\nIf you want to use another button and you don't know the ID, you can check easily using the following code:\n\n```\nfrom cv2_tools.Managment import ManagerCV2\nimport cv2\n\n# keystroke=27 is the button `esc`\nmanager_cv2 = ManagerCV2(cv2.VideoCapture(0), is_stream=True, keystroke=27, wait_key=1, fps_limit=60)\n\n  # This for will manage file descriptor for you\n  for frame in manager_cv2:\n      # Each time you press a button, you will get its id in your terminal\n      last_keystroke = manager_cv2.get_last_keystroke()\n      if last_keystroke != -1:\n        print(last_keystroke)\n      cv2.imshow('Easy button checker', frame)\n  cv2.destroyAllWindows()\n```\n\n### SelectorCV2\n\nFirstly create a SelectorCV2 object. You can pass it optional parameters to configure the output.\n```\nfrom cv2_tools.Selection import SelectorCV2\nselector = SelectorCV2(color=(200,90,0), filled=True)\n```\n\nAlso you can configure it later using the method (all optional parameters):\n```\nselector.set_properties()\n```\n\nNow, each time you want to add a selected zone call the method:\n```\n\"\"\"\nCoordinates:\n\n(x1,y1)____(x2,y1)\n   |          |\n   |          |\n(x1,y2)____(x2,y2)\n\nTags (optional parameter):\n* It could be a normal string\n* A string with '\\n'\n* A list of strings\n* None / '' / [] / False\n\"\"\"\nselector.add_zone((x1,y1,x2,y2),tags=tag)\n```\n\nFinally, when you want to draw all the rectangles execute:\n```\nedited_frame = selector.draw(frame)\n```\n\nIf you want to use the same object multiple times you can easily change the content inside it:\n```\n# This method could help change rectangles to\nselector.set_range_valid_rectangles( origin, destination)\n\n# This method could help if you know exactly the indexes that you want to keep\n# Default = [], so if you just want to clean the buffer call this method without parameters\nset_valid_rectangles(indexes)\n```\n\nIf you want, you can see the example [detect_faces.py](examples/detect_faces.py), it also use an open source library called `face_recognition`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffernaper%2Fcv2-tools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffernaper%2Fcv2-tools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffernaper%2Fcv2-tools/lists"}