niimaqdxsrc: add bayer-as-gray property to use GRAY caps instead of BAYER
This commit is contained in:
parent
59bce030b0
commit
ccacc9bdb8
@ -55,12 +55,14 @@ enum
|
|||||||
PROP_0,
|
PROP_0,
|
||||||
PROP_DEVICE,
|
PROP_DEVICE,
|
||||||
PROP_RING_BUFFER_COUNT,
|
PROP_RING_BUFFER_COUNT,
|
||||||
PROP_ATTRIBUTES
|
PROP_ATTRIBUTES,
|
||||||
|
PROP_BAYER_AS_GRAY
|
||||||
};
|
};
|
||||||
|
|
||||||
#define DEFAULT_PROP_DEVICE "cam0"
|
#define DEFAULT_PROP_DEVICE "cam0"
|
||||||
#define DEFAULT_PROP_RING_BUFFER_COUNT 3
|
#define DEFAULT_PROP_RING_BUFFER_COUNT 3
|
||||||
#define DEFAULT_PROP_ATTRIBUTES ""
|
#define DEFAULT_PROP_ATTRIBUTES ""
|
||||||
|
#define DEFAULT_PROP_BAYER_AS_GRAY FALSE
|
||||||
|
|
||||||
static void gst_niimaqdxsrc_init_interfaces (GType type);
|
static void gst_niimaqdxsrc_init_interfaces (GType type);
|
||||||
|
|
||||||
@ -178,7 +180,7 @@ ImaqDxCapsInfo imaq_dx_caps_infos[] = {
|
|||||||
{"Bayer BG 16", 0, VIDEO_CAPS_MAKE_BAYER16 ("bggr16", "1234"), 16, 16, 1}
|
{"Bayer BG 16", 0, VIDEO_CAPS_MAKE_BAYER16 ("bggr16", "1234"), 16, 16, 1}
|
||||||
};
|
};
|
||||||
|
|
||||||
static ImaqDxCapsInfo *
|
static const ImaqDxCapsInfo *
|
||||||
gst_niimaqdxsrc_get_caps_info (const char *pixel_format, int endianness)
|
gst_niimaqdxsrc_get_caps_info (const char *pixel_format, int endianness)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@ -198,7 +200,7 @@ static const char *
|
|||||||
gst_niimaqdxsrc_pixel_format_to_caps_string (const char *pixel_format,
|
gst_niimaqdxsrc_pixel_format_to_caps_string (const char *pixel_format,
|
||||||
int endianness)
|
int endianness)
|
||||||
{
|
{
|
||||||
ImaqDxCapsInfo *info =
|
const ImaqDxCapsInfo *info =
|
||||||
gst_niimaqdxsrc_get_caps_info (pixel_format, endianness);
|
gst_niimaqdxsrc_get_caps_info (pixel_format, endianness);
|
||||||
|
|
||||||
if (!info)
|
if (!info)
|
||||||
@ -227,7 +229,7 @@ gst_niimaqdxsrc_pixel_format_from_caps (const GstCaps * caps, int *endianness)
|
|||||||
static int
|
static int
|
||||||
gst_niimaqdxsrc_pixel_format_get_depth (const char *pixel_format, int endianness)
|
gst_niimaqdxsrc_pixel_format_get_depth (const char *pixel_format, int endianness)
|
||||||
{
|
{
|
||||||
ImaqDxCapsInfo *info =
|
const ImaqDxCapsInfo *info =
|
||||||
gst_niimaqdxsrc_get_caps_info (pixel_format, endianness);
|
gst_niimaqdxsrc_get_caps_info (pixel_format, endianness);
|
||||||
|
|
||||||
if (!info)
|
if (!info)
|
||||||
@ -389,6 +391,11 @@ gst_niimaqdxsrc_class_init (GstNiImaqDxSrcClass * klass)
|
|||||||
PROP_ATTRIBUTES, g_param_spec_string ("attributes",
|
PROP_ATTRIBUTES, g_param_spec_string ("attributes",
|
||||||
"Attributes", "Initial attributes to set", DEFAULT_PROP_ATTRIBUTES,
|
"Attributes", "Initial attributes to set", DEFAULT_PROP_ATTRIBUTES,
|
||||||
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE));
|
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE));
|
||||||
|
g_object_class_install_property (G_OBJECT_CLASS (klass),
|
||||||
|
PROP_BAYER_AS_GRAY, g_param_spec_boolean ("bayer-as-gray",
|
||||||
|
"Bayer as gray",
|
||||||
|
"For Bayer sources use GRAY caps", DEFAULT_PROP_BAYER_AS_GRAY,
|
||||||
|
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE));
|
||||||
|
|
||||||
{
|
{
|
||||||
GstCaps *caps = gst_caps_new_empty ();
|
GstCaps *caps = gst_caps_new_empty ();
|
||||||
@ -496,6 +503,9 @@ gst_niimaqdxsrc_set_property (GObject * object, guint prop_id,
|
|||||||
g_free (niimaqdxsrc->attributes);
|
g_free (niimaqdxsrc->attributes);
|
||||||
niimaqdxsrc->attributes = g_strdup (g_value_get_string (value));
|
niimaqdxsrc->attributes = g_strdup (g_value_get_string (value));
|
||||||
break;
|
break;
|
||||||
|
case PROP_BAYER_AS_GRAY:
|
||||||
|
niimaqdxsrc->bayer_as_gray = g_value_get_boolean(value);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -517,6 +527,9 @@ gst_niimaqdxsrc_get_property (GObject * object, guint prop_id, GValue * value,
|
|||||||
case PROP_ATTRIBUTES:
|
case PROP_ATTRIBUTES:
|
||||||
g_value_set_string (value, niimaqdxsrc->attributes);
|
g_value_set_string (value, niimaqdxsrc->attributes);
|
||||||
break;
|
break;
|
||||||
|
case PROP_BAYER_AS_GRAY:
|
||||||
|
g_value_set_boolean (value, niimaqdxsrc->bayer_as_gray);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
@ -820,6 +833,15 @@ gst_niimaqdxsrc_get_cam_caps (GstNiImaqDxSrc * niimaqdxsrc)
|
|||||||
else
|
else
|
||||||
endianness = G_BIG_ENDIAN;
|
endianness = G_BIG_ENDIAN;
|
||||||
|
|
||||||
|
if (g_str_has_prefix(pixel_format, "Bayer") && niimaqdxsrc->bayer_as_gray) {
|
||||||
|
const ImaqDxCapsInfo *info = gst_niimaqdxsrc_get_caps_info (pixel_format, endianness);
|
||||||
|
if (info->depth == 8) {
|
||||||
|
g_strlcpy (pixel_format, "Mono 8", IMAQDX_MAX_API_STRING_LENGTH);
|
||||||
|
} else if (info->depth == 16) {
|
||||||
|
g_strlcpy (pixel_format, "Mono 16", IMAQDX_MAX_API_STRING_LENGTH);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//TODO: add all available caps by enumerating PixelFormat's available, and query for framerate
|
//TODO: add all available caps by enumerating PixelFormat's available, and query for framerate
|
||||||
caps =
|
caps =
|
||||||
gst_niimaqdxsrc_new_caps_from_pixel_format (pixel_format, endianness,
|
gst_niimaqdxsrc_new_caps_from_pixel_format (pixel_format, endianness,
|
||||||
|
|||||||
@ -63,6 +63,7 @@ struct _GstNiImaqDxSrc {
|
|||||||
gchar *device_name;
|
gchar *device_name;
|
||||||
gint ringbuffer_count;
|
gint ringbuffer_count;
|
||||||
gchar *attributes;
|
gchar *attributes;
|
||||||
|
gboolean bayer_as_gray;
|
||||||
|
|
||||||
/* image info */
|
/* image info */
|
||||||
int width;
|
int width;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user