class Monitor

Overview

outputs the video stream and detections via websockets

Defined in:

controllers/monitor.cr

Constant Summary

DETECTOR = Detector.new(INPUT_DEVICE, INPUT_WIDTH, INPUT_HEIGHT, MODEL)
ENABLE_DETECTOR = ENV["ENABLE_DETECTOR"]? == "true"
ENABLE_EDGETPU = ENV["ENABLE_EDGETPU"]? == "true"
ENABLE_REPLAY = ENV["ENABLE_REPLAY"]? == "true"
ENABLE_STREAMING = ENV["ENABLE_STREAMING"]? == "true"
INPUT_DEVICE = Path[ENV["INPUT_DEVICE"]? || "/dev/video0"]

The device details

INPUT_HEIGHT = ENV["INPUT_HEIGHT"].to_i
INPUT_WIDTH = ENV["INPUT_WIDTH"].to_i
MODEL = Imagine::Model::TFLiteImage.new(MODEL_LOC, labels: MODEL_LABELS, enable_tpu: ENABLE_EDGETPU)
MODEL_LABELS = ENV["LABELS_URI"]?.presence ? URI.parse(ENV["LABELS_URI"]) : (ENV["LABELS_FILE"]? ? (File.read(ENV["LABELS_FILE"])).split("\n") : nil)
MODEL_LOC = ENV["MODEL_PATH"]?.presence ? Path.new(ENV["MODEL_PATH"]) : URI.parse(ENV["MODEL_URI"])

CPU MODEL_URI=https://raw.githubusercontent.com/google-coral/test_data/master/efficientdet_lite0_320_ptq.tflite LABELS_URI=https://raw.githubusercontent.com/google-coral/test_data/master/coco_labels.txt CORAL MODEL_URI=https://raw.githubusercontent.com/google-coral/test_data/master/efficientdet_lite0_320_ptq_edgetpu.tflite

MULTICAST_ADDRESS = ENV["MULTICAST_ADDRESS"]

where we want the video to be streamed

MULTICAST_PORT = ENV["MULTICAST_PORT"].to_i
PARSER_LIST = ["application/json"]

outputs the video stream and detections via websockets

REPLAY = CaptureReplay.new(REPLAY_MOUNT_PATH, MULTICAST_ADDRESS, MULTICAST_PORT)
REPLAY_MOUNT_PATH = Path[ENV["REPLAY_MOUNT_PATH"]? || "/mnt/ramdisk"]
RESPONDER_LIST = ["application/json", "application/yaml", "text/html"]

outputs the video stream and detections via websockets

STREAM = StreamWebsocket.new(MULTICAST_ADDRESS, MULTICAST_PORT)

Class Method Summary

Instance Method Summary

Instance methods inherited from class Application

bad_media_type(error) : ContentError bad_media_type, invalid_param(error) : ParameterError invalid_param, set_date_header set_date_header, set_request_id set_request_id

Class Method Detail

def self.base_route #

Helper for obtaining base route


def self.stream(hash_parts : Hash(String | Symbol, Nil | Bool | Int32 | Int64 | Float32 | Float64 | String | Symbol) | Nil = nil, **tuple_parts) #

Helper methods for performing redirect_to calls


Instance Method Detail

def base_route(*args, **options) #

Helper for obtaining base route


def base_route(*args, **options, &) #

Helper for obtaining base route


def detect(socket, include_frame : Bool = false) #

[View source]
def replay(seconds : UInt32) #

[View source]
def stream(socket) #

[View source]