bool CvCaptureCAM_Aravis::startCapture() { if(init_buffers() ) { arv_camera_set_acquisition_mode(camera, ARV_ACQUISITION_MODE_CONTINUOUS); arv_camera_start_acquisition(camera); return true; } return false; }
bool CvCaptureCAM_Aravis::startCapture() { if( init_buffers() ) { arv_camera_set_acquisition_mode(camera, ARV_ACQUISITION_MODE_CONTINUOUS); arv_device_set_string_feature_value(arv_camera_get_device (camera), "TriggerMode" , "Off"); arv_camera_start_acquisition(camera); return true; } return false; }
CamGigE::CamGigE(int id): Cam(id) { mWidth = XSIZE; mHeight = YSIZE; xshift = 0; yshift = 0; exposure = 2*1000; gain = 300; isCapturing = false; framerate = 15.0f; mId = id; g_type_init (); camera = arv_camera_new(NULL); if(camera == NULL) { throw "No camera found"; } arv_camera_set_region(camera, xshift, yshift, mWidth, mHeight); arv_camera_set_exposure_time(camera, exposure); arv_camera_set_gain(camera, gain); arv_camera_set_pixel_format(camera, ARV_PIXEL_FORMAT_MONO_8); //arv_camera_set_pixel_format(camera, ARV_PIXEL_FORMAT_BAYER_BG_8); width = (int)mWidth; height = (int)mHeight; arv_camera_get_region (camera, &xshift, &yshift, &width, &height); payload = arv_camera_get_payload (camera); stream = arv_camera_create_stream (camera, NULL, NULL); if(stream == NULL) { throw "Cannot create stream"; } g_object_set(stream, "packet-timeout", (unsigned) 20 * 1000, "frame-retention", (unsigned) 100 * 1000, NULL); for(int i = 0; i < 4; i++) arv_stream_push_buffer(stream, arv_buffer_new(payload, NULL)); arv_camera_set_acquisition_mode(camera, ARV_ACQUISITION_MODE_CONTINUOUS); arv_camera_set_frame_rate(camera, framerate); rawdata = new unsigned char[width*height]; }
bool CameraGigeAravis::acqStart(){ BOOST_LOG_SEV(logger, notification) << "Set camera to CONTINUOUS MODE"; arv_camera_set_acquisition_mode(camera, ARV_ACQUISITION_MODE_CONTINUOUS); BOOST_LOG_SEV(logger, notification) << "Set camera TriggerMode to Off"; arv_device_set_string_feature_value(arv_camera_get_device (camera), "TriggerMode" , "Off"); BOOST_LOG_SEV(logger, notification) << "Start acquisition on camera"; arv_camera_start_acquisition(camera); return true; }
static unicap_status_t aravis_capture_start( aravis_handle_t handle ) { guint payload; int i; handle->stream = arv_camera_create_stream( handle->camera, aravis_stream_callback, handle); arv_camera_set_acquisition_mode (handle->camera, ARV_ACQUISITION_MODE_CONTINUOUS); arv_camera_start_acquisition (handle->camera); payload = arv_camera_get_payload (handle->camera); for (i=0; i < 8; i++) arv_stream_push_buffer (handle->stream, arv_buffer_new (payload, NULL)); return handle->stream ? STATUS_SUCCESS : STATUS_FAILURE; }
int main(int argc, char *argv[]) { ArvDevice *device; ArvStream *stream; ArvCamera *camera; ArvGcFeatureNode *feature; guint64 n_completed_buffers; guint64 n_failures; guint64 n_underruns; GOptionContext *context; GError *error = NULL; void (*old_sigint_handler)(int); int i, payload; arv_g_thread_init (NULL); arv_g_type_init (); context = g_option_context_new (NULL); g_option_context_set_summary (context, "Test of heartbeat robustness while continuously changing a feature."); g_option_context_add_main_entries (context, arv_option_entries, NULL); if (!g_option_context_parse (context, &argc, &argv, &error)) { g_option_context_free (context); g_print ("Option parsing failed: %s\n", error->message); g_error_free (error); return EXIT_FAILURE; } g_option_context_free (context); arv_debug_enable (arv_option_debug_domains); camera = arv_camera_new (arv_option_camera_name); if (!ARV_IS_CAMERA (camera)) { printf ("Device not found\n"); return EXIT_FAILURE; } device = arv_camera_get_device (camera); stream = arv_camera_create_stream (camera, NULL, NULL); if (!ARV_IS_STREAM (stream)) { printf ("Invalid device\n"); } else { payload = arv_camera_get_payload (camera); if (ARV_IS_GV_STREAM (stream)) { g_object_set (stream, //"socket-buffer", ARV_GV_STREAM_SOCKET_BUFFER_AUTO, "socket-buffer", ARV_GV_STREAM_SOCKET_BUFFER_FIXED, "socket-buffer-size", payload*6, "packet-timeout", 1000 * 1000, "frame-retention", 100 * 1000, "packet-resend", ARV_GV_STREAM_PACKET_RESEND_ALWAYS, NULL); } for (i = 0; i < 100; i++) arv_stream_push_buffer(stream, arv_buffer_new(payload, NULL)); arv_camera_set_acquisition_mode(camera, ARV_ACQUISITION_MODE_CONTINUOUS); feature = ARV_GC_FEATURE_NODE (arv_device_get_feature (device, arv_option_feature_name)); arv_camera_start_acquisition (camera); old_sigint_handler = signal (SIGINT, set_cancel); while (!cancel) { ArvBuffer *buffer = arv_stream_timeout_pop_buffer(stream, 2000000); if (buffer) { usleep(10); arv_stream_push_buffer (stream, buffer); } if (!(++i%5)) { char *value; if ((i/100) % 2 == 0) value = g_strdup_printf ("%d", arv_option_min); else value = g_strdup_printf ("%d", arv_option_max); fprintf (stderr, "Setting %s from %s to %s\n", arv_option_feature_name, arv_gc_feature_node_get_value_as_string (feature, NULL), value); arv_gc_feature_node_set_value_from_string (feature, value, NULL); g_free (value); } } signal (SIGINT, old_sigint_handler); arv_stream_get_statistics (stream, &n_completed_buffers, &n_failures, &n_underruns); printf ("\nCompleted buffers = %Lu\n", (unsigned long long) n_completed_buffers); printf ("Failures = %Lu\n", (unsigned long long) n_failures); printf ("Underruns = %Lu\n", (unsigned long long) n_underruns); arv_camera_stop_acquisition (camera); } g_object_unref (camera); return 0; }