Пример #1
0
def gen(camera):
    global CAMERA_CONTROl
    global OLD_CAMERA_CONTROl
    while (1):
        if CAMERA_CONTROl == 1:
            camera = VideoCamera()
            frame = camera.get_frame()
            yield (b'--frame\r\n'
                   b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n\r\n')
        if OLD_CAMERA_CONTROl == 1 and CAMERA_CONTROl == 0:
            camera.close()
        if OLD_CAMERA_CONTROl == 0 and CAMERA_CONTROl == 0:
            time.sleep(0.4)
        OLD_CAMERA_CONTROl = CAMERA_CONTROl
Пример #2
0
def video_feed():
    """Video streaming route. This is used in the src attribute of an img tag."""

    # Initialising switcher using user selection of switcher
    switcher = get_selected_switcher(session['switcherSelect'],
                                     session['switcherThreshold'])
    detection = get_selected_detector(session['detectionSelect'])

    # Initialising emulated openCV camera using video path selected by user
    camera = VideoCamera(session['firstPath'], session['secondPath'], switcher,
                         detection)

    return Response(gen(camera),
                    mimetype='multipart/x-mixed-replace; boundary=frame')
import threading  # Concerne les thread (exemple : yield)
import os  # Concerne les éléments relatif à l'os
import subprocess  # Concerne l'exécution de processus


app = Flask(__name__)

# Initialisation of the bright pi
bright_special = BrightPiSpecialEffects()
bright_special.reset()
# Setting up indexes
RIGHT_LEDS = [1, 2]
LEFT_LEDS = [3, 4]

# Initialisation de la caméra
pi_camera = VideoCamera(flip=True)  # retourne la caméra


def blink(repetitions, speed, right_leds, left_leds, side):
    """Make the bright pi leds blink
    
    repetitions : The number of times the blink should appear
    speed : The amount of time a led needs to be activated and disabled. 
            The times is divided by 2, e.g. 1 second will be 0.5 second on and 0.5 off
    right_leds : The indexes of the right leds
    left_leds : The indexes of the left leds
    side : The side we want to make it blinks
    """
    # fait clignoter les leds des côtés spécifiés
    duration = speed / 2
    leds_to_activate = []
Пример #4
0
def video_feed():
    return Response(gen(VideoCamera()),
                    mimetype='multipart/x-mixed-replace; boundary=frame')
Пример #5
0
def video_feed(request):
    return StreamingHttpResponse(
        gen(VideoCamera()),
        content_type='multipart/x-mixed-replace; boundary=frame')
Пример #6
0
def video_feed():
    return Response(gen(VideoCamera(int(src0), threshold, labels, detector)),
                    mimetype='multipart/x-mixed-replace; boundary=frame')