pylonsrc: refactored 'feature_supported'
This commit is contained in:
parent
9ed4d32163
commit
6b863f3460
@ -1124,7 +1124,16 @@ unsupported_caps:
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define FEATURE_SUPPORTED(feat) PylonDeviceFeatureIsImplemented(src->deviceHandle, feat)
|
static inline _Bool
|
||||||
|
feature_supported(const GstPylonSrc* src, const char* feature)
|
||||||
|
{
|
||||||
|
if(PylonDeviceFeatureIsImplemented(src->deviceHandle, feature)) {
|
||||||
|
return TRUE;
|
||||||
|
} else {
|
||||||
|
GST_WARNING_OBJECT (src, "Camera does not implement feature: %s", feature);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_pylonsrc_set_trigger (GstPylonSrc * src)
|
gst_pylonsrc_set_trigger (GstPylonSrc * src)
|
||||||
@ -1358,7 +1367,7 @@ gst_pylonsrc_set_resolution_axis(GstPylonSrc * src, GST_PYLONSRC_AXIS axis)
|
|||||||
static const char* const featMaxSize[2] = {"WidthMax", "HeightMax"};
|
static const char* const featMaxSize[2] = {"WidthMax", "HeightMax"};
|
||||||
|
|
||||||
// set binning of camera
|
// set binning of camera
|
||||||
if (FEATURE_SUPPORTED (featBinning[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 =
|
res =
|
||||||
PylonDeviceSetIntegerFeature (src->deviceHandle, featBinning[axis],
|
PylonDeviceSetIntegerFeature (src->deviceHandle, featBinning[axis],
|
||||||
@ -1366,7 +1375,7 @@ gst_pylonsrc_set_resolution_axis(GstPylonSrc * src, GST_PYLONSRC_AXIS axis)
|
|||||||
PYLONC_CHECK_ERROR (src, res);
|
PYLONC_CHECK_ERROR (src, res);
|
||||||
}
|
}
|
||||||
// Get the camera's resolution
|
// Get the camera's resolution
|
||||||
if (!FEATURE_SUPPORTED (featSize[axis])) {
|
if (!feature_supported(src, featSize[axis])) {
|
||||||
GST_ERROR_OBJECT (src,
|
GST_ERROR_OBJECT (src,
|
||||||
"The camera doesn't seem to be reporting it's resolution.");
|
"The camera doesn't seem to be reporting it's resolution.");
|
||||||
GST_ELEMENT_ERROR (src, RESOURCE, FAILED,
|
GST_ELEMENT_ERROR (src, RESOURCE, FAILED,
|
||||||
@ -1379,7 +1388,7 @@ gst_pylonsrc_set_resolution_axis(GstPylonSrc * src, GST_PYLONSRC_AXIS axis)
|
|||||||
PYLONC_CHECK_ERROR (src, res);
|
PYLONC_CHECK_ERROR (src, res);
|
||||||
|
|
||||||
// Max Width and Height.
|
// Max Width and Height.
|
||||||
if (FEATURE_SUPPORTED (featMaxSize[axis])) {
|
if (feature_supported(src, featMaxSize[axis])) {
|
||||||
int64_t maxSize;
|
int64_t maxSize;
|
||||||
res =
|
res =
|
||||||
PylonDeviceGetIntegerFeature (src->deviceHandle, featMaxSize[axis], &maxSize);
|
PylonDeviceGetIntegerFeature (src->deviceHandle, featMaxSize[axis], &maxSize);
|
||||||
@ -1432,16 +1441,9 @@ gst_pylonsrc_set_offset_axis (GstPylonSrc * src, GST_PYLONSRC_AXIS axis)
|
|||||||
static const char* const featCenter[2] = {"CenterX", "CenterY"};
|
static const char* const featCenter[2] = {"CenterX", "CenterY"};
|
||||||
|
|
||||||
// Set the offset
|
// Set the offset
|
||||||
if (!FEATURE_SUPPORTED (featOffset[axis])) {
|
if (feature_supported(src, featOffset[axis])) {
|
||||||
GST_WARNING_OBJECT (src,
|
|
||||||
"The camera doesn't seem to allow setting offsets. Skipping...");
|
|
||||||
} else {
|
|
||||||
// Check if the user wants to center image first
|
// Check if the user wants to center image first
|
||||||
_Bool cameraSupportsCenter = FEATURE_SUPPORTED (featCenter[axis]);
|
if (feature_supported(src, featCenter[axis])) {
|
||||||
if (!cameraSupportsCenter) {
|
|
||||||
GST_WARNING_OBJECT (src,
|
|
||||||
"The camera doesn't seem to allow offset centering. Skipping...");
|
|
||||||
} else {
|
|
||||||
res =
|
res =
|
||||||
PylonDeviceSetBooleanFeature (src->deviceHandle, featCenter[axis],
|
PylonDeviceSetBooleanFeature (src->deviceHandle, featCenter[axis],
|
||||||
src->center[axis]);
|
src->center[axis]);
|
||||||
@ -1492,11 +1494,7 @@ gst_pylonsrc_set_reverse_axis (GstPylonSrc * src, GST_PYLONSRC_AXIS axis)
|
|||||||
static const char* const featReverse[2] = {"ReverseX", "ReverseY"};
|
static const char* const featReverse[2] = {"ReverseX", "ReverseY"};
|
||||||
|
|
||||||
// Flip the image
|
// Flip the image
|
||||||
if (!FEATURE_SUPPORTED (featReverse[axis])) {
|
if (feature_supported(src, featReverse[axis])) {
|
||||||
src->flip[axis] = FALSE;
|
|
||||||
GST_WARNING_OBJECT (src,
|
|
||||||
"Camera doesn't support %s. Skipping...", featReverse[axis]);
|
|
||||||
} else {
|
|
||||||
res =
|
res =
|
||||||
PylonDeviceSetBooleanFeature (src->deviceHandle, featReverse[axis],
|
PylonDeviceSetBooleanFeature (src->deviceHandle, featReverse[axis],
|
||||||
src->flip[axis]);
|
src->flip[axis]);
|
||||||
@ -1602,7 +1600,7 @@ gst_pylonsrc_set_test_image (GstPylonSrc * src)
|
|||||||
GENAPIC_RESULT res;
|
GENAPIC_RESULT res;
|
||||||
|
|
||||||
// Set whether test image will be shown
|
// Set whether test image will be shown
|
||||||
if (FEATURE_SUPPORTED ("TestImageSelector")) {
|
if (feature_supported(src, "TestImageSelector")) {
|
||||||
if (src->testImage != 0) {
|
if (src->testImage != 0) {
|
||||||
char *ImageId;
|
char *ImageId;
|
||||||
GST_DEBUG_OBJECT (src, "Test image mode enabled.");
|
GST_DEBUG_OBJECT (src, "Test image mode enabled.");
|
||||||
@ -1618,8 +1616,6 @@ gst_pylonsrc_set_test_image (GstPylonSrc * src)
|
|||||||
"Off");
|
"Off");
|
||||||
PYLONC_CHECK_ERROR (src, res);
|
PYLONC_CHECK_ERROR (src, res);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
GST_WARNING_OBJECT (src, "The camera doesn't support test image mode.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -1634,7 +1630,7 @@ gst_pylonsrc_set_readout (GstPylonSrc * src)
|
|||||||
GENAPIC_RESULT res;
|
GENAPIC_RESULT res;
|
||||||
|
|
||||||
// Set sensor readout mode (default: Normal)
|
// Set sensor readout mode (default: Normal)
|
||||||
if (FEATURE_SUPPORTED ("SensorReadoutMode")) {
|
if (feature_supported (src, "SensorReadoutMode")) {
|
||||||
ascii_strdown (&src->sensorMode, -1);
|
ascii_strdown (&src->sensorMode, -1);
|
||||||
|
|
||||||
if (strcmp (src->sensorMode, "normal") == 0) {
|
if (strcmp (src->sensorMode, "normal") == 0) {
|
||||||
@ -1657,9 +1653,6 @@ gst_pylonsrc_set_readout (GstPylonSrc * src)
|
|||||||
("Failed to initialise the camera"), ("Invalid parameters provided"));
|
("Failed to initialise the camera"), ("Invalid parameters provided"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
GST_WARNING_OBJECT (src,
|
|
||||||
"Camera does not support changing the readout mode.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -1674,27 +1667,17 @@ gst_pylonsrc_set_bandwidth (GstPylonSrc * src)
|
|||||||
GENAPIC_RESULT res;
|
GENAPIC_RESULT res;
|
||||||
|
|
||||||
// Set bandwidth limit mode (default: on)
|
// Set bandwidth limit mode (default: on)
|
||||||
if (FEATURE_SUPPORTED ("DeviceLinkThroughputLimitMode")) {
|
if (feature_supported (src, "DeviceLinkThroughputLimitMode")) {
|
||||||
if (src->limitBandwidth) {
|
GST_DEBUG_OBJECT (src, "%s camera's bandwidth.", src->limitBandwidth ? "Limiting" : "Unlocking");
|
||||||
GST_DEBUG_OBJECT (src, "Limiting camera's bandwidth.");
|
|
||||||
res =
|
res =
|
||||||
PylonDeviceFeatureFromString (src->deviceHandle,
|
PylonDeviceFeatureFromString (src->deviceHandle,
|
||||||
"DeviceLinkThroughputLimitMode", "On");
|
"DeviceLinkThroughputLimitMode", src->limitBandwidth ? "On" : "Off");
|
||||||
PYLONC_CHECK_ERROR (src, res);
|
|
||||||
} else {
|
|
||||||
GST_DEBUG_OBJECT (src, "Unlocking camera's bandwidth.");
|
|
||||||
res =
|
|
||||||
PylonDeviceFeatureFromString (src->deviceHandle,
|
|
||||||
"DeviceLinkThroughputLimitMode", "Off");
|
|
||||||
PYLONC_CHECK_ERROR (src, res);
|
PYLONC_CHECK_ERROR (src, res);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
GST_WARNING_OBJECT (src,
|
|
||||||
"Camera does not support disabling the throughput limit.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set bandwidth limit
|
// Set bandwidth limit
|
||||||
if (FEATURE_SUPPORTED ("DeviceLinkThroughputLimit")) {
|
if (feature_supported (src, "DeviceLinkThroughputLimit")) {
|
||||||
if (src->maxBandwidth != 0) {
|
if (src->maxBandwidth != 0) {
|
||||||
if (!src->limitBandwidth) {
|
if (!src->limitBandwidth) {
|
||||||
GST_DEBUG_OBJECT (src,
|
GST_DEBUG_OBJECT (src,
|
||||||
@ -1708,9 +1691,6 @@ gst_pylonsrc_set_bandwidth (GstPylonSrc * src)
|
|||||||
"DeviceLinkThroughputLimit", src->maxBandwidth);
|
"DeviceLinkThroughputLimit", src->maxBandwidth);
|
||||||
PYLONC_CHECK_ERROR (src, res);
|
PYLONC_CHECK_ERROR (src, res);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
GST_WARNING_OBJECT (src,
|
|
||||||
"Camera does not support changing the throughput limit.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -2246,7 +2226,7 @@ gst_pylonsrc_set_pgi (GstPylonSrc * src)
|
|||||||
GENAPIC_RESULT res;
|
GENAPIC_RESULT res;
|
||||||
|
|
||||||
// Basler PGI
|
// Basler PGI
|
||||||
if (FEATURE_SUPPORTED ("DemosaicingMode")) {
|
if (feature_supported (src, "DemosaicingMode")) {
|
||||||
if (src->demosaicing || fnequal(src->sharpnessenhancement, 999.0)
|
if (src->demosaicing || fnequal(src->sharpnessenhancement, 999.0)
|
||||||
|| fnequal(src->noisereduction, 999.0)) {
|
|| fnequal(src->noisereduction, 999.0)) {
|
||||||
if (strncmp ("bayer", src->pixel_format, 5) != 0) {
|
if (strncmp ("bayer", src->pixel_format, 5) != 0) {
|
||||||
@ -2298,8 +2278,6 @@ gst_pylonsrc_set_pgi (GstPylonSrc * src)
|
|||||||
GST_DEBUG_OBJECT (src,
|
GST_DEBUG_OBJECT (src,
|
||||||
"Usage of PGI is not permitted with bayer output. Skipping.");
|
"Usage of PGI is not permitted with bayer output. Skipping.");
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
GST_DEBUG_OBJECT (src, "Basler's PGI is not supported. Skipping.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -2395,8 +2373,8 @@ gst_pylonsrc_configure_start_acquisition (GstPylonSrc * src)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Output the bandwidth the camera will actually use [B/s]
|
// Output the bandwidth the camera will actually use [B/s]
|
||||||
if (FEATURE_SUPPORTED ("DeviceLinkCurrentThroughput")
|
if (feature_supported (src, "DeviceLinkCurrentThroughput")
|
||||||
&& FEATURE_SUPPORTED ("DeviceLinkSpeed")) {
|
&& feature_supported (src, "DeviceLinkSpeed")) {
|
||||||
int64_t throughput = 0, linkSpeed = 0;
|
int64_t throughput = 0, linkSpeed = 0;
|
||||||
|
|
||||||
res =
|
res =
|
||||||
@ -2420,12 +2398,10 @@ gst_pylonsrc_configure_start_acquisition (GstPylonSrc * src)
|
|||||||
"With current settings the camera requires %d/%d B/s (%.1lf out of %.1lf MB/s) of bandwidth.",
|
"With current settings the camera requires %d/%d B/s (%.1lf out of %.1lf MB/s) of bandwidth.",
|
||||||
(gint) throughput, (gint) linkSpeed, (double) throughput / 1000000,
|
(gint) throughput, (gint) linkSpeed, (double) throughput / 1000000,
|
||||||
(double) linkSpeed / 1000000);
|
(double) linkSpeed / 1000000);
|
||||||
} else {
|
|
||||||
GST_WARNING_OBJECT (src, "Couldn't determine link speed.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Output sensor readout time [us]
|
// Output sensor readout time [us]
|
||||||
if (FEATURE_SUPPORTED ("SensorReadoutTime")) {
|
if (feature_supported (src, "SensorReadoutTime")) {
|
||||||
double readoutTime = 0.0;
|
double readoutTime = 0.0;
|
||||||
|
|
||||||
res =
|
res =
|
||||||
@ -2436,12 +2412,10 @@ gst_pylonsrc_configure_start_acquisition (GstPylonSrc * src)
|
|||||||
GST_DEBUG_OBJECT (src,
|
GST_DEBUG_OBJECT (src,
|
||||||
"With these settings it will take approximately %.0lf microseconds to grab each frame.",
|
"With these settings it will take approximately %.0lf microseconds to grab each frame.",
|
||||||
readoutTime);
|
readoutTime);
|
||||||
} else {
|
|
||||||
GST_WARNING_OBJECT (src, "Couldn't determine sensor readout time.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Output final frame rate [Hz]
|
// Output final frame rate [Hz]
|
||||||
if (FEATURE_SUPPORTED ("ResultingFrameRate")) {
|
if (feature_supported (src, "ResultingFrameRate")) {
|
||||||
double frameRate = 0.0;
|
double frameRate = 0.0;
|
||||||
|
|
||||||
res =
|
res =
|
||||||
@ -2454,8 +2428,6 @@ gst_pylonsrc_configure_start_acquisition (GstPylonSrc * src)
|
|||||||
"Each frame is %d bytes big (%.1lf MB). That's %.1lfMB/s.",
|
"Each frame is %d bytes big (%.1lf MB). That's %.1lfMB/s.",
|
||||||
src->payloadSize, (double) src->payloadSize / 1000000,
|
src->payloadSize, (double) src->payloadSize / 1000000,
|
||||||
(src->payloadSize * frameRate) / 1000000);
|
(src->payloadSize * frameRate) / 1000000);
|
||||||
} else {
|
|
||||||
GST_WARNING_OBJECT (src, "Couldn't determine the resulting framerate.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tell the camera to start recording
|
// Tell the camera to start recording
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user