Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gst: gamma control added for aravissrc (help needed) #940

Closed
wants to merge 2 commits into from

Conversation

WhaSukGO
Copy link
Contributor

@WhaSukGO WhaSukGO commented Sep 5, 2024

Overview

  • gamma has been added to aravissrc
  • Tested on iRAYPLE's A5051CU545E
 - USB3.0 interface, 5Gbps theoretical transfer bandwidth, power supply via USB interface
 - Compatible with USB3.0 Vision protocol and GenICam standard
 - Support Software Trigger/Hardware Trigger/Free Run Mode
 - Resolution: 800 × 600
 - Frame Rate: 545 fps

Example

$ gst-inspect-1.0 aravissrc
  ...

  gain                : Gain (dB)
                        flags: readable, writable
                        Double. Range:              -1 -             500 Default:              -1 
  gain-auto           : Auto Gain Mode
                        flags: readable, writable
                        Enum "GstArvAuto" Default: 0, "off"
                           (0): off              - Off
                           (1): once             - Once
                           (2): on               - Continuous
  gamma               : Gamma
                        flags: readable, writable
                        Double. Range:               0 -             3.9 Default:               1 
$ gst-launch-1.0 aravissrc exposure=1700 do-timestamp=true gamma=1.0 \
    ! video/x-bayer,format=rggb,width=800,height=600 \
    ! bayer2rgb \
    ! videoconvert \
    ! autovideosink

Help Needed

I was able to adjust gamma using arv_gc_float_set_value() in avexample.c.
However, when I try to retrieve the updated value using arv_device_get_feature_value(), it throws an segmentation fault.

In gstaravis.c, arv_camera_is_feature_available() returns false.

avexample.c

/* Instantiation of the first available camera */
camera = arv_camera_new (NULL, &error);
device = arv_camera_get_device(camera);

gboolean is_gamma_available = arv_camera_is_feature_available (camera, "Gamma", NULL);

if (is_gamma_available) {
	printf ("Gamma feature is available\n");

	double gamma_max, gamma_min;
	gdouble gamma ;

	arv_camera_get_float_bounds(camera, "Gamma", &gamma_min, &gamma_max, &error);
	printf ("Gamma bounds are %f and %f\n", gamma_min, gamma_max);

	ArvGcNode *gamma_node = NULL;
	gamma_node = arv_device_get_feature(device, "Gamma");
	printf("%p\n", gamma_node);

	arv_device_get_feature_value(device, "Gamma", &gamma, &error);
	printf("Gamma: %f\n", gamma);

	// Successful
	arv_gc_float_set_value(gamma_node, 0.5, &error);

	if (error != NULL) {
		printf ("Can't set gamma value: %s\n", error->message);
		g_clear_error (&error);
	} else {
		printf ("Gamma value set to 0.5\n");
	}

	// No response
	// arv_device_set_float_feature_value(device, "Gamma", 0.5, &error);

	// if (error != NULL) {
	// 	printf ("Can't set gamma value: %s\n", error->message);
	// 	g_clear_error (&error);
	// } else {
	// 	printf ("Gamma value set to 0.5\n");
	// }

	// Segmentation fault
	arv_device_get_feature_value(device, "Gamma", &gamma, &error);

	printf("Gamma: %f\n", gamma);

} else {
	printf ("Gamma feature is not available\n");
}

gstaravis.c

		...

		case PROP_GAMMA:
			GST_OBJECT_LOCK (gst_aravis);
			gst_aravis->gamma = g_value_get_double (value);
			// arv_camera_is_feature_available returns FALSE
			if (gst_aravis->camera != NULL &&
				arv_camera_is_feature_available (gst_aravis->camera, "Gamma", NULL)) {
					// Not working
					// arv_device_set_float_feature_value(gst_aravis->camera, "Gamma", gst_aravis->gamma, NULL);			

					double gamma_max, gamma_min;
					arv_camera_get_float_bounds(gst_aravis->camera, "Gamma", &gamma_min, &gamma_max, NULL);

					if (gamma_min <= gst_aravis->gamma && gst_aravis->gamma <= gamma_max) {
						ArvDevice *device = arv_camera_get_device(gst_aravis->camera);
						ArvGcNode *gamma_node = arv_device_get_feature(device, "Gamma");
						arv_gc_float_set_value(ARV_GC_FLOAT(gamma_node), gst_aravis->gamma, NULL);
					}
				}
			GST_OBJECT_UNLOCK (gst_aravis);
			break;

Appreciate any help!

@WhaSukGO WhaSukGO changed the title gst: gamma control added (help needed) gst: gamma control added for aravissrc (help needed) Sep 5, 2024
@EmmanuelP
Copy link
Contributor

EmmanuelP commented Nov 5, 2024

Hi,

I have created a new pull request from a tweaked version of your patch. It seems to work fine for me. Please test #957 and report any issue there.

@EmmanuelP EmmanuelP closed this Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants