/* * Connect to the first available camera, then acquire 10 buffers. */ intmain(int argc, char **argv) { CLogManager& p_log_instance = CLogManager::GetInstance();
ArvCamera *camera; GError *error = NULL;
//连接相机 camera = arv_camera_new ("192.168.6.63", &error);
if (ARV_IS_CAMERA (camera)) { ArvStreamCallbackData callback_data;
if (error == NULL) { //创建流对象,注册回调 PAW_INFO("create stream"); callback_data.stream = arv_camera_create_stream (camera, stream_callback, &callback_data, &error); PAW_INFO("create stream end"); } if (ARV_IS_STREAM (callback_data.stream)) { int i; size_t payload;
/* Retrieve the payload size for buffer creation */ //从相机对象中获取图像负载大小(每个图像的字节大小) payload = arv_camera_get_payload (camera, &error); PAW_INFO("payload:" << payload); if (error == NULL) { /* Insert some buffers in the stream buffer pool */ //双缓冲 for (i = 0; i < 2; i++) arv_stream_push_buffer (callback_data.stream, arv_buffer_new (payload, NULL)); }
if (error == NULL) /* Start the acquisition */ arv_camera_start_acquisition (camera, &error);
if (error == NULL) { while (!callback_data.done) { usleep (1000); } }
if (error == NULL) /* Stop the acquisition */ arv_camera_stop_acquisition (camera, &error);
/* Destroy the stream object */ g_clear_object (&callback_data.stream); }
/* Destroy the camera instance */ PAW_INFO("destroy stream"); g_clear_object (&camera); PAW_INFO("destroy stream end"); }
if (error != NULL) { /* En error happened, display the correspdonding message */ printf ("Error: %s\n", error->message); return EXIT_FAILURE; }