Ejemplo n.º 1
0
    def get_camera_caps(self) -> Gst.Caps:

        width_min, width_max = self.get_cam_node_range("Width")
        height_min, height_max = self.get_cam_node_range("Height")

        genicam_formats = self.get_cam_node_entries("PixelFormat")

        supported_pixel_formats = [
            self.get_format_from_genicam(pf) for pf in genicam_formats
        ]

        supported_pixel_formats = [
            pf for pf in supported_pixel_formats if pf is not None
        ]

        camera_caps = Gst.Caps.new_empty()

        for pixel_format in supported_pixel_formats:
            camera_caps.append_structure(
                Gst.Structure(
                    pixel_format.cap_type,
                    format=pixel_format.gst,
                    width=Gst.IntRange(range(width_min, width_max)),
                    height=Gst.IntRange(range(height_min, height_max)),
                ))

        return camera_caps
Ejemplo n.º 2
0
    def testGetValue(self):
        Gst.init(None)

        st = Gst.Structure.new_empty("video/x-raw")
        st["range"] = Gst.IntRange(range(0, 10, 2))
        value = st["range"]

        self.assertEqual(value, range(0, 10, 2))
Ejemplo n.º 3
0
    def testConstructor(self):
        Gst.init(None)

        r = Gst.IntRange(range(0, 10, 2))
        self.assertEqual(r.range, range(0, 10, 2))
        self.assertRaises(TypeError, Gst.IntRange, range(1, 10, 2))
        self.assertRaises(TypeError, Gst.IntRange, range(0, 9, 2))
        self.assertRaises(TypeError, Gst.IntRange, range(10, 0))
        self.assertRaises(TypeError, Gst.IntRange, 1)
        self.assertRaises(TypeError, Gst.IntRange)
Ejemplo n.º 4
0
    def test_fixate_caps_with_defalt_values(self):
        voaacenc_caps = Gst.Caps.from_string(
            "audio/x-raw, format=(string)S16LE, layout=(string)interleaved, rate=(int){ 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000, 64000, 88200, 96000 }, channels=(int)1;"
            "audio/x-raw, format=(string)S16LE, layout=(string)interleaved, rate=(int){ 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000, 64000, 88200, 96000 }, channels=(int)2, channel-mask=(bitmask)0x0000000000000003"
        )
        yt_audiorest = Gst.Caps(
            "audio/x-raw,channels=6,channel-mask=0x3f,rate={48000,96000};"
            "audio/x-raw,channels=2,rate={48000,96000}")

        vorbis_caps = Gst.Caps(
            "audio/x-raw, format=(string)F32LE, layout=(string)interleaved, rate=(int)[ 1, 200000 ], channels=(int)1;"
            "audio/x-raw, format=(string)F32LE, layout=(string)interleaved, rate=(int)[ 1, 200000 ], channels=(int)2, channel-mask=(bitmask)0x0000000000000003;"
            "audio/x-raw, format=(string)F32LE, layout=(string)interleaved, rate=(int)[ 1, 200000 ], channels=(int)3, channel-mask=(bitmask)0x0000000000000007;"
            "audio/x-raw, format=(string)F32LE, layout=(string)interleaved, rate=(int)[ 1, 200000 ], channels=(int)4, channel-mask=(bitmask)0x0000000000000033;"
            "audio/x-raw, format=(string)F32LE, layout=(string)interleaved, rate=(int)[ 1, 200000 ], channels=(int)5, channel-mask=(bitmask)0x0000000000000037;"
            "audio/x-raw, format=(string)F32LE, layout=(string)interleaved, rate=(int)[ 1, 200000 ], channels=(int)6, channel-mask=(bitmask)0x000000000000003f;"
            "audio/x-raw, format=(string)F32LE, layout=(string)interleaved, rate=(int)[ 1, 200000 ], channels=(int)7, channel-mask=(bitmask)0x0000000000000d0f;"
            "audio/x-raw, format=(string)F32LE, layout=(string)interleaved, rate=(int)[ 1, 200000 ], channels=(int)8, channel-mask=(bitmask)0x0000000000000c3f;"
            "audio/x-raw, format=(string)F32LE, layout=(string)interleaved, rate=(int)[ 1, 200000 ], channels=(int)[ 9, 255 ], channel-mask=(bitmask)0x0000000000000000"
        )

        audio_defaults = {
            'channels': Gst.IntRange(range(1, 2147483647)),
            "rate": Gst.IntRange(range(8000, GLib.MAXINT))
        }

        dataset = [(
            voaacenc_caps, yt_audiorest, audio_defaults, None,
            Gst.Caps(
                "audio/x-raw, channels=2,rate=48000,channel-mask=(bitmask)0x03"
            )),
                   (vorbis_caps, None, audio_defaults,
                    Gst.Caps('audio/x-raw,channels=1,rate=8000'))]

        for data in dataset:
            res = fixate_caps_with_default_values(*data[:-1])
            print(res)
            self.assertTrue(res.is_equal_fixed(data[-1]),
                            "%s != %s" % (res, data[-1]))
Ejemplo n.º 5
0
    from matplotlib import pyplot as plt
    from matplotlib.backends.backend_agg import FigureCanvasAgg
except ImportError:
    Gst.error('audioplot requires numpy, numpy_ringbuffer and matplotlib')
    raise


Gst.init(None)

AUDIO_FORMATS = [f.strip() for f in
                 GstAudio.AUDIO_FORMATS_ALL.strip('{ }').split(',')]

ICAPS = Gst.Caps(Gst.Structure('audio/x-raw',
                               format=Gst.ValueList(AUDIO_FORMATS),
                               layout='interleaved',
                               rate = Gst.IntRange(range(1, GLib.MAXINT)),
                               channels = Gst.IntRange(range(1, GLib.MAXINT))))

OCAPS = Gst.Caps(Gst.Structure('video/x-raw',
                               format='ARGB',
                               width=Gst.IntRange(range(1, GLib.MAXINT)),
                               height=Gst.IntRange(range(1, GLib.MAXINT)),
                               framerate=Gst.FractionRange(Gst.Fraction(1, 1),
                                                           Gst.Fraction(GLib.MAXINT, 1))))

DEFAULT_WINDOW_DURATION = 1.0
DEFAULT_WIDTH = 640
DEFAULT_HEIGHT = 480
DEFAULT_FRAMERATE_NUM = 25
DEFAULT_FRAMERATE_DENOM = 1
Ejemplo n.º 6
0
    def test_fixate_caps_with_defalt_values(self):
        voaacenc_caps = Gst.Caps.from_string(
            "audio/x-raw, format=(string)S16LE, layout=(string)interleaved, rate=(int){ 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000, 64000, 88200, 96000 }, channels=(int)1;"
            "audio/x-raw, format=(string)S16LE, layout=(string)interleaved, rate=(int){ 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000, 64000, 88200, 96000 }, channels=(int)2, channel-mask=(bitmask)0x0000000000000003"
        )
        yt_audiorest = Gst.Caps(
            "audio/x-raw,channels=6,channel-mask=0x3f,rate={48000,96000};"
            "audio/x-raw,channels=2,rate={48000,96000}")

        vorbis_caps = Gst.Caps(
            "audio/x-raw, format=(string)F32LE, layout=(string)interleaved, rate=(int)[ 1, 200000 ], channels=(int)1;"
            "audio/x-raw, format=(string)F32LE, layout=(string)interleaved, rate=(int)[ 1, 200000 ], channels=(int)2, channel-mask=(bitmask)0x0000000000000003;"
            "audio/x-raw, format=(string)F32LE, layout=(string)interleaved, rate=(int)[ 1, 200000 ], channels=(int)3, channel-mask=(bitmask)0x0000000000000007;"
            "audio/x-raw, format=(string)F32LE, layout=(string)interleaved, rate=(int)[ 1, 200000 ], channels=(int)4, channel-mask=(bitmask)0x0000000000000033;"
            "audio/x-raw, format=(string)F32LE, layout=(string)interleaved, rate=(int)[ 1, 200000 ], channels=(int)5, channel-mask=(bitmask)0x0000000000000037;"
            "audio/x-raw, format=(string)F32LE, layout=(string)interleaved, rate=(int)[ 1, 200000 ], channels=(int)6, channel-mask=(bitmask)0x000000000000003f;"
            "audio/x-raw, format=(string)F32LE, layout=(string)interleaved, rate=(int)[ 1, 200000 ], channels=(int)7, channel-mask=(bitmask)0x0000000000000d0f;"
            "audio/x-raw, format=(string)F32LE, layout=(string)interleaved, rate=(int)[ 1, 200000 ], channels=(int)8, channel-mask=(bitmask)0x0000000000000c3f;"
            "audio/x-raw, format=(string)F32LE, layout=(string)interleaved, rate=(int)[ 1, 200000 ], channels=(int)[ 9, 255 ], channel-mask=(bitmask)0x0000000000000000"
        )

        avenc_ac3_caps = Gst.Caps(
            "audio/x-raw, channel-mask=(bitmask)0x0000000000000000, channels=(int)1, rate=(int){ 48000, 44100, 32000 }, layout=(string)interleaved, format=(string)F32LE;"
            " audio/x-raw, channel-mask=(bitmask)0x0000000000000003, channels=(int)2, rate=(int){ 48000, 44100, 32000 }, layout=(string)interleaved, format=(string)F32LE;"
            " audio/x-raw, channel-mask=(bitmask)0x0000000000000103, channels=(int)3, rate=(int){ 48000, 44100, 32000 }, layout=(string)interleaved, format=(string)F32LE;"
            " audio/x-raw, channel-mask=(bitmask)0x0000000000000007, channels=(int)3, rate=(int){ 48000, 44100, 32000 }, layout=(string)interleaved, format=(string)F32LE;"
            " audio/x-raw, channel-mask=(bitmask)0x0000000000000c03, channels=(int)4, rate=(int){ 48000, 44100, 32000 }, layout=(string)interleaved, format=(string)F32LE;"
            " audio/x-raw, channel-mask=(bitmask)0x0000000000000033, channels=(int)4, rate=(int){ 48000, 44100, 32000 }, layout=(string)interleaved, format=(string)F32LE;"
            " audio/x-raw, channel-mask=(bitmask)0x0000000000000107, channels=(int)4, rate=(int){ 48000, 44100, 32000 }, layout=(string)interleaved, format=(string)F32LE;"
            " audio/x-raw, channel-mask=(bitmask)0x0000000000000c07, channels=(int)5, rate=(int){ 48000, 44100, 32000 }, layout=(string)interleaved, format=(string)F32LE;"
            " audio/x-raw, channel-mask=(bitmask)0x0000000000000037, channels=(int)5, rate=(int){ 48000, 44100, 32000 }, layout=(string)interleaved, format=(string)F32LE;"
            " audio/x-raw, channel-mask=(bitmask)0x000000000000000c, channels=(int)2, rate=(int){ 48000, 44100, 32000 }, layout=(string)interleaved, format=(string)F32LE;"
            " audio/x-raw, channel-mask=(bitmask)0x000000000000000b, channels=(int)3, rate=(int){ 48000, 44100, 32000 }, layout=(string)interleaved, format=(string)F32LE;"
            " audio/x-raw, channel-mask=(bitmask)0x000000000000010b, channels=(int)4, rate=(int){ 48000, 44100, 32000 }, layout=(string)interleaved, format=(string)F32LE;"
            " audio/x-raw, channel-mask=(bitmask)0x000000000000000f, channels=(int)4, rate=(int){ 48000, 44100, 32000 }, layout=(string)interleaved, format=(string)F32LE;"
            " audio/x-raw, channel-mask=(bitmask)0x0000000000000c0b, channels=(int)5, rate=(int){ 48000, 44100, 32000 }, layout=(string)interleaved, format=(string)F32LE;"
            " audio/x-raw, channel-mask=(bitmask)0x000000000000003b, channels=(int)5, rate=(int){ 48000, 44100, 32000 }, layout=(string)interleaved, format=(string)F32LE;"
            " audio/x-raw, channel-mask=(bitmask)0x000000000000010f, channels=(int)5, rate=(int){ 48000, 44100, 32000 }, layout=(string)interleaved, format=(string)F32LE;"
            " audio/x-raw, channel-mask=(bitmask)0x0000000000000c0f, channels=(int)6, rate=(int){ 48000, 44100, 32000 }, layout=(string)interleaved, format=(string)F32LE;"
            " audio/x-raw, channel-mask=(bitmask)0x000000000000003f, channels=(int)6, rate=(int){ 48000, 44100, 32000 }, layout=(string)interleaved, format=(string)F32LE;"
        )

        audio_defaults = {
            "channels": Gst.IntRange(range(1, 2147483647)),
            "rate": Gst.IntRange(range(8000, GLib.MAXINT))
        }

        dataset = [
            (voaacenc_caps, yt_audiorest, audio_defaults, None,
             Gst.Caps(
                 "audio/x-raw, channels=2,rate=48000,channel-mask=(bitmask)0x03"
             )),
            (vorbis_caps, None, audio_defaults, None,
             Gst.Caps("audio/x-raw,channels=1,rate=8000")),
            (avenc_ac3_caps, None, audio_defaults,
             Gst.Caps("audio/x-raw, channels=(int)6, rate=(int)44100"),
             Gst.Caps("audio/x-raw, channels=(int)6, rate=(int)44100")),
        ]

        for template, restrictions, default_values, prev_vals, expected in dataset:
            res = fixate_caps_with_default_values(template, restrictions,
                                                  default_values, prev_vals)
            self.assertTrue(res.is_equal_fixed(expected),
                            "%s != %s" % (res, expected))
Ejemplo n.º 7
0
    def testRepr(self):
        Gst.init(None)

        self.assertEqual(repr(Gst.IntRange(range(0, 10, 2))),
                         '<Gst.IntRange [0,10,2]>')
Ejemplo n.º 8
0
import Jetson.GPIO as GPIO
import os
import threadsched


gi.require_version('Gst', '1.0')
gi.require_version('GstBase', '1.0')
gi.require_version('GstVideo', '1.0')

from gi.repository import Gst, GLib, GObject, GstBase, GstVideo

Gst.init(None)


VIDEOCAPS = Gst.Caps(Gst.Structure("video/x-bayer",
                                   width=Gst.IntRange(range(1, GLib.MAXINT)),
                                   height=Gst.IntRange(range(1, GLib.MAXINT)),
                                   framerate=Gst.FractionRange(Gst.Fraction(1,1), Gst.Fraction(GLib.MAXINT, 1))
                                   ))



class ImgProc(GstBase.BaseTransform):
    __gstmetadata__ = ("ImgProc", "Filter", "Process image data", "Arne Caspari")

    __gsttemplates__ = (
        Gst.PadTemplate.new("src",
            Gst.PadDirection.SRC,
            Gst.PadPresence.ALWAYS,
            VIDEOCAPS ),
        Gst.PadTemplate.new("sink",