def thread_function():
        ds = DataStore.getInstance()
        tos = TwitchBufferedOutputStream(
            twitch_stream_key=os.environ['TWITCH_SECRET'],
            width=1280,
            height=720,
            fps=30,
            verbose=True)
        camera = picamera.PiCamera(1280, 720, framerate=24)
        camera.start_preview()
        camera.annotate_background = picamera.Color('black')
        camera.annotate_text = "Current orientation: " + ds.getOrientation()
        sleep(2)
        now = datetime.now()
        # Begine recording the video
        camera.start_recording('launches/launch-' +
                               now.strftime("%m-%d-%H-%M-%S") + '.h264')

        while True:
            # Get current frame
            camera.annotate_text = "Current orientation: " + ds.getOrientation(
            )
            frame = camera.frame
            tos.send_video_frame(frame)
            time.sleep(1 / 30)
Exemple #2
0
            width=streamW,
            height=streamH,
            fps=45.,
            enable_audio=False,
            verbose=False)
        print(stream.height, stream.width, "3")

    if stream.get_video_frame_buffer_state() < 15:
        norm_image = cv2.cvtColor(frame, cv2.COLOR_RGB2BGR)
        norm_image = cv2.normalize(norm_image,
                                   None,
                                   alpha=0,
                                   beta=1,
                                   norm_type=cv2.NORM_MINMAX,
                                   dtype=cv2.CV_32F)
        stream.send_video_frame(norm_image)
#         sys.stdout.write( f"{norm_image}" )
# show the output frame
    cv2.imshow("Frame", frame)
    key = cv2.waitKey(1) & 0xFF

    # if the `q` key was pressed, break from the loop
    if key == ord("q"):
        break

    # increment the total number of frames processed thus far and
    # then update the FPS counter
    totalFrames += 1
    fps.update()

# stop the timer and display FPS information
Exemple #3
0
import os, sys, subprocess
import numpy as np
import gym
import asteroid
import random

from twitchstream.outputvideo import TwitchBufferedOutputStream
from twitchstream.chat import TwitchChatStream

TWITCH_KEY = "live_86944108_XVDMuEvn7AFBEOLuvNeiyCSE4VX4bY"
OAUTH_KEY = "oauth:y56mfwbmq724genm9bchxqi11u5iac"

#env = gym.make("asteroid-v1")
#env._configure("ec2-34-249-73-16.eu-west-1.compute.amazonaws.com", "")

videostream = TwitchBufferedOutputStream(twitch_stream_key=TWITCH_KEY, width=1238, height=822)
#chat = TwitchChatStream(username='******', oauth=OAUTH_KEY)

while True:
    if videostream.get_video_frame_buffer_state() < 30:
        videostream.send_video_frame(np.ones((822, 1238, 3)))