Skip to content

Commit

Permalink
0.0.1a10
Browse files Browse the repository at this point in the history
  • Loading branch information
eanorambuena committed Sep 16, 2021
1 parent 37038f7 commit 331de4c
Show file tree
Hide file tree
Showing 24 changed files with 314 additions and 84 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
config.py
3 changes: 2 additions & 1 deletion build/lib/eggdriver/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
from eggdriver.nqs import *
from eggdriver.resources import *
from eggdriver.app import *
from eggdriver.pypi import build
from eggdriver.pypi import *
from eggdriver.version import *
32 changes: 29 additions & 3 deletions build/lib/eggdriver/pypi.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from eggdriver.resources import installFromRequests, sysCommand, py

defaultVersion = '0.0.1a'

"""
FUNCTION build()
Build and upload a pypi package release
Expand All @@ -10,18 +12,42 @@
py -m twine check dist/*
py -m twine upload dist/*
"""
def build(autoVersion = True):



def build(autoVersion = True, baseVersion = defaultVersion):
"""Build and upload a pypi package release"""
installFromRequests(["setuptools", "twine", "build"], False)
if autoVersion:
setup = py.getLines("setup")
firstLine = setup[0].split()
v = firstLine[2]
value = int(v[7:-1]) + 1
v = '0.0.1a' + str(value)
index = len(baseVersion) + 1
value = int(v[index:-1]) + 1
v = baseVersion + str(value)
firstLine = [f"v = \"{v}\""]
py.writeLines(firstLine + setup[1:], "setup")
sysCommand("-m build --sdist")
sysCommand("-m build --wheel")
sysCommand("-m twine check dist/*")
sysCommand("-m twine upload dist/*")

def buildEggdriver(autoVersion = True, baseVersion = defaultVersion):
"""Build and upload a eggdriver release"""
installFromRequests(["setuptools", "twine", "build"], False)
if autoVersion:
setup = py.getLines("setup")
firstLine = setup[0].split()
v = firstLine[2]
index = len(baseVersion) + 1
value = int(v[index:-1]) + 1
v = baseVersion + str(value)
firstLine = [f"v = \"{v}\""]
py.writeLines(firstLine + setup[1:], "setup")
version = py.getLines("eggdriver/version")
firstLine2 = [f"ver = \"{v}\""]
py.writeLines(firstLine2 + version[1:], "eggdriver/version")
sysCommand("-m build --sdist")
sysCommand("-m build --wheel")
sysCommand("-m twine check dist/*")
sysCommand("-m twine upload dist/*")
1 change: 1 addition & 0 deletions build/lib/eggdriver/resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from eggdriver.resources.utils import *
from eggdriver.resources.web import *
from eggdriver.resources.math import *
from eggdriver.resources.video import *

author="eanorambuena"
author_email="[email protected]"
104 changes: 104 additions & 0 deletions build/lib/eggdriver/resources/video/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import cv2
import mediapipe as mp
import numpy as np
from eggdriver.resources.video.effects import *
from eggdriver.resources.video.backgrounds import *

counterIterator = 0

def forever():
return True

def stop():
return input()

def itself(var):
return var

def count(value = 100, step = 1):
global counterIterator
counterIterator += step
print(value - counterIterator)
result = counterIterator < value
return result

defaultEffect = [(itself, [])]
defaultCondition = (count, [100])
defaultUser = 'WEBCAM'

def changeBackground(image, bg_image, background_effects = defaultEffect):
th, th_inv = removeBG(image)
bg = maskImage(bg_image, th_inv)
for ef in background_effects:
args = [bg] + ef[1]
bg = ef[0](*args)
fg = maskImage(image, th)
final = cv2.bitwise_or(bg, fg)
return final

def capture():
print("Turning on the WebCam...")
return cv2.VideoCapture(0)

def applyEffects(image, effects, background_effects):
for ef in effects:
args = [image] + ef[1]
image = ef[0](*args)
return changeBackground(image, image, background_effects)

def webCam(user = defaultUser, effects = defaultEffect, background_effects = defaultEffect, number_of_windows = 1, apply_effects_to = "all", condition = defaultCondition):
global counterIterator
counterIterator = 0
cap = capture()
while (cap.isOpened()):
ret, image = cap.read()
if ret == True and condition[0](*condition[1]):
for i in range(number_of_windows):
if apply_effects_to == "all":
image = applyEffects(image, effects, background_effects)
else:
image = applyEffects(image, [effects[i]], [background_effects[i]])
cv2.imshow(user, image)
if cv2.waitKey(1) & 0xFF == ord('s'):
break
else: break
cap.release()
cv2.destroyAllWindows()

def changeBackgroundWebCam(user = defaultUser, new_background = solidBackground(), effects = defaultEffect, condition = defaultCondition):
webCam(user, [(changeBackground, [new_background])] + effects, condition)

class WEBCAM():
def __init__(self, user, condition = count, *args):
self.user = user
self.condition = (condition, args)
def default(self, effects = defaultEffect, background_effects = defaultEffect, number_of_windows = 1, apply_effects_to = "all",):
webCam(user = self.user,
effects = effects,
background_effects = background_effects,
number_of_windows = number_of_windows,
apply_effects_to = apply_effects_to,
condition = self.condition)
def changeBackground(self, new_background, effects = defaultEffect, background_effects = defaultEffect, number_of_windows = 1, apply_effects_to = "all"):
changeBackgroundWebCam(user = self.user,
new_background = new_background,
effects = effects,
background_effects = background_effects,
number_of_windows = number_of_windows,
apply_effects_to = apply_effects_to,
condition = self.condition)

class User():
def __init__(self, username = "video"):
self.user = username
self.background = 0
self.ef = defaultEffect
def setBackground(self, background):
self.background = background
def addEffect(self, *effects):
self.ef = effects
def meeting(self, condition = forever, *args):
if type(self.background) == int:
webCam(self.user, condition, *args)
else:
changeBackgroundWebCam(self.user, self.background, condition, *args)
10 changes: 10 additions & 0 deletions build/lib/eggdriver/resources/video/backgrounds.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import cv2
import numpy as np

def solidBackground(shape = (480, 640, 3), color = (0, 255, 0)):
bg_image = np.ones(shape, dtype = np.uint8)
bg_image[:] = color
return bg_image

def imageBackground(source):
return cv2.imread(source)
19 changes: 19 additions & 0 deletions build/lib/eggdriver/resources/video/effects.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import cv2
import numpy as np
import mediapipe as mp

def removeBG(image):
mp_selfie_segmentation = mp.solutions.selfie_segmentation
selfie_segmentation = mp_selfie_segmentation.SelfieSegmentation(model_selection = 1)
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
results = selfie_segmentation.process(image)
_, th = cv2.threshold(results.segmentation_mask, 0.75, 255, cv2.THRESH_BINARY)
th = th.astype(np.uint8)
th_inv = cv2.bitwise_not(th)
return th, th_inv

def maskImage(image, mask):
return cv2.bitwise_and(image, image, mask = mask)

def blur(image):
return cv2.GaussianBlur(image, (15, 15), 0)
9 changes: 9 additions & 0 deletions build/lib/eggdriver/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ver = "0.0.1a10"

"""Simply the current installed eggdriver version. The version information is
stored in the regular eggdriver module as eggdriver.ver'. Keeping the version
information also available in a separate module allows you to test the
eggdriver version without importing the main eggdriver module.
"""

__all__ = ["ver"]
Binary file added dist/eggdriver-0.0.1a10-py3-none-any.whl
Binary file not shown.
Binary file added dist/eggdriver-0.0.1a10.tar.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion eggdriver.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: eggdriver
Version: 0.0.1a9
Version: 0.0.1a10
Summary: Your proyect trusted driver.
Home-page: https://github.com/PythonForChange/eggdriver
Author: Emmanuel Norambuena
Expand Down
Loading

0 comments on commit 331de4c

Please sign in to comment.