Skip to main content

Utilities for Computer Vision Tasks

Project description

requires >= Python 3.6

https://user-images.githubusercontent.com/73752977/188218332-96f6766d-3f7f-4eb0-89f2-c2b58a08c375.mp4

This package contains the following utilities

🚀Frame Saver - save frames from video, folders containing videos or camera feed/livefeed.
🚀Image Resizer - Resize image while retaining the quality
🚀File mover - move specific file types from thousands/myriads of files.

More utility functions to be added subsequently.

I hope you find this package useful

To install:

pip3 install ormedian-utils


FRAME SAVER collect_frames()

Save frames from video, camera feed, video folder containing multiple videos.

collect_frames(num, video_format='mp4', image_name='frame', image_format='jpg', view=True)

num: could be camera id, path to video, or a folder contain a number of videos
video_format: format of output video if saving video, default format is set to mp4
image_name: name of frame files, numbers will be appended at the back in the form of frames_1, frames_2...frames_n, could be changed to wheveter you want
image_format: extension of image/frames to be saved, default format is 'jpg', could be any image format, e.g 'png', 'bmp' etc

This package has 3 methods:


  1. camera

for saving frames from camera feed

USAGE:

from ormedian_utils import collect_frames
camera_id =0
frames = collect_frames(camera_id)
frames.camera(camera_id, save_video=True)

save_video=True saves video from camera feed into the same folder as the collected frames. You may set save_video to False to not save video.

  1. videofolder

for saving frames from videos in a folder(s)

USAGE:

from ormedian_utils import collect_frames
video_folder_path ='path/to/foldercontaining/videos
frames = collect_frames(video_folder_path)
Image_folder = 'Image Folder' 
frames.videofolder(video_folder_path, Image_folder=Image_folder)

Image_folder: Where Frames will be saved. defaults to Image Folder unless otherwise changed
A new folder will be created for each video, and corresponding frames will be saved in this folder.


  1. videofile

for saving frames from a single video file

USAGE:

from ormedian_utils import collect_frames
video_path = 'path/to/a/singlevideo'
frames = collect_frames(video_path)
frames.videofile()

IMAGE RESIZER image_resizer()

Resize images in a folder or in multiple folders

https://user-images.githubusercontent.com/73752977/187389467-3e4c8e8f-bab9-433f-9e0a-e80dca32037b.mp4

image_resizer (new_size: tuple,
                  image_path: str,
                  n_f=True, new_folder='ResizedImages',
                  view=True, multiple_folders=False):

new_size: expected New Image size e.g (224, 224)

image_path: '/path/to/where/images/are

n_f: set to True if resized images be saved in new_folder, set to True by default NOTE: if resizing multiple folders (multiple_folders=True) and n_f is set True This will create a separate folder for each folder (Parent_folder of image_path/ResizedImages/subfolders) in the parent directory of image_path. Setting n_f to False when resizing multiple_folders will override the existing image_path and overwrite the images in the subfolders.

new_folder: Name of new folder to save resized images, accepts strings, default value is set to 'ResizedImages'

view: default value is set to True, this would display window showing resized images

multiple_folders: Set to True if image_path contains more than one image folder, default is False

USAGE:

from ormedian_utils import  image_resizer

new_size = (100, 100)
images_folder = '/path/to/images/folder' 
quality =100

In this case images_folder contains multiple image folders. Hence we set multiple_folders to True below.

image_resizer(new_size,
              images_folder,
              n_f=True,
              quality, multiple_folders=True)

FILE MOVER filemover()

Move files from one folder to another

filemover(folder_path: str, file_ext: str, new_folder: str)

folder_path: path to files, e.g /path/to/folder/files/

file_ext: file extension of files to move e.g 'json'

new_folder: folder name of where to move files to, creates directory in parent directory if it does not already exist

USAGE:

from ormedian_utils import filemover

folder_path = /path/to/different/files     #contains json, csv, jpg, and docs files
file_ext = 'json'
new_folder = 'MovedFiles'

filemover(folder_path, file_ext, new_folder)

Todo

  • Image Converter
  • Video Converter
  • Audio Parser

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

ormedian_utils-0.2.2.tar.gz (14.8 kB view details)

Uploaded Source

Built Distribution

ormedian_utils-0.2.2-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

File details

Details for the file ormedian_utils-0.2.2.tar.gz.

File metadata

  • Download URL: ormedian_utils-0.2.2.tar.gz
  • Upload date:
  • Size: 14.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.11

File hashes

Hashes for ormedian_utils-0.2.2.tar.gz
Algorithm Hash digest
SHA256 3f7c9856e180aa27cdb127a49864bf2adf658d7bc8234e44af045f80d3f9de62
MD5 c805eed05a3bdeddcb03ddf3b56f7228
BLAKE2b-256 d896ca4e52da99186634512ed79eeff0a1737b13cb3abd574b889d9d665e1516

See more details on using hashes here.

File details

Details for the file ormedian_utils-0.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for ormedian_utils-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 19e9d46b4e9a196e58fe6bb3c9f1fdf0530274ab0fe909516efbe5d9f01613b1
MD5 a0aa646fca0444dec5f04c5f84fa590a
BLAKE2b-256 410d00a30d2af084d95993ea16928fe4a4ee47e32ac9d493a9116806b7042f8c

See more details on using hashes here.

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