Ejemplo n.º 1
0
def run():
    """
    Entry point for the program. Starts the web server in its own thread and begins the main loop.
    """

    # Create our logger singleton instance for the rest of the application to use
    global logger
    logger = Logger.get_instance()

    global camera
    camera = TempCamera()

    try:
        web_app = Thread(target=website.webstreaming.app.run,
                         kwargs={
                             'host': '0.0.0.0',
                             'port': 5000,
                             'debug': True,
                             'use_reloader': False,
                             'threaded': True
                         })
        web_app.daemon = True
        web_app.start()
        main_loop()
    except Exception as e:
        logger.log("Web server failed to start: " + str(e), LogLevel.ERROR)
Ejemplo n.º 2
0
 def __init__(self, config: Config):
     self._configObject = config
     self._logger = Logger.get_instance()
     self._messenger_dict = self._configObject.get_config("messaging")
     self._server_connection = None
     if self._messenger_dict:
         self._connect_server()
     else:
         self._logger.log(
             'No messenger_login dict found in config object, messaging system will not work',
             LogLevel.ERROR)
         self._messenger_dict = {}
Ejemplo n.º 3
0
    def __init__(self, config_file=None):
        """
        The constructor for the config class

        @param config_file: The path to the config file to ingest JSON data from
        """
        self._logger = Logger.get_instance()
        if config_file:
            try:
                with open(config_file) as cFile:
                    self._config = json.load(cFile)
            except FileNotFoundError:
                self._logger.log(
                    "No config file was found at {}".format(config_file),
                    LogLevel.ERROR)
                self._config = {}

        else:
            self._logger.log("No config file parameter found", LogLevel.ERROR)
            self._config = {}
Ejemplo n.º 4
0
"""
This file handles the web server and streaming of video for PiEye. Runs a Flask web server.
"""
from flask import Response, Flask, render_template, request
import threading
import cv2
from log.logger import Logger, LogLevel

# The logger instance
logger = Logger.get_instance()
# global variable for output frame so it can be set by the main logic loop
outputFrame = None
# Lock for manipulating the output frame to avoid race conditions
lock = threading.Lock()
# Kill switch
kill_switch = False

app = Flask(__name__)


def set_output_frame(frame):
    """
    Sets the new output frame

    @param: frame: the new output frame
    """
    global outputFrame
    outputFrame = frame


def gen():