{"id":15136032,"url":"https://github.com/abeed04/object-detection-model-using-cv2","last_synced_at":"2026-01-19T22:01:09.507Z","repository":{"id":245691457,"uuid":"818958529","full_name":"abeed04/Object-detection-model-using-Cv2","owner":"abeed04","description":"Leverage OpenCV (cv2) to build an object detection system. This system would combine a pre-trained MobileNet model, trained on the COCO dataset, with a frozen inference graph for real-time object identification within images or videos.","archived":false,"fork":false,"pushed_at":"2024-07-02T05:31:41.000Z","size":20991,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-06T02:31:49.876Z","etag":null,"topics":["cocodataset","frozen","mobilenetv3","opencv","pycharm-ide"],"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/abeed04.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":"2024-06-23T11:16:01.000Z","updated_at":"2025-03-11T12:10:32.000Z","dependencies_parsed_at":"2024-06-23T13:43:27.752Z","dependency_job_id":"75241181-8166-4f1b-872b-b7b6706525f6","html_url":"https://github.com/abeed04/Object-detection-model-using-Cv2","commit_stats":null,"previous_names":["abeed04/object-detection-model-using-cv2"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/abeed04/Object-detection-model-using-Cv2","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abeed04%2FObject-detection-model-using-Cv2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abeed04%2FObject-detection-model-using-Cv2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abeed04%2FObject-detection-model-using-Cv2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abeed04%2FObject-detection-model-using-Cv2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abeed04","download_url":"https://codeload.github.com/abeed04/Object-detection-model-using-Cv2/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abeed04%2FObject-detection-model-using-Cv2/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28587037,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-19T20:45:59.482Z","status":"ssl_error","status_checked_at":"2026-01-19T20:45:41.500Z","response_time":67,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["cocodataset","frozen","mobilenetv3","opencv","pycharm-ide"],"created_at":"2024-09-26T06:03:46.392Z","updated_at":"2026-01-19T22:01:09.491Z","avatar_url":"https://github.com/abeed04.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003eObject Detection Model using Cv2 👨‍💻 \u003c/h1\u003e\n\u003cbr/\u003e\n\u003cimg align=\"right\" height=\"270\" width=\"430\" src=\"https://miro.medium.com/v2/resize:fit:1200/0*e9eu2a2tZyI2qCfN.gif\" /\u003e\n 🔭 This project demonstrates real-time object detection using OpenCV (cv2), the MobileNet deep learning model, and the COCO dataset. It leverages a pre-trained frozen inference graph for efficient object identification within images or video streams.\n\u003ch2 align=\"left\"\u003eRequirements \u003c/h2\u003e\n-Python 3.x\n\u003cbr/\u003e\n-OpenCV (cv2) library\n\u003cbr/\u003e\n-Pre-trained MobileNet, COCO model files and Frozen model (download them to local pc)\n\u003cbr/\u003e\n\u003ch2 align=\"left\"\u003eUsage \u003c/h2\u003e\n-The program automatically attempts to open the video file Streets.mp4(You can upload your own videos). If the file is unavailable, it defaults to your webcam stream.\n\u003cbr/\u003e\n-A window titled \"Object Detection Program\" will display the video feed with detected objects highlighted.\n\u003cbr/\u003e\n-Bounding boxes will be drawn around detected objects, and their corresponding class labels will be displayed.(Note:Only Objects that are labeled in labels.txt file are displayed)\n\u003cbr/\u003e\n-You can adjust the confidence threshold (confThreshold=0.55) in the code to control the minimum confidence required for a detection to be displayed.\n\u003cbr/\u003e\n-Press the 'q' key to exit the program.\n\u003ch2 align=\"left\"\u003eExplanation \u003c/h2\u003e\n\u003ch3 align=\"left\"\u003eImports\u003c/h3\u003e\n-The script imports necessary modules, including OpenCV (cv2)\n\u003ch3 align=\"left\"\u003eModel and Label Loading\u003c/h3\u003e\n-The model configuration file (mobilenet_and_coco.txt) and the frozen inference graph (frozen_model.pb) are loaded using cv2.dnn_DetectionModel.\n\u003cbr/\u003e\n-Class labels are read from labels.txt and stored in a list class_labels.\n\u003ch3 align=\"left\"\u003eModel Configuration\u003c/h3\u003e\n-The model's input size is set to 200x200 pixels.\n\u003cbr/\u003e\n-The input scale and mean values are adjusted for normalization.\n\u003cbr/\u003e\n-The input color channel order is swapped to BGR (OpenCV's default) if necessary.\n\u003ch3 align=\"left\"\u003eVideo Capture\u003c/h3\u003e\n-A video capture object cap is created, attempting to open the video file Streets.mp4 first. It then falls back to the webcam if the file is not found.\n\u003cbr/\u003e\n-Error handling is included to raise an exception if video capture fails.\n\u003ch3 align=\"left\"\u003eMain Loop\u003c/h3\u003e\n-The loop continuously reads frames from the video stream using cap.read().\n\u003cbr/\u003e\n-The frame is resized to match the model's expected input size using OpenCV's resizing functions.\n\u003cbr/\u003e\n-model.detect is used for object detection in the frame. It returns class indices, confidence scores, and bounding boxes for detected objects that meet the specified confidence threshold.\n\u003cbr/\u003e\n-For each detected object:\n\n\u003cbr/\u003e\n1)A bounding box is drawn around the object using cv2.rectangle.\n\u003cbr/\u003e\n2)The corresponding class label from class_labels is retrieved and displayed on the frame using cv2.putText.\n\u003cbr/\u003e\n-The processed frame is displayed in the \"Object Detection Program\" window.\n\u003cbr/\u003e\n-The program exits when the 'q' key is pressed.\nYou can modify the script to:\n-The video capture object is released using cap.release().\n\u003cbr/\u003e\n-OpenCV windows are destroyed using cv2.destroyAllWindows().\n\u003ch2 align=\"left\"\u003eCustomization \u003c/h2\u003e\n\u003ch3 align=\"left\"\u003eYou can modify the script to:\u003c/h3\u003e\n-Use a different video file or image set for object detection.\n\u003cbr/\u003e\n-Experiment with different confidence thresholds (confThreshold) to adjust the detection sensitivity.\n\u003cbr/\u003e\n-Explore ways to integrate this object detection functionality into a larger application.\n\u003ch2 align=\"left\"\u003eFurther Considerations\u003c/h2\u003e\n-The pre-trained MobileNet model may not be ideal for all object detection tasks. Consider exploring other models or fine-tuning the provided model on your specific dataset for improved accuracy.\n\u003cbr/\u003e\n-The script currently processes frames one by one. For more efficient real-time performance, you might investigate techniques like multithreading or GPU acceleration.\n\n\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabeed04%2Fobject-detection-model-using-cv2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabeed04%2Fobject-detection-model-using-cv2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabeed04%2Fobject-detection-model-using-cv2/lists"}