Skip to content

Instantly share code, notes, and snippets.

@idvorkin
Created March 24, 2024 15:39
Show Gist options
  • Save idvorkin/c1e201ad1a1c90069fc51bf11fa37817 to your computer and use it in GitHub Desktop.
Save idvorkin/c1e201ad1a1c90069fc51bf11fa37817 to your computer and use it in GitHub Desktop.

Changes to idvorkin/video-edit Between [2024-03-25] and [14 days ago]

Changes in idvorkin/video-edit


pose_helper.py

  • +195, -0, * 0:
  • (https://github.com/idvorkin/video-edit/blob/f585dbf580133b0fd2e2d1c911892d1b83502055/pose_helper.py)
  • Added the pose_helper.py file containing classes and functions for pose estimation and manipulation.
    • Added BodyPart Enum for mapping from index to body part.
    • Added functions get_body_part and is_interesting_body_part for handling body part indexes.
    • Defined Bone as a NamedTuple with bottom and top as torch.tensor.
    • Added Body class for handling keypoints and confidence of body parts.
      • Methods in Body class include make_bone, get_part, neck, spine, r_upper_arm, r_total_arm, r_arm_lower, r_leg_upper, r_leg_lower, hip_angle, knee_angle, armpit_angle, spine_vertical, and neck_to_head.
    • Added functions make_angle, bone_to_horizontal, bone_to_vertical for angle calculations.
    • Added add_pose function to annotate poses on images using OpenCV. This function visualizes keypoints, angles, and bones on the given image.---

cv_helper.py

  • +73, -3, * 12:
  • (https://github.com/idvorkin/video-edit/blob/f585dbf580133b0fd2e2d1c911892d1b83502055/cv_helper.py)
  • Significant restructuring of LazyVideoWriter to support multithreading.
    • Added threading and queue imports.
    • Introduced a frame queue for buffering frames before they are written.
    • Implemented a process_queue method to handle frame writing in a separate thread.
    • Modified the write method to enqueue frames instead of writing them directly.
    • Added thread management logic in release method to ensure proper thread shutdown.
  • Added write_text function for drawing text on images.
    • Supports multi-line text and automatically calculates box size.
    • Allows specifying font scale.
    • Draws a background rectangle for the text for better visibility.
  • Added scale_point_to_image function.
    • Scales a normalized point to image dimensions.
    • Validates input types and value ranges.
  • Simplified for loop syntax in process_video function by removing unnecessary parentheses.---

yolo.py

  • +13, -2, *5
  • (https://github.com/idvorkin/video-edit/blob/f585dbf580133b0fd2e2d1c911892d1b83502055/yolo.py)
  • Removed the import of Annotator and colors from plots.
  • Imported BodyPart, get_body_part, is_interesting_body_part, Body, and add_pose from pose_helper.
  • Changed the pretrained YOLO model from yolov8n-seg.pt to yolov8n-pose.pt.
  • Added a new method add_pose in the YoloProcessor class to add pose to the image.
  • Modified the frame method to use the added pose to the base image before writing to yolo_writer.
  • Adjusted the call to cv_helper.process_video to include a space after the comma, improving code style consistency.---

.pre-commit-config.yaml

Unranked diff report

cv_helper.py

  • +73, -3, * 12:
  • (https://github.com/idvorkin/video-edit/blob/f585dbf580133b0fd2e2d1c911892d1b83502055/cv_helper.py)
  • Significant restructuring of LazyVideoWriter to support multithreading.
    • Added threading and queue imports.
    • Introduced a frame queue for buffering frames before they are written.
    • Implemented a process_queue method to handle frame writing in a separate thread.
    • Modified the write method to enqueue frames instead of writing them directly.
    • Added thread management logic in release method to ensure proper thread shutdown.
  • Added write_text function for drawing text on images.
    • Supports multi-line text and automatically calculates box size.
    • Allows specifying font scale.
    • Draws a background rectangle for the text for better visibility.
  • Added scale_point_to_image function.
    • Scales a normalized point to image dimensions.
    • Validates input types and value ranges.
  • Simplified for loop syntax in process_video function by removing unnecessary parentheses.---

pose_helper.py

  • +195, -0, * 0:
  • (https://github.com/idvorkin/video-edit/blob/f585dbf580133b0fd2e2d1c911892d1b83502055/pose_helper.py)
  • Added the pose_helper.py file containing classes and functions for pose estimation and manipulation.
    • Added BodyPart Enum for mapping from index to body part.
    • Added functions get_body_part and is_interesting_body_part for handling body part indexes.
    • Defined Bone as a NamedTuple with bottom and top as torch.tensor.
    • Added Body class for handling keypoints and confidence of body parts.
      • Methods in Body class include make_bone, get_part, neck, spine, r_upper_arm, r_total_arm, r_arm_lower, r_leg_upper, r_leg_lower, hip_angle, knee_angle, armpit_angle, spine_vertical, and neck_to_head.
    • Added functions make_angle, bone_to_horizontal, bone_to_vertical for angle calculations.
    • Added add_pose function to annotate poses on images using OpenCV. This function visualizes keypoints, angles, and bones on the given image.---

yolo.py

  • +13, -2, *5
  • (https://github.com/idvorkin/video-edit/blob/f585dbf580133b0fd2e2d1c911892d1b83502055/yolo.py)
  • Removed the import of Annotator and colors from plots.
  • Imported BodyPart, get_body_part, is_interesting_body_part, Body, and add_pose from pose_helper.
  • Changed the pretrained YOLO model from yolov8n-seg.pt to yolov8n-pose.pt.
  • Added a new method add_pose in the YoloProcessor class to add pose to the image.
  • Modified the frame method to use the added pose to the base image before writing to yolo_writer.
  • Adjusted the call to cv_helper.process_video to include a space after the comma, improving code style consistency.---

.pre-commit-config.yaml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment