This package allows you to detect faces in real-time using a webcam and overlay an AR object above the detected face.
Project description
Refined Augment
Refined Augment is a powerful Python package designed for enhancing and augmenting data using Artificial Intelligence. It specializes in Computer Vision tasks, allowing users to seamlessly overlay 2D images and 3D OBJ models onto faces and hands in real-time.
Features
- Dual Target Detection: Support for both Face and Hand landmarks.
- 3D Model Support: Render
.objfiles directly onto detected targets with automatic scaling. - 2D Overlay Support: Perspective warping for
.png,.jpg, and web-hosted images. - Flexible Positioning: Place overlays
above,below,left,right, orinfrontof the target. - Multiple Detection Backends: Integration with Haar Cascades and MediaPipe.
Installation
Ensure you have the required dependencies installed:
pip install opencv-python numpy mediapipe scikit-image
Usage Samples
1. 3D Face Augmentation (Real-time)
This sample uses a 3D .obj model and overlays it directly "infront" of detected faces.
import cv2
from refined_augment import Refined_Augment
ar = Refined_Augment()
cap = cv2.VideoCapture(0)
while True:
ret, frame = cap.read()
if not ret: break
# Overlay a 3D wolf model on the face
imgAug = ar.overlay(frame, "wolf.obj", target='face', position='infront')
cv2.imshow('3D Face AR', imgAug)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
2. Hand Tracking with MediaPipe
Advanced hand augmentation using MediaPipe landmarks for precise object placement.
import cv2
import mediapipe as mp
from refined_augment import Refined_Augment
ar = Refined_Augment()
mp_hands = mp.solutions.hands
hands = mp_hands.Hands(
static_image_mode=False,
max_num_hands=1,
min_detection_confidence=0.7,
min_tracking_confidence=0.5
)
cap = cv2.VideoCapture(0)
while True:
ret, frame = cap.read()
if not ret: break
img_rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
results = hands.process(img_rgb)
imgAug = frame
if results.multi_hand_landmarks:
your_hand_landmarks = results.multi_hand_landmarks[0]
# Apply the 3D model to the detected hand landmarks
imgAug = ar.overlay(
frame,
"wolf.obj",
target='hand',
hand_landmarks=your_hand_landmarks,
show_bounding_box=True,
position='infront'
)
cv2.imshow('Hand AR', imgAug)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
hands.close()
cv2.destroyAllWindows()
3. Classic 2D Image Overlay
Overlay a standard image (like a mask or logo) onto faces using Haar Cascades.
import cv2
from refined_augment import Refined_Augment
ar = Refined_Augment()
cap = cv2.VideoCapture(0)
while True:
ret, frame = cap.read()
if not ret: break
# Overlay a 2D PNG on detected faces
imgAug = ar.overlay(frame, "AR_photo.png",
use_haar=True,
manual_faces=None,
show_bounding_box=False)
cv2.imshow('2D Overlay', imgAug)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
📖 API Documentation
Refined_Augment.overlay(...)
| Parameter | Type | Description |
|---|---|---|
image |
ndarray |
The input BGR frame from OpenCV. |
overlay_path |
str |
Path to .obj or image file (Local or URL). |
target |
str |
'face' or 'hand'. |
position |
str |
'above', 'below', 'left', 'right', or 'infront'. |
use_haar |
bool |
Uses Haar Cascades for face detection (Default: True). |
hand_landmarks |
list |
Manual landmarks for hand positioning. |
hand_scale_factor |
float |
Resize the object relative to the hand size. |
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 Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file refined_augment-0.1.7-py3-none-any.whl.
File metadata
- Download URL: refined_augment-0.1.7-py3-none-any.whl
- Upload date:
- Size: 8.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d399791f3da45303d6a3f3bdedf80d85fd8a916ded41fc41af97fa21084a1bb5
|
|
| MD5 |
7581aa009e896483c8d9e3444076379b
|
|
| BLAKE2b-256 |
dd51b46517e86ea4d991365c659dff197d3eaef266739cd6e2043e0234a6c377
|