pylonsrc: fixed offset default behaviour and continuous mode reading
This commit is contained in:
parent
11b85fcc3a
commit
2ea7e9ee63
@ -44,7 +44,8 @@
|
||||
|
||||
static int plugin_counter = 0;
|
||||
|
||||
int gst_pylonsrc_ref_pylon_environment()
|
||||
int
|
||||
gst_pylonsrc_ref_pylon_environment ()
|
||||
{
|
||||
if (plugin_counter == 0) {
|
||||
GST_DEBUG ("pylonsrc: Initializing Pylon environment");
|
||||
@ -55,7 +56,8 @@ int gst_pylonsrc_ref_pylon_environment()
|
||||
return ++plugin_counter;
|
||||
}
|
||||
|
||||
int gst_pylonsrc_unref_pylon_environment()
|
||||
int
|
||||
gst_pylonsrc_unref_pylon_environment ()
|
||||
{
|
||||
if (plugin_counter == 1) {
|
||||
GST_DEBUG ("pylonsrc: Terminating Pylon environment");
|
||||
@ -174,7 +176,8 @@ typedef enum _GST_PYLONSRC_PROP
|
||||
|
||||
G_STATIC_ASSERT (PROP_NUM_PROPERTIES == GST_PYLONSRC_NUM_PROPS);
|
||||
|
||||
typedef enum _GST_PYLONSRC_AUTOFEATURE {
|
||||
typedef enum _GST_PYLONSRC_AUTOFEATURE
|
||||
{
|
||||
AUTOF_GAIN,
|
||||
AUTOF_EXPOSURE,
|
||||
AUTOF_WHITEBALANCE,
|
||||
@ -187,19 +190,29 @@ typedef enum _GST_PYLONSRC_AUTOFEATURE {
|
||||
G_STATIC_ASSERT (AUTOF_NUM_FEATURES == GST_PYLONSRC_NUM_AUTO_FEATURES);
|
||||
G_STATIC_ASSERT (AUTOF_NUM_LIMITED == GST_PYLONSRC_NUM_LIMITED_FEATURES);
|
||||
|
||||
static const char* const featAutoFeature[AUTOF_NUM_FEATURES] = {"GainAuto", "ExposureAuto", "BalanceWhiteAuto"};
|
||||
static const GST_PYLONSRC_PROP propAutoFeature[AUTOF_NUM_FEATURES] = {PROP_GAIN, PROP_EXPOSURE, PROP_AUTOWHITEBALANCE};
|
||||
static const char *const featAutoFeature[AUTOF_NUM_FEATURES] =
|
||||
{ "GainAuto", "ExposureAuto", "BalanceWhiteAuto" };
|
||||
static const GST_PYLONSRC_PROP propAutoFeature[AUTOF_NUM_FEATURES] =
|
||||
{ PROP_GAIN, PROP_EXPOSURE, PROP_AUTOWHITEBALANCE };
|
||||
// Yes,there is no "WhiteBalance" feature, it is only used for logging
|
||||
static const char* const featManualFeature[AUTOF_NUM_FEATURES] = {"Gain", "ExposureTime", "WhiteBalance"};
|
||||
static const char* const featLimitedLower[AUTOF_NUM_LIMITED] = {"AutoGainLowerLimit", "AutoExposureTimeLowerLimit"};
|
||||
static const char* const featLimitedUpper[AUTOF_NUM_LIMITED] = {"AutoGainUpperLimit", "AutoExposureTimeUpperLimit"};
|
||||
static const GST_PYLONSRC_PROP propManualFeature[AUTOF_NUM_LIMITED] = {PROP_GAIN, PROP_EXPOSURE};
|
||||
static const GST_PYLONSRC_PROP propLimitedLower[AUTOF_NUM_LIMITED] = {PROP_GAINLOWERLIMIT, PROP_AUTOEXPOSURELOWERLIMIT};
|
||||
static const GST_PYLONSRC_PROP propLimitedUpper[AUTOF_NUM_LIMITED] = {PROP_GAINUPPERLIMIT, PROP_AUTOEXPOSUREUPPERLIMIT};
|
||||
static const char *const featManualFeature[AUTOF_NUM_FEATURES] =
|
||||
{ "Gain", "ExposureTime", "WhiteBalance" };
|
||||
static const char *const featLimitedLower[AUTOF_NUM_LIMITED] =
|
||||
{ "AutoGainLowerLimit", "AutoExposureTimeLowerLimit" };
|
||||
static const char *const featLimitedUpper[AUTOF_NUM_LIMITED] =
|
||||
{ "AutoGainUpperLimit", "AutoExposureTimeUpperLimit" };
|
||||
static const GST_PYLONSRC_PROP propManualFeature[AUTOF_NUM_LIMITED] =
|
||||
{ PROP_GAIN, PROP_EXPOSURE };
|
||||
static const GST_PYLONSRC_PROP propLimitedLower[AUTOF_NUM_LIMITED] =
|
||||
{ PROP_GAINLOWERLIMIT, PROP_AUTOEXPOSURELOWERLIMIT };
|
||||
static const GST_PYLONSRC_PROP propLimitedUpper[AUTOF_NUM_LIMITED] =
|
||||
{ PROP_GAINUPPERLIMIT, PROP_AUTOEXPOSUREUPPERLIMIT };
|
||||
|
||||
static const double defaultLimitedValue[AUTOF_NUM_LIMITED] = {999.0, 9999999.0};
|
||||
static const double defaultLimitedValue[AUTOF_NUM_LIMITED] =
|
||||
{ 999.0, 9999999.0 };
|
||||
|
||||
typedef enum _GST_PYLONSRC_AXIS {
|
||||
typedef enum _GST_PYLONSRC_AXIS
|
||||
{
|
||||
AXIS_X,
|
||||
AXIS_Y
|
||||
} GST_PYLONSRC_AXIS;
|
||||
@ -214,9 +227,11 @@ static const GST_PYLONSRC_PROP propCenter[2] = {PROP_CENTERX, PROP_CENTERY};
|
||||
static const char *const featReverse[2] = { "ReverseX", "ReverseY" };
|
||||
static const GST_PYLONSRC_PROP propReverse[2] = { PROP_FLIPX, PROP_FLIPY };
|
||||
|
||||
static const GST_PYLONSRC_PROP propBinning[2] = {PROP_BINNINGH, PROP_BINNINGV};
|
||||
static const GST_PYLONSRC_PROP propBinning[2] =
|
||||
{ PROP_BINNINGH, PROP_BINNINGV };
|
||||
static const GST_PYLONSRC_PROP propSize[2] = { PROP_WIDTH, PROP_HEIGHT };
|
||||
static const char* const featBinning[2] = {"BinningHorizontal", "BinningVertical"};
|
||||
static const char *const featBinning[2] =
|
||||
{ "BinningHorizontal", "BinningVertical" };
|
||||
static const char *const featSize[2] = { "Width", "Height" };
|
||||
static const char *const featMaxSize[2] = { "WidthMax", "HeightMax" };
|
||||
|
||||
@ -232,7 +247,8 @@ static const GST_PYLONSRC_PROP propGain[3][3] = {
|
||||
{PROP_TRANSFORMATION20, PROP_TRANSFORMATION21, PROP_TRANSFORMATION22}
|
||||
};
|
||||
|
||||
typedef enum _GST_PYLONSRC_COLOUR {
|
||||
typedef enum _GST_PYLONSRC_COLOUR
|
||||
{
|
||||
COLOUR_RED,
|
||||
COLOUR_GREEN,
|
||||
COLOUR_BLUE,
|
||||
@ -241,12 +257,21 @@ typedef enum _GST_PYLONSRC_COLOUR {
|
||||
COLOUR_YELLOW
|
||||
} GST_PYLONSRC_COLOUR;
|
||||
|
||||
static const char* const featColour[6] = {"Red", "Green", "Blue", "Cyan", "Magenta", "Yellow"};
|
||||
static const GST_PYLONSRC_PROP propColourBalance[3] = {PROP_BALANCERED, PROP_BALANCEGREEN, PROP_BALANCEBLUE};
|
||||
static const GST_PYLONSRC_PROP propColourHue[6] = {PROP_COLORREDHUE, PROP_COLORGREENHUE, PROP_COLORBLUEHUE,
|
||||
PROP_COLORCYANHUE, PROP_COLORMAGENTAHUE, PROP_COLORYELLOWHUE};
|
||||
static const GST_PYLONSRC_PROP propColourSaturation[6]= {PROP_COLORREDSATURATION, PROP_COLORGREENSATURATION, PROP_COLORBLUESATURATION,
|
||||
PROP_COLORCYANSATURATION, PROP_COLORMAGENTASATURATION, PROP_COLORYELLOWSATURATION};
|
||||
static const char *const featColour[6] =
|
||||
{ "Red", "Green", "Blue", "Cyan", "Magenta", "Yellow" };
|
||||
static const GST_PYLONSRC_PROP propColourBalance[3] =
|
||||
{ PROP_BALANCERED, PROP_BALANCEGREEN, PROP_BALANCEBLUE };
|
||||
static const GST_PYLONSRC_PROP propColourHue[6] =
|
||||
{ PROP_COLORREDHUE, PROP_COLORGREENHUE, PROP_COLORBLUEHUE,
|
||||
PROP_COLORCYANHUE, PROP_COLORMAGENTAHUE, PROP_COLORYELLOWHUE
|
||||
};
|
||||
|
||||
static const GST_PYLONSRC_PROP propColourSaturation[6] =
|
||||
{ PROP_COLORREDSATURATION, PROP_COLORGREENSATURATION,
|
||||
PROP_COLORBLUESATURATION,
|
||||
PROP_COLORCYANSATURATION, PROP_COLORMAGENTASATURATION,
|
||||
PROP_COLORYELLOWSATURATION
|
||||
};
|
||||
|
||||
static inline const char *
|
||||
boolalpha (_Bool arg)
|
||||
@ -607,12 +632,12 @@ gst_pylonsrc_class_init (GstPylonSrcClass * klass)
|
||||
g_object_class_install_property (gobject_class, PROP_CONFIGFILE,
|
||||
g_param_spec_string ("config-file", "Pylon Feature Stream (.pfs) file",
|
||||
"Path to PFS file containing configurations for all features. PFS file can be obtained with PylonViewer or PylonFeaturePersistenceSave() function. Configuration file is only applied on plugin startup prior to any other properties. Using configuration file implies setting \"ignore-defaults\"",
|
||||
"",
|
||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
"", (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
g_object_class_install_property (gobject_class, PROP_IGNOREDEFAULTS,
|
||||
g_param_spec_boolean ("ignore-defaults", "Ignore default values to other properties",
|
||||
"(true/false) Apply features only if those are set explicitly. Can only be applied on plugin startup. This property is implicitly set to true if config-file is provided. Setting this to false while config-file is set will lead to strange result and is not recommended", FALSE,
|
||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
g_param_spec_boolean ("ignore-defaults",
|
||||
"Ignore default values to other properties",
|
||||
"(true/false) Apply features only if those are set explicitly. Can only be applied on plugin startup. This property is implicitly set to true if config-file is provided. Setting this to false while config-file is set will lead to strange result and is not recommended",
|
||||
FALSE, (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -710,24 +735,28 @@ is_prop_set(const GstPylonSrc* src, GST_PYLONSRC_PROP prop)
|
||||
{
|
||||
return src->propFlags[prop] == GST_PYLONSRC_PROPST_SET;
|
||||
}
|
||||
|
||||
// check if property is already processed (value is loaded to device)
|
||||
static inline _Bool
|
||||
is_prop_not_set (const GstPylonSrc * src, GST_PYLONSRC_PROP prop)
|
||||
{
|
||||
return src->propFlags[prop] == GST_PYLONSRC_PROPST_NOT_SET;
|
||||
}
|
||||
|
||||
// check if property is defaulted
|
||||
static inline _Bool
|
||||
is_prop_default (const GstPylonSrc * src, GST_PYLONSRC_PROP prop)
|
||||
{
|
||||
return src->propFlags[prop] == GST_PYLONSRC_PROPST_DEFAULT;
|
||||
}
|
||||
|
||||
// check if property is set implicitly, i.e. set explicitly or defaulted
|
||||
static inline _Bool
|
||||
is_prop_implicit (const GstPylonSrc * src, GST_PYLONSRC_PROP prop)
|
||||
{
|
||||
return src->propFlags[prop] != GST_PYLONSRC_PROPST_NOT_SET;
|
||||
}
|
||||
|
||||
// mark property as processed
|
||||
static inline void
|
||||
reset_prop (GstPylonSrc * src, GST_PYLONSRC_PROP prop)
|
||||
@ -737,7 +766,8 @@ reset_prop(GstPylonSrc* src, GST_PYLONSRC_PROP prop)
|
||||
|
||||
// Use in gst_pylonsrc_set_property to set related boolean property
|
||||
static inline void
|
||||
set_prop_implicitly(GObject * object, GST_PYLONSRC_PROP prop, GParamSpec * pspec)
|
||||
set_prop_implicitly (GObject * object, GST_PYLONSRC_PROP prop,
|
||||
GParamSpec * pspec)
|
||||
{
|
||||
GstPylonSrc *src = GST_PYLONSRC (object);
|
||||
if (!is_prop_set (src, prop)) {
|
||||
@ -1198,7 +1228,8 @@ gst_pylonsrc_get_caps (GstBaseSrc * bsrc, GstCaps * filter)
|
||||
{
|
||||
GstPylonSrc *src = GST_PYLONSRC (bsrc);
|
||||
|
||||
GST_DEBUG_OBJECT (src, "Received a request for caps. Filter:\n%" GST_PTR_FORMAT, filter);
|
||||
GST_DEBUG_OBJECT (src,
|
||||
"Received a request for caps. Filter:\n%" GST_PTR_FORMAT, filter);
|
||||
if (!src->deviceConnected) {
|
||||
GST_DEBUG_OBJECT (src, "Could not send caps - no camera connected.");
|
||||
return gst_pad_get_pad_template_caps (GST_BASE_SRC_PAD (bsrc));
|
||||
@ -1511,7 +1542,8 @@ gst_pylonsrc_set_resolution_axis(GstPylonSrc * src, GST_PYLONSRC_AXIS axis)
|
||||
// set binning of camera
|
||||
if (is_prop_implicit (src, propBinning[axis])) {
|
||||
if (feature_supported (src, featBinning[axis])) {
|
||||
GST_DEBUG_OBJECT (src, "Setting %s to %d", featBinning[axis], src->binning[axis]);
|
||||
GST_DEBUG_OBJECT (src, "Setting %s to %d", featBinning[axis],
|
||||
src->binning[axis]);
|
||||
res =
|
||||
PylonDeviceSetIntegerFeature (src->deviceHandle, featBinning[axis],
|
||||
src->binning[axis]);
|
||||
@ -1534,24 +1566,28 @@ gst_pylonsrc_set_resolution_axis(GstPylonSrc * src, GST_PYLONSRC_AXIS axis)
|
||||
if (feature_supported (src, featMaxSize[axis])) {
|
||||
int64_t maxSize;
|
||||
res =
|
||||
PylonDeviceGetIntegerFeature (src->deviceHandle, featMaxSize[axis], &maxSize);
|
||||
PylonDeviceGetIntegerFeature (src->deviceHandle, featMaxSize[axis],
|
||||
&maxSize);
|
||||
src->maxSize[axis] = (gint) maxSize;
|
||||
PYLONC_CHECK_ERROR (src, res);
|
||||
}
|
||||
|
||||
// Check if custom resolution is even possible and set it
|
||||
if (src->size[axis] > src->maxSize[axis]) {
|
||||
GST_ERROR_OBJECT (src, "Set %s is above camera's capabilities.", featSize[axis]);
|
||||
GST_ERROR_OBJECT (src, "Set %s is above camera's capabilities.",
|
||||
featSize[axis]);
|
||||
goto error;
|
||||
}
|
||||
|
||||
// Set the final resolution
|
||||
res = PylonDeviceSetIntegerFeature (src->deviceHandle, featSize[axis], src->size[axis]);
|
||||
res =
|
||||
PylonDeviceSetIntegerFeature (src->deviceHandle, featSize[axis],
|
||||
src->size[axis]);
|
||||
PYLONC_CHECK_ERROR (src, res);
|
||||
} else {
|
||||
// if defaulted, just read from camera
|
||||
int64_t size = 0;
|
||||
res = PylonDeviceGetIntegerFeature (src->deviceHandle, featSize[axis], &size);
|
||||
res =
|
||||
PylonDeviceGetIntegerFeature (src->deviceHandle, featSize[axis],
|
||||
&size);
|
||||
PYLONC_CHECK_ERROR (src, res);
|
||||
src->size[axis] = (gint) size;
|
||||
}
|
||||
@ -1593,16 +1629,18 @@ gst_pylonsrc_set_offset_axis (GstPylonSrc * src, GST_PYLONSRC_AXIS axis)
|
||||
src->center[axis]);
|
||||
PYLONC_CHECK_ERROR (src, res);
|
||||
|
||||
GST_DEBUG_OBJECT (src, "%s: %s", featCenter[axis], boolalpha(src->center[axis]));
|
||||
GST_DEBUG_OBJECT (src, "%s: %s", featCenter[axis],
|
||||
boolalpha (src->center[axis]));
|
||||
} else {
|
||||
src->center[axis] = FALSE;
|
||||
}
|
||||
reset_prop (src, propCenter[axis]);
|
||||
}
|
||||
|
||||
if(is_prop_implicit(src, propOffset[axis])) {
|
||||
if (is_prop_set (src, propOffset[axis])) {
|
||||
if (src->center[axis]) {
|
||||
GST_WARNING_OBJECT(src, "%s is ignored due to %s is set", featOffset[axis], featCenter[axis]);
|
||||
GST_WARNING_OBJECT (src, "%s is ignored due to %s is set",
|
||||
featOffset[axis], featCenter[axis]);
|
||||
} else {
|
||||
if (feature_supported (src, featOffset[axis])) {
|
||||
const gint maxoffset = src->maxSize[axis] - src->size[axis];
|
||||
@ -1612,14 +1650,15 @@ gst_pylonsrc_set_offset_axis (GstPylonSrc * src, GST_PYLONSRC_AXIS axis)
|
||||
PylonDeviceSetIntegerFeature (src->deviceHandle, featOffset[axis],
|
||||
src->offset[axis]);
|
||||
PYLONC_CHECK_ERROR (src, res);
|
||||
GST_DEBUG_OBJECT (src, "Setting %s to %d", featOffset[axis], src->offset[axis]);
|
||||
GST_DEBUG_OBJECT (src, "Setting %s to %d", featOffset[axis],
|
||||
src->offset[axis]);
|
||||
} else {
|
||||
GST_DEBUG_OBJECT (src,
|
||||
"Set %s is above camera's capabilities. (%d > %d)", featOffset[axis],
|
||||
src->offset[axis], maxoffset);
|
||||
"Set %s is above camera's capabilities. (%d > %d)",
|
||||
featOffset[axis], src->offset[axis], maxoffset);
|
||||
GST_ELEMENT_ERROR (src, RESOURCE, FAILED,
|
||||
("Failed to initialise the camera"),
|
||||
("Wrong %s specified", featOffset[axis]));
|
||||
("Failed to initialise the camera"), ("Wrong %s specified",
|
||||
featOffset[axis]));
|
||||
goto error;
|
||||
}
|
||||
} // if (feature_supported (src, featOffset[axis]))
|
||||
@ -1653,7 +1692,8 @@ gst_pylonsrc_set_reverse_axis (GstPylonSrc * src, GST_PYLONSRC_AXIS axis)
|
||||
src->flip[axis]);
|
||||
PYLONC_CHECK_ERROR (src, res);
|
||||
|
||||
GST_DEBUG_OBJECT (src, "%s: %s", featReverse[axis], boolalpha(src->flip[axis]));
|
||||
GST_DEBUG_OBJECT (src, "%s: %s", featReverse[axis],
|
||||
boolalpha (src->flip[axis]));
|
||||
} else {
|
||||
src->flip[axis] = FALSE;
|
||||
}
|
||||
@ -1706,8 +1746,9 @@ gst_pylonsrc_get_supported_caps (GstPylonSrc * src)
|
||||
|
||||
// TODO: query FPS
|
||||
format_caps =
|
||||
gst_genicam_pixel_format_caps_from_pixel_format_var (info->pixel_format,
|
||||
G_BYTE_ORDER, src->size[AXIS_X], src->size[AXIS_Y]);
|
||||
gst_genicam_pixel_format_caps_from_pixel_format_var
|
||||
(info->pixel_format, G_BYTE_ORDER, src->size[AXIS_X],
|
||||
src->size[AXIS_Y]);
|
||||
|
||||
if (format_caps)
|
||||
gst_caps_append (caps, format_caps);
|
||||
@ -1766,14 +1807,14 @@ gst_pylonsrc_set_test_image (GstPylonSrc * src)
|
||||
GST_DEBUG_OBJECT (src, "Test image mode enabled.");
|
||||
ImageId = g_strdup_printf ("Testimage%d", src->testImage);
|
||||
res =
|
||||
PylonDeviceFeatureFromString (src->deviceHandle, "TestImageSelector",
|
||||
ImageId);
|
||||
PylonDeviceFeatureFromString (src->deviceHandle,
|
||||
"TestImageSelector", ImageId);
|
||||
g_free (ImageId);
|
||||
PYLONC_CHECK_ERROR (src, res);
|
||||
} else {
|
||||
res =
|
||||
PylonDeviceFeatureFromString (src->deviceHandle, "TestImageSelector",
|
||||
"Off");
|
||||
PylonDeviceFeatureFromString (src->deviceHandle,
|
||||
"TestImageSelector", "Off");
|
||||
PYLONC_CHECK_ERROR (src, res);
|
||||
}
|
||||
}
|
||||
@ -1797,21 +1838,22 @@ gst_pylonsrc_set_readout (GstPylonSrc * src)
|
||||
|
||||
GST_DEBUG_OBJECT (src, "Setting the sensor readout mode to normal.");
|
||||
res =
|
||||
PylonDeviceFeatureFromString (src->deviceHandle, "SensorReadoutMode",
|
||||
"Normal");
|
||||
PylonDeviceFeatureFromString (src->deviceHandle,
|
||||
"SensorReadoutMode", "Normal");
|
||||
PYLONC_CHECK_ERROR (src, res);
|
||||
} else if (strcmp (src->sensorMode, "fast") == 0) {
|
||||
GST_DEBUG_OBJECT (src, "Setting the sensor readout mode to fast.");
|
||||
res =
|
||||
PylonDeviceFeatureFromString (src->deviceHandle, "SensorReadoutMode",
|
||||
"Fast");
|
||||
PylonDeviceFeatureFromString (src->deviceHandle,
|
||||
"SensorReadoutMode", "Fast");
|
||||
PYLONC_CHECK_ERROR (src, res);
|
||||
} else {
|
||||
GST_ERROR_OBJECT (src,
|
||||
"Invalid parameter value for sensorreadoutmode. Available values are normal/fast, while the value provided was \"%s\".",
|
||||
src->sensorMode);
|
||||
GST_ELEMENT_ERROR (src, RESOURCE, FAILED,
|
||||
("Failed to initialise the camera"), ("Invalid parameters provided"));
|
||||
("Failed to initialise the camera"),
|
||||
("Invalid parameters provided"));
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
@ -1830,7 +1872,8 @@ gst_pylonsrc_set_bandwidth (GstPylonSrc * src)
|
||||
if (is_prop_implicit (src, PROP_LIMITBANDWIDTH)) {
|
||||
// Set bandwidth limit mode (default: on)
|
||||
if (feature_supported (src, "DeviceLinkThroughputLimitMode")) {
|
||||
GST_DEBUG_OBJECT (src, "%s camera's bandwidth.", src->limitBandwidth ? "Limiting" : "Unlocking");
|
||||
GST_DEBUG_OBJECT (src, "%s camera's bandwidth.",
|
||||
src->limitBandwidth ? "Limiting" : "Unlocking");
|
||||
res =
|
||||
PylonDeviceFeatureFromString (src->deviceHandle,
|
||||
"DeviceLinkThroughputLimitMode", src->limitBandwidth ? "On" : "Off");
|
||||
@ -1877,7 +1920,8 @@ gst_pylonsrc_set_framerate (GstPylonSrc * src)
|
||||
PYLONC_CHECK_ERROR (src, res);
|
||||
|
||||
GST_DEBUG_OBJECT (src,
|
||||
"Limiting framerate: %s. See below for current framerate.", boolalpha(src->setFPS));
|
||||
"Limiting framerate: %s. See below for current framerate.",
|
||||
boolalpha (src->setFPS));
|
||||
}
|
||||
reset_prop (src, PROP_ACQUISITIONFRAMERATEENABLE);
|
||||
}
|
||||
@ -1916,36 +1960,37 @@ gst_pylonsrc_set_lightsource (GstPylonSrc * src)
|
||||
if (strcmp (src->lightsource, "off") == 0) {
|
||||
GST_DEBUG_OBJECT (src, "Not using a lightsource preset.");
|
||||
res =
|
||||
PylonDeviceFeatureFromString (src->deviceHandle, "LightSourcePreset",
|
||||
"Off");
|
||||
PylonDeviceFeatureFromString (src->deviceHandle,
|
||||
"LightSourcePreset", "Off");
|
||||
PYLONC_CHECK_ERROR (src, res);
|
||||
} else if (strcmp (src->lightsource, "2800k") == 0) {
|
||||
GST_DEBUG_OBJECT (src,
|
||||
"Setting light preset to Tungsten 2800k (Incandescen light).");
|
||||
res =
|
||||
PylonDeviceFeatureFromString (src->deviceHandle, "LightSourcePreset",
|
||||
"Tungsten2800K");
|
||||
PylonDeviceFeatureFromString (src->deviceHandle,
|
||||
"LightSourcePreset", "Tungsten2800K");
|
||||
PYLONC_CHECK_ERROR (src, res);
|
||||
} else if (strcmp (src->lightsource, "5000k") == 0) {
|
||||
GST_DEBUG_OBJECT (src,
|
||||
"Setting light preset to Daylight 5000k (Daylight).");
|
||||
res =
|
||||
PylonDeviceFeatureFromString (src->deviceHandle, "LightSourcePreset",
|
||||
"Daylight5000K");
|
||||
PylonDeviceFeatureFromString (src->deviceHandle,
|
||||
"LightSourcePreset", "Daylight5000K");
|
||||
PYLONC_CHECK_ERROR (src, res);
|
||||
} else if (strcmp (src->lightsource, "6500k") == 0) {
|
||||
GST_DEBUG_OBJECT (src,
|
||||
"Setting light preset to Daylight 6500k (Very bright day).");
|
||||
res =
|
||||
PylonDeviceFeatureFromString (src->deviceHandle, "LightSourcePreset",
|
||||
"Daylight6500K");
|
||||
PylonDeviceFeatureFromString (src->deviceHandle,
|
||||
"LightSourcePreset", "Daylight6500K");
|
||||
PYLONC_CHECK_ERROR (src, res);
|
||||
} else {
|
||||
GST_ERROR_OBJECT (src,
|
||||
"Invalid parameter value for lightsource. Available values are off/2800k/5000k/6500k, while the value provided was \"%s\".",
|
||||
src->lightsource);
|
||||
GST_ELEMENT_ERROR (src, RESOURCE, FAILED,
|
||||
("Failed to initialise the camera"), ("Invalid parameters provided"));
|
||||
("Failed to initialise the camera"),
|
||||
("Invalid parameters provided"));
|
||||
goto error;
|
||||
}
|
||||
} else {
|
||||
@ -1962,7 +2007,8 @@ error:
|
||||
}
|
||||
|
||||
static _Bool
|
||||
gst_pylonsrc_set_auto_feature (GstPylonSrc * src, GST_PYLONSRC_AUTOFEATURE feature)
|
||||
gst_pylonsrc_set_auto_feature (GstPylonSrc * src,
|
||||
GST_PYLONSRC_AUTOFEATURE feature)
|
||||
{
|
||||
if (is_prop_implicit (src, propAutoFeature[feature])) {
|
||||
// Enable/disable automatic feature
|
||||
@ -1972,29 +2018,31 @@ gst_pylonsrc_set_auto_feature (GstPylonSrc * src, GST_PYLONSRC_AUTOFEATURE featu
|
||||
if (strcmp (src->autoFeature[feature], "off") == 0) {
|
||||
GST_DEBUG_OBJECT (src, "Disabling %s.", featAutoFeature[feature]);
|
||||
res =
|
||||
PylonDeviceFeatureFromString (src->deviceHandle, featAutoFeature[feature],
|
||||
"Off");
|
||||
PylonDeviceFeatureFromString (src->deviceHandle,
|
||||
featAutoFeature[feature], "Off");
|
||||
PYLONC_CHECK_ERROR (src, res);
|
||||
} else if (strcmp (src->autoFeature[feature], "once") == 0) {
|
||||
GST_DEBUG_OBJECT (src, "Making the camera only calibrate %s once.", featManualFeature[feature]);
|
||||
GST_DEBUG_OBJECT (src, "Making the camera only calibrate %s once.",
|
||||
featManualFeature[feature]);
|
||||
res =
|
||||
PylonDeviceFeatureFromString (src->deviceHandle, featAutoFeature[feature],
|
||||
"Once");
|
||||
PylonDeviceFeatureFromString (src->deviceHandle,
|
||||
featAutoFeature[feature], "Once");
|
||||
PYLONC_CHECK_ERROR (src, res);
|
||||
} else if (strcmp (src->autoFeature[feature], "continuous") == 0) {
|
||||
GST_DEBUG_OBJECT (src,
|
||||
"Making the camera calibrate %s automatically all the time.", featManualFeature[feature]);
|
||||
"Making the camera calibrate %s automatically all the time.",
|
||||
featManualFeature[feature]);
|
||||
res =
|
||||
PylonDeviceFeatureFromString (src->deviceHandle, featAutoFeature[feature],
|
||||
"Continuous");
|
||||
PylonDeviceFeatureFromString (src->deviceHandle,
|
||||
featAutoFeature[feature], "Continuous");
|
||||
PYLONC_CHECK_ERROR (src, res);
|
||||
} else {
|
||||
GST_ERROR_OBJECT (src,
|
||||
"Invalid parameter value for %s. Available values are off/once/continuous, while the value provided was \"%s\".",
|
||||
featAutoFeature[feature],
|
||||
src->autoFeature[feature]);
|
||||
featAutoFeature[feature], src->autoFeature[feature]);
|
||||
GST_ELEMENT_ERROR (src, RESOURCE, FAILED,
|
||||
("Failed to initialise the camera"), ("Invalid parameters provided"));
|
||||
("Failed to initialise the camera"),
|
||||
("Invalid parameters provided"));
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
@ -2007,7 +2055,8 @@ error:
|
||||
}
|
||||
|
||||
static _Bool
|
||||
gst_pylonsrc_set_limited_feature (GstPylonSrc * src, GST_PYLONSRC_AUTOFEATURE feature)
|
||||
gst_pylonsrc_set_limited_feature (GstPylonSrc * src,
|
||||
GST_PYLONSRC_AUTOFEATURE feature)
|
||||
{
|
||||
if (feature >= AUTOF_NUM_LIMITED) {
|
||||
GST_WARNING_OBJECT (src,
|
||||
@ -2019,7 +2068,8 @@ gst_pylonsrc_set_limited_feature (GstPylonSrc * src, GST_PYLONSRC_AUTOFEATURE fe
|
||||
// Apply boundaries only if explicitly set
|
||||
if (is_prop_set (src, propLimitedUpper[feature])) {
|
||||
if (is_prop_default (src, propLimitedLower[feature])) {
|
||||
GST_WARNING_OBJECT(src, "Only the upper bound is set for %s", featManualFeature[feature]);
|
||||
GST_WARNING_OBJECT (src, "Only the upper bound is set for %s",
|
||||
featManualFeature[feature]);
|
||||
}
|
||||
if (feature_available (src, featLimitedUpper[feature])) {
|
||||
res =
|
||||
@ -2032,14 +2082,18 @@ gst_pylonsrc_set_limited_feature (GstPylonSrc * src, GST_PYLONSRC_AUTOFEATURE fe
|
||||
|
||||
if (is_prop_set (src, propLimitedLower[feature])) {
|
||||
if (is_prop_default (src, propLimitedLower[feature])) {
|
||||
GST_WARNING_OBJECT(src, "Only the lower bound is set for %s", featManualFeature[feature]);
|
||||
GST_WARNING_OBJECT (src, "Only the lower bound is set for %s",
|
||||
featManualFeature[feature]);
|
||||
} else {
|
||||
if (src->limitedFeature[feature].lower >= src->limitedFeature[feature].upper) {
|
||||
if (src->limitedFeature[feature].lower >=
|
||||
src->limitedFeature[feature].upper) {
|
||||
GST_ERROR_OBJECT (src,
|
||||
"Invalid parameter value for %s. It seems like you're trying to set a lower limit (%.2f) that's higher than the upper limit (%.2f).",
|
||||
featLimitedLower[feature], src->limitedFeature[feature].lower, src->limitedFeature[feature].upper);
|
||||
featLimitedLower[feature], src->limitedFeature[feature].lower,
|
||||
src->limitedFeature[feature].upper);
|
||||
GST_ELEMENT_ERROR (src, RESOURCE, FAILED,
|
||||
("Failed to initialise the camera"), ("Invalid parameters provided"));
|
||||
("Failed to initialise the camera"),
|
||||
("Invalid parameters provided"));
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
@ -2080,8 +2134,8 @@ gst_pylonsrc_set_auto_exp_gain_wb (GstPylonSrc * src)
|
||||
if (is_prop_set (src, PROP_AUTOBRIGHTNESSTARGET)) {
|
||||
if (feature_available (src, "AutoTargetBrightness")) {
|
||||
res =
|
||||
PylonDeviceSetFloatFeature (src->deviceHandle, "AutoTargetBrightness",
|
||||
src->brightnesstarget);
|
||||
PylonDeviceSetFloatFeature (src->deviceHandle,
|
||||
"AutoTargetBrightness", src->brightnesstarget);
|
||||
PYLONC_CHECK_ERROR (src, res);
|
||||
}
|
||||
}
|
||||
@ -2108,7 +2162,8 @@ gst_pylonsrc_set_auto_exp_gain_wb (GstPylonSrc * src)
|
||||
"Invalid parameter value for autoprofile. Available values are gain/exposure, while the value provided was \"%s\".",
|
||||
src->autoprofile);
|
||||
GST_ELEMENT_ERROR (src, RESOURCE, FAILED,
|
||||
("Failed to initialise the camera"), ("Invalid parameters provided"));
|
||||
("Failed to initialise the camera"),
|
||||
("Invalid parameters provided"));
|
||||
goto error;
|
||||
}
|
||||
} else {
|
||||
@ -2141,13 +2196,17 @@ gst_pylonsrc_set_colour_balance(GstPylonSrc* src, GST_PYLONSRC_COLOUR colour)
|
||||
src->balance[colour]);
|
||||
PYLONC_CHECK_ERROR (src, res);
|
||||
|
||||
GST_DEBUG_OBJECT (src, "%s balance set to %.2lf", featColour[colour], src->balance[colour]);
|
||||
GST_DEBUG_OBJECT (src, "%s balance set to %.2lf", featColour[colour],
|
||||
src->balance[colour]);
|
||||
}
|
||||
} else {
|
||||
GST_DEBUG_OBJECT (src, "Auto White Balance is enabled. Not setting %s Balance Ratio.", featColour[colour]);
|
||||
GST_DEBUG_OBJECT (src,
|
||||
"Auto White Balance is enabled. Not setting %s Balance Ratio.",
|
||||
featColour[colour]);
|
||||
}
|
||||
} else {
|
||||
GST_DEBUG_OBJECT (src, "Using current settings for the colour %s.", featColour[colour]);
|
||||
GST_DEBUG_OBJECT (src, "Using current settings for the colour %s.",
|
||||
featColour[colour]);
|
||||
}
|
||||
reset_prop (src, propColourBalance[colour]);
|
||||
}
|
||||
@ -2173,7 +2232,8 @@ gst_pylonsrc_set_colour_hue(GstPylonSrc* src, GST_PYLONSRC_COLOUR colour)
|
||||
src->hue[colour]);
|
||||
PYLONC_CHECK_ERROR (src, res);
|
||||
|
||||
GST_DEBUG_OBJECT (src, "%s hue set to %.2lf", featColour[colour], src->hue[colour]);
|
||||
GST_DEBUG_OBJECT (src, "%s hue set to %.2lf", featColour[colour],
|
||||
src->hue[colour]);
|
||||
}
|
||||
} else {
|
||||
GST_DEBUG_OBJECT (src, "Using saved %s hue.", featColour[colour]);
|
||||
@ -2187,7 +2247,8 @@ error:
|
||||
}
|
||||
|
||||
static _Bool
|
||||
gst_pylonsrc_set_colour_saturation(GstPylonSrc* src, GST_PYLONSRC_COLOUR colour)
|
||||
gst_pylonsrc_set_colour_saturation (GstPylonSrc * src,
|
||||
GST_PYLONSRC_COLOUR colour)
|
||||
{
|
||||
if (is_prop_implicit (src, propColourSaturation[colour])) {
|
||||
if (is_prop_set (src, propColourSaturation[colour])) {
|
||||
@ -2202,7 +2263,8 @@ gst_pylonsrc_set_colour_saturation(GstPylonSrc* src, GST_PYLONSRC_COLOUR colour)
|
||||
"ColorAdjustmentSaturation", src->saturation[colour]);
|
||||
PYLONC_CHECK_ERROR (src, res);
|
||||
|
||||
GST_DEBUG_OBJECT (src, "%s saturation set to %.2lf", featColour[colour], src->saturation[colour]);
|
||||
GST_DEBUG_OBJECT (src, "%s saturation set to %.2lf", featColour[colour],
|
||||
src->saturation[colour]);
|
||||
}
|
||||
} else {
|
||||
GST_DEBUG_OBJECT (src, "Using saved %s saturation.", featColour[colour]);
|
||||
@ -2232,10 +2294,12 @@ gst_pylonsrc_set_colour_transformation(GstPylonSrc* src, int i, int j)
|
||||
"ColorTransformationValueSelector", src->transformation[j][i]);
|
||||
PYLONC_CHECK_ERROR (src, res);
|
||||
|
||||
GST_DEBUG_OBJECT (src, "%s set to %.2lf", featGain[j][i], src->transformation[j][i]);
|
||||
GST_DEBUG_OBJECT (src, "%s set to %.2lf", featGain[j][i],
|
||||
src->transformation[j][i]);
|
||||
}
|
||||
} else {
|
||||
GST_DEBUG_OBJECT (src, "Using saved %s transformation value. ", featGain[j][i]);
|
||||
GST_DEBUG_OBJECT (src, "Using saved %s transformation value. ",
|
||||
featGain[j][i]);
|
||||
}
|
||||
reset_prop (src, propGain[j][i]);
|
||||
}
|
||||
@ -2313,11 +2377,13 @@ error:
|
||||
}
|
||||
|
||||
static _Bool
|
||||
gst_pylonsrc_set_manual_feature (GstPylonSrc * src, GST_PYLONSRC_AUTOFEATURE feature)
|
||||
gst_pylonsrc_set_manual_feature (GstPylonSrc * src,
|
||||
GST_PYLONSRC_AUTOFEATURE feature)
|
||||
{
|
||||
if (feature >= AUTOF_NUM_LIMITED) {
|
||||
GST_WARNING_OBJECT (src,
|
||||
"Trying to set manual value for unsupported autofeature: %d", (int) feature);
|
||||
"Trying to set manual value for unsupported autofeature: %d",
|
||||
(int) feature);
|
||||
} else {
|
||||
// Configure exposure/gain
|
||||
if (is_prop_implicit (src, propManualFeature[feature])) {
|
||||
@ -2325,19 +2391,24 @@ gst_pylonsrc_set_manual_feature (GstPylonSrc * src, GST_PYLONSRC_AUTOFEATURE fea
|
||||
if (feature_available (src, featManualFeature[feature])) {
|
||||
if (strcmp (src->autoFeature[feature], "off") == 0) {
|
||||
GENAPIC_RESULT res;
|
||||
GST_DEBUG_OBJECT (src, "Setting %s to %0.2lf", featManualFeature[feature], src->limitedFeature[feature].manual);
|
||||
GST_DEBUG_OBJECT (src, "Setting %s to %0.2lf",
|
||||
featManualFeature[feature],
|
||||
src->limitedFeature[feature].manual);
|
||||
res =
|
||||
PylonDeviceSetFloatFeature (src->deviceHandle, featManualFeature[feature],
|
||||
PylonDeviceSetFloatFeature (src->deviceHandle,
|
||||
featManualFeature[feature],
|
||||
src->limitedFeature[feature].manual);
|
||||
PYLONC_CHECK_ERROR (src, res);
|
||||
} else {
|
||||
GST_WARNING_OBJECT (src,
|
||||
"%s has been enabled, skipping setting manual %s.", featAutoFeature[feature], featManualFeature[feature]);
|
||||
"%s has been enabled, skipping setting manual %s.",
|
||||
featAutoFeature[feature], featManualFeature[feature]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
GST_DEBUG_OBJECT (src,
|
||||
"%s property not set, using the saved setting.", featManualFeature[feature]);
|
||||
"%s property not set, using the saved setting.",
|
||||
featManualFeature[feature]);
|
||||
}
|
||||
reset_prop (src, propManualFeature[feature]);
|
||||
}
|
||||
@ -2371,7 +2442,6 @@ gst_pylonsrc_set_exposure_gain_level (GstPylonSrc * src)
|
||||
}
|
||||
reset_prop (src, PROP_BLACKLEVEL);
|
||||
}
|
||||
|
||||
// Configure gamma correction
|
||||
if (is_prop_implicit (src, PROP_GAMMA)) {
|
||||
if (feature_available (src, "Gamma")) {
|
||||
@ -2398,8 +2468,8 @@ gst_pylonsrc_set_pgi (GstPylonSrc * src)
|
||||
if (strncmp ("bayer", src->pixel_format, 5) != 0) {
|
||||
GST_DEBUG_OBJECT (src, "Enabling Basler's PGI.");
|
||||
res =
|
||||
PylonDeviceFeatureFromString (src->deviceHandle, "DemosaicingMode",
|
||||
"BaslerPGI");
|
||||
PylonDeviceFeatureFromString (src->deviceHandle,
|
||||
"DemosaicingMode", "BaslerPGI");
|
||||
PYLONC_CHECK_ERROR (src, res);
|
||||
|
||||
// PGI Modules (Noise reduction and Sharpness enhancement).
|
||||
@ -2409,12 +2479,13 @@ gst_pylonsrc_set_pgi (GstPylonSrc * src)
|
||||
GST_DEBUG_OBJECT (src, "Setting PGI noise reduction to %0.2lf",
|
||||
src->noisereduction);
|
||||
res =
|
||||
PylonDeviceSetFloatFeature (src->deviceHandle, "NoiseReduction",
|
||||
src->noisereduction);
|
||||
PylonDeviceSetFloatFeature (src->deviceHandle,
|
||||
"NoiseReduction", src->noisereduction);
|
||||
PYLONC_CHECK_ERROR (src, res);
|
||||
}
|
||||
} else {
|
||||
GST_DEBUG_OBJECT (src, "Using the stored value for noise reduction.");
|
||||
GST_DEBUG_OBJECT (src,
|
||||
"Using the stored value for noise reduction.");
|
||||
}
|
||||
reset_prop (src, PROP_DEMOSAICINGNOISEREDUCTION);
|
||||
}
|
||||
@ -2431,7 +2502,8 @@ gst_pylonsrc_set_pgi (GstPylonSrc * src)
|
||||
PYLONC_CHECK_ERROR (src, res);
|
||||
}
|
||||
} else {
|
||||
GST_DEBUG_OBJECT (src, "Using the stored value for sharpness enhancement.");
|
||||
GST_DEBUG_OBJECT (src,
|
||||
"Using the stored value for sharpness enhancement.");
|
||||
}
|
||||
reset_prop (src, PROP_DEMOSAICINGSHARPNESSENHANCEMENT);
|
||||
}
|
||||
@ -2469,8 +2541,7 @@ gst_pylonsrc_set_properties(GstPylonSrc* src)
|
||||
gst_pylonsrc_set_auto_exp_gain_wb (src) &&
|
||||
gst_pylonsrc_set_color (src) &&
|
||||
gst_pylonsrc_set_exposure_gain_level (src) &&
|
||||
gst_pylonsrc_set_pgi (src) &&
|
||||
gst_pylonsrc_set_trigger (src);
|
||||
gst_pylonsrc_set_pgi (src) && gst_pylonsrc_set_trigger (src);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -2572,7 +2643,6 @@ gst_pylonsrc_configure_start_acquisition (GstPylonSrc * src)
|
||||
(gint) throughput, (gint) linkSpeed, (double) throughput / 1000000,
|
||||
(double) linkSpeed / 1000000);
|
||||
}
|
||||
|
||||
// Output sensor readout time [us]
|
||||
if (feature_supported (src, "SensorReadoutTime")) {
|
||||
double readoutTime = 0.0;
|
||||
@ -2586,7 +2656,6 @@ gst_pylonsrc_configure_start_acquisition (GstPylonSrc * src)
|
||||
"With these settings it will take approximately %.0lf microseconds to grab each frame.",
|
||||
readoutTime);
|
||||
}
|
||||
|
||||
// Output final frame rate [Hz]
|
||||
if (feature_supported (src, "ResultingFrameRate")) {
|
||||
double frameRate = 0.0;
|
||||
@ -2602,7 +2671,6 @@ gst_pylonsrc_configure_start_acquisition (GstPylonSrc * src)
|
||||
src->payloadSize, (double) src->payloadSize / 1000000,
|
||||
(src->payloadSize * frameRate) / 1000000);
|
||||
}
|
||||
|
||||
// Tell the camera to start recording
|
||||
res =
|
||||
PylonDeviceExecuteCommandFeature (src->deviceHandle, "AcquisitionStart");
|
||||
@ -2634,10 +2702,11 @@ read_string_feature(GstPylonSrc* src, const char* feature)
|
||||
// get bufLen at first iteration
|
||||
// read value at second iteration
|
||||
GENAPIC_RESULT res =
|
||||
PylonDeviceFeatureToString(src->deviceHandle, feature, result, &bufLen);
|
||||
PylonDeviceFeatureToString (src->deviceHandle, feature, result,
|
||||
&bufLen);
|
||||
PYLONC_CHECK_ERROR (src, res);
|
||||
}
|
||||
|
||||
GST_DEBUG_OBJECT (src, "Reading string feature: %s = %s", feature, result);
|
||||
return result;
|
||||
|
||||
error:
|
||||
@ -2646,16 +2715,54 @@ read_string_feature(GstPylonSrc* src, const char* feature)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static GENAPIC_RESULT
|
||||
read_bool_feature (GstPylonSrc * src, const char *feature, _Bool * result)
|
||||
{
|
||||
GENAPIC_RESULT res = GENAPI_E_FAIL;
|
||||
if (feature_readable (src, feature)) {
|
||||
res = PylonDeviceGetBooleanFeature (src->deviceHandle, feature, result);
|
||||
GST_DEBUG_OBJECT (src, "Reading bool feature: %s = %s", feature,
|
||||
boolalpha (*result));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static GENAPIC_RESULT
|
||||
read_integer_feature (GstPylonSrc * src, const char *feature, int64_t * result)
|
||||
{
|
||||
GENAPIC_RESULT res = GENAPI_E_FAIL;
|
||||
if (feature_readable (src, feature)) {
|
||||
res = PylonDeviceGetIntegerFeature (src->deviceHandle, feature, result);
|
||||
GST_DEBUG_OBJECT (src, "Reading integer feature: %s = %ld", feature,
|
||||
*result);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static GENAPIC_RESULT
|
||||
read_float_feature (GstPylonSrc * src, const char *feature, double *result)
|
||||
{
|
||||
GENAPIC_RESULT res = GENAPI_E_FAIL;
|
||||
if (feature_readable (src, feature)) {
|
||||
res = PylonDeviceGetFloatFeature (src->deviceHandle, feature, result);
|
||||
GST_DEBUG_OBJECT (src, "Reading float feature: %s = %f", feature, *result);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_pylonsrc_read_offset_axis (GstPylonSrc * src, GST_PYLONSRC_AXIS axis)
|
||||
{
|
||||
if (is_prop_not_set (src, propCenter[axis])) {
|
||||
PylonDeviceGetBooleanFeature (src->deviceHandle, featCenter[axis], &src->center[axis]);
|
||||
read_bool_feature (src, featCenter[axis], &src->center[axis]);
|
||||
}
|
||||
|
||||
if (is_prop_not_set (src, propOffset[axis])) {
|
||||
int64_t temp;
|
||||
GENAPIC_RESULT res = PylonDeviceGetIntegerFeature (src->deviceHandle, featOffset[axis], &temp);
|
||||
GENAPIC_RESULT res = read_integer_feature (src, featOffset[axis], &temp);
|
||||
if (res == GENAPI_E_OK) {
|
||||
src->offset[axis] = temp;
|
||||
}
|
||||
@ -2673,7 +2780,7 @@ static _Bool
|
||||
gst_pylonsrc_read_reverse_axis (GstPylonSrc * src, GST_PYLONSRC_AXIS axis)
|
||||
{
|
||||
if (is_prop_not_set (src, propReverse[axis])) {
|
||||
PylonDeviceGetBooleanFeature (src->deviceHandle, featReverse[axis], &src->flip[axis]);
|
||||
read_bool_feature (src, featReverse[axis], &src->flip[axis]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2692,8 +2799,7 @@ gst_pylonsrc_read_pixel_format (GstPylonSrc* src)
|
||||
src->pixel_format = read_string_feature (src, "PixelFormat");
|
||||
if (src->pixel_format == NULL) {
|
||||
GST_ELEMENT_ERROR (src, RESOURCE, FAILED,
|
||||
("Failed to initialise the camera"),
|
||||
("Unable to read PixelFormat"));
|
||||
("Failed to initialise the camera"), ("Unable to read PixelFormat"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2705,7 +2811,8 @@ gst_pylonsrc_read_test_image (GstPylonSrc* src)
|
||||
static const char prefix[] = "Testimage";
|
||||
char *ImageID = read_string_feature (src, "TestImageSelector");
|
||||
|
||||
if((ImageID != NULL) && (g_ascii_strncasecmp (ImageID, prefix, sizeof(prefix) - 1) == 0)) {
|
||||
if ((ImageID != NULL)
|
||||
&& (g_ascii_strncasecmp (ImageID, prefix, sizeof (prefix) - 1) == 0)) {
|
||||
src->testImage = atoi (&ImageID[sizeof (prefix) - 1]);
|
||||
} else {
|
||||
src->testImage = 0;
|
||||
@ -2738,7 +2845,8 @@ gst_pylonsrc_read_bandwidth (GstPylonSrc* src)
|
||||
|
||||
if (is_prop_not_set (src, PROP_MAXBANDWIDTH)) {
|
||||
int64_t temp;
|
||||
GENAPIC_RESULT res = PylonDeviceGetIntegerFeature (src->deviceHandle, "DeviceLinkThroughputLimit", &temp);
|
||||
GENAPIC_RESULT res =
|
||||
read_integer_feature (src, "DeviceLinkThroughputLimit", &temp);
|
||||
if (res == GENAPI_E_OK) {
|
||||
src->maxBandwidth = temp;
|
||||
}
|
||||
@ -2749,7 +2857,7 @@ static void
|
||||
gst_pylonsrc_read_framerate (GstPylonSrc * src)
|
||||
{
|
||||
if (is_prop_not_set (src, PROP_ACQUISITIONFRAMERATEENABLE)) {
|
||||
GENAPIC_RESULT res = PylonDeviceGetBooleanFeature (src->deviceHandle,
|
||||
GENAPIC_RESULT res = read_bool_feature (src,
|
||||
"AcquisitionFrameRateEnable", &src->setFPS);
|
||||
if (res != GENAPI_E_OK) {
|
||||
src->setFPS = FALSE;
|
||||
@ -2757,7 +2865,7 @@ gst_pylonsrc_read_framerate (GstPylonSrc* src)
|
||||
}
|
||||
|
||||
if (is_prop_not_set (src, PROP_FPS)) {
|
||||
GENAPIC_RESULT res = PylonDeviceGetFloatFeature (src->deviceHandle,
|
||||
GENAPIC_RESULT res = read_float_feature (src,
|
||||
"AcquisitionFrameRate", &src->fps);
|
||||
if (res != GENAPI_E_OK) {
|
||||
src->fps = 0.0;
|
||||
@ -2793,11 +2901,13 @@ gst_pylonsrc_read_lightsource (GstPylonSrc* src)
|
||||
}
|
||||
|
||||
static void
|
||||
gst_pylonsrc_read_auto_feature (GstPylonSrc * src, GST_PYLONSRC_AUTOFEATURE feature)
|
||||
gst_pylonsrc_read_auto_feature (GstPylonSrc * src,
|
||||
GST_PYLONSRC_AUTOFEATURE feature)
|
||||
{
|
||||
if (is_prop_not_set (src, propAutoFeature[feature])) {
|
||||
g_free (src->autoFeature[feature]);
|
||||
src->autoFeature[feature] = read_string_feature(src, featAutoFeature[feature]);
|
||||
src->autoFeature[feature] =
|
||||
read_string_feature (src, featAutoFeature[feature]);
|
||||
if (src->autoFeature[feature] == NULL) {
|
||||
src->autoFeature[feature] = g_strdup ("off");
|
||||
}
|
||||
@ -2805,18 +2915,21 @@ gst_pylonsrc_read_auto_feature (GstPylonSrc * src, GST_PYLONSRC_AUTOFEATURE feat
|
||||
}
|
||||
|
||||
static void
|
||||
gst_pylonsrc_read_limited_feature (GstPylonSrc * src, GST_PYLONSRC_AUTOFEATURE feature)
|
||||
gst_pylonsrc_read_limited_feature (GstPylonSrc * src,
|
||||
GST_PYLONSRC_AUTOFEATURE feature)
|
||||
{
|
||||
if (feature >= AUTOF_NUM_LIMITED) {
|
||||
GST_WARNING_OBJECT (src,
|
||||
"Trying to read limits for unsupported autofeature: %d", (int) feature);
|
||||
} else {
|
||||
if (is_prop_not_set (src, propLimitedUpper[feature])) {
|
||||
PylonDeviceGetFloatFeature (src->deviceHandle, featLimitedUpper[feature], &src->limitedFeature[feature].upper);
|
||||
read_float_feature (src, featLimitedUpper[feature],
|
||||
&src->limitedFeature[feature].upper);
|
||||
}
|
||||
|
||||
if (is_prop_not_set (src, propLimitedLower[feature])) {
|
||||
PylonDeviceGetFloatFeature (src->deviceHandle, featLimitedLower[feature], &src->limitedFeature[feature].lower);
|
||||
read_float_feature (src, featLimitedLower[feature],
|
||||
&src->limitedFeature[feature].lower);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2836,7 +2949,7 @@ GENAPIC_RESULT res;
|
||||
}
|
||||
|
||||
if (is_prop_not_set (src, PROP_AUTOBRIGHTNESSTARGET)) {
|
||||
PylonDeviceGetFloatFeature (src->deviceHandle, "AutoTargetBrightness", &src->brightnesstarget);
|
||||
read_float_feature (src, "AutoTargetBrightness", &src->brightnesstarget);
|
||||
}
|
||||
|
||||
if (is_prop_not_set (src, PROP_AUTOPROFILE)) {
|
||||
@ -2844,7 +2957,8 @@ GENAPIC_RESULT res;
|
||||
g_free (src->autoprofile);
|
||||
|
||||
char *temp = read_string_feature (src, "AutoFunctionProfile");
|
||||
if((temp != NULL) && (g_ascii_strncasecmp (temp, prefix, sizeof(prefix) - 1) == 0)) {
|
||||
if ((temp != NULL)
|
||||
&& (g_ascii_strncasecmp (temp, prefix, sizeof (prefix) - 1) == 0)) {
|
||||
src->autoprofile = g_ascii_strdown (&temp[sizeof (prefix) - 1], -1);
|
||||
} else {
|
||||
src->autoprofile = g_strdup ("off");
|
||||
@ -2860,7 +2974,7 @@ gst_pylonsrc_read_colour_balance(GstPylonSrc* src, GST_PYLONSRC_COLOUR colour)
|
||||
GENAPIC_RESULT res = PylonDeviceFeatureFromString (src->deviceHandle,
|
||||
"BalanceRatioSelector", featColour[colour]);
|
||||
if (res == GENAPI_E_OK) {
|
||||
PylonDeviceGetFloatFeature (src->deviceHandle, "BalanceRatio", &src->balance[colour]);
|
||||
read_float_feature (src, "BalanceRatio", &src->balance[colour]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2872,19 +2986,21 @@ gst_pylonsrc_read_colour_hue(GstPylonSrc* src, GST_PYLONSRC_COLOUR colour)
|
||||
GENAPIC_RESULT res = PylonDeviceFeatureFromString (src->deviceHandle,
|
||||
"ColorAdjustmentSelector", featColour[colour]);
|
||||
if (res = GENAPI_E_OK) {
|
||||
PylonDeviceGetFloatFeature (src->deviceHandle, "ColorAdjustmentHue", &src->hue[colour]);
|
||||
read_float_feature (src, "ColorAdjustmentHue", &src->hue[colour]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static _Bool
|
||||
gst_pylonsrc_read_colour_saturation(GstPylonSrc* src, GST_PYLONSRC_COLOUR colour)
|
||||
gst_pylonsrc_read_colour_saturation (GstPylonSrc * src,
|
||||
GST_PYLONSRC_COLOUR colour)
|
||||
{
|
||||
if (is_prop_not_set (src, propColourSaturation[colour])) {
|
||||
GENAPIC_RESULT res = PylonDeviceFeatureFromString (src->deviceHandle,
|
||||
"ColorAdjustmentSelector", featColour[colour]);
|
||||
if (res == GENAPI_E_OK) {
|
||||
PylonDeviceGetFloatFeature (src->deviceHandle, "ColorAdjustmentSaturation", &src->saturation[colour]);
|
||||
read_float_feature (src, "ColorAdjustmentSaturation",
|
||||
&src->saturation[colour]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2896,7 +3012,7 @@ gst_pylonsrc_read_colour_transformation(GstPylonSrc* src, int i, int j)
|
||||
GENAPIC_RESULT res = PylonDeviceFeatureFromString (src->deviceHandle,
|
||||
"ColorTransformationSelector", featGain[j][i]);
|
||||
if (res == GENAPI_E_OK) {
|
||||
PylonDeviceGetFloatFeature (src->deviceHandle,
|
||||
read_float_feature (src,
|
||||
"ColorTransformationValueSelector", &src->transformation[j][i]);
|
||||
}
|
||||
}
|
||||
@ -2945,14 +3061,16 @@ gst_pylonsrc_read_color (GstPylonSrc* src)
|
||||
}
|
||||
|
||||
static void
|
||||
gst_pylonsrc_read_manual_feature (GstPylonSrc * src, GST_PYLONSRC_AUTOFEATURE feature)
|
||||
gst_pylonsrc_read_manual_feature (GstPylonSrc * src,
|
||||
GST_PYLONSRC_AUTOFEATURE feature)
|
||||
{
|
||||
if (feature >= AUTOF_NUM_LIMITED) {
|
||||
GST_WARNING_OBJECT (src,
|
||||
"Trying to read manual value for unsupported autofeature: %d", (int) feature);
|
||||
"Trying to read manual value for unsupported autofeature: %d",
|
||||
(int) feature);
|
||||
} else {
|
||||
if (is_prop_not_set (src, propManualFeature[feature])) {
|
||||
PylonDeviceGetFloatFeature (src->deviceHandle, featManualFeature[feature],
|
||||
read_float_feature (src, featManualFeature[feature],
|
||||
&src->limitedFeature[feature].manual);
|
||||
}
|
||||
}
|
||||
@ -2968,12 +3086,11 @@ gst_pylonsrc_read_exposure_gain_level (GstPylonSrc* src)
|
||||
}
|
||||
|
||||
if (is_prop_not_set (src, PROP_BLACKLEVEL)) {
|
||||
PylonDeviceGetFloatFeature (src->deviceHandle, "BlackLevel", &src->blacklevel);
|
||||
read_float_feature (src, "BlackLevel", &src->blacklevel);
|
||||
}
|
||||
|
||||
// Configure gamma correction
|
||||
if (is_prop_not_set (src, PROP_GAMMA)) {
|
||||
PylonDeviceGetFloatFeature (src->deviceHandle, "Gamma", &src->gamma);
|
||||
read_float_feature (src, "Gamma", &src->gamma);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2991,29 +3108,36 @@ gst_pylonsrc_read_pgi (GstPylonSrc* src)
|
||||
}
|
||||
|
||||
if (is_prop_not_set (src, PROP_DEMOSAICINGNOISEREDUCTION)) {
|
||||
PylonDeviceGetFloatFeature (src->deviceHandle, "NoiseReduction", &src->noisereduction);
|
||||
read_float_feature (src, "NoiseReduction", &src->noisereduction);
|
||||
}
|
||||
|
||||
if (is_prop_not_set (src, PROP_DEMOSAICINGSHARPNESSENHANCEMENT)) {
|
||||
PylonDeviceGetFloatFeature (src->deviceHandle,
|
||||
read_float_feature (src,
|
||||
"SharpnessEnhancement", &src->sharpnessenhancement);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gst_pylonsrc_read_trigger_selector_mode(GstPylonSrc* src, const char* trigger_selector)
|
||||
gst_pylonsrc_read_trigger_selector_mode (GstPylonSrc * src,
|
||||
const char *trigger_selector)
|
||||
{
|
||||
GENAPIC_RESULT res = PylonDeviceFeatureFromString (src->deviceHandle, "TriggerSelector", trigger_selector);
|
||||
GST_DEBUG_OBJECT (src, "Reading trigger selector mode: %s", trigger_selector);
|
||||
GENAPIC_RESULT res =
|
||||
PylonDeviceFeatureFromString (src->deviceHandle, "TriggerSelector",
|
||||
trigger_selector);
|
||||
if (res == GENAPI_E_OK) {
|
||||
char *temp = read_string_feature (src, "TriggerMode");
|
||||
GST_DEBUG_OBJECT (src, "Trigger mode: %s", temp);
|
||||
if ((temp != NULL) && (strcmp (temp, "On") == 0)) {
|
||||
src->continuousMode = TRUE;
|
||||
} else {
|
||||
src->continuousMode = FALSE;
|
||||
} else {
|
||||
src->continuousMode = TRUE;
|
||||
}
|
||||
g_free (temp);
|
||||
} else {
|
||||
src->continuousMode = FALSE;
|
||||
GST_WARNING_OBJECT (src,
|
||||
"Failed to get TriggerSelector. Assuming continuous acquisition");
|
||||
src->continuousMode = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3041,7 +3165,7 @@ gst_pylonsrc_read_resolution_axis(GstPylonSrc * src, GST_PYLONSRC_AXIS axis)
|
||||
{
|
||||
if (is_prop_not_set (src, propBinning[axis])) {
|
||||
int64_t temp;
|
||||
GENAPIC_RESULT res = PylonDeviceGetIntegerFeature (src->deviceHandle, featBinning[axis], &temp);
|
||||
GENAPIC_RESULT res = read_integer_feature (src, featBinning[axis], &temp);
|
||||
if (res == GENAPI_E_OK) {
|
||||
src->binning[axis] = temp;
|
||||
}
|
||||
@ -3049,7 +3173,7 @@ gst_pylonsrc_read_resolution_axis(GstPylonSrc * src, GST_PYLONSRC_AXIS axis)
|
||||
|
||||
if (is_prop_not_set (src, propSize[axis])) {
|
||||
int64_t temp;
|
||||
GENAPIC_RESULT res = PylonDeviceGetIntegerFeature (src->deviceHandle, featSize[axis], &temp);
|
||||
GENAPIC_RESULT res = read_integer_feature (src, featSize[axis], &temp);
|
||||
if (res == GENAPI_E_OK) {
|
||||
src->size[axis] = temp;
|
||||
} else {
|
||||
@ -3058,7 +3182,7 @@ gst_pylonsrc_read_resolution_axis(GstPylonSrc * src, GST_PYLONSRC_AXIS axis)
|
||||
("Camera isn't reporting it's resolution. (Unsupported device?)"));
|
||||
}
|
||||
|
||||
res = PylonDeviceGetIntegerFeature (src->deviceHandle, featMaxSize[axis], &temp);
|
||||
res = read_integer_feature (src, featMaxSize[axis], &temp);
|
||||
if (res == GENAPI_E_OK) {
|
||||
src->maxSize[axis] = temp;
|
||||
}
|
||||
|
||||
@ -34,33 +34,34 @@
|
||||
int gst_pylonsrc_ref_pylon_environment ();
|
||||
int gst_pylonsrc_unref_pylon_environment ();
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
GST_PYLONSRC_NUM_CAPTURE_BUFFERS = 10,
|
||||
GST_PYLONSRC_NUM_AUTO_FEATURES = 3,
|
||||
GST_PYLONSRC_NUM_LIMITED_FEATURES = 2,
|
||||
GST_PYLONSRC_NUM_PROPS = 66
|
||||
};
|
||||
|
||||
typedef enum _GST_PYLONSRC_PROPERTY_STATE {
|
||||
typedef enum _GST_PYLONSRC_PROPERTY_STATE
|
||||
{
|
||||
GST_PYLONSRC_PROPST_DEFAULT,
|
||||
GST_PYLONSRC_PROPST_NOT_SET,
|
||||
GST_PYLONSRC_PROPST_SET
|
||||
} GST_PYLONSRC_PROPERTY_STATE;
|
||||
|
||||
typedef struct _GstPylonSrcLimitedFeature {
|
||||
typedef struct _GstPylonSrcLimitedFeature
|
||||
{
|
||||
double lower;
|
||||
double upper;
|
||||
double manual;
|
||||
} GstPylonSrcLimitedFeature;
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_TYPE_PYLONSRC (gst_pylonsrc_get_type())
|
||||
#define GST_PYLONSRC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_PYLONSRC,GstPylonSrc))
|
||||
#define GST_PYLONSRC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_PYLONSRC,GstPylonSrcClass))
|
||||
#define GST_IS_PYLONSRC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_PYLONSRC))
|
||||
#define GST_IS_PYLONSRC_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_PYLONSRC))
|
||||
|
||||
typedef struct _GstPylonSrc GstPylonSrc;
|
||||
typedef struct _GstPylonSrcClass GstPylonSrcClass;
|
||||
|
||||
@ -89,7 +90,8 @@ struct _GstPylonSrc
|
||||
_Bool center[2];
|
||||
_Bool flip[2];
|
||||
_Bool ignoreDefaults;
|
||||
double fps, blacklevel, gamma, sharpnessenhancement, noisereduction, brightnesstarget;
|
||||
double fps, blacklevel, gamma, sharpnessenhancement, noisereduction,
|
||||
brightnesstarget;
|
||||
double balance[3];
|
||||
double hue[6];
|
||||
double saturation[6];
|
||||
@ -102,7 +104,8 @@ struct _GstPylonSrc
|
||||
gint binning[2];
|
||||
gint maxSize[2];
|
||||
gint offset[2];
|
||||
gchar *pixel_format, *sensorMode, *lightsource, *reset, *autoprofile, *transformationselector, *userid;
|
||||
gchar *pixel_format, *sensorMode, *lightsource, *reset, *autoprofile,
|
||||
*transformationselector, *userid;
|
||||
gchar *autoFeature[GST_PYLONSRC_NUM_AUTO_FEATURES];
|
||||
gchar *configFile;
|
||||
GST_PYLONSRC_PROPERTY_STATE propFlags[GST_PYLONSRC_NUM_PROPS];
|
||||
@ -116,5 +119,4 @@ struct _GstPylonSrcClass
|
||||
GType gst_pylonsrc_get_type (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user