Skip to main content

cv2utils

PyPI Travis PyPI - Downloads License Implementation of some object detection in Python3.5+.

Installation

It can be installed through pip:

pip3 install --user cv2utils

This implementation requires OpenCV and Numpy.

Usage

OpenCV Face DNN

The following example illustrates the ease of use of this package:

>>> import cv2
>>> from cv2utils import FaceDnn
>>> image = cv2.imread("face.jpg")
>>> detector = FaceDnn()
>>> detector.detect_faces(image)
[{'label': 'face', 'confidence': 0.9966524243354797, 'box': [210, 64, 522, 465]}]

The detector returns a list of DICTIONARY objects. Each DICTIONARY object contains three main keys: 'box', 'confidence' and 'label':

  • The bounding box is formatted as [x_initial, y_initial, x_final, y_final] under the key 'box'.
  • The confidence is the probability estimate for a bounding box to be matching the label.
  • The label identifies which object is detecting.

Look the file result_dnn.py to see how the image below was generated.

OpenCV Face Cascade and Eye Cascade

The following example illustrates the ease of use of this package:

>>> import cv2
>>> from cv2utils import FaceCascade, EyeCascade
>>> image = imread("face.jpg")
>>> face_detector = FaceCascade()
>>> faces = face_detector.detect_faces(image)
>>> faces
[{'label': 'face', 'box': [199, 65, 591, 457]}]
>>>
>>> [x,y,x_final,y_final] = faces[0]['box']
>>> eye_detector = EyeCascade()
>>> eye_detector.detect_eyes(image[y:y_final, x:x_final])
[{'label': 'eye', 'box': [83, 132, 166, 215]}, {'label': 'eye', 'box': [218, 119, 298, 199]}]

The detector returns a list of DICTIONARY objects. Each DICTIONARY object contains two main keys: 'box', 'label':

  • The bounding box is formatted as [x_initial, y_initial, x_final, y_final] under the key 'box'.
  • The label identifies which object is detecting.

Look the file result_cascade.py to see how the image below was generated.

References

License

MIT.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cv2utils-0.1.0.tar.gz (5.3 MB view details)

Uploaded Source

File details

Details for the file cv2utils-0.1.0.tar.gz.

File metadata

  • Download URL: cv2utils-0.1.0.tar.gz
  • Upload date:
  • Size: 5.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.1

File hashes

Hashes for cv2utils-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6c4b12f34e9b8944a768d8824a05173ea990d1f5fe26f3b06d707cbc34720669
MD5 dc83daee2b798a6a2c00c490dcad1741
BLAKE2b-256 fb015b5dfdd41d3ed0c24e6b18b9ac5837a1147c13ad67a6559c8bdf0f7e5520

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.2

1 file

0.1.1

1 file

This release

0.1.0 This release

1 file

0.0.9

1 file

0.0.8

1 file

0.0.7

1 file

0.0.6

1 file

0.0.5

1 file

0.0.4

1 file

0.0.3

2 files

0.0.2

2 files

0.0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page