Slow fps when I increase the roi

Whenever I try to increase the roi my framerate drops. It works with the cameras sdk so I think the problem has something to do with my code.

#include <arv.h>
#include <stdlib.h>
#include <signal.h>
#include <stdio.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <string.h>
#include <unistd.h>

int sockfd;
struct sockaddr_in serveraddr;

int portno;
char* ip_address;
size_t payload;

typedef struct {
    GMainLoop *main_loop;
    int buffer_count;
    ArvStream *stream;
} ApplicationData;

static gboolean cancel = FALSE;

static void set_cancel(int signal)
{
    cancel = TRUE;
}

static void new_buffer_cb(ArvStream *stream, ApplicationData *data)
{
    ArvBuffer *buffer;
    buffer = arv_stream_try_pop_buffer(stream);
    if (buffer != NULL)
    {
        if (arv_buffer_get_status(buffer) == ARV_BUFFER_STATUS_SUCCESS)
        {
            data->buffer_count++;
            
            
            const void *buffer_data = arv_buffer_get_data(buffer, NULL);
            
            
            if (send(sockfd, buffer_data, payload, 0) < 0)
            {
                perror("Error sending image data");
            }
            
            arv_stream_push_buffer(stream, buffer);
        }
    }
}

static gboolean periodic_task_cb(void *abstract_data)
{
    ApplicationData *data = abstract_data;

    printf("Frame rate = %d Hz\n", data->buffer_count);

    data->buffer_count = 0;

    if (cancel)
    {
        g_main_loop_quit(data->main_loop);
        return FALSE;
    }

    return TRUE;
}

static void control_lost_cb(ArvGvDevice *gv_device)
{
    printf("Control lost\n");
    cancel = TRUE;
}

int main(int argc, char *argv[])
{
    ApplicationData data;
    ArvCamera *camera;
    GError *error = NULL;
    int i;

    portno = atoi(argv[2]);
    ip_address = argv[1];

    /* create socket and connect it to the server */
    sockfd = socket(AF_INET, SOCK_STREAM, 0);
    if (sockfd < 0)
    {
        perror("Error opening socket");
        return 1;
    }
    bzero(&serveraddr, sizeof(serveraddr));
    serveraddr.sin_family = AF_INET;
    serveraddr.sin_port = htons(portno);
    inet_pton(AF_INET, ip_address, &serveraddr.sin_addr);
    if (connect(sockfd, (struct sockaddr *)&serveraddr, sizeof(serveraddr)) < 0)
    {
        perror("Error connecting to server");
        return 1;
    }

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

    if (ARV_IS_CAMERA(camera))
    {
        void (*old_sigint_handler)(int);

        // set exposure time
        double exposure_time = 7000;
        arv_camera_set_exposure_mode (camera,
                              arv_exposure_mode_from_string ("Timed"),
                              &error);
                
        arv_camera_set_exposure_time(camera, exposure_time, &error);

        // set gain -> at the moment set to 0
        arv_camera_set_gain (camera,0.0, &error);

        //set acquisition mode
        arv_camera_set_acquisition_mode(camera, ARV_ACQUISITION_MODE_CONTINUOUS, &error);


        // set region of interest
        //arv_camera_set_region(camera, 0, 0, 1920, 1200, NULL);

        /* set frame rate */
        arv_camera_set_frame_rate(camera, 50, NULL);
        /* retrieve image payload (number of bytes per image) */
        payload = arv_camera_get_payload(camera, NULL);

        printf("payload : %d \n", payload);

        /* create a new stream object */
        data.stream = arv_camera_create_stream(camera, NULL, NULL, &error);

        if (ARV_IS_STREAM(data.stream))
        {
			/* Push 50 buffer in the stream input buffer queue */
			for (i = 0; i < 50; i++){
				arv_stream_push_buffer (data.stream, arv_buffer_new (payload, NULL));
            }

			/* Start the video stream */
			arv_camera_start_acquisition (camera, NULL);

			/* Connect the new-buffer signal */
			g_signal_connect (data.stream, "new-buffer", G_CALLBACK (new_buffer_cb), &data);
			/* And enable emission of this signal (it's disabled by default for performance reason) */
			arv_stream_set_emit_signals (data.stream, TRUE);

			/* Connect the control-lost signal */
			g_signal_connect (arv_camera_get_device (camera), "control-lost",
					  G_CALLBACK (control_lost_cb), NULL);

			/* Install the callback for frame rate display */
			g_timeout_add_seconds (1, periodic_task_cb, &data);

			/* Create a new glib main loop */
			data.main_loop = g_main_loop_new (NULL, FALSE);

			old_sigint_handler = signal (SIGINT, set_cancel);

			/* Run the main loop */
			g_main_loop_run (data.main_loop);

			signal (SIGINT, old_sigint_handler);

			g_main_loop_unref (data.main_loop);

			/* Stop the video stream */
			arv_camera_stop_acquisition (camera, NULL);

			/* Signal must be inhibited to avoid stream thread running after the last unref */
			arv_stream_set_emit_signals (data.stream, FALSE);

			g_object_unref (data.stream);
		} else {
			printf ("Can't create stream thread%s%s\n",
				error != NULL ? ": " : "",
				error != NULL ? error->message : "");

			g_clear_error (&error);
		}

		g_object_unref (camera);
	} else {
		printf ("No camera found%s%s\n",
			error != NULL ? ": " : "",
			error != NULL ? error->message : "");
		g_clear_error (&error);
	}

	return 0;
}

I’m running it on Debian. Love aravis so far but I can’t figure out what could be the issue.

I’m using the following camera: exo174MGE Industriekamera - SVS-Vistek

Hi,

Did you try arv-camera-test-0.8 ?

Emmanuel.

hello Emmanuel,
thank you for responding.
I get the following error:

Looking for the first available camera
arv-camera-test-0.8: symbol lookup error: arv-camera-test-0.8: undefined symbol: arv_camera_set_register_cache_policy