Skip to content

Commit 331de4c

Browse files
committed
0.0.1a10
1 parent 37038f7 commit 331de4c

24 files changed

+314
-84
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
config.py

build/lib/eggdriver/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
from eggdriver.nqs import *
55
from eggdriver.resources import *
66
from eggdriver.app import *
7-
from eggdriver.pypi import build
7+
from eggdriver.pypi import *
8+
from eggdriver.version import *

build/lib/eggdriver/pypi.py

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from eggdriver.resources import installFromRequests, sysCommand, py
22

3+
defaultVersion = '0.0.1a'
4+
35
"""
46
FUNCTION build()
57
Build and upload a pypi package release
@@ -10,18 +12,42 @@
1012
py -m twine check dist/*
1113
py -m twine upload dist/*
1214
"""
13-
def build(autoVersion = True):
15+
16+
17+
18+
def build(autoVersion = True, baseVersion = defaultVersion):
1419
"""Build and upload a pypi package release"""
1520
installFromRequests(["setuptools", "twine", "build"], False)
1621
if autoVersion:
1722
setup = py.getLines("setup")
1823
firstLine = setup[0].split()
1924
v = firstLine[2]
20-
value = int(v[7:-1]) + 1
21-
v = '0.0.1a' + str(value)
25+
index = len(baseVersion) + 1
26+
value = int(v[index:-1]) + 1
27+
v = baseVersion + str(value)
2228
firstLine = [f"v = \"{v}\""]
2329
py.writeLines(firstLine + setup[1:], "setup")
2430
sysCommand("-m build --sdist")
2531
sysCommand("-m build --wheel")
2632
sysCommand("-m twine check dist/*")
2733
sysCommand("-m twine upload dist/*")
34+
35+
def buildEggdriver(autoVersion = True, baseVersion = defaultVersion):
36+
"""Build and upload a eggdriver release"""
37+
installFromRequests(["setuptools", "twine", "build"], False)
38+
if autoVersion:
39+
setup = py.getLines("setup")
40+
firstLine = setup[0].split()
41+
v = firstLine[2]
42+
index = len(baseVersion) + 1
43+
value = int(v[index:-1]) + 1
44+
v = baseVersion + str(value)
45+
firstLine = [f"v = \"{v}\""]
46+
py.writeLines(firstLine + setup[1:], "setup")
47+
version = py.getLines("eggdriver/version")
48+
firstLine2 = [f"ver = \"{v}\""]
49+
py.writeLines(firstLine2 + version[1:], "eggdriver/version")
50+
sysCommand("-m build --sdist")
51+
sysCommand("-m build --wheel")
52+
sysCommand("-m twine check dist/*")
53+
sysCommand("-m twine upload dist/*")

build/lib/eggdriver/resources/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from eggdriver.resources.utils import *
1212
from eggdriver.resources.web import *
1313
from eggdriver.resources.math import *
14+
from eggdriver.resources.video import *
1415

1516
author="eanorambuena"
1617
author_email="[email protected]"
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
import cv2
2+
import mediapipe as mp
3+
import numpy as np
4+
from eggdriver.resources.video.effects import *
5+
from eggdriver.resources.video.backgrounds import *
6+
7+
counterIterator = 0
8+
9+
def forever():
10+
return True
11+
12+
def stop():
13+
return input()
14+
15+
def itself(var):
16+
return var
17+
18+
def count(value = 100, step = 1):
19+
global counterIterator
20+
counterIterator += step
21+
print(value - counterIterator)
22+
result = counterIterator < value
23+
return result
24+
25+
defaultEffect = [(itself, [])]
26+
defaultCondition = (count, [100])
27+
defaultUser = 'WEBCAM'
28+
29+
def changeBackground(image, bg_image, background_effects = defaultEffect):
30+
th, th_inv = removeBG(image)
31+
bg = maskImage(bg_image, th_inv)
32+
for ef in background_effects:
33+
args = [bg] + ef[1]
34+
bg = ef[0](*args)
35+
fg = maskImage(image, th)
36+
final = cv2.bitwise_or(bg, fg)
37+
return final
38+
39+
def capture():
40+
print("Turning on the WebCam...")
41+
return cv2.VideoCapture(0)
42+
43+
def applyEffects(image, effects, background_effects):
44+
for ef in effects:
45+
args = [image] + ef[1]
46+
image = ef[0](*args)
47+
return changeBackground(image, image, background_effects)
48+
49+
def webCam(user = defaultUser, effects = defaultEffect, background_effects = defaultEffect, number_of_windows = 1, apply_effects_to = "all", condition = defaultCondition):
50+
global counterIterator
51+
counterIterator = 0
52+
cap = capture()
53+
while (cap.isOpened()):
54+
ret, image = cap.read()
55+
if ret == True and condition[0](*condition[1]):
56+
for i in range(number_of_windows):
57+
if apply_effects_to == "all":
58+
image = applyEffects(image, effects, background_effects)
59+
else:
60+
image = applyEffects(image, [effects[i]], [background_effects[i]])
61+
cv2.imshow(user, image)
62+
if cv2.waitKey(1) & 0xFF == ord('s'):
63+
break
64+
else: break
65+
cap.release()
66+
cv2.destroyAllWindows()
67+
68+
def changeBackgroundWebCam(user = defaultUser, new_background = solidBackground(), effects = defaultEffect, condition = defaultCondition):
69+
webCam(user, [(changeBackground, [new_background])] + effects, condition)
70+
71+
class WEBCAM():
72+
def __init__(self, user, condition = count, *args):
73+
self.user = user
74+
self.condition = (condition, args)
75+
def default(self, effects = defaultEffect, background_effects = defaultEffect, number_of_windows = 1, apply_effects_to = "all",):
76+
webCam(user = self.user,
77+
effects = effects,
78+
background_effects = background_effects,
79+
number_of_windows = number_of_windows,
80+
apply_effects_to = apply_effects_to,
81+
condition = self.condition)
82+
def changeBackground(self, new_background, effects = defaultEffect, background_effects = defaultEffect, number_of_windows = 1, apply_effects_to = "all"):
83+
changeBackgroundWebCam(user = self.user,
84+
new_background = new_background,
85+
effects = effects,
86+
background_effects = background_effects,
87+
number_of_windows = number_of_windows,
88+
apply_effects_to = apply_effects_to,
89+
condition = self.condition)
90+
91+
class User():
92+
def __init__(self, username = "video"):
93+
self.user = username
94+
self.background = 0
95+
self.ef = defaultEffect
96+
def setBackground(self, background):
97+
self.background = background
98+
def addEffect(self, *effects):
99+
self.ef = effects
100+
def meeting(self, condition = forever, *args):
101+
if type(self.background) == int:
102+
webCam(self.user, condition, *args)
103+
else:
104+
changeBackgroundWebCam(self.user, self.background, condition, *args)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import cv2
2+
import numpy as np
3+
4+
def solidBackground(shape = (480, 640, 3), color = (0, 255, 0)):
5+
bg_image = np.ones(shape, dtype = np.uint8)
6+
bg_image[:] = color
7+
return bg_image
8+
9+
def imageBackground(source):
10+
return cv2.imread(source)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import cv2
2+
import numpy as np
3+
import mediapipe as mp
4+
5+
def removeBG(image):
6+
mp_selfie_segmentation = mp.solutions.selfie_segmentation
7+
selfie_segmentation = mp_selfie_segmentation.SelfieSegmentation(model_selection = 1)
8+
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
9+
results = selfie_segmentation.process(image)
10+
_, th = cv2.threshold(results.segmentation_mask, 0.75, 255, cv2.THRESH_BINARY)
11+
th = th.astype(np.uint8)
12+
th_inv = cv2.bitwise_not(th)
13+
return th, th_inv
14+
15+
def maskImage(image, mask):
16+
return cv2.bitwise_and(image, image, mask = mask)
17+
18+
def blur(image):
19+
return cv2.GaussianBlur(image, (15, 15), 0)

build/lib/eggdriver/version.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
ver = "0.0.1a10"
2+
3+
"""Simply the current installed eggdriver version. The version information is
4+
stored in the regular eggdriver module as eggdriver.ver'. Keeping the version
5+
information also available in a separate module allows you to test the
6+
eggdriver version without importing the main eggdriver module.
7+
"""
8+
9+
__all__ = ["ver"]
37.9 KB
Binary file not shown.

dist/eggdriver-0.0.1a10.tar.gz

94 MB
Binary file not shown.

0 commit comments

Comments
 (0)