joshdoe / gst-plugins-vision

GStreamer plugins related to the field of machine vision
Other
134 stars 50 forks source link

Pylon Feature Duplicates #49

Closed mrstecklo closed 3 years ago

mrstecklo commented 3 years ago

This PR generally resolves issues #47 and #48. And property handling modifications I've mentioned here I've tested it on acA720-290gm and acA2040-55uc. This pair is a fairly good example of feature name duplicates. However they do not cover all of the possible aliases.

joshdoe commented 3 years ago

Had a few minutes to test. I got an error when pixel format is left to "auto", setting to "Mono8" got past that. Got error setting BlackLevelRaw to 0.0 (had to set as Integer)

   // Configure black level
   if (is_prop_implicit (src, PROP_BLACKLEVEL)) {
-    const char *name =
-        feature_alias_available (src, "BlackLevel", "BlackLevelRaw");
-    if (name != NULL) {
-      GST_DEBUG_OBJECT (src, "Setting black level to %0.2lf", src->blacklevel);
+    if (feature_available (src, "BlackLevel")) {
+      GST_DEBUG_OBJECT (src, "Setting BlackLevel to %0.2lf", src->blacklevel);
       res =
-          PylonDeviceSetFloatFeature (src->deviceHandle, name, src->blacklevel);
+          PylonDeviceSetFloatFeature (src->deviceHandle, "BlackLevel", src->blacklevel);
       PYLONC_CHECK_ERROR (src, res);
+    } else if (feature_available(src, "BlackLevelRaw")) {
+      GST_DEBUG_OBJECT(src, "Setting BlackLevelRaw to %d", (int)src->blacklevel);
+      res =
+        PylonDeviceSetIntegerFeature(src->deviceHandle, "BlackLevelRaw", (int)src->blacklevel);
+      PYLONC_CHECK_ERROR(src, res);
     }
     reset_prop (src, PROP_BLACKLEVEL);
   }

I'll see what's up with the auto not working.

joshdoe commented 3 years ago

pixel-format=auto no longer works, because _set_caps() doesn't get called until after _start(). If I change this:

@@ -3632,7 +3635,7 @@ gst_pylonsrc_start (GstBaseSrc * bsrc)

   if (!gst_pylonsrc_select_device (src) ||
-      !gst_pylonsrc_connect_device (src) || !gst_pylonsrc_set_properties (src))
+      !gst_pylonsrc_connect_device (src))
     goto error;

   src->caps = gst_pylonsrc_get_supported_caps (src);

I get past that, but then width and height are set to zero, so then I have to manually set both width and height.

I'll have to think of a way to fix the auto format issue, if fixed I should also set the width, height, and framerate from the negotiated caps.

If you have insights for these fixes let me know, I can't look at it again until next week. Thanks for the PR!

mrstecklo commented 3 years ago

Found and fixed some more float features with integer aliases. Wonder how I've missed them at first time. Moved resolving pixel format to negotiation phase. Probably _set_caps() could be improved to handle resolution and framerate in the same manner as pixel-format.

joshdoe commented 3 years ago

Ok seems to work pretty now. @mrstecklo ready to merge then?

mrstecklo commented 3 years ago

@joshdoe sure