pylonsrc: fixed PGI alias handling

This commit is contained in:
mrstecklo 2021-02-05 14:23:04 +03:00 committed by joshdoe
parent ed3dd3915a
commit 48f104dbdb

View File

@ -191,9 +191,16 @@ typedef enum _GST_PYLONSRC_AUTOFEATURE
G_STATIC_ASSERT ((int) AUTOF_NUM_FEATURES == GST_PYLONSRC_NUM_AUTO_FEATURES); G_STATIC_ASSERT ((int) AUTOF_NUM_FEATURES == GST_PYLONSRC_NUM_AUTO_FEATURES);
G_STATIC_ASSERT ((int) AUTOF_NUM_LIMITED == GST_PYLONSRC_NUM_LIMITED_FEATURES); G_STATIC_ASSERT ((int) AUTOF_NUM_LIMITED == GST_PYLONSRC_NUM_LIMITED_FEATURES);
static const char *const featDemosaicing[2] = { "DemosaicingMode", "PgiMode" }; typedef struct _DemosaicingStrings {
static const char *const featDemosaicingPgi[2] = { "BaslerPGI", "On" }; const char* name;
static const char *const featDemosaicingSimple[2] = { "Simple", "Off" }; const char* on;
const char* off;
} DemosaicingStrings;
static const DemosaicingStrings featDemosaicing[2] = {
{ "DemosaicingMode", "BaslerPGI", "Simple" },
{ "PgiMode", "On", "Off" }
};
static const char *const featAutoFeature[AUTOF_NUM_FEATURES] = static const char *const featAutoFeature[AUTOF_NUM_FEATURES] =
{ "GainAuto", "ExposureAuto", "BalanceWhiteAuto" }; { "GainAuto", "ExposureAuto", "BalanceWhiteAuto" };
static const GST_PYLONSRC_PROP propAutoFeature[AUTOF_NUM_FEATURES] = static const GST_PYLONSRC_PROP propAutoFeature[AUTOF_NUM_FEATURES] =
@ -2709,12 +2716,12 @@ gst_pylonsrc_set_pgi (GstPylonSrc * src)
{ {
if (is_prop_implicit (src, PROP_BASLERDEMOSAICING)) { if (is_prop_implicit (src, PROP_BASLERDEMOSAICING)) {
const char *demosaicing = const char *demosaicing =
feature_alias_available (src, featDemosaicing[0], featDemosaicing[1]); feature_alias_available (src, featDemosaicing[0].name, featDemosaicing[1].name);
if (demosaicing != NULL) { if (demosaicing != NULL) {
GENAPIC_RESULT res; GENAPIC_RESULT res;
ptrdiff_t idx = demosaicing - featDemosaicing[0]; ptrdiff_t idx = (demosaicing == featDemosaicing[0].name) ? 0 : 1;
const char *pgiOn = featDemosaicingPgi[idx]; const char *pgiOn = featDemosaicing[idx].on;
const char *pgiOff = featDemosaicingSimple[idx]; const char *pgiOff = featDemosaicing[idx].off;
if (src->demosaicing) { if (src->demosaicing) {
if (strncmp ("bayer", src->pixel_format, 5) != 0) { if (strncmp ("bayer", src->pixel_format, 5) != 0) {
@ -3432,10 +3439,10 @@ gst_pylonsrc_read_pgi (GstPylonSrc * src)
{ {
if (is_prop_not_set (src, PROP_BASLERDEMOSAICING)) { if (is_prop_not_set (src, PROP_BASLERDEMOSAICING)) {
const char *demosaicing = const char *demosaicing =
feature_alias_readable (src, featDemosaicing[0], featDemosaicing[1]); feature_alias_readable (src, featDemosaicing[0].name, featDemosaicing[1].name);
if (demosaicing != NULL) { if (demosaicing != NULL) {
const ptrdiff_t idx = demosaicing - featDemosaicing[0]; const ptrdiff_t idx = (demosaicing == featDemosaicing[0].name) ? 0 : 1;
const char *pgiOn = featDemosaicingPgi[idx]; const char *pgiOn = featDemosaicing[idx].on;
char *temp = read_string_feature (src, demosaicing); char *temp = read_string_feature (src, demosaicing);
if ((temp != NULL) && (strcmp (temp, pgiOn))) { if ((temp != NULL) && (strcmp (temp, pgiOn))) {
src->demosaicing = TRUE; src->demosaicing = TRUE;
@ -3865,7 +3872,17 @@ pylonc_print_camera_info (GstPylonSrc * src, PYLON_DEVICE_HANDLE deviceHandle,
res = res =
PylonDeviceFeatureToString (deviceHandle, "DeviceSerialNumber", serial, PylonDeviceFeatureToString (deviceHandle, "DeviceSerialNumber", serial,
&siz); &siz);
PYLONC_CHECK_ERROR (src, res); if(siz <= 2 || res != GENAPI_E_OK) {
if(PylonDeviceFeatureIsReadable(deviceHandle, "DeviceID")) {
siz = sizeof (serial);
res =
PylonDeviceFeatureToString (deviceHandle, "DeviceID", serial,
&siz);
} else {
serial[0] = '0';
serial[1] = '\0';
}
}
if (PylonDeviceFeatureIsReadable (deviceHandle, "DeviceUserID")) { if (PylonDeviceFeatureIsReadable (deviceHandle, "DeviceUserID")) {
siz = sizeof (id); siz = sizeof (id);