vision module is not using rtmp stream anymore

jpeg webstream now runs with nearly zerolatency (currently limited to 640x480px)
This commit is contained in:
Joel 2021-02-04 16:02:45 +01:00
parent 6c579bb5fb
commit d4b577046e
No known key found for this signature in database
GPG key ID: BDDDBECD0808290E
5 changed files with 20 additions and 8 deletions

View file

@ -34,7 +34,7 @@ fpm -s python --python-bin python3 --python-pip pip3 --python-package-name-prefi
-d "python3-pigpio" \
-d "python3-numpy" \
-d "ffmpeg" \
-v 0.0.4-16 -t deb setup.py
-v 0.0.4-17 -t deb setup.py
# --deb-changelog changelog \
# --deb-upstream-changelog changelog \

View file

@ -47,8 +47,9 @@ class __Streaming:
This is done implicitly when importing the vision module and will only fail if you would
create an object of this class. (There can (SHOULD!) only be one VideCapture)
"""
self.__camera_stream = cv2.VideoCapture(RTMP_SERVER)
# self.__camera_stream = cv2.VideoCapture(0)
Logging.get_logger().info("capturing rtmp stream is disabled in this version")
#self.__camera_stream = cv2.VideoCapture(RTMP_SERVER)
self.__camera_stream = cv2.VideoCapture(0)
self.__newest_frame = None
self.__lock = threading.Lock()
Logging.get_logger().info("Initialized vision")

View file

@ -16,6 +16,8 @@ except Exception as e:
__run = """raspivid -t 0 -b 5000000 -w 1280 -h 720 -fps 30 -n -o - | gst-launch-1.0 fdsrc ! video/x-h264,width=1280,height=720,framerate=30/1,noise-reduction=1,profile=high,stream-format=byte-stream ! h264parse ! queue ! flvmux streamable=true ! rtmpsink location=\"rtmp://localhost/live/stream\""""
STREAM_RASPI = False if os.getenv("STREAM_RASPI", "false") == "false" else True
def check_battery():
while True:
@ -40,6 +42,7 @@ if __name__ == '__main__':
systemd.daemon.notify('READY=1')
logstash_logger.info("starting battery checker")
battery_checker = None
try:
battery_checker = threading.Thread(target=check_battery)
battery_checker.start()
@ -47,6 +50,14 @@ if __name__ == '__main__':
except Exception as e:
logstash_logger.error(f"could not start battery checker -> {str(e)}")
logstash_logger.info("starting gstreamer background process")
os.system(__run)
logstash_logger.error("gstreamer stopped...")
if STREAM_RASPI:
logstash_logger.info("starting gstreamer background process")
os.system(__run)
logstash_logger.error("gstreamer stopped...")
else:
logstash_logger.info("not starting gstreamer background process and only checking for battery")
if battery_checker is not None:
battery_checker.join()
else:
logstash_logger.info("battery checker failed to initialize.. sleeping for a day")
time.sleep(60*60*24)

View file

@ -1,4 +1,4 @@
__version__ = "0.0.4-16"
__version__ = "0.0.4-17"
import compLib.LogstashLogging
import logging

View file

@ -12,7 +12,7 @@ else:
setuptools.setup(
name="complib",
version="0.0.4-16",
version="0.0.4-17",
author="F-WuTs",
author_email="--",
description="",