From 76f92babb8b4aae930cdb10902c17e76657e2cae Mon Sep 17 00:00:00 2001 From: "xinyu.li" Date: Wed, 14 Aug 2024 14:16:46 -0700 Subject: [PATCH 1/5] acq before steram --- src/bb/image-io/rt_u3v.h | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/bb/image-io/rt_u3v.h b/src/bb/image-io/rt_u3v.h index 0d879585..07fcffc2 100644 --- a/src/bb/image-io/rt_u3v.h +++ b/src/bb/image-io/rt_u3v.h @@ -922,6 +922,18 @@ class U3VRealCam: public U3V{ throw std::runtime_error(err_->message); } + arv_device_set_string_feature_value(devices_[i].device_, "AcquisitionMode", arv_acquisition_mode_to_string(ARV_ACQUISITION_MODE_CONTINUOUS), &err_); + if (err_) { + throw std::runtime_error(err_->message); + } + log::info("\tDevice/USB {}::{} : {}", i, "Command", "AcquisitionMode"); + + arv_device_execute_command(devices_[i].device_, "AcquisitionStart", &err_); + if (err_) { + throw std::runtime_error(err_->message); + } + log::info("\tDevice/USB {}::{} : {}", i, "Command", "AcquisitionStart"); + devices_[i].stream_ = arv_device_create_stream(devices_[i].device_, nullptr, nullptr, &err_); if (err_ ) { throw std::runtime_error(err_->message); @@ -1072,21 +1084,8 @@ class U3VRealCam: public U3V{ } - for (auto i=0; imessage); - } - log::info("\tDevice/USB {}::{} : {}", i, "Command", "AcquisitionMode"); - } - for (auto i=0; imessage); - } - log::info("\tDevice/USB {}::{} : {}", i, "Command", "AcquisitionStart"); - } + } }; From c5e4b96e7796c2bd5e990e39529a7141e526deb8 Mon Sep 17 00:00:00 2001 From: "xinyu.li" Date: Wed, 14 Aug 2024 14:47:41 -0700 Subject: [PATCH 2/5] fix gendc --- src/bb/image-io/rt_u3v.h | 84 ++++++++++++++++++++-------------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/src/bb/image-io/rt_u3v.h b/src/bb/image-io/rt_u3v.h index 07fcffc2..042db009 100644 --- a/src/bb/image-io/rt_u3v.h +++ b/src/bb/image-io/rt_u3v.h @@ -922,26 +922,6 @@ class U3VRealCam: public U3V{ throw std::runtime_error(err_->message); } - arv_device_set_string_feature_value(devices_[i].device_, "AcquisitionMode", arv_acquisition_mode_to_string(ARV_ACQUISITION_MODE_CONTINUOUS), &err_); - if (err_) { - throw std::runtime_error(err_->message); - } - log::info("\tDevice/USB {}::{} : {}", i, "Command", "AcquisitionMode"); - - arv_device_execute_command(devices_[i].device_, "AcquisitionStart", &err_); - if (err_) { - throw std::runtime_error(err_->message); - } - log::info("\tDevice/USB {}::{} : {}", i, "Command", "AcquisitionStart"); - - devices_[i].stream_ = arv_device_create_stream(devices_[i].device_, nullptr, nullptr, &err_); - if (err_ ) { - throw std::runtime_error(err_->message); - } - if (devices_[i].stream_ == nullptr) { - throw std::runtime_error("stream is null"); - } - // check it the device has gendc mode ============================== is_gendc_ = arv_device_is_feature_available(devices_[i].device_, "GenDCDescriptor", &err_); if (err_) { @@ -1069,6 +1049,27 @@ class U3VRealCam: public U3V{ } log::info("\tDevice/USB {}::{} : {}", i, "OperationMode", operation_mode_in_string); } + + arv_device_set_string_feature_value(devices_[i].device_, "AcquisitionMode", arv_acquisition_mode_to_string(ARV_ACQUISITION_MODE_CONTINUOUS), &err_); + if (err_) { + throw std::runtime_error(err_->message); + } + log::info("\tDevice/USB {}::{} : {}", i, "Command", "AcquisitionMode"); + + arv_device_execute_command(devices_[i].device_, "AcquisitionStart", &err_); + if (err_) { + throw std::runtime_error(err_->message); + } + log::info("\tDevice/USB {}::{} : {}", i, "Command", "AcquisitionStart"); + + devices_[i].stream_ = arv_device_create_stream(devices_[i].device_, nullptr, nullptr, &err_); + if (err_ ) { + throw std::runtime_error(err_->message); + } + if (devices_[i].stream_ == nullptr) { + throw std::runtime_error("stream is null"); + } + } for (auto i=0; imessage); } - devices_[i].stream_ = arv_device_create_stream(devices_[i].device_, nullptr, nullptr, &err_); - if (err_ ) { - throw std::runtime_error(err_->message); - } - if (devices_[i].stream_ == nullptr) { - throw std::runtime_error("stream is null"); - } - // check it the device has gendc mode ============================== is_gendc_ = arv_device_is_feature_available(devices_[i].device_, "GenDCDescriptor", &err_); if (err_) { @@ -1546,6 +1539,27 @@ class U3VGenDC: public U3V{ } log::info("\tDevice/USB {}::{} : {}", i, "OperationMode", operation_mode_in_string); } + + arv_device_set_string_feature_value(devices_[i].device_, "AcquisitionMode", arv_acquisition_mode_to_string(ARV_ACQUISITION_MODE_CONTINUOUS), &err_); + if (err_) { + throw std::runtime_error(err_->message); + } + log::info("\tDevice/USB {}::{} : {}", i, "Command", "AcquisitionMode"); + + arv_device_execute_command(devices_[i].device_, "AcquisitionStart", &err_); + if (err_) { + throw std::runtime_error(err_->message); + } + log::info("\tDevice/USB {}::{} : {}", i, "Command", "AcquisitionStart"); + + devices_[i].stream_ = arv_device_create_stream(devices_[i].device_, nullptr, nullptr, &err_); + if (err_ ) { + throw std::runtime_error(err_->message); + } + if (devices_[i].stream_ == nullptr) { + throw std::runtime_error("stream is null"); + } + } for (auto i=0; imessage); - } - log::info("\tDevice/USB {}::{} : {}", i, "Command", "AcquisitionMode"); - } - for (auto i=0; imessage); - } - log::info("\tDevice/USB {}::{} : {}", i, "Command", "AcquisitionStart"); - } } }; From 28f7a4b2bcc6dc5e11874dd1cb3605044200e5c5 Mon Sep 17 00:00:00 2001 From: Xinyu Li Date: Fri, 9 Aug 2024 16:15:06 -0700 Subject: [PATCH 3/5] hotfix --- src/bb/image-io/rt_u3v.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/bb/image-io/rt_u3v.h b/src/bb/image-io/rt_u3v.h index 042db009..2794f411 100644 --- a/src/bb/image-io/rt_u3v.h +++ b/src/bb/image-io/rt_u3v.h @@ -89,6 +89,12 @@ class U3V { ARV_DEVICE_STATUS_WRITE_ERROR }ArvDeviceStatus_t; + typedef enum ArvUvUsbMode{ + ARV_UV_USB_MODE_SYNC, + ARV_UV_USB_MODE_ASYNC, + ARV_UV_USB_MODE_DEFAULT = ARV_UV_USB_MODE_ASYNC + } ArvUvUsbMode_t; + using ArvDevice_t = struct ArvDevice*; using ArvFakeDevice_t = struct ArvFakeDevice*; using ArvStream_t = struct ArvStream*; @@ -154,6 +160,8 @@ class U3V { using arv_camera_create_stream_t = ArvStream*(*)(ArvCamera*, ArvStreamCallback*, void*, GError**); using arv_fake_device_get_fake_camera_t = ArvCamera*(*)(ArvFakeDevice*); + using arv_uv_device_set_usb_mode_t = void(*)(ArvDevice *, ArvUvUsbMode ); + struct DeviceInfo { const char* dev_id_; ArvDevice* device_; @@ -412,6 +420,8 @@ class U3V { GET_SYMBOL(arv_set_fake_camera_genicam_filename, "arv_set_fake_camera_genicam_filename"); GET_SYMBOL(arv_enable_interface, "arv_enable_interface"); GET_SYMBOL(arv_fake_device_get_fake_camera, "arv_fake_device_get_fake_camera"); + GET_SYMBOL(arv_uv_device_set_usb_mode, " arv_uv_device_set_usb_mode"); + #undef GET_SYMBOL } @@ -535,6 +545,8 @@ class U3V { arv_set_fake_camera_genicam_filename_t arv_set_fake_camera_genicam_filename; arv_fake_device_get_fake_camera_t arv_fake_device_get_fake_camera; + arv_uv_device_set_usb_mode_t arv_uv_device_set_usb_mode; + static std::map> instances_; int32_t num_sensor_; //SENSOR NUMBER @@ -909,6 +921,8 @@ class U3VRealCam: public U3V{ throw std::runtime_error("device is null"); } + arv_uv_device_set_usb_mode(devices_[i].device_, ARV_UV_USB_MODE_SYNC); //hotfix + pixel_format_ = arv_device_get_string_feature_value(devices_[i].device_, "PixelFormat", &err_); if (err_ ) { throw std::runtime_error(err_->message); From aaff107887500147b170fa7082aee1c0a3946146 Mon Sep 17 00:00:00 2001 From: "xinyu.li" Date: Thu, 15 Aug 2024 13:17:59 -0700 Subject: [PATCH 4/5] fix v1.0 --- src/bb/image-io/rt_u3v.h | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/bb/image-io/rt_u3v.h b/src/bb/image-io/rt_u3v.h index 2794f411..fbc2fc51 100644 --- a/src/bb/image-io/rt_u3v.h +++ b/src/bb/image-io/rt_u3v.h @@ -420,7 +420,7 @@ class U3V { GET_SYMBOL(arv_set_fake_camera_genicam_filename, "arv_set_fake_camera_genicam_filename"); GET_SYMBOL(arv_enable_interface, "arv_enable_interface"); GET_SYMBOL(arv_fake_device_get_fake_camera, "arv_fake_device_get_fake_camera"); - GET_SYMBOL(arv_uv_device_set_usb_mode, " arv_uv_device_set_usb_mode"); + GET_SYMBOL(arv_uv_device_set_usb_mode, "arv_uv_device_set_usb_mode"); #undef GET_SYMBOL } @@ -666,9 +666,8 @@ class U3VFakeCam : public U3V{ } // Start streaming and start acquisition - devices_[0].stream_ = arv_device_create_stream (devices_[0].device_, NULL, NULL, &err_); - if (num_sensor_==2){ - devices_[1].stream_ = arv_device_create_stream (devices_[1].device_, NULL, NULL, &err_); + for (auto i=0; imessage); } log::info("\tDevice/USB {}::{} : {}", i, "Command", "AcquisitionStart"); + } + //start streaming after AcquisitionStart + for (auto i=0; imessage); } if (devices_[i].stream_ == nullptr) { throw std::runtime_error("stream is null"); } - } for (auto i=0; imessage); } log::info("\tDevice/USB {}::{} : {}", i, "Command", "AcquisitionStart"); + } + for (auto i=0; imessage); @@ -1573,7 +1575,6 @@ class U3VGenDC: public U3V{ if (devices_[i].stream_ == nullptr) { throw std::runtime_error("stream is null"); } - } for (auto i=0; i Date: Mon, 19 Aug 2024 14:39:46 -0700 Subject: [PATCH 5/5] add link --- src/bb/image-io/rt_u3v.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/bb/image-io/rt_u3v.h b/src/bb/image-io/rt_u3v.h index fbc2fc51..8a6caa87 100644 --- a/src/bb/image-io/rt_u3v.h +++ b/src/bb/image-io/rt_u3v.h @@ -1076,6 +1076,13 @@ class U3VRealCam: public U3V{ log::info("\tDevice/USB {}::{} : {}", i, "Command", "AcquisitionStart"); } + /* + * ion-kit starts the acquisition before stream creation This is a tentative fix only in ion-kit due to hardware issue + * In aravis, the acquisition should be done afterward. Since this maps better with GenAPI, where buffers + * must be pushed to DataStream objectsbefore DataStream acquisition is started. + * refer to https://github.com/AravisProject/aravis/blob/2ebaa8661761ea4bbc4df878aa67b4a9e1a9a3b9/docs/reference/aravis/porting-0.10.md + */ + //start streaming after AcquisitionStart for (auto i=0; i