39 #include "UniquePointer.h"
43 #include "Validator.h"
44 #include <Argus/Ext/BayerSharpnessMap.h>
45 #include <Argus/Ext/DebugCaptureSession.h>
46 #include <Argus/Ext/DeFog.h>
47 #include <Argus/Ext/FaceDetect.h>
48 #include <Argus/Ext/InternalFrameCount.h>
49 #include <Argus/Ext/SensorPrivateMetadata.h>
50 #include <Argus/Ext/DebugCaptureSession.h>
51 #include <Argus/Ext/PwlWdrSensorMode.h>
52 #include <Argus/Ext/DolWdrSensorMode.h>
54 namespace ArgusSamples
70 virtual bool isInterface(Argus::Interface *interface)
const = 0;
84 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_denoiseMode.registerObserver(
this,
85 static_cast<IObserver::CallbackFunction>(
88 static_cast<IObserver::CallbackFunction>(
97 static_cast<IObserver::CallbackFunction>(
99 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_denoiseMode.unregisterObserver(
this,
100 static_cast<IObserver::CallbackFunction>(
117 ORIGINATE_ERROR(
"Failed to set the denoising mode");
133 ORIGINATE_ERROR(
"Failed to set the denoise strength");
156 static_cast<IObserver::CallbackFunction>(
159 static_cast<IObserver::CallbackFunction>(
168 static_cast<IObserver::CallbackFunction>(
171 static_cast<IObserver::CallbackFunction>(
190 ORIGINATE_ERROR(
"Failed to set the edge enhancement mode");
207 ORIGINATE_ERROR(
"Failed to set the edge enhancement strength");
231 static_cast<IObserver::CallbackFunction>(
233 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_gainRange.registerObserver(
this,
234 static_cast<IObserver::CallbackFunction>(
237 static_cast<IObserver::CallbackFunction>(
239 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_frameRate.registerObserver(
this,
240 static_cast<IObserver::CallbackFunction>(
242 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_focusPosition.registerObserver(
this,
243 static_cast<IObserver::CallbackFunction>(
246 static_cast<IObserver::CallbackFunction>(
248 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_apertureFnum.registerObserver(
this,
249 static_cast<IObserver::CallbackFunction>(
252 static_cast<IObserver::CallbackFunction>(
255 static_cast<IObserver::CallbackFunction>(
264 static_cast<IObserver::CallbackFunction>(
267 static_cast<IObserver::CallbackFunction>(
269 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_apertureFnum.unregisterObserver(
this,
270 static_cast<IObserver::CallbackFunction>(
272 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_focusPosition.unregisterObserver(
this,
273 static_cast<IObserver::CallbackFunction>(
275 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_frameRate.unregisterObserver(
this,
276 static_cast<IObserver::CallbackFunction>(
279 static_cast<IObserver::CallbackFunction>(
281 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_gainRange.unregisterObserver(
this,
282 static_cast<IObserver::CallbackFunction>(
285 static_cast<IObserver::CallbackFunction>(
288 static_cast<IObserver::CallbackFunction>(
307 ORIGINATE_ERROR(
"Failed to set exposure time range");
322 ORIGINATE_ERROR(
"Failed to set gain range");
335 Argus::SensorMode *sensorMode = NULL;
339 ORIGINATE_ERROR(
"Failed to set sensor mode");
369 ORIGINATE_ERROR(
"Failed to set focus position");
386 ORIGINATE_ERROR(
"Failed to set aperture motor step");
403 ORIGINATE_ERROR(
"Failed to set aperture F-num");
420 ORIGINATE_ERROR(
"Failed to set aperture motor speed");
434 Argus::Range<uint64_t> frameDurationRangeNs(0);
440 Argus::SensorMode *sensorMode = NULL;
444 Argus::ISensorMode *iSensorMode =
445 Argus::interface_cast<Argus::ISensorMode>(sensorMode);
447 frameDurationRangeNs = iSensorMode->getFrameDurationRange();
452 frameDurationRangeNs =
456 if (
m_iSourceSettings->setFrameDurationRange(frameDurationRangeNs) != Argus::STATUS_OK)
457 ORIGINATE_ERROR(
"Failed to set frame duration range");
480 static_cast<IObserver::CallbackFunction>(
482 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_aeLock.registerObserver(
this,
483 static_cast<IObserver::CallbackFunction>(
485 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_awbLock.registerObserver(
this,
486 static_cast<IObserver::CallbackFunction>(
488 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_awbMode.registerObserver(
this,
489 static_cast<IObserver::CallbackFunction>(
492 static_cast<IObserver::CallbackFunction>(
495 static_cast<IObserver::CallbackFunction>(
498 static_cast<IObserver::CallbackFunction>(
501 static_cast<IObserver::CallbackFunction>(
510 static_cast<IObserver::CallbackFunction>(
513 static_cast<IObserver::CallbackFunction>(
515 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_awbMode.unregisterObserver(
this,
516 static_cast<IObserver::CallbackFunction>(
518 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_awbLock.unregisterObserver(
this,
519 static_cast<IObserver::CallbackFunction>(
521 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_aeLock.unregisterObserver(
this,
522 static_cast<IObserver::CallbackFunction>(
525 static_cast<IObserver::CallbackFunction>(
528 static_cast<IObserver::CallbackFunction>(
531 static_cast<IObserver::CallbackFunction>(
550 ORIGINATE_ERROR(
"Failed to set the AE antibanding mode");
562 assert(&source == &dispatcher.
m_aeLock);
565 ORIGINATE_ERROR(
"Failed to set the AE lock");
576 assert(&source == &dispatcher.
m_awbLock);
579 ORIGINATE_ERROR(
"Failed to set the AWB lock");
590 assert(&source == &dispatcher.
m_awbMode);
593 ORIGINATE_ERROR(
"Failed to set the AWB mode");
609 ORIGINATE_ERROR(
"Failed to set the exposure compensation");
626 ORIGINATE_ERROR(
"Failed to set the Isp Digital Gain Range");
643 if ((horizontal.min() < horizontal.max()) &&
644 vertical.min() < vertical.max())
647 Argus::Rectangle<uint32_t> histRegion(horizontal.min(), vertical.min(),
648 horizontal.max(), vertical.max());
652 ORIGINATE_ERROR(
"Failed to set the bayer histogram region");
656 std::vector<Argus::AcRegion> afRegions;
657 Argus::AcRegion oneRegion(horizontal.min(), vertical.min(), horizontal.max(),
658 vertical.max(), 1.0f);
659 afRegions.push_back(oneRegion);
663 ORIGINATE_ERROR(
"Failed to set the af region");
687 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_deFogEnable.registerObserver(
this,
689 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_deFogAmount.registerObserver(
this,
691 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_deFogQuality.registerObserver(
this,
699 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_deFogQuality.unregisterObserver(
this,
701 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_deFogAmount.unregisterObserver(
this,
703 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_deFogEnable.unregisterObserver(
this,
733 ORIGINATE_ERROR(
"Failed to set the DeFog amount");
747 ORIGINATE_ERROR(
"Failed to set the DeFog quality");
758 static const ValidatorEnum<Argus::PixelFormat>::ValueStringPair s_captureYuvFormatTypes[] =
760 { Argus::PIXEL_FMT_YCbCr_420_888,
"nv12" },
761 { Argus::PIXEL_FMT_P016,
"p016" }
765 static const ValidatorEnum<Argus::DenoiseMode>::ValueStringPair s_denoiseModes[] =
767 { Argus::DENOISE_MODE_OFF,
"off" },
768 { Argus::DENOISE_MODE_FAST,
"fast" },
769 { Argus::DENOISE_MODE_HIGH_QUALITY,
"highquality" }
773 static const ValidatorEnum<Argus::EdgeEnhanceMode>::ValueStringPair s_edgeEnhanceModes[] =
775 { Argus::EDGE_ENHANCE_MODE_OFF,
"off" },
776 { Argus::EDGE_ENHANCE_MODE_FAST,
"fast" },
777 { Argus::EDGE_ENHANCE_MODE_HIGH_QUALITY,
"highquality" }
781 static const ValidatorEnum<Argus::AeAntibandingMode>::ValueStringPair s_aeAntibandingModes[] =
783 { Argus::AE_ANTIBANDING_MODE_OFF,
"off" },
784 { Argus::AE_ANTIBANDING_MODE_AUTO,
"auto" },
785 { Argus::AE_ANTIBANDING_MODE_50HZ,
"50hz" },
786 { Argus::AE_ANTIBANDING_MODE_60HZ,
"60hz" }
790 static const ValidatorEnum<Argus::AwbMode>::ValueStringPair s_awbModes[] =
792 { Argus::AWB_MODE_OFF,
"off" },
793 { Argus::AWB_MODE_AUTO,
"auto" },
794 { Argus::AWB_MODE_INCANDESCENT,
"incandescent" },
795 { Argus::AWB_MODE_FLUORESCENT,
"fluorescent" },
796 { Argus::AWB_MODE_WARM_FLUORESCENT,
"warmfluorescent" },
797 { Argus::AWB_MODE_DAYLIGHT,
"daylight" },
798 { Argus::AWB_MODE_CLOUDY_DAYLIGHT,
"cloudydaylight" },
799 { Argus::AWB_MODE_TWILIGHT,
"twilight" },
800 { Argus::AWB_MODE_SHADE,
"shade" },
801 { Argus::AWB_MODE_MANUAL,
"manual" }
805 static const ValidatorEnum<ArgusSamples::StillFileType>::ValueStringPair s_stillFileTypes[] =
812 static const ValidatorEnum<VideoPipeline::VideoFormat>::ValueStringPair s_videoFormats[] =
821 static const ValidatorEnum<VideoPipeline::VideoFileType>::ValueStringPair s_videoFileTypes[] =
830 static const Argus::Size2D<uint32_t> s_outputSizes[] =
832 Argus::Size2D<uint32_t>(0, 0),
833 Argus::Size2D<uint32_t>(176, 144),
834 Argus::Size2D<uint32_t>(320, 240),
835 Argus::Size2D<uint32_t>(640, 480),
836 Argus::Size2D<uint32_t>(1280, 720),
837 Argus::Size2D<uint32_t>(1920, 1080),
838 Argus::Size2D<uint32_t>(3840, 2160),
842 : m_deviceFocusPositionRange(0)
843 , m_deviceAperturePositionRange(0)
844 , m_deviceApertureMotorSpeedRange(1.0f)
845 , m_deviceExposureCompensationRange(0.0f)
846 , m_deviceIspDigitalGainRange(Argus::Range<float>(0.0f))
847 , m_sensorExposureTimeRange(Argus::Range<uint64_t>(0))
848 , m_sensorAnalogGainRange(Argus::Range<float>(0.0f))
849 , m_sensorFrameRateRange(0.0f)
850 , m_deviceIndex(new ValidatorStdVector<uint32_t, Argus::CameraDevice*>(&m_cameraDevices), 0)
851 , m_deviceOpen(false)
852 , m_sensorModeValid(false)
855 , m_exposureTimeRange(new ValidatorRange<Argus::Range<uint64_t> >(&m_sensorExposureTimeRange),
856 Argus::Range<uint64_t>(0))
857 , m_gainRange(new ValidatorRange<Argus::Range<float > >(&m_sensorAnalogGainRange),
858 Argus::Range<float>(0.0f))
859 , m_sensorModeIndex(new ValidatorEnum<uint32_t>(), 0)
860 , m_frameRate(new ValidatorRange<float>(&m_sensorFrameRateRange), 0.0f)
861 , m_focusPosition(new ValidatorRange<int32_t>(&m_deviceFocusPositionRange), 0)
862 , m_aperturePosition(new ValidatorRange<int32_t>(&m_deviceAperturePositionRange), 0)
863 , m_apertureFnum(new ValidatorEnum<float>(), 0.0f)
864 , m_apertureMotorSpeed(new ValidatorRange<float>(&m_deviceApertureMotorSpeedRange), 1.0f)
865 , m_captureYuvFormat(new ValidatorEnum<Argus::PixelFormat>(
866 s_captureYuvFormatTypes,
867 sizeof(s_captureYuvFormatTypes) / sizeof(s_captureYuvFormatTypes[0])),
868 Argus::PIXEL_FMT_YCbCr_420_888)
869 , m_denoiseMode(new ValidatorEnum<Argus::DenoiseMode>(
870 s_denoiseModes, sizeof(s_denoiseModes) / sizeof(s_denoiseModes[0])),
871 Argus::DENOISE_MODE_FAST)
872 , m_denoiseStrength(new ValidatorRange<float>(-1.0f, 1.0f), -1.0f)
873 , m_edgeEnhanceMode(new ValidatorEnum<Argus::EdgeEnhanceMode>(
874 s_edgeEnhanceModes, sizeof(s_edgeEnhanceModes) / sizeof(s_edgeEnhanceModes[0])),
875 Argus::EDGE_ENHANCE_MODE_FAST)
876 , m_edgeEnhanceStrength(new ValidatorRange<float>(-1.0f, 1.0f), -1.0f)
877 , m_aeAntibandingMode(new ValidatorEnum<Argus::AeAntibandingMode>(
878 s_aeAntibandingModes, sizeof(s_aeAntibandingModes) / sizeof(s_aeAntibandingModes[0])),
879 Argus::AE_ANTIBANDING_MODE_AUTO)
882 , m_awbMode(new ValidatorEnum<Argus::AwbMode>(
883 s_awbModes, sizeof(s_awbModes) / sizeof(s_awbModes[0])),
884 Argus::AWB_MODE_AUTO)
885 , m_exposureCompensation(new ValidatorRange<float>(&m_deviceExposureCompensationRange), 0.0f)
886 , m_ispDigitalGainRange(new ValidatorRange<Argus::Range<float> >(&m_deviceIspDigitalGainRange),
887 Argus::Range<float>(1.0f))
888 , m_acRegionHorizontal(Argus::Range<uint32_t>(0))
889 , m_acRegionVertical(Argus::Range<uint32_t>(0))
891 s_stillFileTypes, sizeof(s_stillFileTypes) / sizeof(s_stillFileTypes[0])),
893 , m_videoFormat(new ValidatorEnum<
VideoPipeline::VideoFormat>(
894 s_videoFormats, sizeof(s_videoFormats) / sizeof(s_videoFormats[0])),
896 , m_videoFileType(new ValidatorEnum<
VideoPipeline::VideoFileType>(
897 s_videoFileTypes, sizeof(s_videoFileTypes) / sizeof(s_videoFileTypes[0])),
899 , m_videoBitRate(new ValidatorRange<uint32_t>(0,
VideoPipeline::VIDEO_BITRATE_MAX),0)
900 , m_outputSize(new ValidatorSize2D<uint32_t>(s_outputSizes,
901 sizeof(s_outputSizes) / sizeof(s_outputSizes[0]), true ),
902 Argus::Size2D<uint32_t>(0, 0))
904 , m_deFogEnable(false)
905 , m_deFogAmount(new ValidatorRange<float>(0.0f, 1.0f), 0.9f)
906 , m_deFogQuality(new ValidatorRange<float>(0.0f, 1.0f), 0.14285f)
907 , m_initialized(false)
908 , m_iCameraProvider(NULL)
916 REPORT_ERROR(
"Failed to shutdown");
921 static InitOnce initOnce;
924 if (initOnce.begin())
933 REPORT_ERROR(
"Initalization failed");
946 m_cameraProvider = Argus::UniqueObj<Argus::CameraProvider>(Argus::CameraProvider::create());
948 if (!m_iCameraProvider)
949 ORIGINATE_ERROR(
"Failed to create CameraProvider");
950 printf(
"Argus Version: %s\n", m_iCameraProvider->getVersion().c_str());
957 ORIGINATE_ERROR(
"No cameras available");
964 PROPAGATE_ERROR_CONTINUE(
m_deviceIndex.registerObserver(
this,
980 PROPAGATE_ERROR_CONTINUE(
m_deviceIndex.unregisterObserver(
this,
994 assert(
static_cast<const Value<uint32_t>&
>(source).
get() ==
m_deviceIndex);
1008 const Argus::ICameraProperties *iCameraProperties =
1010 if (!iCameraProperties)
1011 ORIGINATE_ERROR(
"Failed to get ICameraProperties interface");
1014 if (iCameraProperties->getAllSensorModes(&
m_sensorModes) != Argus::STATUS_OK)
1015 ORIGINATE_ERROR(
"Failed to get sensor modes");
1018 ORIGINATE_ERROR(
"No sensor modes found");
1028 ORIGINATE_ERROR(
"Failed to get Aperture Fnum");
1030 ValidatorEnum<float>* apertureFnumValidator =
1031 static_cast<ValidatorEnum<float>*
>(
m_apertureFnum.getValidator());
1040 Argus::Range<float> digitalGainRange = iCameraProperties->getIspDigitalGainRange();
1041 Argus::Range<float> deviceExposureCompensationRange =
1042 iCameraProperties->getExposureCompensationRange();
1050 Argus::Range<float> unifiedDigitalGainRange(0);
1051 unifiedDigitalGainRange.min() =
1053 unifiedDigitalGainRange.max() =
1056 Argus::Range<float> unifiedExposureCompensationRange(0);
1057 unifiedExposureCompensationRange.min() =
1059 deviceExposureCompensationRange.min());
1060 unifiedExposureCompensationRange.max() =
1062 deviceExposureCompensationRange.max());
1065 Argus::Range<Argus::Range<float> >(unifiedDigitalGainRange)));
1067 Argus::Range<float> (unifiedExposureCompensationRange)));
1075 digitalGainRange, digitalGainRange)));
1077 deviceExposureCompensationRange)));
1080 std::vector<ValidatorEnum<uint32_t>::ValueStringPair> valueStringPairs;
1082 for (
size_t index = 0; index <
m_sensorModes.size(); ++index)
1084 Argus::ISensorMode *sensorMode =
1085 Argus::interface_cast<Argus::ISensorMode>(
m_sensorModes[index]);
1087 valueStringPairs[index].value = (uint32_t)index;
1089 std::ostringstream stream;
1090 stream << index <<
": "
1091 << sensorMode->getResolution().width() <<
"x" << sensorMode->getResolution().height();
1093 Argus::Ext::IPwlWdrSensorMode* pwlMode =
1094 Argus::interface_cast<Argus::Ext::IPwlWdrSensorMode>(
m_sensorModes[index]);
1096 Argus::Ext::IDolWdrSensorMode* dolMode =
1097 Argus::interface_cast<Argus::Ext::IDolWdrSensorMode>(
m_sensorModes[index]);
1100 stream <<
" @" << sensorMode->getInputBitDepth() <<
"bpp -> " <<
1101 sensorMode->getOutputBitDepth() <<
"bpp";
1105 stream <<
" @" << sensorMode->getOutputBitDepth() <<
"bpp -> " <<
1106 dolMode->getExposureCount() <<
" exposure" <<
" DOL WDR";
1110 stream <<
" @" << sensorMode->getOutputBitDepth() <<
"bpp";
1113 valueStringPairs[index].string = stream.str();
1116 ValidatorEnum<uint32_t> *validator =
1118 PROPAGATE_ERROR(validator->setValidValues(valueStringPairs.data(), valueStringPairs.size()));
1135 Argus::ISensorMode *iSensorMode =
1138 ORIGINATE_ERROR(
"Failed to get ISensorMode interface");
1141 Argus::Range<uint64_t> sensorExposureTimeRange = iSensorMode->getExposureTimeRange();
1142 Argus::Range<float> sensorAnalogGainRange = iSensorMode->getAnalogGainRange();
1143 Argus::Range<TimeValue> sensorFrameDurationRange(
1146 Argus::Range<float> sensorFrameRateRange(
1147 sensorFrameDurationRange.max().toCyclesPerSec(),
1148 sensorFrameDurationRange.min().toCyclesPerSec());
1151 Argus::Range<uint64_t> unifiedSensorExposureTimeRange(0);
1152 unifiedSensorExposureTimeRange.min() =
1154 unifiedSensorExposureTimeRange.max() =
1156 Argus::Range<float> unifiedSensorAnalogGainRange(0);
1157 unifiedSensorAnalogGainRange.min() =
1159 unifiedSensorAnalogGainRange.max() =
1161 Argus::Range<float> unifiedSensorFrameRateRange(0.0f);
1162 unifiedSensorFrameRateRange.min() =
1164 unifiedSensorFrameRateRange.max() =
1168 Argus::Range<Argus::Range<uint64_t> >(unifiedSensorExposureTimeRange)));
1170 Argus::Range<Argus::Range<float> >(unifiedSensorAnalogGainRange)));
1175 PROPAGATE_ERROR(
m_gainRange.set(sensorAnalogGainRange));
1176 PROPAGATE_ERROR(
m_frameRate.set(sensorFrameRateRange.max()));
1180 sensorExposureTimeRange, sensorExposureTimeRange)));
1182 sensorAnalogGainRange, sensorAnalogGainRange)));
1196 std::ostringstream stream;
1200 stream <<
"Argus extensions:" << std::endl;
1201 stream <<
" BayerSharpnessMap: " <<
1203 "supported" :
"not supported") << std::endl;
1204 stream <<
" DebugCaptureSession: " <<
1206 "supported" :
"not supported") << std::endl;
1207 stream <<
" DeFog: " <<
1209 "supported" :
"not supported") << std::endl;
1210 stream <<
" FaceDetect: " <<
1212 "supported" :
"not supported") << std::endl;
1213 stream <<
" InternalFrameCount: " <<
1215 "supported" :
"not supported") << std::endl;
1216 stream <<
" SensorPrivateMetadata: " <<
1218 "supported" :
"not supported") << std::endl;
1220 stream <<
"Number of camera devices: " <<
m_cameraDevices.size() << std::endl;
1222 for (uint32_t deviceIndex = 0; deviceIndex <
m_cameraDevices.size(); ++deviceIndex)
1224 stream <<
"Device: " << deviceIndex << std::endl;
1226 const Argus::ICameraProperties *iCameraProperties =
1227 Argus::interface_cast<Argus::ICameraProperties>(
m_cameraDevices[deviceIndex]);
1228 if (!iCameraProperties)
1229 ORIGINATE_ERROR(
"Failed to get ICameraProperties interface");
1231 stream <<
" Max AE Regions: " <<
1232 iCameraProperties->getMaxAeRegions() << std::endl;
1233 stream <<
" Max AWB Regions: " <<
1234 iCameraProperties->getMaxAwbRegions() << std::endl;
1235 stream <<
" Focus Position Range: " <<
1236 iCameraProperties->getFocusPositionRange().min() <<
" - " <<
1237 iCameraProperties->getFocusPositionRange().max() << std::endl;
1238 stream <<
" Aperture Position Range: " <<
1239 iCameraProperties->getAperturePositionRange().min() <<
" - " <<
1240 iCameraProperties->getAperturePositionRange().max() << std::endl;
1241 stream <<
" Aperture Motor Speed Range: " <<
1242 iCameraProperties->getApertureMotorSpeedRange().min() <<
" - " <<
1243 iCameraProperties->getApertureMotorSpeedRange().max() << std::endl;
1244 stream <<
" Lens Aperture Available values: ";
1245 std::vector<float> availableFnums;
1246 iCameraProperties->getAvailableApertureFNumbers(&availableFnums);
1247 for (std::vector<float>::iterator it = availableFnums.begin();
1248 it != availableFnums.end(); ++it)
1250 stream << *it <<
", ";
1252 stream << std::endl;
1254 stream <<
" Isp Digital Gain Range: " <<
1255 iCameraProperties->getIspDigitalGainRange().min() <<
" - " <<
1256 iCameraProperties->getIspDigitalGainRange().max() << std::endl;
1259 std::vector<Argus::SensorMode*> sensorModes;
1260 iCameraProperties->getAllSensorModes(&sensorModes);
1261 stream <<
" Number of sensor modes: " << sensorModes.size() << std::endl;
1262 for (uint32_t sensorModeIndex = 0; sensorModeIndex < sensorModes.size(); ++sensorModeIndex)
1264 Argus::ISensorMode *sensorMode =
1265 Argus::interface_cast<Argus::ISensorMode>(sensorModes[sensorModeIndex]);
1267 ORIGINATE_ERROR(
"Failed to get ISensorMode interface");
1271 sensorMode->getFrameDurationRange().min()).toCyclesPerSec();
1273 sensorMode->getFrameDurationRange().max()).toCyclesPerSec();
1275 stream <<
" Sensor mode: " << sensorModeIndex << std::endl;
1276 stream <<
" Resolution: " <<
1277 sensorMode->getResolution().width() <<
"x" <<
1278 sensorMode->getResolution().height() << std::endl;
1279 stream <<
" Exposure time range: " <<
1280 sensorMode->getExposureTimeRange().min() <<
" - " <<
1281 sensorMode->getExposureTimeRange().max() <<
" ns" << std::endl;
1282 stream <<
" Frame duration range: " <<
1283 sensorMode->getFrameDurationRange().min() <<
" - " <<
1284 sensorMode->getFrameDurationRange().max() <<
" ns" << std::endl;
1285 stream <<
" Framerate range: " <<
1286 minimum_fps <<
" - " <<
1287 maximum_fps <<
" fps" << std::endl;
1288 stream <<
" InputBitDepth: " <<
1289 sensorMode->getInputBitDepth() << std::endl;
1290 stream <<
" OutputBitDepth: " <<
1291 sensorMode->getOutputBitDepth() << std::endl;
1292 stream <<
" Analog gain range: " <<
1293 sensorMode->getAnalogGainRange().min() <<
" - " <<
1294 sensorMode->getAnalogGainRange().max() << std::endl;
1296 stream <<
" SensorModeType: " <<
1297 sensorMode->getSensorModeType().getName() << std::endl;
1299 Argus::Ext::IPwlWdrSensorMode* pwlMode =
1300 Argus::interface_cast<Argus::Ext::IPwlWdrSensorMode>(sensorModes[sensorModeIndex]);
1302 Argus::Ext::IDolWdrSensorMode* dolMode =
1303 Argus::interface_cast<Argus::Ext::IDolWdrSensorMode>(sensorModes[sensorModeIndex]);
1307 stream <<
" Piecewise Linear (PWL) WDR Extension supported with: " <<
1308 pwlMode->getControlPointCount() <<
" control points." << std::endl;
1309 std::vector< Argus::Point2D<float> > points;
1310 Argus::Status status = pwlMode->getControlPoints(&points);
1311 if (status != Argus::STATUS_OK)
1312 ORIGINATE_ERROR(
"Error obtaining control points");
1313 stream <<
" - Control Points: " << std::endl;
1314 for (uint32_t j = 0; j < pwlMode->getControlPointCount(); j++)
1316 stream <<
" (" << points[j].x() <<
", " <<
1317 points[j].y() <<
")" << std::endl;
1322 stream <<
" Digital Overlap (DOL) WDR Extension supported with: " << std::endl <<
1323 " - Number of Exposures: " <<
1324 dolMode->getExposureCount() << std::endl <<
1325 " - Number of Optical Black Lines per exposure: " <<
1326 dolMode->getOpticalBlackRowCount() << std::endl <<
1327 " - Number of Line Info marker pixels per row per exposure: " <<
1328 dolMode->getLineInfoMarkerWidth() << std::endl <<
1329 " - Number of margin pixels on left per row per exposure: " <<
1330 dolMode->getLeftMarginWidth() << std::endl <<
1331 " - Number of margin pixels on right per row per exposure: " <<
1332 dolMode->getRightMarginWidth() << std::endl;
1334 std::vector<u_int32_t> verticalBlankPeriodRowCounts;
1335 Argus::Status status =
1336 dolMode->getVerticalBlankPeriodRowCount(&verticalBlankPeriodRowCounts);
1337 if (status != Argus::STATUS_OK)
1338 ORIGINATE_ERROR(
"Error obtaining vertical blank period offsets per exposure");
1339 stream <<
" - Vertical blank period section row counts per exposure: "
1341 for (uint32_t j = 0; j < verticalBlankPeriodRowCounts.size(); j++)
1343 stream <<
" - VBP-section[" << j <<
"] : "
1344 << verticalBlankPeriodRowCounts[j] << std::endl;
1347 stream <<
" - Physical Resolution: " <<
1348 dolMode->getPhysicalResolution().width() <<
"x" <<
1349 dolMode->getPhysicalResolution().height() << std::endl;
1352 stream << std::endl;
1356 info = stream.str();
1366 ORIGINATE_ERROR(
"Invalid sensor mode index");
1396 uint32_t deviceIndex)
1401 ORIGINATE_ERROR(
"Invalid device index");
1408 Argus::UniqueObj<Argus::CaptureSession> newSession(
1411 ORIGINATE_ERROR(
"Failed to create CaptureSession");
1413 PROPAGATE_ERROR(session.
reset(newSession.release(),
this));
1423 Argus::Ext::IDebugCaptureSession *iDebugCaptureSession =
1424 Argus::interface_cast<Argus::Ext::IDebugCaptureSession>(it->m_session);
1425 if (!iDebugCaptureSession)
1426 ORIGINATE_ERROR(
"DebugCaptureSession extension not supported");
1428 const Argus::Status status = iDebugCaptureSession->dump(STDOUT_FILENO);
1429 if (status != Argus::STATUS_OK)
1430 ORIGINATE_ERROR(
"Failed to get dump runtime info");
1469 if (it->m_session == session)
1476 ORIGINATE_ERROR(
"Session not found");
1480 Argus::CaptureSession *session)
1489 Argus::IEventProvider *iEventProvider = Argus::interface_cast<Argus::IEventProvider>(session);
1490 if (!iEventProvider)
1491 ORIGINATE_ERROR(
"Failed to get iEventProvider interface");
1494 const Argus::Status status = iEventProvider->waitForEvents(eventQueue, timeout.
toNSec());
1495 if ((status != Argus::STATUS_OK) && (status != Argus::STATUS_TIMEOUT))
1496 ORIGINATE_ERROR(
"Failed to get events");
1502 Argus::CaptureIntent captureIntent, Argus::CaptureSession *session)
1511 Argus::ICaptureSession *iCaptureSession =
1512 Argus::interface_cast<Argus::ICaptureSession>(session);
1513 if (!iCaptureSession)
1514 ORIGINATE_ERROR(
"Failed to get ICaptureSession interface");
1517 Argus::UniqueObj<Argus::Request> newRequest =
1518 Argus::UniqueObj<Argus::Request>(iCaptureSession->createRequest(captureIntent));
1520 ORIGINATE_ERROR(
"Failed to create request");
1523 Argus::IRequest *iRequest = Argus::interface_cast<Argus::IRequest>(newRequest);
1525 ORIGINATE_ERROR(
"Failed to get IRequest interface");
1528 Argus::ISourceSettings *iSourceSettings =
1529 Argus::interface_cast<Argus::ISourceSettings>(iRequest->getSourceSettings());
1530 if (!iSourceSettings)
1531 ORIGINATE_ERROR(
"Failed to get ISourceSettings interface");
1537 Argus::IAutoControlSettings *iAutoControlSettings =
1538 Argus::interface_cast<Argus::IAutoControlSettings>(iRequest->getAutoControlSettings());
1539 if (!iAutoControlSettings)
1540 ORIGINATE_ERROR(
"Failed to get IAutoControlSettings interface");
1546 Argus::IDenoiseSettings *iDenoiseSettings =
1547 Argus::interface_cast<Argus::IDenoiseSettings>(newRequest);
1548 if (!iDenoiseSettings)
1549 ORIGINATE_ERROR(
"Failed to get IDenoiseSettings interface");
1553 Argus::IEdgeEnhanceSettings *iEdgeEnhanceSettings =
1554 Argus::interface_cast<Argus::IEdgeEnhanceSettings>(newRequest);
1555 if (!iEdgeEnhanceSettings)
1556 ORIGINATE_ERROR(
"Failed to get IEdgeEnhanceSettings interface");
1562 Argus::Ext::IDeFogSettings *iDeFogSettings =
1563 Argus::interface_cast<Argus::Ext::IDeFogSettings>(newRequest);
1571 PROPAGATE_ERROR(request.
reset(newRequest.release(),
this));
1583 Argus::IRequest *iRequest = Argus::interface_cast<Argus::IRequest>(request);
1585 ORIGINATE_ERROR(
"Failed to get IRequest interface");
1588 Argus::ISourceSettings *iSourceSettings =
1589 Argus::interface_cast<Argus::ISourceSettings>(iRequest->getSourceSettings());
1590 if (!iSourceSettings)
1591 ORIGINATE_ERROR(
"Failed to get ISourceSettings interface");
1597 Argus::IAutoControlSettings *iAutoControlSettings =
1598 Argus::interface_cast<Argus::IAutoControlSettings>(iRequest->getAutoControlSettings());
1599 if (!iAutoControlSettings)
1600 ORIGINATE_ERROR(
"Failed to get IAutoControlSettings interface");
1606 Argus::IDenoiseSettings *iDenoiseSettings =
1607 Argus::interface_cast<Argus::IDenoiseSettings>(request);
1608 if (!iDenoiseSettings)
1609 ORIGINATE_ERROR(
"Failed to get IDenoiseSettings interface");
1613 Argus::IEdgeEnhanceSettings *iEdgeEnhanceSettings =
1614 Argus::interface_cast<Argus::IEdgeEnhanceSettings>(request);
1615 if (!iEdgeEnhanceSettings)
1616 ORIGINATE_ERROR(
"Failed to get IEdgeEnhanceSettings interface");
1622 Argus::Ext::IDeFogSettings *iDeFogSettings =
1623 Argus::interface_cast<Argus::Ext::IDeFogSettings>(request);
1635 Argus::UniqueObj<Argus::EventQueue>& eventQueue, Argus::CaptureSession *session)
1644 Argus::IEventProvider *iEventProvider =
1645 Argus::interface_cast<Argus::IEventProvider>(session);
1646 if (!iEventProvider)
1647 ORIGINATE_ERROR(
"Failed to get IEventProvider interface");
1649 Argus::EventQueue *newEventQueue = iEventProvider->createEventQueue(eventTypes);
1651 ORIGINATE_ERROR(
"Failed to create eventQueue");
1653 eventQueue.reset(newEventQueue);
1667 Argus::ICaptureSession *iCaptureSession =
1668 Argus::interface_cast<Argus::ICaptureSession>(session);
1669 if (!iCaptureSession)
1670 ORIGINATE_ERROR(
"Failed to get ICaptureSession interface");
1672 if (iCaptureSession->capture(request, Argus::TIMEOUT_INFINITE) == 0)
1673 ORIGINATE_ERROR(
"Failed to submit the still capture request");
1687 Argus::ICaptureSession *iCaptureSession =
1688 Argus::interface_cast<Argus::ICaptureSession>(session);
1689 if (!iCaptureSession)
1690 ORIGINATE_ERROR(
"Failed to get ICaptureSession interface");
1692 if (iCaptureSession->repeat(request) != Argus::STATUS_OK)
1693 ORIGINATE_ERROR(
"Failed to submit repeating capture request");
1700 if (it->m_session == session)
1702 it->m_requests.push_back(request);
1708 ORIGINATE_ERROR(
"Did not find the session in the list of active sessions");
1714 Argus::CaptureSession *session)
1723 Argus::ICaptureSession *iCaptureSession =
1724 Argus::interface_cast<Argus::ICaptureSession>(session);
1725 if (!iCaptureSession)
1726 ORIGINATE_ERROR(
"Failed to get ICaptureSession interface");
1728 if (iCaptureSession->repeatBurst(requestList) != Argus::STATUS_OK)
1729 ORIGINATE_ERROR(
"Failed to submit repeating burst request");
1736 if (it->m_session == session)
1738 it->m_requests.insert(it->m_requests.end(), requestList.begin(), requestList.end());
1744 ORIGINATE_ERROR(
"Did not find the session in the list of active sessions");
1758 Argus::ICaptureSession *iCaptureSession =
1759 Argus::interface_cast<Argus::ICaptureSession>(session);
1760 if (!iCaptureSession)
1761 ORIGINATE_ERROR(
"Failed to get ICaptureSession interface");
1763 iCaptureSession->stopRepeat();
1770 if (it->m_session == session)
1772 it->m_requests.clear();
1778 ORIGINATE_ERROR(
"Did not find the session in the list of active sessions");
1788 if (!it->m_requests.empty())
1790 Argus::ICaptureSession *iCaptureSession =
1791 Argus::interface_cast<Argus::ICaptureSession>(it->m_session);
1792 if (!iCaptureSession)
1793 ORIGINATE_ERROR(
"Failed to get ICaptureSession interface");
1795 iCaptureSession->stopRepeat();
1797 if (iCaptureSession->repeatBurst(it->m_requests) != Argus::STATUS_OK)
1798 ORIGINATE_ERROR(
"Failed to submit repeating burst request");
1814 Argus::ICaptureSession *iCaptureSession =
1815 Argus::interface_cast<Argus::ICaptureSession>(session);
1816 if (!iCaptureSession)
1818 REPORT_ERROR(
"Failed to get ICaptureSession interface");
1822 return iCaptureSession->maxBurstRequests();
1834 Argus::ICaptureSession *iCaptureSession =
1835 Argus::interface_cast<Argus::ICaptureSession>(session);
1836 if (!iCaptureSession)
1837 ORIGINATE_ERROR(
"Failed to get ICaptureSession interface");
1839 if (iCaptureSession->waitForIdle() != Argus::STATUS_OK)
1840 ORIGINATE_ERROR(
"Waiting for idle failed");
1853 Argus::ISensorMode *sensorMode =
1856 ORIGINATE_ERROR(
"Failed to get ISensorMode interface");
1857 *size = sensorMode->getResolution();
1868 Argus::UniqueObj<Argus::OutputStream> &stream, Argus::CaptureSession *session)
1877 Argus::IRequest *iRequest = Argus::interface_cast<Argus::IRequest>(request);
1879 ORIGINATE_ERROR(
"Failed to get IRequest interface");
1881 Argus::Size2D<uint32_t> outputSize;
1884 Argus::ICaptureSession *iCaptureSession =
1885 Argus::interface_cast<Argus::ICaptureSession>(session);
1886 if (!iCaptureSession)
1887 ORIGINATE_ERROR(
"Failed to get ICaptureSession interface");
1889 Argus::UniqueObj<Argus::OutputStreamSettings> outputStreamSettings(
1890 iCaptureSession->createOutputStreamSettings(Argus::STREAM_TYPE_EGL));
1891 Argus::IEGLOutputStreamSettings* iEGLOutputStreamSettings =
1892 Argus::interface_cast<Argus::IEGLOutputStreamSettings>(outputStreamSettings);
1893 if (!iEGLOutputStreamSettings)
1894 ORIGINATE_ERROR(
"Failed to get IEGLOutputStreamSettings interface");
1897 iEGLOutputStreamSettings->setResolution(outputSize);
1899 iEGLOutputStreamSettings->setMetadataEnable(enableMetadata);
1901 Argus::UniqueObj<Argus::OutputStream> outputStream(
1902 iCaptureSession->createOutputStream(outputStreamSettings.get()));
1904 ORIGINATE_ERROR(
"Failed to create OutputStream");
1906 stream.reset(outputStream.release());
1913 Argus::IRequest *iRequest = Argus::interface_cast<Argus::IRequest>(request);
1915 ORIGINATE_ERROR(
"Failed to get IRequest interface");
1918 if (iRequest->enableOutputStream(stream) != Argus::STATUS_OK)
1919 ORIGINATE_ERROR(
"Failed to enable the output stream");
1926 Argus::IRequest *iRequest = Argus::interface_cast<Argus::IRequest>(request);
1928 ORIGINATE_ERROR(
"Failed to get IRequest interface");
1931 if (iRequest->disableOutputStream(stream) != Argus::STATUS_OK)
1932 ORIGINATE_ERROR(
"Failed to disable the output stream");
1939 UniquePointer<DenoiseSettingsObserver> denoiseSettings;
1942 if (!denoiseSettings)
1943 ORIGINATE_ERROR(
"Out of memory");
1945 m_observers.push_front(denoiseSettings.release());
1951 UniquePointer<EdgeEnhanceSettingsObserver> edgeEnhanceSettings;
1954 if (!edgeEnhanceSettings)
1955 ORIGINATE_ERROR(
"Out of memory");
1957 m_observers.push_front(edgeEnhanceSettings.release());
1963 UniquePointer<SourceSettingsObserver> sourceSettings;
1966 if (!sourceSettings)
1967 ORIGINATE_ERROR(
"Out of memory");
1975 UniquePointer<AutoControlSettingsObserver> autoControlSettings;
1978 if (!autoControlSettings)
1979 ORIGINATE_ERROR(
"Out of memory");
1981 m_observers.push_front(autoControlSettings.release());
1987 UniquePointer<DeFogSettingsObserver> deFogSettings;
1991 ORIGINATE_ERROR(
"Out of memory");
1999 for (std::list<IObserverForInterface*>::iterator it =
m_observers.begin();
2002 if ((*it)->isInterface(interface))
2010 ORIGINATE_ERROR(
"Observer not found");
2019 va_start(list, msg);
2021 if (vprintf(msg, list) < 0)
2024 ORIGINATE_ERROR(
"Failed to print message");