Ejemplo n.º 1
0
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)

    cap = cv2.VideoCapture(gs.SHMSrc(cap_string))
Ejemplo n.º 2
0
    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()

    # 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
Ejemplo n.º 3
0
    **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

    # Now that the pipeline has been (hopefully) successfully started,
    # GStreamer doesn't need to be debugged anymore and the thread can be
Ejemplo n.º 4
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.
Ejemplo n.º 5
0
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))

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

vc = VideoCapture(gs.SHMSrc(cap_string))