objectvisions 0.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3 @@
1
+ from .detector import ObjectDetector
2
+
3
+ __all__ = ["ObjectDetector"]
@@ -0,0 +1,42 @@
1
+ import cv2
2
+ import numpy as np
3
+ from .model import load_model
4
+ from .utils import load_class_names
5
+
6
+ class ObjectDetector:
7
+ def __init__(self, threshold=0.65, nms_threshold=0.35):
8
+ self.threshold = threshold
9
+ self.nms_threshold = nms_threshold
10
+
11
+ self.net = load_model()
12
+ self.classNames = load_class_names()
13
+
14
+ def detect(self, img):
15
+ classIds, confs, bbox = self.net.detect(img, confThreshold=self.threshold)
16
+
17
+ if len(bbox) == 0:
18
+ return img
19
+
20
+ bbox = list(bbox)
21
+ confs = list(np.array(confs).reshape(1, -1)[0])
22
+ confs = list(map(float, confs))
23
+
24
+ indices = cv2.dnn.NMSBoxes(bbox, confs, self.threshold, self.nms_threshold)
25
+
26
+ for i in indices:
27
+ if len(indices.shape) > 1:
28
+ i = i[0]
29
+
30
+ box = bbox[i]
31
+ x, y, w, h = box
32
+ cv2.rectangle(img, (x, y), (x + w, y + h), (0, 255, 0), 2)
33
+
34
+ classId = classIds[i][0] if len(classIds[i].shape) > 0 else classIds[i]
35
+ cv2.putText(img,
36
+ self.classNames[classId - 1].upper(),
37
+ (x + 10, y + 30),
38
+ cv2.FONT_HERSHEY_COMPLEX,
39
+ 1,
40
+ (0, 255, 0),
41
+ 2)
42
+ return img
objectvisions/model.py ADDED
@@ -0,0 +1,22 @@
1
+ import cv2
2
+ import os
3
+
4
+ def load_model():
5
+ base_path = os.path.abspath(os.path.dirname(__file__))
6
+
7
+ weightsPath = os.path.join(base_path, "frozen_inference_graph.pb")
8
+ configPath = os.path.join(base_path, "ssd_mobilenet_v3_large_coco_2020_01_14.pbtxt")
9
+
10
+ if not os.path.exists(weightsPath):
11
+ raise FileNotFoundError(f"Model file not found at {weightsPath}")
12
+
13
+ if not os.path.exists(configPath):
14
+ raise FileNotFoundError(f"Config file not found at {configPath}")
15
+
16
+ net = cv2.dnn_DetectionModel(weightsPath, configPath)
17
+ net.setInputSize(320, 320)
18
+ net.setInputScale(1.0 / 127.5)
19
+ net.setInputMean((127.5, 127.5, 127.5))
20
+ net.setInputSwapRB(True)
21
+
22
+ return net
objectvisions/utils.py ADDED
@@ -0,0 +1,10 @@
1
+ import os
2
+
3
+ def load_class_names():
4
+ base_path = os.path.dirname(__file__)
5
+ classFile = os.path.join(base_path, "coco.names")
6
+
7
+ with open(classFile, 'rt') as f:
8
+ classNames = f.read().rstrip('\n').split('\n')
9
+
10
+ return classNames
@@ -0,0 +1,51 @@
1
+ Metadata-Version: 2.4
2
+ Name: objectvisions
3
+ Version: 0.0.1
4
+ Summary: Real-time Object Detection using OpenCV DNN
5
+ Author-email: Naman Lohiya <your_email@gmail.com>
6
+ License-Expression: MIT
7
+ Requires-Python: >=3.8
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: opencv-python
11
+ Requires-Dist: numpy
12
+ Dynamic: license-file
13
+
14
+ # ObjectVision-Naman 🚀
15
+
16
+ Real-time Object Detection Library built using OpenCV DNN and SSD MobileNet v3.
17
+
18
+ ## 📌 Features
19
+
20
+ - Real-time webcam detection
21
+ - Pre-trained COCO model
22
+ - Non-Maximum Suppression (NMS)
23
+ - Easy-to-use ObjectDetector class
24
+
25
+ ## 📦 Installation
26
+
27
+ ```bash
28
+ pip install objectvision-naman
29
+
30
+ 🚀 Usage Example
31
+ import cv2
32
+ from objectvision_naman import ObjectDetector
33
+
34
+ detector = ObjectDetector()
35
+
36
+ cap = cv2.VideoCapture(0)
37
+
38
+ while True:
39
+ success, img = cap.read()
40
+ img = detector.detect(img)
41
+ cv2.imshow("Detection", img)
42
+
43
+ if cv2.waitKey(1) & 0xFF == ord('q'):
44
+ break
45
+
46
+ 🧠 Model Used
47
+ 💠SSD MobileNet v3
48
+ 💠COCO Dataset
49
+
50
+ 👨‍💻 Author
51
+ Naman Lohiya
@@ -0,0 +1,9 @@
1
+ objectvisions/__init__.py,sha256=L9URvYsP1NtgoSliFFSDibtPa__9FVD8T0QB1F-BYOQ,68
2
+ objectvisions/detector.py,sha256=SICngLgWibonBAB9fjpOBXm6G7fojPSRrPn_fmR1SOI,1349
3
+ objectvisions/model.py,sha256=FuwydOc_b_0GBXD6ISAbzr5N46WCczwBRmH0bEJYu-4,723
4
+ objectvisions/utils.py,sha256=dLAZ8rg9qFzWpG_V3DyYRTfk-5xpkX3kyNMmd5k4aQU,255
5
+ objectvisions-0.0.1.dist-info/licenses/LICENSE,sha256=2UQ7mgEcHNZ7Dk8pj8BkMO8x-3bW9GYYci4zxiXSVi8,1088
6
+ objectvisions-0.0.1.dist-info/METADATA,sha256=ifvEBmbF25AUCw1Nk4bGDM1RG3tHX3y2To1WKRpooqk,1087
7
+ objectvisions-0.0.1.dist-info/WHEEL,sha256=YCfwYGOYMi5Jhw2fU4yNgwErybb2IX5PEwBKV4ZbdBo,91
8
+ objectvisions-0.0.1.dist-info/top_level.txt,sha256=0WNsJuMrcp5UrYqr9pKKty9aBYN17WYI72YmxCNW1bg,14
9
+ objectvisions-0.0.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Naman Lohiya
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ objectvisions