Skip to content

Commit

Permalink
The cool branch
Browse files Browse the repository at this point in the history
  • Loading branch information
cnheider committed Mar 27, 2020
1 parent 77d75f7 commit 4dc55cf
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 34 deletions.
6 changes: 3 additions & 3 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
# General information about the project.
project = "Neo"
author = "Christian Heider Nielsen"
copyright = "2017, {author}".format(author=author)
copyright = f"2017, {author}"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -208,7 +208,7 @@ def handle_item(fieldarg, content):
# inconsistencies later when references are resolved
fieldtype = types.pop(fieldarg)
if len(fieldtype) == 1 and isinstance(fieldtype[0], nodes.Text):
typename = u"".join(n.astext() for n in fieldtype)
typename = "".join(n.astext() for n in fieldtype)
typename = typename.replace("int", "python:int")
typename = typename.replace("long", "python:long")
typename = typename.replace("float", "python:float")
Expand All @@ -219,7 +219,7 @@ def handle_item(fieldarg, content):
domain,
typename,
addnodes.literal_emphasis,
**kw
**kw,
)
)
else:
Expand Down
2 changes: 1 addition & 1 deletion scripts/clean_generated_files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ rm models/ -r
mkdir logs
mkdir models
touch models/.trackfolder
touch logs/.trackfolder
touch logs/.trackfolder
42 changes: 36 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@ def python_version_check(major=3, minor=6):
with open(
pathlib.Path(__file__).parent / "streamserver" / "__init__.py", "r"
) as project_init_file:
str_reg_exp = "['\"]([^'\"]*)['\"]"
content = project_init_file.read() # get strings from module
version = re.search(r"__version__ = ['\"]([^'\"]*)['\"]", content, re.M).group(1)
project_name = re.search(
r"PROJECT_NAME = ['\"]([^'\"]*)['\"]", content, re.M
).group(1)
author = re.search(r"__author__ = ['\"]([^'\"]*)['\"]", content, re.M).group(1)
version = re.search(rf"__version__ = {str_reg_exp}", content, re.M).group(1)
project_name = re.search(rf"__project__ = {str_reg_exp}", content, re.M).group(1)
author = re.search(rf"__author__ = {str_reg_exp}", content, re.M).group(1)
__author__ = author


Expand Down Expand Up @@ -59,18 +58,49 @@ def get_license():
return "Apache License, Version 2.0"


def get_extras():
these_extras = {
# 'ExtraName':['package-name; platform_system == "System(Linux,Windows)"'
}

path: pathlib.Path = pathlib.Path(__file__).parent

for file in path.iterdir():
if file.name.startswith("requirements_"):

requirements_group = []
with open(str(file.absolute())) as f:
requirements = f.readlines()

for requirement in requirements:
requirements_group.append(requirement.strip())

group_name_ = "_".join(file.name.strip(".txt").split("_")[1:])

these_extras[group_name_] = requirements_group

all_dependencies = []

for group_name in these_extras:
all_dependencies += these_extras[group_name]
these_extras["all"] = all_dependencies

return these_extras


setup(
name=project_name,
version=version,
description="Server to stream multi-part images over HTTP",
author=author,
package_data={"": ["viewer_mini.html"]},
include_package_data=True,
python_requires=">=3",
python_requires=">=3.6",
packages=find_packages(),
install_requires=get_requirements(),
entry_points=get_entry_points(),
license=get_license(),
extras_require=get_extras(),
long_description_content_type="text/markdown",
long_description=get_readme(),
url="",
Expand Down
9 changes: 5 additions & 4 deletions streamserver/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@
# -*- coding: utf-8 -*-
from apppath import AppPath

__project__ = "StreamServer"
__author__ = "Soeren Rasmussen"
__version__ = "0.4.2"
__doc__ = r"""
.. module:: streamserver
:platform: Unix, Windows
:synopsis: multipart image HTTP streaming server.
.. moduleauthor:: Soeren Rasmussen
Created on 27/04/2018
@author: Soeren Rasmussen
"""

PROJECT_NAME = "StreamServer"
PROJECT_NAME = __project__.lower().strip().replace(" ", "_")
PROJECT_AUTHOR = __author__.lower().strip().replace(" ", "_")
PROJECT_APP_PATH = AppPath(app_name=PROJECT_NAME, app_author=PROJECT_AUTHOR)
8 changes: 4 additions & 4 deletions streamserver/samples/ss_cv2.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
__author__ = 'cnheider'
__author__ = "cnheider"


def main():
Expand All @@ -12,15 +12,15 @@ def main():
ret, _ = cap.read()
assert ret == True

with streamserver.StreamServer(JPEG_quality=75, host='localhost', port=5000) as ss:
with streamserver.StreamServer(JPEG_quality=75, host="localhost", port=5000) as ss:
while cap.isOpened():
ret, frame = cap.read()
ss.set_frame(frame)
wk = cv2.waitKey(20)
if wk == ord('q'):
if wk == ord("q"):
break
cap.release()


if __name__ == '__main__':
if __name__ == "__main__":
main()
13 changes: 7 additions & 6 deletions streamserver/samples/ss_imageio.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
__author__ = 'cnheider'
__author__ = "cnheider"


def main():
import imageio
import streamserver


reader = imageio.get_reader('<video0>')
reader = imageio.get_reader("<video0>")

try:
with streamserver.StreamServer(JPEG_quality=75, host='localhost', port=5000) as ss:
with streamserver.StreamServer(
JPEG_quality=75, host="localhost", port=5000
) as ss:
for im in reader:
ss.set_frame(im)
except KeyboardInterrupt:
pass



if __name__ == '__main__':
if __name__ == "__main__":
main()
18 changes: 9 additions & 9 deletions streamserver/viewer.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,18 @@
xhr.open('GET', url + '?q=ping', true);
xhr.send();
};
</script>
</head>
<body style="background-color: #FFFFFF; background-image:radial-gradient(closest-side at 60% 55%, #FFF,
</script>
</head>
<body style="background-color: #FFFFFF; background-image:radial-gradient(closest-side at 60% 55%, #FFF,
#f2f2f2);"
onload="connect();
onload="connect();
timerrunning = true; timer =
setInterval(connect,200);">
<div style='text-align: center;'>
<div style='text-align: center;'>
<span style='font-family: monospace; font-weight: bold;'>
<span id='status' style='color:yellow;'>Initializing</span>
</span><br>
<img id='image' src=''>
</div>
</body>
</html>
<img id='image' src=''>
</div>
</body>
</html>
42 changes: 41 additions & 1 deletion streamserver/viewer_mini.html
Original file line number Diff line number Diff line change
@@ -1 +1,41 @@
<html> <head> <script>var url='{URL}'; var timer; var timerrunning=false; disconnected=function(){document.getElementById('status').innerText='Disconnected'; document.getElementById('status').style='color:red'; if (timerrunning==false){timerrunning=true; timer=setInterval(connect,250);}}; connected=function(){clearInterval(timer); timerrunning=false; document.getElementById('image').src=url; document.getElementById('status').innerText='Connected'; document.getElementById('status').style='color:green';}; var xhr=new XMLHttpRequest(); xhr.onreadystatechange=function (){var rst=xhr.readyState; if (rst==2){connected();}else if (rst==4){disconnected();}}; connect=function(){xhr.open('GET',url+'?q=ping',true); xhr.send();}; </script> </head> <body style="background-color: #FFFFFF; background-image:radial-gradient(closest-side at 60% 55%, #FFF, #f2f2f2);" onload="connect(); timerrunning=true; timer=setInterval(connect,200);"> <div style='text-align: center;'> <span style='font-family: monospace; font-weight: bold;'> <span id='status' style='color:yellow;'>Initializing</span> </span><br><img id='image' src=''> </div></body></html>
<html>
<head>
<script>var url = '{URL}';
var timer;
var timerrunning = false;
disconnected = function () {
document.getElementById('status').innerText = 'Disconnected';
document.getElementById('status').style = 'color:red';
if (timerrunning == false) {
timerrunning = true;
timer = setInterval(connect, 250);
}
};
connected = function () {
clearInterval(timer);
timerrunning = false;
document.getElementById('image').src = url;
document.getElementById('status').innerText = 'Connected';
document.getElementById('status').style = 'color:green';
};
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
var rst = xhr.readyState;
if (rst == 2) {
connected();
} else if (rst == 4) {
disconnected();
}
};
connect = function () {
xhr.open('GET', url + '?q=ping', true);
xhr.send();
}; </script>
</head>
<body
style="background-color: #FFFFFF; background-image:radial-gradient(closest-side at 60% 55%, #FFF, #f2f2f2);"
onload="connect(); timerrunning=true; timer=setInterval(connect,200);">
<div style='text-align: center;'><span style='font-family: monospace; font-weight: bold;'> <span
id='status' style='color:yellow;'>Initializing</span> </span><br><img id='image' src=''></div>
</body>
</html>

0 comments on commit 4dc55cf

Please sign in to comment.