@@ -336,7 +336,7 @@ class U3V {
336
336
devices_(num_sensor), buffers_(num_sensor), operation_mode_(OperationMode::Came1USB1), frame_cnt_(0 ), device_idx_(-1 ), disposed_(false ), sim_mode_(sim_mode), order_filp_(false )
337
337
{
338
338
init_symbols ();
339
- log::debug (" U3V:: 24-08-30 : Tested on device 1.2" );
339
+ log::debug (" U3V:: 24-09-03 : Tested on device 1.2" );
340
340
log::info (" Using aravis-{}.{}.{}" , arv_get_major_version (), arv_get_minor_version (), arv_get_micro_version ());
341
341
}
342
342
@@ -500,7 +500,7 @@ class U3V {
500
500
log::info (" Acquisition option::{} is {}" , " realtime_display_mode_" , realtime_display_mode_);
501
501
}
502
502
503
- GError* command_acquisition_mode_contd_and_start (){
503
+ void command_acquisition_mode_contd_and_start (){
504
504
for (auto i=0 ; i<devices_.size (); ++i) {
505
505
arv_device_set_string_feature_value (devices_[i].device_ , " AcquisitionMode" , arv_acquisition_mode_to_string (ARV_ACQUISITION_MODE_CONTINUOUS), &err_);
506
506
if (err_) {
@@ -514,10 +514,9 @@ class U3V {
514
514
}
515
515
log::info (" \t Device/USB {}::{} : {}" , i, " Command" , " AcquisitionStart" );
516
516
}
517
- return err_;
518
517
}
519
518
520
- GError* open_fake_devices (int32_t width, int32_t height , float_t fps, const std::string & pixel_format){
519
+ void open_fake_devices (int32_t width, int32_t height , float_t fps, const std::string & pixel_format){
521
520
auto path = std::getenv (" GENICAM_FILENAME" );
522
521
if (path == nullptr ){
523
522
throw std::runtime_error (" Please define GENICAM_FILENAME by `set GENICAM_FILENAME=` or `export GENICAM_FILENAME=`" );
@@ -529,13 +528,19 @@ class U3V {
529
528
log::info (" Creating U3V instance with {} fake sensors..." , num_sensor_);
530
529
531
530
auto fake_camera0 = arv_camera_new (" Fake_1" , &err_);
531
+ if (err_) {
532
+ throw std::runtime_error (err_->message );
533
+ }
532
534
auto fake_device0 = arv_camera_get_device (fake_camera0);
533
535
devices_[0 ].device_ = fake_device0;
534
536
devices_[0 ].dev_id_ = " fake_0" ;
535
537
devices_[0 ].camera_ = fake_camera0;
536
538
if (num_sensor_==2 ){
537
539
// aravis only provide on ARV_FAKE_DEVICE_ID https://github.com/Sensing-Dev/aravis/blob/main/src/arvfakeinterface.c
538
540
auto fake_camera1 = arv_camera_new (" Fake_1" , &err_);
541
+ if (err_) {
542
+ throw std::runtime_error (err_->message );
543
+ }
539
544
auto fake_device1 = arv_camera_get_device (fake_camera1);
540
545
devices_[1 ].device_ = fake_device1;
541
546
devices_[1 ].dev_id_ = " fake_1" ;
@@ -546,13 +551,35 @@ class U3V {
546
551
// setting the params if it is not zero
547
552
log::info (" Width {}, Height {} PixelFormat {}..." , width, height, pixel_format_);
548
553
arv_device_set_integer_feature_value (devices_[i].device_ , " Width" , width, &err_);
554
+ if (err_) {
555
+ throw std::runtime_error (err_->message );
556
+ }
549
557
arv_device_set_integer_feature_value (devices_[i].device_ , " Height" , height, &err_);
558
+ if (err_) {
559
+ throw std::runtime_error (err_->message );
560
+ }
550
561
arv_device_set_float_feature_value (devices_[i].device_ , " AcquisitionFrameRate" ,fps, &err_);
551
- if (pixel_format_ != " Mono8" )
562
+ if (err_) {
563
+ throw std::runtime_error (err_->message );
564
+ }
565
+ if (pixel_format_ != " Mono8" ){
552
566
arv_device_set_string_feature_value (devices_[i].device_ , " PixelFormat" , pixel_format.c_str (), &err_);
567
+ if (err_) {
568
+ throw std::runtime_error (err_->message );
569
+ }
570
+ }
553
571
devices_[i].u3v_payload_size_ = arv_device_get_integer_feature_value (devices_[i].device_ , " PayloadSize" , &err_);
572
+ if (err_) {
573
+ throw std::runtime_error (err_->message );
574
+ }
554
575
auto px =arv_device_get_integer_feature_value (devices_[i].device_ , " PixelFormat" , &err_);
576
+ if (err_) {
577
+ throw std::runtime_error (err_->message );
578
+ }
555
579
auto fps = arv_device_get_float_feature_value (devices_[i].device_ , " AcquisitionFrameRate" , &err_);
580
+ if (err_) {
581
+ throw std::runtime_error (err_->message );
582
+ }
556
583
struct rawHeader header= { 1 , width, height,
557
584
1 , 1 , 1 , 1 , 1 , 1 , 0 , 0 , 0 , 0 ,
558
585
width, height, width, height, static_cast <float >(fps), px, 0 };
@@ -561,10 +588,9 @@ class U3V {
561
588
devices_[i].frame_count_ = 0 ;
562
589
563
590
}
564
- return err_;
565
591
}
566
592
567
- GError* open_real_devices (int32_t num_detected_device, int32_t num_usb_to_open, char * dev_id){
593
+ void open_real_devices (int32_t num_detected_device, int32_t num_usb_to_open, char * dev_id){
568
594
569
595
int index_on_detected_device = 0 ;
570
596
int index_on_opened_device = 0 ;
@@ -598,16 +624,18 @@ class U3V {
598
624
599
625
pixel_format_ = arv_device_get_string_feature_value (devices_[index_on_opened_device].device_ , " PixelFormat" , &err_);
600
626
if (err_ ) {
601
- throw std::runtime_error (err_->message );
627
+ log::error (err_->message );
628
+ err_ = nullptr ;
629
+ }else {
630
+ log::info (" \t Device/USB {}::{} : {}" , index_on_opened_device, " PixelFormat" , pixel_format_);
602
631
}
603
- log::info (" \t Device/USB {}::{} : {}" , index_on_opened_device, " PixelFormat" , pixel_format_);
604
-
632
+
605
633
// Here PayloadSize is the one for U3V data
606
634
devices_[index_on_opened_device].u3v_payload_size_ = arv_device_get_integer_feature_value (devices_[index_on_opened_device].device_ , " PayloadSize" , &err_);
607
- log::info (" \t Device/USB {}::{} : {}" , index_on_opened_device, " PayloadSize" , devices_[index_on_opened_device].u3v_payload_size_ );
608
635
if (err_ ) {
609
636
throw std::runtime_error (err_->message );
610
637
}
638
+ log::info (" \t Device/USB {}::{} : {}" , index_on_opened_device, " PayloadSize" , devices_[index_on_opened_device].u3v_payload_size_ );
611
639
612
640
// check it the device has gendc mode ==============================
613
641
is_gendc_ = arv_device_is_feature_available (devices_[index_on_opened_device].device_ , " GenDCDescriptor" , &err_);
@@ -632,19 +660,30 @@ class U3V {
632
660
// Some type of U3V Camera supports Frame count generated by its device
633
661
const char * device_vender_name;
634
662
device_vender_name = arv_device_get_string_feature_value (devices_[index_on_opened_device].device_ , " DeviceVendorName" , &err_);
635
- if (strcmp (device_vender_name, " Sony Semiconductor Solutions Corporation" )==0 ){
636
- const char * device_model_name;
637
- device_model_name = arv_device_get_string_feature_value (devices_[index_on_opened_device].device_ , " DeviceModelName" , &err_);
638
- if (strcmp (device_model_name, " " )==0 ){
639
- is_param_integer_ = true ;
640
- frame_count_method_ = FrameCountMethod::TIMESTAMP;
641
- arv_uv_device_set_usb_mode (devices_[index_on_opened_device].device_ , ARV_UV_USB_MODE_SYNC); // hotfix for v1.0
642
- }
643
- if (is_gendc_){
644
- frame_count_method_ = FrameCountMethod::TYPESPECIFIC3;
645
- order_filp_ = true ;
663
+ if (err_) {
664
+ log::error (err_->message );
665
+ err_ = nullptr ;
666
+ }else {
667
+ if (strcmp (device_vender_name, " Sony Semiconductor Solutions Corporation" )==0 ){
668
+ const char * device_model_name;
669
+ device_model_name = arv_device_get_string_feature_value (devices_[index_on_opened_device].device_ , " DeviceModelName" , &err_);
670
+ if (err_) {
671
+ log::error (err_->message );
672
+ err_ = nullptr ;
673
+ }else {
674
+ if (strcmp (device_model_name, " " )==0 ){
675
+ is_param_integer_ = true ;
676
+ frame_count_method_ = FrameCountMethod::TIMESTAMP;
677
+ arv_uv_device_set_usb_mode (devices_[index_on_opened_device].device_ , ARV_UV_USB_MODE_SYNC); // hotfix for v1.0
678
+ }
679
+ }
680
+ if (is_gendc_){
681
+ frame_count_method_ = FrameCountMethod::TYPESPECIFIC3;
682
+ order_filp_ = true ;
683
+ }
646
684
}
647
685
}
686
+
648
687
log::info (" \t Device/USB {}::{} : {}" , index_on_opened_device, " frame_count method is " ,
649
688
frame_count_method_ == FrameCountMethod::TIMESTAMP ? " Timestamp" :
650
689
frame_count_method_ == FrameCountMethod::TYPESPECIFIC3 ? " TypeSpecific" : " Unavailabe" );
@@ -694,17 +733,28 @@ class U3V {
694
733
// Set Device Info =================================================
695
734
{
696
735
int32_t wi = arv_device_get_integer_feature_value (devices_[index_on_opened_device].device_ , " Width" , &err_);
736
+ if (err_) {
737
+ throw std::runtime_error (err_->message );
738
+ }
697
739
int32_t hi = arv_device_get_integer_feature_value (devices_[index_on_opened_device].device_ , " Height" , &err_);
740
+ if (err_) {
741
+ throw std::runtime_error (err_->message );
742
+ }
698
743
double fps = 0.0 ;
699
744
if (arv_device_is_feature_available (devices_[index_on_opened_device].device_ , " AcquisitionFrameRate" , &err_)){
700
745
fps = arv_device_get_float_feature_value (devices_[index_on_opened_device].device_ , " AcquisitionFrameRate" , &err_);
701
746
}
747
+ if (err_) {
748
+ throw std::runtime_error (err_->message );
749
+ }
702
750
log::info (" \t Device/USB {}::{} : {}" , index_on_opened_device, " Width" , wi);
703
751
log::info (" \t Device/USB {}::{} : {}" , index_on_opened_device, " Height" , hi);
704
752
705
753
int32_t px = arv_device_get_integer_feature_value (devices_[index_on_opened_device].device_ , " PixelFormat" , &err_);
706
- if (px == 0 ){
754
+ if (err_ || px == 0 ){
707
755
log::info (" The pixel format is not supported for header info" );
756
+ err_ = nullptr ;
757
+ px = 0 ;
708
758
}
709
759
710
760
devices_[index_on_opened_device].header_info_ = { 1 , wi, hi,
@@ -714,8 +764,14 @@ class U3V {
714
764
}
715
765
716
766
if (index_on_opened_device == 0 && arv_device_is_feature_available (devices_[index_on_opened_device].device_ , " OperationMode" , &err_)){
767
+ if (err_) {
768
+ throw std::runtime_error (err_->message );
769
+ }
717
770
const char * operation_mode_in_string;
718
771
operation_mode_in_string = arv_device_get_string_feature_value (devices_[index_on_opened_device].device_ , " OperationMode" , &err_);
772
+ if (err_) {
773
+ throw std::runtime_error (err_->message );
774
+ }
719
775
if (strcmp (operation_mode_in_string, " Came2USB1" )==0 ){
720
776
operation_mode_ = OperationMode::Came2USB1;
721
777
}else if (strcmp (operation_mode_in_string, " Came1USB1" )==0 ){
@@ -737,10 +793,9 @@ class U3V {
737
793
738
794
index_on_detected_device += 1 ;
739
795
}
740
- return err_;
741
796
}
742
797
743
- GError* create_stream_and_start_acquisition (bool specific_device_to_flip_order){
798
+ void create_stream_and_start_acquisition (bool specific_device_to_flip_order){
744
799
/*
745
800
* ion-kit starts the acquisition before stream creation This is a tentative fix only in ion-kit due to hardware issue
746
801
* In aravis, the acquisition should be done afterward. Since this maps better with GenAPI, where buffers
@@ -749,7 +804,7 @@ class U3V {
749
804
*/
750
805
if (specific_device_to_flip_order){
751
806
log::info (" Execute AcquisitionStart before create stream on this device." );
752
- err_ = command_acquisition_mode_contd_and_start ();
807
+ command_acquisition_mode_contd_and_start ();
753
808
}
754
809
// start streaming after AcquisitionStart
755
810
for (auto i=0 ; i<devices_.size (); ++i) {
@@ -763,9 +818,8 @@ class U3V {
763
818
}
764
819
765
820
if (! specific_device_to_flip_order){
766
- err_ = command_acquisition_mode_contd_and_start ();
821
+ command_acquisition_mode_contd_and_start ();
767
822
}
768
- return err_;
769
823
}
770
824
771
825
void allocate_buffers (){
@@ -989,7 +1043,7 @@ class U3VFakeCam : public U3V{
989
1043
private:
990
1044
U3VFakeCam (int32_t num_sensor, int32_t width, int32_t height , float_t fps, const std::string & pixel_format, char * dev_id = nullptr )
991
1045
: U3V(num_sensor, false , false , true , width, height , fps, pixel_format, nullptr ){
992
- err_ = open_fake_devices (width, height, fps, pixel_format);
1046
+ open_fake_devices (width, height, fps, pixel_format);
993
1047
994
1048
// Start streaming and start acquisition
995
1049
for (auto i=0 ; i<devices_.size (); ++i) {
@@ -1154,15 +1208,15 @@ class U3VRealCam: public U3V{
1154
1208
sim_mode_ = true ;
1155
1209
}
1156
1210
if (sim_mode_){
1157
- err_ = open_fake_devices (width, height, fps, pixel_format);
1211
+ open_fake_devices (width, height, fps, pixel_format);
1158
1212
1159
1213
// Start streaming and start acquisition
1160
- err_ = create_stream_and_start_acquisition (order_filp_);
1214
+ create_stream_and_start_acquisition (order_filp_);
1161
1215
}else {
1162
1216
// Real Camera
1163
1217
validate_user_input (num_device, dev_id);
1164
- err_ = open_real_devices (num_device, num_sensor_, dev_id);
1165
- err_ = create_stream_and_start_acquisition (order_filp_);
1218
+ open_real_devices (num_device, num_sensor_, dev_id);
1219
+ create_stream_and_start_acquisition (order_filp_);
1166
1220
allocate_buffers ();
1167
1221
}
1168
1222
};
@@ -1314,15 +1368,15 @@ class U3VGenDC: public U3V{
1314
1368
sim_mode_ = true ;
1315
1369
}
1316
1370
if (sim_mode_){
1317
- err_ = open_fake_devices (width, height, fps, pixel_format);
1371
+ open_fake_devices (width, height, fps, pixel_format);
1318
1372
1319
1373
// Start streaming and start acquisition
1320
- err_ = create_stream_and_start_acquisition (order_filp_);
1374
+ create_stream_and_start_acquisition (order_filp_);
1321
1375
}else {
1322
1376
// Real Camera
1323
1377
validate_user_input (num_device, dev_id);
1324
- err_ = open_real_devices (num_device, num_sensor_, dev_id);
1325
- err_ = create_stream_and_start_acquisition (order_filp_);
1378
+ open_real_devices (num_device, num_sensor_, dev_id);
1379
+ create_stream_and_start_acquisition (order_filp_);
1326
1380
allocate_buffers ();
1327
1381
}
1328
1382
};
0 commit comments