Skip to content

Commit e037800

Browse files
committed
Merge pull request opencv#15714 from neurodroid:patch-1
2 parents 5542dcb + 1358c0a commit e037800

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

modules/videoio/include/opencv2/videoio.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,16 @@ enum { CAP_PROP_XI_DOWNSAMPLING = 400, //!< Chan
485485

486486
//! @} XIMEA
487487

488+
/** @name XIMEA Camera API
489+
* @{
490+
*/
491+
492+
//! Properties of cameras available through ARAVIS backend
493+
enum { CAP_PROP_ARAVIS_AUTOTRIGGER = 600 //!< Automatically trigger frame capture if camera is configured with software trigger
494+
};
495+
496+
//! @} ARAVIS
497+
488498
/** @name AVFoundation framework for iOS
489499
OS X Lion will have the same API
490500
@{

modules/videoio/src/cap_aravis.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ class CvCaptureCAM_Aravis : public CvCapture
148148
double exposureCompensation;
149149
bool autoGain;
150150
double targetGrey; // Target grey value (mid grey))
151+
bool softwareTriggered; // Flag if the camera is software triggered
152+
bool allowAutoTrigger; // Flag that user allowed to trigger software triggered cameras automatically
151153

152154
gint64 *pixelFormats;
153155
guint pixelFormatsCnt;
@@ -189,6 +191,7 @@ CvCaptureCAM_Aravis::CvCaptureCAM_Aravis()
189191
exposureCompensation = 0;
190192
targetGrey = 0;
191193
frameID = prevFrameID = 0;
194+
allowAutoTrigger = false;
192195

193196
num_buffers = 10;
194197
frame = NULL;
@@ -275,6 +278,7 @@ bool CvCaptureCAM_Aravis::open( int index )
275278
exposure = exposureAvailable ? arv_camera_get_exposure_time(camera) : 0;
276279
gain = gainAvailable ? arv_camera_get_gain(camera) : 0;
277280
fps = arv_camera_get_frame_rate(camera);
281+
softwareTriggered = (strcmp(arv_camera_get_trigger_source(camera), "Software") == 0);
278282

279283
return startCapture();
280284
}
@@ -290,6 +294,9 @@ bool CvCaptureCAM_Aravis::grabFrame()
290294
ArvBuffer *arv_buffer = NULL;
291295
int max_tries = 10;
292296
int tries = 0;
297+
if (softwareTriggered && allowAutoTrigger) {
298+
arv_camera_software_trigger (camera);
299+
}
293300
for(; tries < max_tries; tries ++) {
294301
arv_buffer = arv_stream_timeout_pop_buffer (stream, 200000);
295302
if (arv_buffer != NULL && arv_buffer_get_status (arv_buffer) != ARV_BUFFER_STATUS_SUCCESS) {
@@ -494,6 +501,12 @@ double CvCaptureCAM_Aravis::getProperty( int property_id ) const
494501
return out;
495502
}
496503
break;
504+
505+
case CAP_PROP_ARAVIS_AUTOTRIGGER:
506+
{
507+
return allowAutoTrigger ? 1. : 0.;
508+
}
509+
break;
497510
}
498511
return -1.0;
499512
}
@@ -578,6 +591,11 @@ bool CvCaptureCAM_Aravis::setProperty( int property_id, double value )
578591
}
579592
break;
580593

594+
case CAP_PROP_ARAVIS_AUTOTRIGGER:
595+
{
596+
allowAutoTrigger = (bool) value;
597+
}
598+
break;
581599

582600
default:
583601
return false;

0 commit comments

Comments
 (0)