Skip to main content

Using this library you can detect objects from a video, images, with few lines of code

Project description

In this Project I am Using YoloV4 for object detection. To detect object using YoloV4 and OpenCv you have to write many lines of code, but using this framework you can do this using few lines of code.

Installation

pip install object_detector

Extract Images from a video

Import ExtractImages class from object_detector Library

>>> from object_detector import ExtractImages

Create a object ext of ExtractImages class

>>> ext = ExtractImages(path=0)

path=0 if you want to extract images from a video, write video path in place of 0.

or you can create object specifing Output path

>>> ext = ExtractImages(path=0,op=MyOutput)

By default Output path is Output

Start Extracting Images.

>>> ext.extract("A","B","C")

A, B, C are the path where extracting images collected. Relative path of "A" is MyOutput/A

Note: We are extracting Images in multiple path such that we can run our object detection task simultaneously.

Object Detection

Import ObjectDetector class from object_detector Library

>>> from object_detector import ObjectDetector

Create a object obj of class ObjectDetector

>>> obj = ObjectDetector(weights="cars.weights", cfg="yolov4-custom.cfg", classes=['licence'])

Object detection is done using YoLo. cars.weights is the trained file generated by training image dataset by darknet, and we are using yolov4-custom.cfg.

>>> img = obj.detect_object(path)

Write path of the image, from which you want to detect object. img is numpy array of image. To the image from numpy array write

>>> import cv2
>>> cv2.imshow("Image_Name",img)

or You can write

>>> import matplotlib.pyplot as plt
>>> plt.imshow(img)

If you want image without label write the code as

>>> img = obj.detect_object(path,label=False)

If you want to img only when obj is detected from image write the code as

>>> img = detect_object(path,detected_only=True)

To read text on the image add following code

>>> text = extract_text()

Show or Write objects from a video or camera

Import LiveDetect class and make a object of this class.

l = LiveDetect(weights="cars.weights", cfg="yolov4-custom.cfg", classes=['licence'])

Save images when object detect on video.

l.write_from_video(path="Traffic.mp4")

Show images when object detect on video.

l.show_from_video(path="Traffic.mp4")

Save images when object detect on the dir.

l.write_from_dir(path="Traffic.mp4")

Show images when object detect on the dir.

l.show_from_dir(path="Traffic.mp4")

Project details


Download files

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

Source Distribution

object_detector-1.7.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

object_detector-1.7-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file object_detector-1.7.tar.gz.

File metadata

  • Download URL: object_detector-1.7.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.26.0 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.7 CPython/3.10.4

File hashes

Hashes for object_detector-1.7.tar.gz
Algorithm Hash digest
SHA256 4b32774a29d749cd3742d00d55734e3f190fb38ada98fc87de2fac8bb13bebf2
MD5 2b65b10bd44eeab4d63a0a616ff1ca80
BLAKE2b-256 6f6c05608c3e81c813d92f4b4c19845510e33986d161ef543960c6d3412bf884

See more details on using hashes here.

Provenance

File details

Details for the file object_detector-1.7-py3-none-any.whl.

File metadata

  • Download URL: object_detector-1.7-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.26.0 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.7 CPython/3.10.4

File hashes

Hashes for object_detector-1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 23aa127e06a91c36f1ba74de9f74a07dd8d3ffa1e3fe88eff351ee7fc3489ac8
MD5 27d690917f35b9eb96799ea8b22d6b34
BLAKE2b-256 2915beb7028845e3235a2431ca37b2101c1ac3d8aec2176f0100033e88fef097

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page