Skip to content

Commit

Permalink
Merge pull request #307 from fixstars/update/add-groupid
Browse files Browse the repository at this point in the history
Update/add groupid
  • Loading branch information
iitaku authored Aug 1, 2024
2 parents 12111cb + 89681eb commit 62771da
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 5 deletions.
17 changes: 17 additions & 0 deletions src/bb/image-io/gendc_separator/ComponentHeader.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,23 @@ class ComponentHeader : public Header{
return *this;
}

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);

Expand Down
18 changes: 18 additions & 0 deletions src/bb/image-io/gendc_separator/ContainerHeader.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,24 @@ class ContainerHeader : public Header{
return *this;
}

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_;
}
Expand Down
1 change: 1 addition & 0 deletions src/bb/image-io/rt_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ struct rawHeader {
float fps_;
// ---------- 72
int pfnc_pixelformat;
int group_id;
};

// PFNC
Expand Down
1 change: 1 addition & 0 deletions src/bb/image-io/rt_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
27 changes: 22 additions & 5 deletions src/bb/image-io/rt_u3v.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -645,7 +646,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<float>(fps), px};
width, height, width, height, static_cast<float>(fps), px, 0};
devices_[i].header_info_ = header;
devices_[i].image_payload_size_ = devices_[i].u3v_payload_size_;
devices_[i].frame_count_ = 0;
Expand Down Expand Up @@ -852,7 +853,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<float>(fps), px};
width, height, width, height, static_cast<float>(fps), px, 0};
devices_[i].header_info_ = header;
devices_[i].image_payload_size_ = devices_[i].u3v_payload_size_;
devices_[i].frame_count_ = 0;
Expand Down Expand Up @@ -967,6 +968,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_);
Expand All @@ -980,6 +982,7 @@ class U3VRealCam: public U3V{
if (err_) {
throw std::runtime_error(err_->message);
}

if(isGenDC(buffer)){
gendc_descriptor_= ContainerHeader(buffer);
std::tuple<int32_t, int32_t> data_comp_and_part = gendc_descriptor_.getFirstAvailableDataOffset(true);
Expand All @@ -997,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{
Expand Down Expand Up @@ -1025,7 +1035,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<float>(fps), px
wi, hi, wi, hi, static_cast<float>(fps), px, group_id
};
}

Expand Down Expand Up @@ -1336,7 +1346,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<float>(fps), px};
width, height, width, height, static_cast<float>(fps), px, 0};
devices_[i].header_info_ = header;
devices_[i].image_payload_size_ = devices_[i].u3v_payload_size_;
devices_[i].frame_count_ = 0;
Expand Down Expand Up @@ -1451,6 +1461,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_);
Expand Down Expand Up @@ -1481,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{
Expand Down Expand Up @@ -1508,7 +1525,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<float>(fps), px
wi, hi, wi, hi, static_cast<float>(fps), px, group_id
};
}

Expand Down

0 comments on commit 62771da

Please sign in to comment.