From bd085cf11fb0a07c7ccc285dfdda79f47875b290 Mon Sep 17 00:00:00 2001 From: Xinyu Li Date: Mon, 29 Jul 2024 12:41:28 -0700 Subject: [PATCH 1/3] add group 0 --- src/bb/image-io/gendc_separator/ComponentHeader.h | 4 ++++ src/bb/image-io/gendc_separator/ContainerHeader.h | 4 ++++ src/bb/image-io/rt_u3v.h | 1 + 3 files changed, 9 insertions(+) diff --git a/src/bb/image-io/gendc_separator/ComponentHeader.h b/src/bb/image-io/gendc_separator/ComponentHeader.h index 819500c0..02d7b34b 100644 --- a/src/bb/image-io/gendc_separator/ComponentHeader.h +++ b/src/bb/image-io/gendc_separator/ComponentHeader.h @@ -61,6 +61,10 @@ class ComponentHeader : public Header{ return *this; } + int getGroupID(){ + return GroupId_; + } + size_t GenerateDescriptor(char* ptr, size_t offset=0){ offset = GenerateHeader(ptr, offset); diff --git a/src/bb/image-io/gendc_separator/ContainerHeader.h b/src/bb/image-io/gendc_separator/ContainerHeader.h index 5edb6c28..1730fcb6 100644 --- a/src/bb/image-io/gendc_separator/ContainerHeader.h +++ b/src/bb/image-io/gendc_separator/ContainerHeader.h @@ -71,6 +71,10 @@ class ContainerHeader : public Header{ return *this; } + ComponentHeader getComponentByIndex(int ith_component_index){ + return component_header_[ith_component_index]; + } + int32_t getDescriptorSize(){ return DescriptorSize_; } diff --git a/src/bb/image-io/rt_u3v.h b/src/bb/image-io/rt_u3v.h index 62330e7e..a8d7640f 100644 --- a/src/bb/image-io/rt_u3v.h +++ b/src/bb/image-io/rt_u3v.h @@ -982,6 +982,7 @@ class U3VRealCam: public U3V{ } if(isGenDC(buffer)){ gendc_descriptor_= ContainerHeader(buffer); + std::cout<<"Group id is"< data_comp_and_part = gendc_descriptor_.getFirstAvailableDataOffset(true); if (std::get<0>(data_comp_and_part) == -1){ devices_[i].is_data_image_ = false; From 0c2a5a6b6ac0f897aef9e9de3036e64db9ae23ef Mon Sep 17 00:00:00 2001 From: Xinyu Li Date: Mon, 29 Jul 2024 14:44:57 -0700 Subject: [PATCH 2/3] write group id for gendc --- src/bb/image-io/rt_common.h | 1 + src/bb/image-io/rt_file.h | 1 + src/bb/image-io/rt_u3v.h | 16 +++++++++++----- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/bb/image-io/rt_common.h b/src/bb/image-io/rt_common.h index 7b4f6607..c0475f89 100644 --- a/src/bb/image-io/rt_common.h +++ b/src/bb/image-io/rt_common.h @@ -302,6 +302,7 @@ struct rawHeader { float fps_; // ---------- 72 int pfnc_pixelformat; + int group_id; }; // PFNC diff --git a/src/bb/image-io/rt_file.h b/src/bb/image-io/rt_file.h index 839a5ed2..c380534a 100644 --- a/src/bb/image-io/rt_file.h +++ b/src/bb/image-io/rt_file.h @@ -216,6 +216,7 @@ class Writer { j_sensor["width"] = header_info.width_; j_sensor["height"] = header_info.height_; j_sensor["pfnc_pixelformat"] = header_info.pfnc_pixelformat; + j_sensor["group_id"] = header_info.group_id; auto filename = prefix_ + "config.json"; std::ofstream config(output_directory_ / filename); diff --git a/src/bb/image-io/rt_u3v.h b/src/bb/image-io/rt_u3v.h index a8d7640f..1a838e49 100644 --- a/src/bb/image-io/rt_u3v.h +++ b/src/bb/image-io/rt_u3v.h @@ -645,7 +645,7 @@ class U3VFakeCam : public U3V{ auto fps = arv_device_get_float_feature_value(devices_[i].device_, "AcquisitionFrameRate", &err_); struct rawHeader header= { 1, width, height, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, - width, height, width, height, static_cast(fps), px}; + width, height, width, height, static_cast(fps), px, 0}; devices_[i].header_info_ = header; devices_[i].image_payload_size_ = devices_[i].u3v_payload_size_; devices_[i].frame_count_ = 0; @@ -852,7 +852,7 @@ class U3VRealCam: public U3V{ auto fps = arv_device_get_float_feature_value(devices_[i].device_, "AcquisitionFrameRate", &err_); struct rawHeader header= { 1, width, height, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, - width, height, width, height, static_cast(fps), px}; + width, height, width, height, static_cast(fps), px, 0}; devices_[i].header_info_ = header; devices_[i].image_payload_size_ = devices_[i].u3v_payload_size_; devices_[i].frame_count_ = 0; @@ -967,6 +967,7 @@ class U3VRealCam: public U3V{ } // Check each parameters for GenDC device ========================== + int group_id = 0; if (is_gendc_){ log::info("\tDevice/USB {}::{} : {}", i, "GenDC", "Available"); uint64_t gendc_desc_size = arv_device_get_register_feature_length(devices_[i].device_, "GenDCDescriptor", &err_); @@ -980,9 +981,11 @@ class U3VRealCam: public U3V{ if (err_) { throw std::runtime_error(err_->message); } + if(isGenDC(buffer)){ gendc_descriptor_= ContainerHeader(buffer); std::cout<<"Group id is"< data_comp_and_part = gendc_descriptor_.getFirstAvailableDataOffset(true); if (std::get<0>(data_comp_and_part) == -1){ devices_[i].is_data_image_ = false; @@ -1026,7 +1029,7 @@ class U3VRealCam: public U3V{ devices_[i].header_info_ = { 1, wi, hi, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, - wi, hi, wi, hi, static_cast(fps), px + wi, hi, wi, hi, static_cast(fps), px, group_id }; } @@ -1337,7 +1340,7 @@ class U3VGenDC: public U3V{ auto fps = arv_device_get_float_feature_value(devices_[i].device_, "AcquisitionFrameRate", &err_); struct rawHeader header= { 1, width, height, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, - width, height, width, height, static_cast(fps), px}; + width, height, width, height, static_cast(fps), px, 0}; devices_[i].header_info_ = header; devices_[i].image_payload_size_ = devices_[i].u3v_payload_size_; devices_[i].frame_count_ = 0; @@ -1452,6 +1455,7 @@ class U3VGenDC: public U3V{ frame_count_method_ == FrameCountMethod::TYPESPECIFIC3 ? "TypeSpecific" : "Unavailabe"); // Check each parameters for GenDC device ========================== + int group_id = 0; if (is_gendc_){ log::info("\tDevice/USB {}::{} : {}", i, "GenDC", "Available"); uint64_t gendc_desc_size = arv_device_get_register_feature_length(devices_[i].device_, "GenDCDescriptor", &err_); @@ -1467,6 +1471,8 @@ class U3VGenDC: public U3V{ } if(isGenDC(buffer)){ gendc_descriptor_= ContainerHeader(buffer); + std::cout<<"Group id is"< data_comp_and_part = gendc_descriptor_.getFirstAvailableDataOffset(true); if (std::get<0>(data_comp_and_part) == -1){ devices_[i].is_data_image_ = false; @@ -1509,7 +1515,7 @@ class U3VGenDC: public U3V{ devices_[i].header_info_ = { 1, wi, hi, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, - wi, hi, wi, hi, static_cast(fps), px + wi, hi, wi, hi, static_cast(fps), px, group_id }; } From 89681ebd343e631775721146dfbe88f640189ce4 Mon Sep 17 00:00:00 2001 From: Xinyu Li Date: Mon, 29 Jul 2024 15:30:09 -0700 Subject: [PATCH 3/3] update --- .../image-io/gendc_separator/ComponentHeader.h | 15 ++++++++++++++- .../image-io/gendc_separator/ContainerHeader.h | 16 +++++++++++++++- src/bb/image-io/rt_u3v.h | 18 ++++++++++++++---- 3 files changed, 43 insertions(+), 6 deletions(-) diff --git a/src/bb/image-io/gendc_separator/ComponentHeader.h b/src/bb/image-io/gendc_separator/ComponentHeader.h index 02d7b34b..248819c2 100644 --- a/src/bb/image-io/gendc_separator/ComponentHeader.h +++ b/src/bb/image-io/gendc_separator/ComponentHeader.h @@ -61,10 +61,23 @@ class ComponentHeader : public Header{ return *this; } - int getGroupID(){ + int64_t getGroupID(){ return GroupId_; } + int64_t getTypeId(){ + return TypeId_; + } + + int16_t getSourceId(){ + return SourceId_; + } + + int16_t getPartCount(){ + return PartCount_; + } + + size_t GenerateDescriptor(char* ptr, size_t offset=0){ offset = GenerateHeader(ptr, offset); diff --git a/src/bb/image-io/gendc_separator/ContainerHeader.h b/src/bb/image-io/gendc_separator/ContainerHeader.h index 1730fcb6..f50ff8c8 100644 --- a/src/bb/image-io/gendc_separator/ContainerHeader.h +++ b/src/bb/image-io/gendc_separator/ContainerHeader.h @@ -71,10 +71,24 @@ class ContainerHeader : public Header{ return *this; } - ComponentHeader getComponentByIndex(int ith_component_index){ + ComponentHeader getComponentByIndex(int ith_component_index){ return component_header_[ith_component_index]; } + int32_t getFirstComponentIndexByTypeID(int64_t type_id){ + int cnt = 0; + for (ComponentHeader &ch : component_header_){ + if (ch.isComponentValid()){ + if (type_id==ch.getTypeId()){ + return cnt; + } + } + ++cnt; + } + return -1; + } + + int32_t getDescriptorSize(){ return DescriptorSize_; } diff --git a/src/bb/image-io/rt_u3v.h b/src/bb/image-io/rt_u3v.h index 1a838e49..fbfe739b 100644 --- a/src/bb/image-io/rt_u3v.h +++ b/src/bb/image-io/rt_u3v.h @@ -13,6 +13,7 @@ #include "gendc_separator/ContainerHeader.h" #include "gendc_separator/tools.h" +#define ComponentIDIntensity 1 #ifdef _WIN32 #define GOBJECT_FILE "gobject-2.0-0" #define ARAVIS_FILE "aravis-0.8-0" @@ -984,8 +985,6 @@ class U3VRealCam: public U3V{ if(isGenDC(buffer)){ gendc_descriptor_= ContainerHeader(buffer); - std::cout<<"Group id is"< data_comp_and_part = gendc_descriptor_.getFirstAvailableDataOffset(true); if (std::get<0>(data_comp_and_part) == -1){ devices_[i].is_data_image_ = false; @@ -1001,6 +1000,13 @@ class U3VRealCam: public U3V{ if (frame_count_method_ == FrameCountMethod::TYPESPECIFIC3){ devices_[i].framecount_offset_ = gendc_descriptor_.getOffsetFromTypeSpecific(std::get<0>(data_comp_and_part), std::get<1>(data_comp_and_part), 3, 0); } + + int32_t image_component_index = gendc_descriptor_.getFirstComponentIndexByTypeID(ComponentIDIntensity); + if (image_component_index == -1){ + throw ::std::runtime_error("No available component found"); + } + ComponentHeader image_component = gendc_descriptor_.getComponentByIndex(image_component_index); + group_id = gendc_descriptor_.getComponentByIndex(image_component_index).getGroupID(); } free(buffer); }else{ @@ -1471,8 +1477,6 @@ class U3VGenDC: public U3V{ } if(isGenDC(buffer)){ gendc_descriptor_= ContainerHeader(buffer); - std::cout<<"Group id is"< data_comp_and_part = gendc_descriptor_.getFirstAvailableDataOffset(true); if (std::get<0>(data_comp_and_part) == -1){ devices_[i].is_data_image_ = false; @@ -1488,6 +1492,12 @@ class U3VGenDC: public U3V{ if (frame_count_method_ == FrameCountMethod::TYPESPECIFIC3){ devices_[i].framecount_offset_ = gendc_descriptor_.getOffsetFromTypeSpecific(std::get<0>(data_comp_and_part), std::get<1>(data_comp_and_part), 3, 0); } + int32_t image_component_index = gendc_descriptor_.getFirstComponentIndexByTypeID(ComponentIDIntensity); + if (image_component_index == -1){ + throw ::std::runtime_error("No available component found"); + } + ComponentHeader image_component = gendc_descriptor_.getComponentByIndex(image_component_index); + group_id = gendc_descriptor_.getComponentByIndex(image_component_index).getGroupID(); } free(buffer); }else{