Skip to main content

A package for processing video frames, annotating keypoints, and more.

Project description

KhachKhach ✂️

<<<<<<< HEAD KhachKhach is a Python library for advanced video and image processing, with a focus on frame extraction, keypoint annotation, and object detection using YOLO models. It is designed to make computer vision workflows easy, flexible, and highly customizable....

KhachKhach is a Python library for advanced video and image processing, with a focus on frame extraction, keypoint annotation, and object detection using YOLO models. It is designed to make computer vision workflows easy, flexible, and highly customizable.

ce34636f857fd468038edcffc16d3643792b6176

Unique Features

  • Flexible YOLO Model Support: Use any Ultralytics YOLO model (including pose models) for detection and keypoint annotation.
  • Frame Extraction: Extract frames from videos at custom intervals, time ranges, or frame counts.
  • Keypoint Annotation: Annotate single images or entire folders with keypoints, supporting normalized coordinates and multiple output formats.
  • Bounding Box Processing: Detect and annotate bounding boxes, with options for saving annotated images and exporting results.
  • Batch Processing: Process entire folders of images or videos in one go.
  • Custom Output: Choose between normalized (0-1) or absolute coordinates, and select output format (space-separated, comma-separated, etc).
  • Easy Integration: Simple API for use in scripts, research, or production pipelines.
  • Utilities: Includes tools for appending text to files, extracting XYN arrays, and more.

Installation

Install the required dependencies and KhachKhach via pip:

pip install opencv-python numpy pillow ultralytics
pip install KhachKhach

Quick Start

1. Extract Frames from a Video

import khachkhach as kk

video_path = "your_video.mp4"
frames_dir = "frames"

video_processor = kk.VideoProcessor()
video_processor.extract_frames(video_path, frames_dir)

2. Detect Objects or Annotate Keypoints

import khachkhach as kk

engine = kk.DetectionEngine("yolo11n-pose.pt")
engine.detect_objects(input_path="frames", output_dir="objectin")
# or for keypoints:
engine.annotate_keypoints(input_path="frames", output_dir="objectin", normalize_coords=True)

3. Full Pipeline Example

import os
import khachkhach as kk

video_path = "your_video.mp4"
frames_dir = "frames"
output_dir = "objectin"

os.makedirs(frames_dir, exist_ok=True)
os.makedirs(output_dir, exist_ok=True)

video_processor = kk.VideoProcessor()
video_processor.extract_frames(video_path, frames_dir)

engine = kk.DetectionEngine("yolo11n-pose.pt")
engine.annotate_keypoints(input_path=frames_dir, output_dir=output_dir)

Advanced Usage

  • Normalized Coordinates: Get keypoints in 0-1 range for ML workflows.
  • Custom Output Format: Choose between space-separated or comma-separated output.
  • Batch Processing: Process all images in a folder with a single call.
  • Integration: Use in your own scripts or extend with custom logic.

Example Scripts

See the test folder for ready-to-run examples:

  • test_detect.py: Object detection on images.
  • test_video.py: Full pipeline from video to keypoints.
  • test.py: Advanced keypoint extraction with normalization.

Requirements

  • Python 3.7+
  • opencv-python
  • numpy
  • pillow
  • ultralytics

License

See LICENSE for details.

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

khachkhach-2.0.3.tar.gz (20.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

khachkhach-2.0.3-py3-none-any.whl (24.8 kB view details)

Uploaded Python 3

File details

Details for the file khachkhach-2.0.3.tar.gz.

File metadata

  • Download URL: khachkhach-2.0.3.tar.gz
  • Upload date:
  • Size: 20.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for khachkhach-2.0.3.tar.gz
Algorithm Hash digest
SHA256 6c6721d548034f0dba62943a532f13418b15606c54db5be9c11063d613ae5c66
MD5 b9568b845a92cb6d5a88cdb5cc09b5d4
BLAKE2b-256 6b47acc78dfdcc91970476e8e85922dfba5a549f1e080ad9ace58390e9ccc219

See more details on using hashes here.

File details

Details for the file khachkhach-2.0.3-py3-none-any.whl.

File metadata

  • Download URL: khachkhach-2.0.3-py3-none-any.whl
  • Upload date:
  • Size: 24.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for khachkhach-2.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 452f45ada509b96d7c0216d01cb50710a87beb2ffef65a1bcf46c94da533a831
MD5 1d6078474d815853c11216c207218d0b
BLAKE2b-256 121fa2840a5cd138b2bb71e4fb6cfacc437d3d201382a3f722a9c5097f56824c

See more details on using hashes here.

Supported by

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