예제 #1
0
    def test_parsable(self):
        """Test that the parsed caps match the given ones."""

        caps = ('video/x-raw, format=I420, width=320, height=240, '
                'framerate=30/1, pixel-aspect-ratio=1/1, '
                'interlace-mode=progressive')
        p = gs.pipeline('videotestsrc ! {} ! fakesink name=sink'.format(caps))
        p.set_state(gs.Gst.State.PLAYING)

        real_caps_obj = gs.get_sink_caps(p.get_by_name('sink'))
        real_caps = gs.make_command_line_parsable(real_caps_obj)

        p.set_state(gs.Gst.State.NULL)

        self.assertEqual(caps, real_caps)
예제 #2
0
import networking
import networking.messages as m
from processing.tapecontours import get_corners_from_image
Gst = gs.Gst

if __name__ == '__main__':
    conf = config.configfor('Vision')

    logging.config.dictConfig(conf.logging)
    logger = logging.getLogger(__name__)

    gs.delete_socket()

    pipeline = gs.pipeline(
        gs.RaspiCam(**conf.params) +
        gs.Tee('t',
               gs.Valve('valve') + gs.H264Video() +
               gs.H264Stream(), gs.SHMSink()))

    pipeline.set_state(Gst.State.PLAYING)

    # Start debugging the gstreamer pipeline
    debuggingThread = gs.MessagePrinter(pipeline)
    debuggingThread.start()

    # TODO: Find a better method to wait for playback to start
    logger.debug(pipeline.get_state(
        Gst.CLOCK_TIME_NONE))  # Wait for pipeline to play

    caps = gs.get_sink_caps(pipeline.get_by_name(gs.SINK_NAME))
    cap_string = gs.make_command_line_parsable(caps)
"""
This program serves a stream of the camera with autofocus turned off.
"""

import threading
import gstreamer as gs
import networking
Gst = gs.Gst

if __name__ == '__main__':
    pipeline = gs.pipeline(
        gs.RaspiCam(awb=True, expmode=1) + gs.Valve('valve') +
        gs.H264Stream(port=5002)  # Default to port 5002
    )
    pipeline.set_state(Gst.State.PLAYING)

    # Start debugging the gstreamer pipeline
    debuggingThread = gs.MessagePrinter(pipeline)
    debuggingThread.start()

    # TODO: Find a better method to wait for playback to start
    print(pipeline.get_state(Gst.CLOCK_TIME_NONE))  # Wait for pipeline to play

    # Now that the pipeline has been (hopefully) successfully started,
    # GStreamer doesn't need to be debugged anymore and the thread can be
    # stopped.
    debuggingThread.stop()

    # Set up server
    sock, clis = networking.server.create_socket_and_client_list()
    handler = networking.create_gst_handler(pipeline, None, 'valve',
예제 #4
0
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.bind(('0.0.0.0', 5806))
    s.listen(1)
    conn, _ = s.accept()
    logger.debug('Got incoming time socket connection')
    time = conn.recv(200)
    logger.info('Got time %s', time)

    pipeline = gs.pipeline(
        # gs.PipelinePart('v4l2src device=/dev/video0 name=pipe_src ! video/x-h264,width=1280,height=720,framerate=15/1,profile=baseline') + gs.H264Stream(port=5002) # Default to port 5002
        gs.PipelinePart((
            'uvch264src device=/dev/video{} name=pipe_src auto_start=true initial-bitrate=1500000 '
            # 'initial-bitrate=3000000 average-bitrate=3000000 peak-bitrate=5000000 '
            # 'rate-control=vbr iframe-period=1000 '
            'pipe_src.vfsrc ! queue ! video/x-raw,format=YUY2,width=320,height=240,framerate=10/1 ! fakesink '
            'pipe_src.vidsrc ! queue ! video/x-h264,width=1280,height=720,framerate=30/1 '
        ).format(camera)) + gs.Valve('valve') + gs.Tee(
            'tee',
            gs.H264Stream(port=5002),  # Default to port 5002
            gs.PipelinePart('filesink append=true location=/mnt/usb/video/' +
                            gs.ts_filename())))

    # Alternative:
    # gst-launch-1.0 -v -e

    pipeline.set_state(Gst.State.PLAYING)

    # Start debugging the gstreamer pipeline
    debuggingThread = gs.MessagePrinter(pipeline)
    debuggingThread.start()
예제 #5
0
import networking.messages as m
from processing.stereo import process

Gst = gs.Gst

if __name__ == '__main__':
    conf = config.configfor('Vision')

    logging.config.dictConfig(conf.logging)
    logger = logging.getLogger(__name__)

    gs.delete_socket('/tmp/foo0')
    gs.delete_socket('/tmp/foo1')

    leftpipeline = gs.pipeline(
        gs.Webcam(device='/dev/video0') +
        gs.Tee('t', gs.SHMSink(socket_path='/tmp/foo0'),
               gs.H264Video() + gs.TSFile(gs.ts_filename(), False)))

    rightpipeline = gs.pipeline(
        gs.Webcam(device='/dev/video1') +
        gs.Tee('t', gs.SHMSink(socket_path='/tmp/foo1'),
               gs.H264Video() + gs.TSFile(gs.ts_filename(), False)))
    leftpipeline.set_state(Gst.State.PLAYING)
    rightpipeline.set_state(Gst.State.PLAYING)

    leftdebuggingThread = gs.MessagePrinter(leftpipeline)
    rightdebuggingThread = gs.MessagePrinter(rightpipeline)
    leftdebuggingThread.start()
    rightdebuggingThread.start()

    # TODO: Find a better method to wait for playback to start
예제 #6
0
and sending results back to clients connected to a server.
"""

import threading
import cv2
import gstreamer as gs
import networking
import networking.messages as m
from processing.tapecontours import get_corners_from_image
Gst = gs.Gst

if __name__ == '__main__':
    gs.delete_socket()

    pipeline = gs.pipeline(gs.RaspiCam() +
                           gs.Tee('t',
                                  gs.Valve('valve') +
                                  gs.H264Stream(), gs.SHMSink()))

    pipeline.set_state(Gst.State.PLAYING)

    # Start debugging the gstreamer pipeline
    debuggingThread = gs.MessagePrinter(pipeline)
    debuggingThread.start()

    # TODO: Find a better method to wait for playback to start
    print(pipeline.get_state(Gst.CLOCK_TIME_NONE))  # Wait for pipeline to play

    caps = gs.get_sink_caps(pipeline.get_by_name(gs.SINK_NAME))
    cap_string = gs.make_command_line_parsable(caps)

    cap = cv2.VideoCapture(gs.SHMSrc(cap_string))
예제 #7
0
import logging
import logging.config
import threading
import time
import config
import gstreamer as gs
import networking
Gst = gs.Gst

if __name__ == '__main__':
    conf = config.configfor('Driver')
    logging.config.dictConfig(conf.logging)
    logger = logging.getLogger(__name__)

    pipeline = gs.pipeline(
        gs.H264RaspiCam(**conf.params) + gs.Valve('valve') +
        gs.H264Stream(port=5002)  # Default to port 5002
    )
    pipeline.set_state(Gst.State.PLAYING)

    # Start debugging the gstreamer pipeline
    debuggingThread = gs.MessagePrinter(pipeline)
    debuggingThread.start()

    # TODO: Find a better method to wait for playback to start
    logging.debug(pipeline.get_state(
        Gst.CLOCK_TIME_NONE))  # Wait for pipeline to play

    # Now that the pipeline has been (hopefully) successfully started,
    # GStreamer doesn't need to be debugged anymore and the thread can be
    # stopped.
    debuggingThread.stop()
예제 #8
0
    rcrns = [(cx-w, cy-h), (cx+w, cy-h), (cx+w, cy+h), (cx-w, cy+h)]
    random.shuffle(rcrns)

    return rcrns

if __name__ == '__main__':
    conf = config.configfor('Vision')

    # logging.config.dictConfig(conf.logging)
    # logger = logging.getLogger(__name__)

    pipeline = gs.pipeline(
        gs.TestSrc() + gs.H264Video(h264encoder='x264enc') +
        #gs.Tee(
        #    't',
            gs.Valve('valve') + gs.H264Stream(port=5805, host='localhost')#,
        #    gs.TSFile(gs.ts_filename(), False)
        #)
    )
    pipeline.set_state(Gst.State.PLAYING)

    # Start debugging the gstreamer pipeline
    debuggingThread = gs.MessagePrinter(pipeline)
    debuggingThread.start()

    # TODO: Find a better method to wait for playback to start
    print(pipeline.get_state(Gst.CLOCK_TIME_NONE)) # Wait for pipeline to play

    # Now that the pipeline has been (hopefully) successfully started,
    # GStreamer doesn't need to be debugged anymore and the thread can be
    # stopped.
예제 #9
0
OUT = 'rtpmp2tpay pt=96 ! udpsink name={udp_name} host={host} port={port} async=false'.format(
    **gs.DEFAULTS)

if __name__ == '__main__':
    conf0 = config.configfor('Driver')
    conf1 = config.configfor('Gear')

    logging.config.dictConfig(conf0.logging)
    logger = logging.getLogger(__name__)

    pipeline = gs.pipeline(
        # str(gs.PipelinePart('mpegtsmux name=mux') + gs.Valve('valve') + gs.PipelinePart(OUT))
        # + ' ' + STREAM.format(0) + '! mux.sink_0 ' + STREAM.format(1) + '! mux.sink_1'
        # gs.PipelinePart('v4l2src device=/dev/video0 name=pipe_src ! video/x-h264,width=1280,height=720,framerate=15/1,profile=baseline') + gs.H264Stream(port=5002) # Default to port 5002
        str(
            gs.PipelinePart(STREAM.format(0)) + gs.Valve('valve0') +
            gs.H264Stream(port=5030, udp_name='udpsink0')) + ' ' + str(
                gs.PipelinePart(STREAM.format(1)) + gs.Valve('valve1') +
                gs.H264Stream(port=5031, udp_name='udpsink1')))

    pipeline.set_state(Gst.State.PLAYING)

    # Start debugging the gstreamer pipeline
    debuggingThread = gs.MessagePrinter(pipeline)
    debuggingThread.start()

    # TODO: Find a better method to wait for playback to start
    logging.debug(pipeline.get_state(
        Gst.CLOCK_TIME_NONE))  # Wait for pipeline to play
예제 #10
0
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
sh = logging.StreamHandler()
sh.setLevel(logging.DEBUG)
logger.addHandler(sh)

gs.delete_socket()

pipeline = gs.pipeline(
    gs.RaspiCam(vflip=True,
                hFlip=True,
                expmode=6,
                framerate=30,
                ec=10,
                awb=False,
                ar=1,
                ab=2.5,
                width=1280,
                height=960) + gs.PipelinePart('videoconvert') +
    gs.Tee(
        't',
        gs.Valve('valve') + gs.H264Video() + gs.H264Stream(),
        gs.PipelinePart('videoscale ! video/x-raw, width=640, height=480') +
        gs.SHMSink()))

# Start debugging the gstreamer pipeline
debuggingThread = gs.MessagePrinter(pipeline)
debuggingThread.start()

pipeline.set_state(Gst.State.PLAYING)

logger.debug(pipeline.get_state(Gst.CLOCK_TIME_NONE))
예제 #11
0
import logging.config
import threading
import time
import config
import gstreamer as gs
import networking
Gst = gs.Gst

if __name__ == '__main__':
    conf = config.configfor('Gear')

    logging.config.dictConfig(conf.logging)
    logger = logging.getLogger(__name__)

    pipeline = gs.pipeline(
        gs.Webcam(**conf.params) + gs.Valve('valve') + gs.H264Video() +
        gs.H264Stream(port=5002)  # Default to port 5002
    )
    pipeline.set_state(Gst.State.PLAYING)

    # Start debugging the gstreamer pipeline
    debuggingThread = gs.MessagePrinter(pipeline)
    debuggingThread.start()

    # TODO: Find a better method to wait for playback to start
    logging.debug(pipeline.get_state(
        Gst.CLOCK_TIME_NONE))  # Wait for pipeline to play

    # Now that the pipeline has been (hopefully) successfully started,
    # GStreamer doesn't need to be debugged anymore and the thread can be
    # stopped.
    debuggingThread.stop()