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>(
254 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_focusPosition.unregisterObserver(
this,
255 static_cast<IObserver::CallbackFunction>(
257 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_frameRate.unregisterObserver(
this,
258 static_cast<IObserver::CallbackFunction>(
261 static_cast<IObserver::CallbackFunction>(
263 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_gainRange.unregisterObserver(
this,
264 static_cast<IObserver::CallbackFunction>(
267 static_cast<IObserver::CallbackFunction>(
270 static_cast<IObserver::CallbackFunction>(
289 ORIGINATE_ERROR(
"Failed to set exposure time range");
304 ORIGINATE_ERROR(
"Failed to set gain range");
317 Argus::SensorMode *sensorMode = NULL;
321 ORIGINATE_ERROR(
"Failed to set sensor mode");
351 ORIGINATE_ERROR(
"Failed to set focus position");
365 Argus::Range<uint64_t> frameDurationRangeNs(0);
371 Argus::SensorMode *sensorMode = NULL;
375 Argus::ISensorMode *iSensorMode =
376 Argus::interface_cast<Argus::ISensorMode>(sensorMode);
378 frameDurationRangeNs = iSensorMode->getFrameDurationRange();
383 frameDurationRangeNs =
387 if (
m_iSourceSettings->setFrameDurationRange(frameDurationRangeNs) != Argus::STATUS_OK)
388 ORIGINATE_ERROR(
"Failed to set frame duration range");
411 static_cast<IObserver::CallbackFunction>(
413 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_aeLock.registerObserver(
this,
414 static_cast<IObserver::CallbackFunction>(
416 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_awbLock.registerObserver(
this,
417 static_cast<IObserver::CallbackFunction>(
419 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_awbMode.registerObserver(
this,
420 static_cast<IObserver::CallbackFunction>(
423 static_cast<IObserver::CallbackFunction>(
426 static_cast<IObserver::CallbackFunction>(
436 static_cast<IObserver::CallbackFunction>(
439 static_cast<IObserver::CallbackFunction>(
441 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_awbMode.unregisterObserver(
this,
442 static_cast<IObserver::CallbackFunction>(
444 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_awbLock.unregisterObserver(
this,
445 static_cast<IObserver::CallbackFunction>(
447 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_aeLock.unregisterObserver(
this,
448 static_cast<IObserver::CallbackFunction>(
451 static_cast<IObserver::CallbackFunction>(
470 ORIGINATE_ERROR(
"Failed to set the AE antibanding mode");
482 assert(&source == &dispatcher.
m_aeLock);
485 ORIGINATE_ERROR(
"Failed to set the AE lock");
496 assert(&source == &dispatcher.
m_awbLock);
499 ORIGINATE_ERROR(
"Failed to set the AWB lock");
510 assert(&source == &dispatcher.
m_awbMode);
513 ORIGINATE_ERROR(
"Failed to set the AWB mode");
529 ORIGINATE_ERROR(
"Failed to set the exposure compensation");
546 ORIGINATE_ERROR(
"Failed to set the Isp Digital Gain Range");
568 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_deFogEnable.registerObserver(
this,
570 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_deFogAmount.registerObserver(
this,
572 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_deFogQuality.registerObserver(
this,
580 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_deFogQuality.unregisterObserver(
this,
582 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_deFogAmount.unregisterObserver(
this,
584 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_deFogEnable.unregisterObserver(
this,
614 ORIGINATE_ERROR(
"Failed to set the DeFog amount");
628 ORIGINATE_ERROR(
"Failed to set the DeFog quality");
639 static const ValidatorEnum<Argus::PixelFormat>::ValueStringPair s_captureYuvFormatTypes[] =
641 { Argus::PIXEL_FMT_YCbCr_420_888,
"nv12" },
642 { Argus::PIXEL_FMT_P016,
"p016" }
646 static const ValidatorEnum<Argus::DenoiseMode>::ValueStringPair s_denoiseModes[] =
648 { Argus::DENOISE_MODE_OFF,
"off" },
649 { Argus::DENOISE_MODE_FAST,
"fast" },
650 { Argus::DENOISE_MODE_HIGH_QUALITY,
"highquality" }
654 static const ValidatorEnum<Argus::EdgeEnhanceMode>::ValueStringPair s_edgeEnhanceModes[] =
656 { Argus::EDGE_ENHANCE_MODE_OFF,
"off" },
657 { Argus::EDGE_ENHANCE_MODE_FAST,
"fast" },
658 { Argus::EDGE_ENHANCE_MODE_HIGH_QUALITY,
"highquality" }
662 static const ValidatorEnum<Argus::AeAntibandingMode>::ValueStringPair s_aeAntibandingModes[] =
664 { Argus::AE_ANTIBANDING_MODE_OFF,
"off" },
665 { Argus::AE_ANTIBANDING_MODE_AUTO,
"auto" },
666 { Argus::AE_ANTIBANDING_MODE_50HZ,
"50hz" },
667 { Argus::AE_ANTIBANDING_MODE_60HZ,
"60hz" }
671 static const ValidatorEnum<Argus::AwbMode>::ValueStringPair s_awbModes[] =
673 { Argus::AWB_MODE_OFF,
"off" },
674 { Argus::AWB_MODE_AUTO,
"auto" },
675 { Argus::AWB_MODE_INCANDESCENT,
"incandescent" },
676 { Argus::AWB_MODE_FLUORESCENT,
"fluorescent" },
677 { Argus::AWB_MODE_WARM_FLUORESCENT,
"warmfluorescent" },
678 { Argus::AWB_MODE_DAYLIGHT,
"daylight" },
679 { Argus::AWB_MODE_CLOUDY_DAYLIGHT,
"cloudydaylight" },
680 { Argus::AWB_MODE_TWILIGHT,
"twilight" },
681 { Argus::AWB_MODE_SHADE,
"shade" },
682 { Argus::AWB_MODE_MANUAL,
"manual" }
686 static const ValidatorEnum<ArgusSamples::StillFileType>::ValueStringPair s_stillFileTypes[] =
693 static const ValidatorEnum<VideoPipeline::VideoFormat>::ValueStringPair s_videoFormats[] =
702 static const ValidatorEnum<VideoPipeline::VideoFileType>::ValueStringPair s_videoFileTypes[] =
711 static const Argus::Size2D<uint32_t> s_outputSizes[] =
713 Argus::Size2D<uint32_t>(0, 0),
714 Argus::Size2D<uint32_t>(176, 144),
715 Argus::Size2D<uint32_t>(320, 240),
716 Argus::Size2D<uint32_t>(640, 480),
717 Argus::Size2D<uint32_t>(1280, 720),
718 Argus::Size2D<uint32_t>(1920, 1080),
719 Argus::Size2D<uint32_t>(3840, 2160),
723 : m_deviceFocusPositionRange(0)
724 , m_deviceExposureCompensationRange(0.0f)
725 , m_deviceIspDigitalGainRange(Argus::Range<float>(0.0f))
726 , m_sensorExposureTimeRange(Argus::Range<uint64_t>(0))
727 , m_sensorAnalogGainRange(Argus::Range<float>(0.0f))
728 , m_sensorFrameRateRange(0.0f)
729 , m_deviceIndex(new ValidatorStdVector<uint32_t, Argus::CameraDevice*>(&m_cameraDevices), 0)
730 , m_deviceOpen(false)
731 , m_sensorModeValid(false)
734 , m_exposureTimeRange(new ValidatorRange<Argus::Range<uint64_t> >(&m_sensorExposureTimeRange),
735 Argus::Range<uint64_t>(0))
736 , m_gainRange(new ValidatorRange<Argus::Range<float > >(&m_sensorAnalogGainRange),
737 Argus::Range<float>(0.0f))
738 , m_sensorModeIndex(new ValidatorEnum<uint32_t>(), 0)
739 , m_frameRate(new ValidatorRange<float>(&m_sensorFrameRateRange), 0.0f)
740 , m_focusPosition(new ValidatorRange<int32_t>(&m_deviceFocusPositionRange), 0)
741 , m_captureYuvFormat(new ValidatorEnum<Argus::PixelFormat>(
742 s_captureYuvFormatTypes,
743 sizeof(s_captureYuvFormatTypes) / sizeof(s_captureYuvFormatTypes[0])),
744 Argus::PIXEL_FMT_YCbCr_420_888)
745 , m_denoiseMode(new ValidatorEnum<Argus::DenoiseMode>(
746 s_denoiseModes, sizeof(s_denoiseModes) / sizeof(s_denoiseModes[0])),
747 Argus::DENOISE_MODE_FAST)
748 , m_denoiseStrength(new ValidatorRange<float>(-1.0f, 1.0f), -1.0f)
749 , m_edgeEnhanceMode(new ValidatorEnum<Argus::EdgeEnhanceMode>(
750 s_edgeEnhanceModes, sizeof(s_edgeEnhanceModes) / sizeof(s_edgeEnhanceModes[0])),
751 Argus::EDGE_ENHANCE_MODE_FAST)
752 , m_edgeEnhanceStrength(new ValidatorRange<float>(-1.0f, 1.0f), -1.0f)
753 , m_aeAntibandingMode(new ValidatorEnum<Argus::AeAntibandingMode>(
754 s_aeAntibandingModes, sizeof(s_aeAntibandingModes) / sizeof(s_aeAntibandingModes[0])),
755 Argus::AE_ANTIBANDING_MODE_AUTO)
758 , m_awbMode(new ValidatorEnum<Argus::AwbMode>(
759 s_awbModes, sizeof(s_awbModes) / sizeof(s_awbModes[0])),
760 Argus::AWB_MODE_AUTO)
761 , m_exposureCompensation(new ValidatorRange<float>(&m_deviceExposureCompensationRange), 0.0f)
762 , m_ispDigitalGainRange(new ValidatorRange<Argus::Range<float> >(&m_deviceIspDigitalGainRange),
763 Argus::Range<float>(1.0f))
765 s_stillFileTypes, sizeof(s_stillFileTypes) / sizeof(s_stillFileTypes[0])),
767 , m_videoFormat(new ValidatorEnum<
VideoPipeline::VideoFormat>(
768 s_videoFormats, sizeof(s_videoFormats) / sizeof(s_videoFormats[0])),
770 , m_videoFileType(new ValidatorEnum<
VideoPipeline::VideoFileType>(
771 s_videoFileTypes, sizeof(s_videoFileTypes) / sizeof(s_videoFileTypes[0])),
773 , m_videoBitRate(new ValidatorRange<uint32_t>(0,
VideoPipeline::VIDEO_BITRATE_MAX),0)
774 , m_outputSize(new ValidatorSize2D<uint32_t>(s_outputSizes,
775 sizeof(s_outputSizes) / sizeof(s_outputSizes[0]), true ),
776 Argus::Size2D<uint32_t>(0, 0))
778 , m_deFogEnable(false)
779 , m_deFogAmount(new ValidatorRange<float>(0.0f, 1.0f), 0.9f)
780 , m_deFogQuality(new ValidatorRange<float>(0.0f, 1.0f), 0.14285f)
781 , m_initialized(false)
782 , m_iCameraProvider(NULL)
790 REPORT_ERROR(
"Failed to shutdown");
795 static InitOnce initOnce;
798 if (initOnce.begin())
807 REPORT_ERROR(
"Initalization failed");
820 m_cameraProvider = Argus::UniqueObj<Argus::CameraProvider>(Argus::CameraProvider::create());
822 if (!m_iCameraProvider)
823 ORIGINATE_ERROR(
"Failed to create CameraProvider");
824 printf(
"Argus Version: %s\n", m_iCameraProvider->getVersion().c_str());
831 ORIGINATE_ERROR(
"No cameras available");
838 PROPAGATE_ERROR_CONTINUE(
m_deviceIndex.registerObserver(
this,
854 PROPAGATE_ERROR_CONTINUE(
m_deviceIndex.unregisterObserver(
this,
868 assert(
static_cast<const Value<uint32_t>&
>(source).
get() ==
m_deviceIndex);
882 const Argus::ICameraProperties *iCameraProperties =
884 if (!iCameraProperties)
885 ORIGINATE_ERROR(
"Failed to get ICameraProperties interface");
888 if (iCameraProperties->getAllSensorModes(&
m_sensorModes) != Argus::STATUS_OK)
889 ORIGINATE_ERROR(
"Failed to get sensor modes");
892 ORIGINATE_ERROR(
"No sensor modes found");
898 Argus::Range<float> digitalGainRange = iCameraProperties->getIspDigitalGainRange();
899 Argus::Range<float> deviceExposureCompensationRange =
900 iCameraProperties->getExposureCompensationRange();
909 Argus::Range<float> unifiedDigitalGainRange(0);
910 unifiedDigitalGainRange.min() =
912 unifiedDigitalGainRange.max() =
915 Argus::Range<float> unifiedExposureCompensationRange(0);
916 unifiedExposureCompensationRange.min() =
918 deviceExposureCompensationRange.min());
919 unifiedExposureCompensationRange.max() =
921 deviceExposureCompensationRange.max());
924 Argus::Range<Argus::Range<float> >(unifiedDigitalGainRange)));
926 Argus::Range<float> (unifiedExposureCompensationRange)));
934 digitalGainRange, digitalGainRange)));
936 deviceExposureCompensationRange)));
940 std::vector<ValidatorEnum<uint32_t>::ValueStringPair> valueStringPairs;
942 for (
size_t index = 0; index <
m_sensorModes.size(); ++index)
944 Argus::ISensorMode *sensorMode =
945 Argus::interface_cast<Argus::ISensorMode>(
m_sensorModes[index]);
947 valueStringPairs[index].value = (uint32_t)index;
949 std::ostringstream stream;
950 stream << index <<
": "
951 << sensorMode->getResolution().width() <<
"x" << sensorMode->getResolution().height();
953 Argus::Ext::IPwlWdrSensorMode* pwlMode =
954 Argus::interface_cast<Argus::Ext::IPwlWdrSensorMode>(
m_sensorModes[index]);
956 Argus::Ext::IDolWdrSensorMode* dolMode =
957 Argus::interface_cast<Argus::Ext::IDolWdrSensorMode>(
m_sensorModes[index]);
960 stream <<
" @" << sensorMode->getInputBitDepth() <<
"bpp -> " <<
961 sensorMode->getOutputBitDepth() <<
"bpp";
965 stream <<
" @" << sensorMode->getOutputBitDepth() <<
"bpp -> " <<
966 dolMode->getExposureCount() <<
" exposure" <<
" DOL WDR";
970 stream <<
" @" << sensorMode->getOutputBitDepth() <<
"bpp";
973 valueStringPairs[index].string = stream.str();
976 ValidatorEnum<uint32_t> *validator =
978 PROPAGATE_ERROR(validator->setValidValues(valueStringPairs.data(), valueStringPairs.size()));
995 Argus::ISensorMode *iSensorMode =
998 ORIGINATE_ERROR(
"Failed to get ISensorMode interface");
1001 Argus::Range<uint64_t> sensorExposureTimeRange = iSensorMode->getExposureTimeRange();
1002 Argus::Range<float> sensorAnalogGainRange = iSensorMode->getAnalogGainRange();
1003 Argus::Range<TimeValue> sensorFrameDurationRange(
1006 Argus::Range<float> sensorFrameRateRange(
1007 sensorFrameDurationRange.max().toCyclesPerSec(),
1008 sensorFrameDurationRange.min().toCyclesPerSec());
1011 Argus::Range<uint64_t> unifiedSensorExposureTimeRange(0);
1012 unifiedSensorExposureTimeRange.min() =
1014 unifiedSensorExposureTimeRange.max() =
1016 Argus::Range<float> unifiedSensorAnalogGainRange(0);
1017 unifiedSensorAnalogGainRange.min() =
1019 unifiedSensorAnalogGainRange.max() =
1021 Argus::Range<float> unifiedSensorFrameRateRange(0.0f);
1022 unifiedSensorFrameRateRange.min() =
1024 unifiedSensorFrameRateRange.max() =
1028 Argus::Range<Argus::Range<uint64_t> >(unifiedSensorExposureTimeRange)));
1030 Argus::Range<Argus::Range<float> >(unifiedSensorAnalogGainRange)));
1035 PROPAGATE_ERROR(
m_gainRange.set(sensorAnalogGainRange));
1036 PROPAGATE_ERROR(
m_frameRate.set(sensorFrameRateRange.max()));
1040 sensorExposureTimeRange, sensorExposureTimeRange)));
1042 sensorAnalogGainRange, sensorAnalogGainRange)));
1056 std::ostringstream stream;
1060 stream <<
"Argus extensions:" << std::endl;
1061 stream <<
" BayerSharpnessMap: " <<
1063 "supported" :
"not supported") << std::endl;
1064 stream <<
" DebugCaptureSession: " <<
1066 "supported" :
"not supported") << std::endl;
1067 stream <<
" DeFog: " <<
1069 "supported" :
"not supported") << std::endl;
1070 stream <<
" FaceDetect: " <<
1072 "supported" :
"not supported") << std::endl;
1073 stream <<
" InternalFrameCount: " <<
1075 "supported" :
"not supported") << std::endl;
1076 stream <<
" SensorPrivateMetadata: " <<
1078 "supported" :
"not supported") << std::endl;
1080 stream <<
"Number of camera devices: " <<
m_cameraDevices.size() << std::endl;
1082 for (uint32_t deviceIndex = 0; deviceIndex <
m_cameraDevices.size(); ++deviceIndex)
1084 stream <<
"Device: " << deviceIndex << std::endl;
1086 const Argus::ICameraProperties *iCameraProperties =
1087 Argus::interface_cast<Argus::ICameraProperties>(
m_cameraDevices[deviceIndex]);
1088 if (!iCameraProperties)
1089 ORIGINATE_ERROR(
"Failed to get ICameraProperties interface");
1091 stream <<
" Max AE Regions: " <<
1092 iCameraProperties->getMaxAeRegions() << std::endl;
1093 stream <<
" Max AWB Regions: " <<
1094 iCameraProperties->getMaxAwbRegions() << std::endl;
1095 stream <<
" Focus Position Range: " <<
1096 iCameraProperties->getFocusPositionRange().min() <<
" - " <<
1097 iCameraProperties->getFocusPositionRange().max() << std::endl;
1098 stream <<
" Lens Aperture Range: " <<
1099 iCameraProperties->getLensApertureRange().min() <<
" - " <<
1100 iCameraProperties->getLensApertureRange().max() << std::endl;
1101 stream <<
" Isp Digital Gain Range: " <<
1102 iCameraProperties->getIspDigitalGainRange().min() <<
" - " <<
1103 iCameraProperties->getIspDigitalGainRange().max() << std::endl;
1106 std::vector<Argus::SensorMode*> sensorModes;
1107 iCameraProperties->getAllSensorModes(&sensorModes);
1108 stream <<
" Number of sensor modes: " << sensorModes.size() << std::endl;
1109 for (uint32_t sensorModeIndex = 0; sensorModeIndex < sensorModes.size(); ++sensorModeIndex)
1111 Argus::ISensorMode *sensorMode =
1112 Argus::interface_cast<Argus::ISensorMode>(sensorModes[sensorModeIndex]);
1114 ORIGINATE_ERROR(
"Failed to get ISensorMode interface");
1118 sensorMode->getFrameDurationRange().min()).toCyclesPerSec();
1120 sensorMode->getFrameDurationRange().max()).toCyclesPerSec();
1122 stream <<
" Sensor mode: " << sensorModeIndex << std::endl;
1123 stream <<
" Resolution: " <<
1124 sensorMode->getResolution().width() <<
"x" <<
1125 sensorMode->getResolution().height() << std::endl;
1126 stream <<
" Exposure time range: " <<
1127 sensorMode->getExposureTimeRange().min() <<
" - " <<
1128 sensorMode->getExposureTimeRange().max() <<
" ns" << std::endl;
1129 stream <<
" Frame duration range: " <<
1130 sensorMode->getFrameDurationRange().min() <<
" - " <<
1131 sensorMode->getFrameDurationRange().max() <<
" ns" << std::endl;
1132 stream <<
" Framerate range: " <<
1133 minimum_fps <<
" - " <<
1134 maximum_fps <<
" fps" << std::endl;
1135 stream <<
" InputBitDepth: " <<
1136 sensorMode->getInputBitDepth() << std::endl;
1137 stream <<
" OutputBitDepth: " <<
1138 sensorMode->getOutputBitDepth() << std::endl;
1139 stream <<
" Analog gain range: " <<
1140 sensorMode->getAnalogGainRange().min() <<
" - " <<
1141 sensorMode->getAnalogGainRange().max() << std::endl;
1143 stream <<
" SensorModeType: " <<
1144 sensorMode->getSensorModeType().getName() << std::endl;
1146 Argus::Ext::IPwlWdrSensorMode* pwlMode =
1147 Argus::interface_cast<Argus::Ext::IPwlWdrSensorMode>(sensorModes[sensorModeIndex]);
1149 Argus::Ext::IDolWdrSensorMode* dolMode =
1150 Argus::interface_cast<Argus::Ext::IDolWdrSensorMode>(sensorModes[sensorModeIndex]);
1154 stream <<
" Piecewise Linear (PWL) WDR Extension supported with: " <<
1155 pwlMode->getControlPointCount() <<
" control points." << std::endl;
1156 std::vector< Argus::Point2D<float> > points;
1157 Argus::Status status = pwlMode->getControlPoints(&points);
1158 if (status != Argus::STATUS_OK)
1159 ORIGINATE_ERROR(
"Error obtaining control points");
1160 stream <<
" - Control Points: " << std::endl;
1161 for (uint32_t j = 0; j < pwlMode->getControlPointCount(); j++)
1163 stream <<
" (" << points[j].x() <<
", " <<
1164 points[j].y() <<
")" << std::endl;
1169 stream <<
" Digital Overlap (DOL) WDR Extension supported with: " << std::endl <<
1170 " - Number of Exposures: " <<
1171 dolMode->getExposureCount() << std::endl <<
1172 " - Number of Optical Black Lines per exposure: " <<
1173 dolMode->getOpticalBlackRowCount() << std::endl <<
1174 " - Number of Line Info marker pixels per row per exposure: " <<
1175 dolMode->getLineInfoMarkerWidth() << std::endl <<
1176 " - Number of margin pixels on left per row per exposure: " <<
1177 dolMode->getLeftMarginWidth() << std::endl <<
1178 " - Number of margin pixels on right per row per exposure: " <<
1179 dolMode->getRightMarginWidth() << std::endl;
1181 std::vector<u_int32_t> verticalBlankPeriodRowCounts;
1182 Argus::Status status =
1183 dolMode->getVerticalBlankPeriodRowCount(&verticalBlankPeriodRowCounts);
1184 if (status != Argus::STATUS_OK)
1185 ORIGINATE_ERROR(
"Error obtaining vertical blank period offsets per exposure");
1186 stream <<
" - Vertical blank period section row counts per exposure: "
1188 for (uint32_t j = 0; j < verticalBlankPeriodRowCounts.size(); j++)
1190 stream <<
" - VBP-section[" << j <<
"] : "
1191 << verticalBlankPeriodRowCounts[j] << std::endl;
1194 stream <<
" - Physical Resolution: " <<
1195 dolMode->getPhysicalResolution().width() <<
"x" <<
1196 dolMode->getPhysicalResolution().height() << std::endl;
1199 stream << std::endl;
1203 info = stream.str();
1213 ORIGINATE_ERROR(
"Invalid sensor mode index");
1233 uint32_t deviceIndex)
1238 ORIGINATE_ERROR(
"Invalid device index");
1245 Argus::UniqueObj<Argus::CaptureSession> newSession(
1248 ORIGINATE_ERROR(
"Failed to create CaptureSession");
1250 PROPAGATE_ERROR(session.
reset(newSession.release(),
this));
1260 Argus::Ext::IDebugCaptureSession *iDebugCaptureSession =
1261 Argus::interface_cast<Argus::Ext::IDebugCaptureSession>(it->m_session);
1262 if (!iDebugCaptureSession)
1263 ORIGINATE_ERROR(
"DebugCaptureSession extension not supported");
1265 const Argus::Status status = iDebugCaptureSession->dump(STDOUT_FILENO);
1266 if (status != Argus::STATUS_OK)
1267 ORIGINATE_ERROR(
"Failed to get dump runtime info");
1306 if (it->m_session == session)
1313 ORIGINATE_ERROR(
"Session not found");
1317 Argus::CaptureSession *session)
1326 Argus::IEventProvider *iEventProvider = Argus::interface_cast<Argus::IEventProvider>(session);
1327 if (!iEventProvider)
1328 ORIGINATE_ERROR(
"Failed to get iEventProvider interface");
1331 const Argus::Status status = iEventProvider->waitForEvents(eventQueue, timeout.
toNSec());
1332 if ((status != Argus::STATUS_OK) && (status != Argus::STATUS_TIMEOUT))
1333 ORIGINATE_ERROR(
"Failed to get events");
1339 Argus::CaptureIntent captureIntent, Argus::CaptureSession *session)
1348 Argus::ICaptureSession *iCaptureSession =
1349 Argus::interface_cast<Argus::ICaptureSession>(session);
1350 if (!iCaptureSession)
1351 ORIGINATE_ERROR(
"Failed to get ICaptureSession interface");
1354 Argus::UniqueObj<Argus::Request> newRequest =
1355 Argus::UniqueObj<Argus::Request>(iCaptureSession->createRequest(captureIntent));
1357 ORIGINATE_ERROR(
"Failed to create request");
1360 Argus::IRequest *iRequest = Argus::interface_cast<Argus::IRequest>(newRequest);
1362 ORIGINATE_ERROR(
"Failed to get IRequest interface");
1365 Argus::ISourceSettings *iSourceSettings =
1366 Argus::interface_cast<Argus::ISourceSettings>(iRequest->getSourceSettings());
1367 if (!iSourceSettings)
1368 ORIGINATE_ERROR(
"Failed to get ISourceSettings interface");
1374 Argus::IAutoControlSettings *iAutoControlSettings =
1375 Argus::interface_cast<Argus::IAutoControlSettings>(iRequest->getAutoControlSettings());
1376 if (!iAutoControlSettings)
1377 ORIGINATE_ERROR(
"Failed to get IAutoControlSettings interface");
1383 Argus::IDenoiseSettings *iDenoiseSettings =
1384 Argus::interface_cast<Argus::IDenoiseSettings>(newRequest);
1385 if (!iDenoiseSettings)
1386 ORIGINATE_ERROR(
"Failed to get IDenoiseSettings interface");
1390 Argus::IEdgeEnhanceSettings *iEdgeEnhanceSettings =
1391 Argus::interface_cast<Argus::IEdgeEnhanceSettings>(newRequest);
1392 if (!iEdgeEnhanceSettings)
1393 ORIGINATE_ERROR(
"Failed to get IEdgeEnhanceSettings interface");
1399 Argus::Ext::IDeFogSettings *iDeFogSettings =
1400 Argus::interface_cast<Argus::Ext::IDeFogSettings>(newRequest);
1408 PROPAGATE_ERROR(request.
reset(newRequest.release(),
this));
1420 Argus::IRequest *iRequest = Argus::interface_cast<Argus::IRequest>(request);
1422 ORIGINATE_ERROR(
"Failed to get IRequest interface");
1425 Argus::ISourceSettings *iSourceSettings =
1426 Argus::interface_cast<Argus::ISourceSettings>(iRequest->getSourceSettings());
1427 if (!iSourceSettings)
1428 ORIGINATE_ERROR(
"Failed to get ISourceSettings interface");
1434 Argus::IAutoControlSettings *iAutoControlSettings =
1435 Argus::interface_cast<Argus::IAutoControlSettings>(iRequest->getAutoControlSettings());
1436 if (!iAutoControlSettings)
1437 ORIGINATE_ERROR(
"Failed to get IAutoControlSettings interface");
1443 Argus::IDenoiseSettings *iDenoiseSettings =
1444 Argus::interface_cast<Argus::IDenoiseSettings>(request);
1445 if (!iDenoiseSettings)
1446 ORIGINATE_ERROR(
"Failed to get IDenoiseSettings interface");
1450 Argus::IEdgeEnhanceSettings *iEdgeEnhanceSettings =
1451 Argus::interface_cast<Argus::IEdgeEnhanceSettings>(request);
1452 if (!iEdgeEnhanceSettings)
1453 ORIGINATE_ERROR(
"Failed to get IEdgeEnhanceSettings interface");
1459 Argus::Ext::IDeFogSettings *iDeFogSettings =
1460 Argus::interface_cast<Argus::Ext::IDeFogSettings>(request);
1472 Argus::UniqueObj<Argus::EventQueue>& eventQueue, Argus::CaptureSession *session)
1481 Argus::IEventProvider *iEventProvider =
1482 Argus::interface_cast<Argus::IEventProvider>(session);
1483 if (!iEventProvider)
1484 ORIGINATE_ERROR(
"Failed to get IEventProvider interface");
1486 Argus::EventQueue *newEventQueue = iEventProvider->createEventQueue(eventTypes);
1488 ORIGINATE_ERROR(
"Failed to create eventQueue");
1490 eventQueue.reset(newEventQueue);
1504 Argus::ICaptureSession *iCaptureSession =
1505 Argus::interface_cast<Argus::ICaptureSession>(session);
1506 if (!iCaptureSession)
1507 ORIGINATE_ERROR(
"Failed to get ICaptureSession interface");
1509 if (iCaptureSession->capture(request, Argus::TIMEOUT_INFINITE) == 0)
1510 ORIGINATE_ERROR(
"Failed to submit the still capture request");
1524 Argus::ICaptureSession *iCaptureSession =
1525 Argus::interface_cast<Argus::ICaptureSession>(session);
1526 if (!iCaptureSession)
1527 ORIGINATE_ERROR(
"Failed to get ICaptureSession interface");
1529 if (iCaptureSession->repeat(request) != Argus::STATUS_OK)
1530 ORIGINATE_ERROR(
"Failed to submit repeating capture request");
1537 if (it->m_session == session)
1539 it->m_requests.push_back(request);
1545 ORIGINATE_ERROR(
"Did not find the session in the list of active sessions");
1551 Argus::CaptureSession *session)
1560 Argus::ICaptureSession *iCaptureSession =
1561 Argus::interface_cast<Argus::ICaptureSession>(session);
1562 if (!iCaptureSession)
1563 ORIGINATE_ERROR(
"Failed to get ICaptureSession interface");
1565 if (iCaptureSession->repeatBurst(requestList) != Argus::STATUS_OK)
1566 ORIGINATE_ERROR(
"Failed to submit repeating burst request");
1573 if (it->m_session == session)
1575 it->m_requests.insert(it->m_requests.end(), requestList.begin(), requestList.end());
1581 ORIGINATE_ERROR(
"Did not find the session in the list of active sessions");
1595 Argus::ICaptureSession *iCaptureSession =
1596 Argus::interface_cast<Argus::ICaptureSession>(session);
1597 if (!iCaptureSession)
1598 ORIGINATE_ERROR(
"Failed to get ICaptureSession interface");
1600 iCaptureSession->stopRepeat();
1607 if (it->m_session == session)
1609 it->m_requests.clear();
1615 ORIGINATE_ERROR(
"Did not find the session in the list of active sessions");
1625 if (!it->m_requests.empty())
1627 Argus::ICaptureSession *iCaptureSession =
1628 Argus::interface_cast<Argus::ICaptureSession>(it->m_session);
1629 if (!iCaptureSession)
1630 ORIGINATE_ERROR(
"Failed to get ICaptureSession interface");
1632 iCaptureSession->stopRepeat();
1634 if (iCaptureSession->repeatBurst(it->m_requests) != Argus::STATUS_OK)
1635 ORIGINATE_ERROR(
"Failed to submit repeating burst request");
1651 Argus::ICaptureSession *iCaptureSession =
1652 Argus::interface_cast<Argus::ICaptureSession>(session);
1653 if (!iCaptureSession)
1655 REPORT_ERROR(
"Failed to get ICaptureSession interface");
1659 return iCaptureSession->maxBurstRequests();
1671 Argus::ICaptureSession *iCaptureSession =
1672 Argus::interface_cast<Argus::ICaptureSession>(session);
1673 if (!iCaptureSession)
1674 ORIGINATE_ERROR(
"Failed to get ICaptureSession interface");
1676 if (iCaptureSession->waitForIdle() != Argus::STATUS_OK)
1677 ORIGINATE_ERROR(
"Waiting for idle failed");
1690 Argus::ISensorMode *sensorMode =
1693 ORIGINATE_ERROR(
"Failed to get ISensorMode interface");
1694 *size = sensorMode->getResolution();
1705 Argus::UniqueObj<Argus::OutputStream> &stream, Argus::CaptureSession *session)
1714 Argus::IRequest *iRequest = Argus::interface_cast<Argus::IRequest>(request);
1716 ORIGINATE_ERROR(
"Failed to get IRequest interface");
1718 Argus::Size2D<uint32_t> outputSize;
1721 Argus::ICaptureSession *iCaptureSession =
1722 Argus::interface_cast<Argus::ICaptureSession>(session);
1723 if (!iCaptureSession)
1724 ORIGINATE_ERROR(
"Failed to get ICaptureSession interface");
1726 Argus::UniqueObj<Argus::OutputStreamSettings> outputStreamSettings(
1727 iCaptureSession->createOutputStreamSettings(Argus::STREAM_TYPE_EGL));
1728 Argus::IEGLOutputStreamSettings* iEGLOutputStreamSettings =
1729 Argus::interface_cast<Argus::IEGLOutputStreamSettings>(outputStreamSettings);
1730 if (!iEGLOutputStreamSettings)
1731 ORIGINATE_ERROR(
"Failed to get IEGLOutputStreamSettings interface");
1734 iEGLOutputStreamSettings->setResolution(outputSize);
1736 iEGLOutputStreamSettings->setMetadataEnable(enableMetadata);
1738 Argus::UniqueObj<Argus::OutputStream> outputStream(
1739 iCaptureSession->createOutputStream(outputStreamSettings.get()));
1741 ORIGINATE_ERROR(
"Failed to create OutputStream");
1743 stream.reset(outputStream.release());
1750 Argus::IRequest *iRequest = Argus::interface_cast<Argus::IRequest>(request);
1752 ORIGINATE_ERROR(
"Failed to get IRequest interface");
1755 if (iRequest->enableOutputStream(stream) != Argus::STATUS_OK)
1756 ORIGINATE_ERROR(
"Failed to enable the output stream");
1763 Argus::IRequest *iRequest = Argus::interface_cast<Argus::IRequest>(request);
1765 ORIGINATE_ERROR(
"Failed to get IRequest interface");
1768 if (iRequest->disableOutputStream(stream) != Argus::STATUS_OK)
1769 ORIGINATE_ERROR(
"Failed to disable the output stream");
1776 UniquePointer<DenoiseSettingsObserver> denoiseSettings;
1779 if (!denoiseSettings)
1780 ORIGINATE_ERROR(
"Out of memory");
1782 m_observers.push_front(denoiseSettings.release());
1788 UniquePointer<EdgeEnhanceSettingsObserver> edgeEnhanceSettings;
1791 if (!edgeEnhanceSettings)
1792 ORIGINATE_ERROR(
"Out of memory");
1794 m_observers.push_front(edgeEnhanceSettings.release());
1800 UniquePointer<SourceSettingsObserver> sourceSettings;
1803 if (!sourceSettings)
1804 ORIGINATE_ERROR(
"Out of memory");
1812 UniquePointer<AutoControlSettingsObserver> autoControlSettings;
1815 if (!autoControlSettings)
1816 ORIGINATE_ERROR(
"Out of memory");
1818 m_observers.push_front(autoControlSettings.release());
1824 UniquePointer<DeFogSettingsObserver> deFogSettings;
1828 ORIGINATE_ERROR(
"Out of memory");
1836 for (std::list<IObserverForInterface*>::iterator it =
m_observers.begin();
1839 if ((*it)->isInterface(interface))
1847 ORIGINATE_ERROR(
"Observer not found");
1856 va_start(list, msg);
1858 if (vprintf(msg, list) < 0)
1861 ORIGINATE_ERROR(
"Failed to print message");