Exemple #1
0
static unicap_status_t aravis_enumerate_devices (unicap_device_t *device, int index)
{
	unicap_status_t status = STATUS_NO_MATCH;   

	if (index == 0)
		arv_update_device_list ();

	unicap_void_device (device);

	if (index < arv_get_n_devices ()){
		ArvCamera *camera;
		strncpy (device->identifier, arv_get_device_id (index), sizeof (device->identifier)-1);
		camera = arv_camera_new (device->identifier);
		if (arv_camera_get_model_name (camera))
			strncpy (device->model_name, arv_camera_get_model_name (camera), sizeof (device->model_name)-1);
		if (arv_camera_get_vendor_name (camera))
			strncpy (device->vendor_name, arv_camera_get_vendor_name (camera), sizeof (device->vendor_name)-1);
		strcpy (device->cpi_layer, "aravis_cpi");
		status = STATUS_SUCCESS;

		g_object_unref (camera);
	}

	return status;
}
Exemple #2
0
static GObject *
arv_camera_constructor (GType gtype, guint n_properties, GObjectConstructParam *properties)
{
    GObject *object;
    ArvCamera *camera;
    ArvCameraVendor vendor;
    ArvCameraSeries series;
    const char *vendor_name;
    const char *model_name;

    /* always call parent constructor */
    object = parent_class->constructor(gtype, n_properties, properties);

    camera = ARV_CAMERA (object);

    if (!camera->priv->device)
        camera->priv->device = arv_open_device (NULL);

    if (!ARV_IS_DEVICE (camera->priv->device))
        return NULL;

    camera->priv->genicam = arv_device_get_genicam (camera->priv->device);

    vendor_name = arv_camera_get_vendor_name (camera);
    model_name = arv_camera_get_model_name (camera);

    if (g_strcmp0 (vendor_name, "Basler") == 0) {
        vendor = ARV_CAMERA_VENDOR_BASLER;
        if (g_str_has_prefix (model_name, "acA"))
            series = ARV_CAMERA_SERIES_BASLER_ACE;
        else if (g_str_has_prefix (model_name, "scA"))
            series = ARV_CAMERA_SERIES_BASLER_SCOUT;
        else
            series = ARV_CAMERA_SERIES_BASLER_OTHER;
    } else if (g_strcmp0 (vendor_name, "Prosilica") == 0) {
        vendor = ARV_CAMERA_VENDOR_PROSILICA;
        series = ARV_CAMERA_SERIES_PROSILICA;
    } else if (g_strcmp0 (vendor_name, "The Imaging Source Europe GmbH") == 0) {
        vendor = ARV_CAMERA_VENDOR_TIS;
        series = ARV_CAMERA_SERIES_TIS;
    } else if (g_strcmp0 (vendor_name, "DALSA") == 0) {
        vendor = ARV_CAMERA_VENDOR_DALSA;
        series = ARV_CAMERA_SERIES_DALSA;
    } else {
        vendor = ARV_CAMERA_VENDOR_UNKNOWN;
        series = ARV_CAMERA_SERIES_UNKNOWN;
    }

    camera->priv->vendor = vendor;
    camera->priv->series = series;

    return object;
}
    bool CameraGigeAravis::grabInitialization(){

        frameCounter = 0;

        payload = arv_camera_get_payload (camera);
        BOOST_LOG_SEV(logger, notification) << "Camera payload : " << payload;

        pixFormat = arv_camera_get_pixel_format(camera);

        arv_camera_get_exposure_time_bounds (camera, &exposureMin, &exposureMax);
        BOOST_LOG_SEV(logger, notification) << "Camera exposure bound min : " << exposureMin;
        BOOST_LOG_SEV(logger, notification) << "Camera exposure bound max : " << exposureMax;

        arv_camera_get_gain_bounds (camera, &gainMin, &gainMax);
        BOOST_LOG_SEV(logger, notification) << "Camera gain bound min : " << gainMin;
        BOOST_LOG_SEV(logger, notification) << "Camera gain bound max : " << gainMax;

        arv_camera_set_frame_rate(camera, 30);

        fps = arv_camera_get_frame_rate(camera);
        BOOST_LOG_SEV(logger, notification) << "Camera frame rate : " << fps;

        capsString = arv_pixel_format_to_gst_caps_string(pixFormat);
        BOOST_LOG_SEV(logger, notification) << "Camera format : " << capsString;

        gain = arv_camera_get_gain(camera);
        BOOST_LOG_SEV(logger, notification) << "Camera gain : " << gain;

        exp = arv_camera_get_exposure_time(camera);
        BOOST_LOG_SEV(logger, notification) << "Camera exposure : " << exp;

        cout << endl;

        cout << "DEVICE SELECTED : " << arv_camera_get_device_id(camera)    << endl;
        cout << "DEVICE NAME     : " << arv_camera_get_model_name(camera)   << endl;
        cout << "DEVICE VENDOR   : " << arv_camera_get_vendor_name(camera)  << endl;
        cout << "PAYLOAD         : " << payload                             << endl;
        cout << "Width           : " << mWidth                               << endl
             << "Height          : " << mHeight                              << endl;
        cout << "Exp Range       : [" << exposureMin    << " - " << exposureMax   << "]"  << endl;
        cout << "Exp             : " << exp                                 << endl;
        cout << "Gain Range      : [" << gainMin        << " - " << gainMax       << "]"  << endl;
        cout << "Gain            : " << gain                                << endl;
        cout << "Fps             : " << fps                                 << endl;
        cout << "Type            : " << capsString                         << endl;

        cout << endl;

        // Create a new stream object. Open stream on Camera.
        stream = arv_camera_create_stream(camera, NULL, NULL);

        if(stream == NULL){

            BOOST_LOG_SEV(logger, critical) << "Fail to create stream with arv_camera_create_stream()";
            return false;

        }

        if (ARV_IS_GV_STREAM(stream)){

            bool            arv_option_auto_socket_buffer   = true;
            bool            arv_option_no_packet_resend     = true;
            unsigned int    arv_option_packet_timeout       = 20;
            unsigned int    arv_option_frame_retention      = 100;

            if(arv_option_auto_socket_buffer){

                g_object_set(stream,
                            // ARV_GV_STREAM_SOCKET_BUFFER_FIXED : socket buffer is set to a given fixed value.
                            // ARV_GV_STREAM_SOCKET_BUFFER_AUTO: socket buffer is set with respect to the payload size.
                            "socket-buffer", ARV_GV_STREAM_SOCKET_BUFFER_AUTO,
                            // Socket buffer size, in bytes.
                            // Allowed values: >= G_MAXULONG
                            // Default value: 0
                            "socket-buffer-size", 0, NULL);

            }

            if(arv_option_no_packet_resend){

                // # packet-resend : Enables or disables the packet resend mechanism

                // If packet resend is disabled and a packet has been lost during transmission,
                // the grab result for the returned buffer holding the image will indicate that
                // the grab failed and the image will be incomplete.
                //
                // If packet resend is enabled and a packet has been lost during transmission,
                // a request is sent to the camera. If the camera still has the packet in its
                // buffer, it will resend the packet. If there are several lost packets in a
                // row, the resend requests will be combined.

                g_object_set(stream,
                            // ARV_GV_STREAM_PACKET_RESEND_NEVER: never request a packet resend
                            // ARV_GV_STREAM_PACKET_RESEND_ALWAYS: request a packet resend if a packet was missing
                            // Default value: ARV_GV_STREAM_PACKET_RESEND_ALWAYS
                            "packet-resend", ARV_GV_STREAM_PACKET_RESEND_NEVER, NULL);

            }

            g_object_set(stream,
                        // # packet-timeout

                        // The Packet Timeout parameter defines how long (in milliseconds) we will wait for
                        // the next expected packet before it initiates a resend request.

                        // Packet timeout, in µs.
                        // Allowed values: [1000,10000000]
                        // Default value: 40000
                        "packet-timeout",/* (unsigned) arv_option_packet_timeout * 1000*/(unsigned)40000,
                        // # frame-retention

                        // The Frame Retention parameter sets the timeout (in milliseconds) for the
                        // frame retention timer. Whenever detection of the leader is made for a frame,
                        // the frame retention timer starts. The timer resets after each packet in the
                        // frame is received and will timeout after the last packet is received. If the
                        // timer times out at any time before the last packet is received, the buffer for
                        // the frame will be released and will be indicated as an unsuccessful grab.

                        // Packet retention, in µs.
                        // Allowed values: [1000,10000000]
                        // Default value: 200000
                        "frame-retention", /*(unsigned) arv_option_frame_retention * 1000*/(unsigned) 200000,NULL);

        }else
            return false;

        // Push 50 buffer in the stream input buffer queue.
        for (int i = 0; i < 50; i++)
            arv_stream_push_buffer(stream, arv_buffer_new(payload, NULL));

        return true;

    }