RojaKatta commited on
Commit
dd4a0c4
·
verified ·
1 Parent(s): 0d48969

Delete overlay.py

Browse files
Files changed (1) hide show
  1. overlay.py +0 -32
overlay.py DELETED
@@ -1,32 +0,0 @@
1
- import cv2
2
- import numpy as np
3
-
4
-
5
- def overlay_hairstyle(img, hairstyle_img, mask, x_offset=0, y_offset=0, scale=1.0):
6
- # Resize the hairstyle
7
- h, w = img.shape[:2]
8
- hs = cv2.resize(hairstyle_img, (0, 0), fx=scale, fy=scale)
9
- hh, hw = hs.shape[:2]
10
-
11
-
12
- # Position
13
- center_x, center_y = w // 2 + x_offset, h // 5 + y_offset
14
- top_left_x = max(0, center_x - hw // 2)
15
- top_left_y = max(0, center_y - hh // 2)
16
-
17
-
18
- roi = img[top_left_y:top_left_y+hh, top_left_x:top_left_x+hw]
19
- if roi.shape[:2] != hs.shape[:2]:
20
- return img
21
-
22
-
23
- if hs.shape[2] == 4:
24
- alpha = hs[:, :, 3] / 255.0
25
- for c in range(3):
26
- roi[:, :, c] = roi[:, :, c] * (1 - alpha) + hs[:, :, c] * alpha
27
- else:
28
- roi[:] = hs
29
-
30
-
31
- img[top_left_y:top_left_y+hh, top_left_x:top_left_x+hw] = roi
32
- return img