{"id":31730046,"url":"https://github.com/dhyeythumar/cv2module","last_synced_at":"2025-10-09T07:24:14.618Z","repository":{"id":40959484,"uuid":"226276362","full_name":"dhyeythumar/cv2module","owner":"dhyeythumar","description":"Python package that provides various functions to assist the OpenCV workflow.","archived":false,"fork":false,"pushed_at":"2024-08-30T23:52:22.000Z","size":5505,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-07T08:45:45.501Z","etag":null,"topics":["opencv-add-ons","opencv-python","opencv-utilities","python"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/cv2module/","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/dhyeythumar.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}},"created_at":"2019-12-06T08:00:45.000Z","updated_at":"2022-06-22T03:14:34.000Z","dependencies_parsed_at":"2022-09-20T19:53:35.548Z","dependency_job_id":null,"html_url":"https://github.com/dhyeythumar/cv2module","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dhyeythumar/cv2module","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhyeythumar%2Fcv2module","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhyeythumar%2Fcv2module/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhyeythumar%2Fcv2module/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhyeythumar%2Fcv2module/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dhyeythumar","download_url":"https://codeload.github.com/dhyeythumar/cv2module/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhyeythumar%2Fcv2module/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279000982,"owners_count":26082973,"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","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["opencv-add-ons","opencv-python","opencv-utilities","python"],"created_at":"2025-10-09T07:24:11.999Z","updated_at":"2025-10-09T07:24:14.613Z","avatar_url":"https://github.com/dhyeythumar.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cv2module 0.1.2\n\nThis package is created to assist the smooth workflow with OpenCV by providing essentials functions such as object detection and tracking for any image/video feed using color filtration and many more such functions.\n \n\n## Installation\nProvided you already have NumPy and OpenCV installed, `cv2module` can be simply installed using `pip`.\n```bash\n$ pip install cv2module\n```\nIf you already have `cv2module` then upgrade it by this command.\n```bash\n$ pip install --upgrade cv2module\n```\n\n\n## What’s In This Document\n- [Import and Usage](#import-and-usage)\n- [Resize Image](#resize-image)\n- [Rotate Image](#rotate-image)\n- [Generate Mask for Image](#generate-mask-for-image)\n- [Generate Mask for Video Feed](#generate-mask-for-video-feed)\n- [Future Development](#future-development)\n- [License](#license)\n\n\n## Import and Usage\n\n- **Import as given below**\n```python\nfrom cv2module import cmask\n```\n\n- **Parameters and returned values**\n```python\nhsv_range, mask, res = cmask(Image)\n```\nThis cmask function will return the HSV lower and upper bound, mask and the resultant image.\n\n\u003c!-- **Note:**\n\u003cp style=\"color:orange;\"\u003e\nHere mentioning width and height is Required or else it will takes the default values as (600, 400) and resizes the image.\n\u003c/p\u003e\n\u003cp style=\"color:red;\"\u003e\nSo take care when you are using the default dimensions, as they may lead to an error when performing any image operations [due to different sizes]. To avoid this simply mention the dimensions.\n\u003c/p\u003e --\u003e\n\n\u003cp style=\"font-weigth:700; font-size:18px;color:\" align=\"center\"\u003e\n\u003cbr/\u003e\n\u0026bull; \u0026bull; \u0026bull; \u0026bull;\n\u003c/p\u003e\n\n\n## Resize Image\nTo resize an image in OpenCV, cv2.resize function is used. However, you have to use your intuitions in a selection of width and height to maintain the aspect ratio. And sometimes it is hard to predict so by using `cv2module.resize` function you can simply specify width or else you can also specify both (width and height). So the control is in your hands.\n\n**Example :**\n```python\nimage = cv2module.resize(ip_image, 500)\n```\n**Output :**\n\u003ctable\u003e\n \u003ctr\u003e\n  \u003cth\u003eOriginal Image\u003c/th\u003e\n  \u003cth\u003eResized Image\u003c/th\u003e\n \u003c/tr\u003e\n \u003ctr\u003e\n  \u003ctd width=\"50%\"\u003e\u003cimg alt=\"input img\" src=\"https://github.com/Dhyeythumar/cv2module/blob/master/output/unresized_image.jpg\"\u003e\u003c/td\u003e\n  \u003ctd width=\"50%\"\u003e\u003cimg alt=\"output img\" height=\"100%\" src=\"https://github.com/Dhyeythumar/cv2module/blob/master/output/resized_image.jpg\"\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/table\u003e\n\n\u003cp style=\"font-weigth:700; font-size:18px;color:\" align=\"center\"\u003e\n\u003cbr/\u003e\n\u0026bull; \u0026bull; \u0026bull; \u0026bull;\n\u003c/p\u003e\n\n\n## Rotate Image\nTo rotate an image in OpenCV, cv2.getRotationMatrix2D and cv2.warpAffine is used. However, if you use these functions then you will lose some of the image parts. But by using `cv2module.rotate` you have the control over that loss.\n\n**Example :**\n```python\n    # loss = 0 means there is no loss of image while rotating it.\n    # loss = 1 means there is a loss of image while rotating it.\n    res = cv2module.rotate(ip_image, 40, loss=1)\n```\n\n```diff\n- The default value of the loss is 1 so it will crop out the image when it's been rotated.\n```\n\n**Output :**\n\u003ctable\u003e\n \u003ctr\u003e\n  \u003cth\u003eloss = 0\u003c/th\u003e\n  \u003cth\u003eloss = 1\u003c/th\u003e\n \u003c/tr\u003e\n \u003ctr\u003e\n  \u003ctd width=\"50%\" height=\"400px\" \u003e\u003cimg alt=\"input img\" src=\"https://github.com/Dhyeythumar/cv2module/blob/master/output/rotate_without_loss.jpg\"\u003e\u003c/td\u003e\n  \u003ctd width=\"50%\" height=\"400px\" align=\"center\"\u003e\u003cimg alt=\"output img\" height=\"100%\" src=\"https://github.com/Dhyeythumar/cv2module/blob/master/output/rotate_with_loss.jpg\"\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/table\u003e\n\n\u003cp style=\"font-weigth:700; font-size:18px;color:\" align=\"center\"\u003e\n\u003cbr/\u003e\n\u0026bull; \u0026bull; \u0026bull; \u0026bull;\n\u003c/p\u003e\n\n\n## Generate Mask for Image\nSometimes it is hard to predict the HSV bound for a given image. So, this is an example of how to create a mask from a particular color from an image. See the code given below, here we are reading a watch image and attempting to create a mask for the yellow color. The cmask (color mask) function is been imported from the cv2module. This function will open a window with the sliders to set the HSV bounds of your choice.\n\n**Example :**\n```python\nimg = cv2.imread(\"../input/watch_image.jpg\", cv2.IMREAD_COLOR)\n\nhsv_range, mask, res = cmask(img)\n\nprint(hsv_range)\ncv2.imshow('Original frame', img)\ncv2.imshow('mask', mask)\ncv2.imshow('resultant', res)\ncv2.waitKey(0)\ncv2.destroyAllWindows()\n```\n\n```diff\n- When you are done with selecting the values:\n-   Click ESC or 'q' key to get the values.\n-   To save the mask and res image generated by the function click 's'.\n```\n\nTo view the full example [Refer](https://github.com/Dhyeythumar/cv2module/blob/master/examples/image_example.py).\n\n**Output :**\n\u003ctable\u003e\n \u003ctr\u003e\n  \u003cth\u003eInput Image\u003c/th\u003e\n  \u003cth\u003eOutput Image\u003c/th\u003e\n \u003c/tr\u003e\n \u003ctr\u003e\n  \u003ctd width=\"50%\"\u003e\u003cimg alt=\"input img\" src=\"https://github.com/Dhyeythumar/cv2module/blob/master/input/watch_image.jpg\"\u003e\u003c/td\u003e\n  \u003ctd width=\"50%\"\u003e\u003cimg alt=\"output img\" src=\"https://github.com/Dhyeythumar/cv2module/blob/master/output/resultant_watch_image.jpg\"\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/table\u003e\n\n\u003cp style=\"font-weigth:700; font-size:18px;color:\" align=\"center\"\u003e\n\u003cbr/\u003e\n\u0026bull; \u0026bull; \u0026bull; \u0026bull;\n\u003c/p\u003e\n\n\n## Generate Mask for Video Feed\nSometimes it is hard to predict the HSV bound for a given video frame. So, this is an example of how to create a mask from a particular color from a video frame. See the code given below, here we are reading a live webcam frame and attempting to create a mask for the green color. For the very first frame, the cmask function will open a window with the sliders to set the HSV bounds of your choice [You can exit and get the values or can save the mask and resultant image]. \n\n**Example :**\n```python\nif((len(hsv_range) == 0) \u0026 (redo == 1)):\n    redo = 0\n    hsv_range, static_mask, static_res = cmask(frame)\nelse:\n    hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)\n    lower_red = hsv_range[0]\n    upper_red = hsv_range[1]\n\n    mask = cv2.inRange(hsv, lower_red, upper_red)\n    res = cv2.bitwise_and(frame, frame, mask=mask)\n\n    cv2.imshow('frame', frame)\n    cv2.imshow('mask', mask)\n    cv2.imshow('res', res)\n```\n\n```diff\n- After this webcam feed will remain ON and you have two choices as:\n-   if you want to again create the mask for another frame then click 'r' to repeat.\n-   else click ESC or 'q' to exit.\n```\n\nTo view the full example [Refer](https://github.com/Dhyeythumar/cv2module/blob/master/examples/video_example.py).\n\n**Output :**\u003cbr/\u003e\nThe following is the resultant video captured by webcam. In this I'm holding the mobile with the green color on the screen.\n\u003cp align=\"center\"\u003e\n\u003cimg  alt=\"output video\" src=\"https://github.com/Dhyeythumar/cv2module/blob/master/output/result_video.gif\" width=\"50%\"\u003e\n\u003c/p\u003e\n\n\u003cp style=\"font-weigth:700; font-size:18px;color:\" align=\"center\"\u003e\n\u003cbr/\u003e\n\u0026bull; \u0026bull; \u0026bull; \u0026bull;\n\u003c/p\u003e\n\n\n## Future Development\nI am planning to create different functions for this `cv2module` such as cropping an image, creating a scanner, creating different haar cascades for different objects, etc.\n\n\n## License\nLicensed under the [MIT License](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdhyeythumar%2Fcv2module","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdhyeythumar%2Fcv2module","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdhyeythumar%2Fcv2module/lists"}