yolozone


Nameyolozone JSON
Version 0.0.2 PyPI version JSON
download
home_pageNone
SummaryNone
upload_time2024-10-26 13:35:40
maintainerNone
docs_urlNone
authorNone
requires_pythonNone
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # YoloZone

YoloZone is a helper library for detecting and analyzing human poses in images and videos using the YOLO models. It provides simple functions for finding keypoints, angles, and distances between points in a pose.

## Installation

```bash
pip install yolozone
```

## Keypoints / Landmarks

We use the YOLO model for pose landmarks without any changes. The model returns 17 keypoints / landmarks.

| Keypoint | Description |
| -------- | -------- |
| 0 | Nose |
| 1 | Left Eye |
| 2 | Right Eye |
| 3 | Left Ear |
| 4 | Right Ear |
| 5 | Left Shoulder |
| 6 | Right Shoulder |
| 7 | Left Elbow |
| 8 | Right Elbow |
| 9 | Left Wrist |
| 10 | Right Wrist |
| 11 | Left Hip |
| 12 | Right Hip |
| 13 | Left Knee |
| 14 | Right Knee |
| 15 | Left Ankle |
| 16 | Right Ankle |

## Usage

```python
from yolozone import PoseDetector
import cv2

model = PoseDetector(model="yolov8n-pose.pt") # Initialize model
cap = cv2.VideoCapture(0) # Initialize video capture for webcam / cameras
# cap = cv2.VideoCapture("test/video.mp4") # Initialize video capture for video

while True:
    try:
        ret, frame = cap.read() # Read frame
        
        # Find keypoints
        keypoints = model.find_keypoints(frame, device="mps")

        # Get Points and Lines to Draw pose
        points, lines = model.draw_pose(keypoints)

        # Draw points
        for point in points:
            cv2.circle(frame, point, 5, (255, 255, 255), 2)
        
        # Draw lines
        for line in lines:
            cv2.line(frame, line[0], line[1], (255, 255, 255), 2) # line[0] and line[1] are starting and ending points of the line
        
        # Find angle between Left Shoulder (5) , Left Elbow (7) and Left Wrist (9)
        angle, text, text_position = model.angle_between_3_points(keypoints, 5, 7, 9)
        cv2.putText(frame, text, text_position, cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 0, 0), 2)
        cv2.circle(frame, text_position, 5, (255, 0, 0), -1)

        # Find distance between Left Shoulder (5) and Left Wrist (9)
        distance, text, text_position, pointOutA, pointOutB = model.distance_between_2_points(keypoints, 5, 9)
        cv2.putText(frame, text, text_position, cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 0), 2)
        cv2.line(frame, pointOutA, pointOutB, (0, 255, 0), 2)

        # Find distance between Right Shoulder (6) and Right Wrist (10)
        distance, text, text_position, pointOutC, pointOutD = model.distance_between_2_points(keypoints, 6, 10)
        cv2.putText(frame, text, text_position, cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 0), 2)
        cv2.line(frame, pointOutC, pointOutD, (0, 255, 0), 2)

        # Find the angle between Left Shoulder (5), Left Wrist (9) and Right Shoulder (6), Right Wrist (10)
        angle, text, text_position = model.angle_between_2_lines(keypoints, 5, 9, 6, 10)
        cv2.putText(frame, text, text_position, cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255), 2)
    
    except Exception as e:
        print(e)
        pass

    cv2.imshow("frame", frame)
    cv2.waitKey(1)
```

## Features

### Pose Detection (WIP)
- [x] Keypoints / Landmarks
- [x] Angles between 3 points
- [x] Distance between 2 points
- [x] Angle between 2 lines

### Object Detection (WIP)

### Face Detection (WIP)

## References

- [Ultralytics YOLOv8](https://docs.ultralytics.com/tasks/pose/)

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "yolozone",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": null,
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/53/e6/b6117df4db6e6de11d6329c0c8c44dc39182d350e508f0190514316e4c63/yolozone-0.0.2.tar.gz",
    "platform": null,
    "description": "# YoloZone\n\nYoloZone is a helper library for detecting and analyzing human poses in images and videos using the YOLO models. It provides simple functions for finding keypoints, angles, and distances between points in a pose.\n\n## Installation\n\n```bash\npip install yolozone\n```\n\n## Keypoints / Landmarks\n\nWe use the YOLO model for pose landmarks without any changes. The model returns 17 keypoints / landmarks.\n\n| Keypoint | Description |\n| -------- | -------- |\n| 0 | Nose |\n| 1 | Left Eye |\n| 2 | Right Eye |\n| 3 | Left Ear |\n| 4 | Right Ear |\n| 5 | Left Shoulder |\n| 6 | Right Shoulder |\n| 7 | Left Elbow |\n| 8 | Right Elbow |\n| 9 | Left Wrist |\n| 10 | Right Wrist |\n| 11 | Left Hip |\n| 12 | Right Hip |\n| 13 | Left Knee |\n| 14 | Right Knee |\n| 15 | Left Ankle |\n| 16 | Right Ankle |\n\n## Usage\n\n```python\nfrom yolozone import PoseDetector\nimport cv2\n\nmodel = PoseDetector(model=\"yolov8n-pose.pt\") # Initialize model\ncap = cv2.VideoCapture(0) # Initialize video capture for webcam / cameras\n# cap = cv2.VideoCapture(\"test/video.mp4\") # Initialize video capture for video\n\nwhile True:\n    try:\n        ret, frame = cap.read() # Read frame\n        \n        # Find keypoints\n        keypoints = model.find_keypoints(frame, device=\"mps\")\n\n        # Get Points and Lines to Draw pose\n        points, lines = model.draw_pose(keypoints)\n\n        # Draw points\n        for point in points:\n            cv2.circle(frame, point, 5, (255, 255, 255), 2)\n        \n        # Draw lines\n        for line in lines:\n            cv2.line(frame, line[0], line[1], (255, 255, 255), 2) # line[0] and line[1] are starting and ending points of the line\n        \n        # Find angle between Left Shoulder (5) , Left Elbow (7) and Left Wrist (9)\n        angle, text, text_position = model.angle_between_3_points(keypoints, 5, 7, 9)\n        cv2.putText(frame, text, text_position, cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 0, 0), 2)\n        cv2.circle(frame, text_position, 5, (255, 0, 0), -1)\n\n        # Find distance between Left Shoulder (5) and Left Wrist (9)\n        distance, text, text_position, pointOutA, pointOutB = model.distance_between_2_points(keypoints, 5, 9)\n        cv2.putText(frame, text, text_position, cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 0), 2)\n        cv2.line(frame, pointOutA, pointOutB, (0, 255, 0), 2)\n\n        # Find distance between Right Shoulder (6) and Right Wrist (10)\n        distance, text, text_position, pointOutC, pointOutD = model.distance_between_2_points(keypoints, 6, 10)\n        cv2.putText(frame, text, text_position, cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 0), 2)\n        cv2.line(frame, pointOutC, pointOutD, (0, 255, 0), 2)\n\n        # Find the angle between Left Shoulder (5), Left Wrist (9) and Right Shoulder (6), Right Wrist (10)\n        angle, text, text_position = model.angle_between_2_lines(keypoints, 5, 9, 6, 10)\n        cv2.putText(frame, text, text_position, cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255), 2)\n    \n    except Exception as e:\n        print(e)\n        pass\n\n    cv2.imshow(\"frame\", frame)\n    cv2.waitKey(1)\n```\n\n## Features\n\n### Pose Detection (WIP)\n- [x] Keypoints / Landmarks\n- [x] Angles between 3 points\n- [x] Distance between 2 points\n- [x] Angle between 2 lines\n\n### Object Detection (WIP)\n\n### Face Detection (WIP)\n\n## References\n\n- [Ultralytics YOLOv8](https://docs.ultralytics.com/tasks/pose/)\n",
    "bugtrack_url": null,
    "license": null,
    "summary": null,
    "version": "0.0.2",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b19c33bb679539079753dee81c33708e35f7ef86adca1cdd2ec32587a86a8771",
                "md5": "0f23dfec1f768cb4eac4e1163979d319",
                "sha256": "8e22105276695237c83e20b4ab0c5c2f818b5bcc2ccfbacfbde8ee99f4c2cda5"
            },
            "downloads": -1,
            "filename": "yolozone-0.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0f23dfec1f768cb4eac4e1163979d319",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 4018,
            "upload_time": "2024-10-26T13:35:38",
            "upload_time_iso_8601": "2024-10-26T13:35:38.715688Z",
            "url": "https://files.pythonhosted.org/packages/b1/9c/33bb679539079753dee81c33708e35f7ef86adca1cdd2ec32587a86a8771/yolozone-0.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "53e6b6117df4db6e6de11d6329c0c8c44dc39182d350e508f0190514316e4c63",
                "md5": "c94ef7e3423596f23ddba178e99c4fcf",
                "sha256": "ec74853d6a10895be46c14c536182df30381efd9097e17c2b56240bc99036e8f"
            },
            "downloads": -1,
            "filename": "yolozone-0.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "c94ef7e3423596f23ddba178e99c4fcf",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 3704,
            "upload_time": "2024-10-26T13:35:40",
            "upload_time_iso_8601": "2024-10-26T13:35:40.646164Z",
            "url": "https://files.pythonhosted.org/packages/53/e6/b6117df4db6e6de11d6329c0c8c44dc39182d350e508f0190514316e4c63/yolozone-0.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-26 13:35:40",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "yolozone"
}
        
Elapsed time: 0.86279s