Package to Calculate Human Body Measurements
Project description
Human Body Measurement via Video and Image
Install the Package
$ pip install body-matrix
Package Usage
#### LOAD VIDEO, Keypoints and Segmentation Model
from body_matrix import load, infer, process, measure, draw, export
video_path = "/content/drive/MyDrive/Body_Matrix/Raw_Vids/vinmart_customers.mp4"
video_rotate = -90
device = "cuda"
font_path = "/content/drive/MyDrive/Body_Matrix/Roboto-Bold.ttf"
keypoints_model, keypoints_transform = load.keypoints_model(device)
segment_model, segment_transform = load.segment_model(device)
video, frame_counts, fps, sample_frame = load.video(
video_path=video_path,
rotate_angle=video_rotate,
frame_position=1
)
sample_frame
#### Measure and Visualize Every frame
from body_matrix import score
from torchvision.transforms.functional import to_pil_image
measure_frames = []
measures = []
for index, vid_frame in enumerate(video):
frame = to_pil_image(vid_frame)
frame = frame.rotate(video_rotate, expand=True)
height, leg, hip, shoulder, markers = measure.find_real_measures(
image_frame=frame,
device=device,
keypoints_model=keypoints_model,
keypoints_transform=keypoints_transform,
segment_model=segment_model,
segment_transform=segment_transform
)
visualized_frame = draw.visualize_measures(
height, leg, hip, shoulder, markers,
frame, font_path
)
measure_frames.append(visualized_frame)
measures.append(height)
mean, median, minim, maxim = score.best_scores(
measures,
100,
200
)
best_score, frame_index = score.find_nearest(
measures,
median
)
#### Export Instagram Video with Measures
export.generate_instagram_vid(
vid_name="instameasures_hoangdo.mp4",
vid_width = sample_frame.width,
vid_height = sample_frame.height,
pil_images = measure_frames,
stop_index=frame_index,
fps=fps,
repeat_rate=2,
slow_motion_rate=1
)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
body_matrix-0.4.4.tar.gz
(12.7 kB
view details)
Built Distribution
File details
Details for the file body_matrix-0.4.4.tar.gz
.
File metadata
- Download URL: body_matrix-0.4.4.tar.gz
- Upload date:
- Size: 12.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dc01882e0f4f5df0351953d2fb77b853a5a57a67a7f154c58008a5f05b5fcadf |
|
MD5 | 84d5a5b6cc470967234053747264a9a3 |
|
BLAKE2b-256 | 0c5bbffc41614532e7db70a7e4d23ad8308c9b6f22ad43414ebc8aa525cbd919 |
File details
Details for the file body_matrix-0.4.4-py3-none-any.whl
.
File metadata
- Download URL: body_matrix-0.4.4-py3-none-any.whl
- Upload date:
- Size: 14.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9cf73651b60f68523474b4f00898550ca414fbc36da97137e984ff39faa36f5d |
|
MD5 | 71bb961c231c899a8f8ec4467344e9c5 |
|
BLAKE2b-256 | 61e8a82af9a18de12488242bb19ac0bcec74ad50f71c9a3d7ba3aff73178752b |