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>(
249 static_cast<IObserver::CallbackFunction>(
252 static_cast<IObserver::CallbackFunction>(
261 static_cast<IObserver::CallbackFunction>(
264 static_cast<IObserver::CallbackFunction>(
266 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_focusPosition.unregisterObserver(
this,
267 static_cast<IObserver::CallbackFunction>(
269 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_frameRate.unregisterObserver(
this,
270 static_cast<IObserver::CallbackFunction>(
273 static_cast<IObserver::CallbackFunction>(
275 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_gainRange.unregisterObserver(
this,
276 static_cast<IObserver::CallbackFunction>(
279 static_cast<IObserver::CallbackFunction>(
282 static_cast<IObserver::CallbackFunction>(
301 ORIGINATE_ERROR(
"Failed to set exposure time range");
316 ORIGINATE_ERROR(
"Failed to set gain range");
329 Argus::SensorMode *sensorMode = NULL;
333 ORIGINATE_ERROR(
"Failed to set sensor mode");
363 ORIGINATE_ERROR(
"Failed to set focus position");
380 ORIGINATE_ERROR(
"Failed to set aperture motor step");
397 ORIGINATE_ERROR(
"Failed to set aperture motor speed");
411 Argus::Range<uint64_t> frameDurationRangeNs(0);
417 Argus::SensorMode *sensorMode = NULL;
421 Argus::ISensorMode *iSensorMode =
422 Argus::interface_cast<Argus::ISensorMode>(sensorMode);
424 frameDurationRangeNs = iSensorMode->getFrameDurationRange();
429 frameDurationRangeNs =
433 if (
m_iSourceSettings->setFrameDurationRange(frameDurationRangeNs) != Argus::STATUS_OK)
434 ORIGINATE_ERROR(
"Failed to set frame duration range");
457 static_cast<IObserver::CallbackFunction>(
459 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_aeLock.registerObserver(
this,
460 static_cast<IObserver::CallbackFunction>(
462 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_awbLock.registerObserver(
this,
463 static_cast<IObserver::CallbackFunction>(
465 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_awbMode.registerObserver(
this,
466 static_cast<IObserver::CallbackFunction>(
469 static_cast<IObserver::CallbackFunction>(
472 static_cast<IObserver::CallbackFunction>(
482 static_cast<IObserver::CallbackFunction>(
485 static_cast<IObserver::CallbackFunction>(
487 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_awbMode.unregisterObserver(
this,
488 static_cast<IObserver::CallbackFunction>(
490 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_awbLock.unregisterObserver(
this,
491 static_cast<IObserver::CallbackFunction>(
493 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_aeLock.unregisterObserver(
this,
494 static_cast<IObserver::CallbackFunction>(
497 static_cast<IObserver::CallbackFunction>(
516 ORIGINATE_ERROR(
"Failed to set the AE antibanding mode");
528 assert(&source == &dispatcher.
m_aeLock);
531 ORIGINATE_ERROR(
"Failed to set the AE lock");
542 assert(&source == &dispatcher.
m_awbLock);
545 ORIGINATE_ERROR(
"Failed to set the AWB lock");
556 assert(&source == &dispatcher.
m_awbMode);
559 ORIGINATE_ERROR(
"Failed to set the AWB mode");
575 ORIGINATE_ERROR(
"Failed to set the exposure compensation");
592 ORIGINATE_ERROR(
"Failed to set the Isp Digital Gain Range");
614 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_deFogEnable.registerObserver(
this,
616 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_deFogAmount.registerObserver(
this,
618 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_deFogQuality.registerObserver(
this,
626 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_deFogQuality.unregisterObserver(
this,
628 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_deFogAmount.unregisterObserver(
this,
630 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_deFogEnable.unregisterObserver(
this,
660 ORIGINATE_ERROR(
"Failed to set the DeFog amount");
674 ORIGINATE_ERROR(
"Failed to set the DeFog quality");
685 static const ValidatorEnum<Argus::PixelFormat>::ValueStringPair s_captureYuvFormatTypes[] =
687 { Argus::PIXEL_FMT_YCbCr_420_888,
"nv12" },
688 { Argus::PIXEL_FMT_P016,
"p016" }
692 static const ValidatorEnum<Argus::DenoiseMode>::ValueStringPair s_denoiseModes[] =
694 { Argus::DENOISE_MODE_OFF,
"off" },
695 { Argus::DENOISE_MODE_FAST,
"fast" },
696 { Argus::DENOISE_MODE_HIGH_QUALITY,
"highquality" }
700 static const ValidatorEnum<Argus::EdgeEnhanceMode>::ValueStringPair s_edgeEnhanceModes[] =
702 { Argus::EDGE_ENHANCE_MODE_OFF,
"off" },
703 { Argus::EDGE_ENHANCE_MODE_FAST,
"fast" },
704 { Argus::EDGE_ENHANCE_MODE_HIGH_QUALITY,
"highquality" }
708 static const ValidatorEnum<Argus::AeAntibandingMode>::ValueStringPair s_aeAntibandingModes[] =
710 { Argus::AE_ANTIBANDING_MODE_OFF,
"off" },
711 { Argus::AE_ANTIBANDING_MODE_AUTO,
"auto" },
712 { Argus::AE_ANTIBANDING_MODE_50HZ,
"50hz" },
713 { Argus::AE_ANTIBANDING_MODE_60HZ,
"60hz" }
717 static const ValidatorEnum<Argus::AwbMode>::ValueStringPair s_awbModes[] =
719 { Argus::AWB_MODE_OFF,
"off" },
720 { Argus::AWB_MODE_AUTO,
"auto" },
721 { Argus::AWB_MODE_INCANDESCENT,
"incandescent" },
722 { Argus::AWB_MODE_FLUORESCENT,
"fluorescent" },
723 { Argus::AWB_MODE_WARM_FLUORESCENT,
"warmfluorescent" },
724 { Argus::AWB_MODE_DAYLIGHT,
"daylight" },
725 { Argus::AWB_MODE_CLOUDY_DAYLIGHT,
"cloudydaylight" },
726 { Argus::AWB_MODE_TWILIGHT,
"twilight" },
727 { Argus::AWB_MODE_SHADE,
"shade" },
728 { Argus::AWB_MODE_MANUAL,
"manual" }
732 static const ValidatorEnum<ArgusSamples::StillFileType>::ValueStringPair s_stillFileTypes[] =
739 static const ValidatorEnum<VideoPipeline::VideoFormat>::ValueStringPair s_videoFormats[] =
748 static const ValidatorEnum<VideoPipeline::VideoFileType>::ValueStringPair s_videoFileTypes[] =
757 static const Argus::Size2D<uint32_t> s_outputSizes[] =
759 Argus::Size2D<uint32_t>(0, 0),
760 Argus::Size2D<uint32_t>(176, 144),
761 Argus::Size2D<uint32_t>(320, 240),
762 Argus::Size2D<uint32_t>(640, 480),
763 Argus::Size2D<uint32_t>(1280, 720),
764 Argus::Size2D<uint32_t>(1920, 1080),
765 Argus::Size2D<uint32_t>(3840, 2160),
769 : m_deviceFocusPositionRange(0)
770 , m_deviceApertureMotorStepRange(0)
771 , m_deviceApertureMotorSpeedRange(1.0f)
772 , m_deviceExposureCompensationRange(0.0f)
773 , m_deviceIspDigitalGainRange(Argus::Range<float>(0.0f))
774 , m_sensorExposureTimeRange(Argus::Range<uint64_t>(0))
775 , m_sensorAnalogGainRange(Argus::Range<float>(0.0f))
776 , m_sensorFrameRateRange(0.0f)
777 , m_deviceIndex(new ValidatorStdVector<uint32_t, Argus::CameraDevice*>(&m_cameraDevices), 0)
778 , m_deviceOpen(false)
779 , m_sensorModeValid(false)
782 , m_exposureTimeRange(new ValidatorRange<Argus::Range<uint64_t> >(&m_sensorExposureTimeRange),
783 Argus::Range<uint64_t>(0))
784 , m_gainRange(new ValidatorRange<Argus::Range<float > >(&m_sensorAnalogGainRange),
785 Argus::Range<float>(0.0f))
786 , m_sensorModeIndex(new ValidatorEnum<uint32_t>(), 0)
787 , m_frameRate(new ValidatorRange<float>(&m_sensorFrameRateRange), 0.0f)
788 , m_focusPosition(new ValidatorRange<int32_t>(&m_deviceFocusPositionRange), 0)
789 , m_apertureMotorStep(new ValidatorRange<int32_t>(&m_deviceApertureMotorStepRange), 0)
790 , m_apertureMotorSpeed(new ValidatorRange<float>(&m_deviceApertureMotorSpeedRange), 1.0f)
791 , m_captureYuvFormat(new ValidatorEnum<Argus::PixelFormat>(
792 s_captureYuvFormatTypes,
793 sizeof(s_captureYuvFormatTypes) / sizeof(s_captureYuvFormatTypes[0])),
794 Argus::PIXEL_FMT_YCbCr_420_888)
795 , m_denoiseMode(new ValidatorEnum<Argus::DenoiseMode>(
796 s_denoiseModes, sizeof(s_denoiseModes) / sizeof(s_denoiseModes[0])),
797 Argus::DENOISE_MODE_FAST)
798 , m_denoiseStrength(new ValidatorRange<float>(-1.0f, 1.0f), -1.0f)
799 , m_edgeEnhanceMode(new ValidatorEnum<Argus::EdgeEnhanceMode>(
800 s_edgeEnhanceModes, sizeof(s_edgeEnhanceModes) / sizeof(s_edgeEnhanceModes[0])),
801 Argus::EDGE_ENHANCE_MODE_FAST)
802 , m_edgeEnhanceStrength(new ValidatorRange<float>(-1.0f, 1.0f), -1.0f)
803 , m_aeAntibandingMode(new ValidatorEnum<Argus::AeAntibandingMode>(
804 s_aeAntibandingModes, sizeof(s_aeAntibandingModes) / sizeof(s_aeAntibandingModes[0])),
805 Argus::AE_ANTIBANDING_MODE_AUTO)
808 , m_awbMode(new ValidatorEnum<Argus::AwbMode>(
809 s_awbModes, sizeof(s_awbModes) / sizeof(s_awbModes[0])),
810 Argus::AWB_MODE_AUTO)
811 , m_exposureCompensation(new ValidatorRange<float>(&m_deviceExposureCompensationRange), 0.0f)
812 , m_ispDigitalGainRange(new ValidatorRange<Argus::Range<float> >(&m_deviceIspDigitalGainRange),
813 Argus::Range<float>(1.0f))
815 s_stillFileTypes, sizeof(s_stillFileTypes) / sizeof(s_stillFileTypes[0])),
817 , m_videoFormat(new ValidatorEnum<
VideoPipeline::VideoFormat>(
818 s_videoFormats, sizeof(s_videoFormats) / sizeof(s_videoFormats[0])),
820 , m_videoFileType(new ValidatorEnum<
VideoPipeline::VideoFileType>(
821 s_videoFileTypes, sizeof(s_videoFileTypes) / sizeof(s_videoFileTypes[0])),
823 , m_videoBitRate(new ValidatorRange<uint32_t>(0,
VideoPipeline::VIDEO_BITRATE_MAX),0)
824 , m_outputSize(new ValidatorSize2D<uint32_t>(s_outputSizes,
825 sizeof(s_outputSizes) / sizeof(s_outputSizes[0]), true ),
826 Argus::Size2D<uint32_t>(0, 0))
828 , m_deFogEnable(false)
829 , m_deFogAmount(new ValidatorRange<float>(0.0f, 1.0f), 0.9f)
830 , m_deFogQuality(new ValidatorRange<float>(0.0f, 1.0f), 0.14285f)
831 , m_initialized(false)
832 , m_iCameraProvider(NULL)
840 REPORT_ERROR(
"Failed to shutdown");
845 static InitOnce initOnce;
848 if (initOnce.begin())
857 REPORT_ERROR(
"Initalization failed");
870 m_cameraProvider = Argus::UniqueObj<Argus::CameraProvider>(Argus::CameraProvider::create());
872 if (!m_iCameraProvider)
873 ORIGINATE_ERROR(
"Failed to create CameraProvider");
874 printf(
"Argus Version: %s\n", m_iCameraProvider->getVersion().c_str());
881 ORIGINATE_ERROR(
"No cameras available");
888 PROPAGATE_ERROR_CONTINUE(
m_deviceIndex.registerObserver(
this,
904 PROPAGATE_ERROR_CONTINUE(
m_deviceIndex.unregisterObserver(
this,
918 assert(
static_cast<const Value<uint32_t>&
>(source).
get() ==
m_deviceIndex);
932 const Argus::ICameraProperties *iCameraProperties =
934 if (!iCameraProperties)
935 ORIGINATE_ERROR(
"Failed to get ICameraProperties interface");
938 if (iCameraProperties->getAllSensorModes(&
m_sensorModes) != Argus::STATUS_OK)
939 ORIGINATE_ERROR(
"Failed to get sensor modes");
942 ORIGINATE_ERROR(
"No sensor modes found");
954 Argus::Range<float> digitalGainRange = iCameraProperties->getIspDigitalGainRange();
955 Argus::Range<float> deviceExposureCompensationRange =
956 iCameraProperties->getExposureCompensationRange();
965 Argus::Range<float> unifiedDigitalGainRange(0);
966 unifiedDigitalGainRange.min() =
968 unifiedDigitalGainRange.max() =
971 Argus::Range<float> unifiedExposureCompensationRange(0);
972 unifiedExposureCompensationRange.min() =
974 deviceExposureCompensationRange.min());
975 unifiedExposureCompensationRange.max() =
977 deviceExposureCompensationRange.max());
980 Argus::Range<Argus::Range<float> >(unifiedDigitalGainRange)));
982 Argus::Range<float> (unifiedExposureCompensationRange)));
990 digitalGainRange, digitalGainRange)));
992 deviceExposureCompensationRange)));
996 std::vector<ValidatorEnum<uint32_t>::ValueStringPair> valueStringPairs;
998 for (
size_t index = 0; index <
m_sensorModes.size(); ++index)
1000 Argus::ISensorMode *sensorMode =
1001 Argus::interface_cast<Argus::ISensorMode>(
m_sensorModes[index]);
1003 valueStringPairs[index].value = (uint32_t)index;
1005 std::ostringstream stream;
1006 stream << index <<
": "
1007 << sensorMode->getResolution().width() <<
"x" << sensorMode->getResolution().height();
1009 Argus::Ext::IPwlWdrSensorMode* pwlMode =
1010 Argus::interface_cast<Argus::Ext::IPwlWdrSensorMode>(
m_sensorModes[index]);
1012 Argus::Ext::IDolWdrSensorMode* dolMode =
1013 Argus::interface_cast<Argus::Ext::IDolWdrSensorMode>(
m_sensorModes[index]);
1016 stream <<
" @" << sensorMode->getInputBitDepth() <<
"bpp -> " <<
1017 sensorMode->getOutputBitDepth() <<
"bpp";
1021 stream <<
" @" << sensorMode->getOutputBitDepth() <<
"bpp -> " <<
1022 dolMode->getExposureCount() <<
" exposure" <<
" DOL WDR";
1026 stream <<
" @" << sensorMode->getOutputBitDepth() <<
"bpp";
1029 valueStringPairs[index].string = stream.str();
1032 ValidatorEnum<uint32_t> *validator =
1034 PROPAGATE_ERROR(validator->setValidValues(valueStringPairs.data(), valueStringPairs.size()));
1051 Argus::ISensorMode *iSensorMode =
1054 ORIGINATE_ERROR(
"Failed to get ISensorMode interface");
1057 Argus::Range<uint64_t> sensorExposureTimeRange = iSensorMode->getExposureTimeRange();
1058 Argus::Range<float> sensorAnalogGainRange = iSensorMode->getAnalogGainRange();
1059 Argus::Range<TimeValue> sensorFrameDurationRange(
1062 Argus::Range<float> sensorFrameRateRange(
1063 sensorFrameDurationRange.max().toCyclesPerSec(),
1064 sensorFrameDurationRange.min().toCyclesPerSec());
1067 Argus::Range<uint64_t> unifiedSensorExposureTimeRange(0);
1068 unifiedSensorExposureTimeRange.min() =
1070 unifiedSensorExposureTimeRange.max() =
1072 Argus::Range<float> unifiedSensorAnalogGainRange(0);
1073 unifiedSensorAnalogGainRange.min() =
1075 unifiedSensorAnalogGainRange.max() =
1077 Argus::Range<float> unifiedSensorFrameRateRange(0.0f);
1078 unifiedSensorFrameRateRange.min() =
1080 unifiedSensorFrameRateRange.max() =
1084 Argus::Range<Argus::Range<uint64_t> >(unifiedSensorExposureTimeRange)));
1086 Argus::Range<Argus::Range<float> >(unifiedSensorAnalogGainRange)));
1091 PROPAGATE_ERROR(
m_gainRange.set(sensorAnalogGainRange));
1092 PROPAGATE_ERROR(
m_frameRate.set(sensorFrameRateRange.max()));
1096 sensorExposureTimeRange, sensorExposureTimeRange)));
1098 sensorAnalogGainRange, sensorAnalogGainRange)));
1112 std::ostringstream stream;
1116 stream <<
"Argus extensions:" << std::endl;
1117 stream <<
" BayerSharpnessMap: " <<
1119 "supported" :
"not supported") << std::endl;
1120 stream <<
" DebugCaptureSession: " <<
1122 "supported" :
"not supported") << std::endl;
1123 stream <<
" DeFog: " <<
1125 "supported" :
"not supported") << std::endl;
1126 stream <<
" FaceDetect: " <<
1128 "supported" :
"not supported") << std::endl;
1129 stream <<
" InternalFrameCount: " <<
1131 "supported" :
"not supported") << std::endl;
1132 stream <<
" SensorPrivateMetadata: " <<
1134 "supported" :
"not supported") << std::endl;
1136 stream <<
"Number of camera devices: " <<
m_cameraDevices.size() << std::endl;
1138 for (uint32_t deviceIndex = 0; deviceIndex <
m_cameraDevices.size(); ++deviceIndex)
1140 stream <<
"Device: " << deviceIndex << std::endl;
1142 const Argus::ICameraProperties *iCameraProperties =
1143 Argus::interface_cast<Argus::ICameraProperties>(
m_cameraDevices[deviceIndex]);
1144 if (!iCameraProperties)
1145 ORIGINATE_ERROR(
"Failed to get ICameraProperties interface");
1147 stream <<
" Max AE Regions: " <<
1148 iCameraProperties->getMaxAeRegions() << std::endl;
1149 stream <<
" Max AWB Regions: " <<
1150 iCameraProperties->getMaxAwbRegions() << std::endl;
1151 stream <<
" Focus Position Range: " <<
1152 iCameraProperties->getFocusPositionRange().min() <<
" - " <<
1153 iCameraProperties->getFocusPositionRange().max() << std::endl;
1154 stream <<
" Aperture Motor Step Range: " <<
1155 iCameraProperties->getApertureMotorStepRange().min() <<
" - " <<
1156 iCameraProperties->getApertureMotorStepRange().max() << std::endl;
1157 stream <<
" Aperture Motor Speed Range: " <<
1158 iCameraProperties->getApertureMotorSpeedRange().min() <<
" - " <<
1159 iCameraProperties->getApertureMotorSpeedRange().max() << std::endl;
1160 stream <<
" Lens Aperture Range: " <<
1161 iCameraProperties->getLensApertureRange().min() <<
" - " <<
1162 iCameraProperties->getLensApertureRange().max() << std::endl;
1163 stream <<
" Isp Digital Gain Range: " <<
1164 iCameraProperties->getIspDigitalGainRange().min() <<
" - " <<
1165 iCameraProperties->getIspDigitalGainRange().max() << std::endl;
1168 std::vector<Argus::SensorMode*> sensorModes;
1169 iCameraProperties->getAllSensorModes(&sensorModes);
1170 stream <<
" Number of sensor modes: " << sensorModes.size() << std::endl;
1171 for (uint32_t sensorModeIndex = 0; sensorModeIndex < sensorModes.size(); ++sensorModeIndex)
1173 Argus::ISensorMode *sensorMode =
1174 Argus::interface_cast<Argus::ISensorMode>(sensorModes[sensorModeIndex]);
1176 ORIGINATE_ERROR(
"Failed to get ISensorMode interface");
1180 sensorMode->getFrameDurationRange().min()).toCyclesPerSec();
1182 sensorMode->getFrameDurationRange().max()).toCyclesPerSec();
1184 stream <<
" Sensor mode: " << sensorModeIndex << std::endl;
1185 stream <<
" Resolution: " <<
1186 sensorMode->getResolution().width() <<
"x" <<
1187 sensorMode->getResolution().height() << std::endl;
1188 stream <<
" Exposure time range: " <<
1189 sensorMode->getExposureTimeRange().min() <<
" - " <<
1190 sensorMode->getExposureTimeRange().max() <<
" ns" << std::endl;
1191 stream <<
" Frame duration range: " <<
1192 sensorMode->getFrameDurationRange().min() <<
" - " <<
1193 sensorMode->getFrameDurationRange().max() <<
" ns" << std::endl;
1194 stream <<
" Framerate range: " <<
1195 minimum_fps <<
" - " <<
1196 maximum_fps <<
" fps" << std::endl;
1197 stream <<
" InputBitDepth: " <<
1198 sensorMode->getInputBitDepth() << std::endl;
1199 stream <<
" OutputBitDepth: " <<
1200 sensorMode->getOutputBitDepth() << std::endl;
1201 stream <<
" Analog gain range: " <<
1202 sensorMode->getAnalogGainRange().min() <<
" - " <<
1203 sensorMode->getAnalogGainRange().max() << std::endl;
1205 stream <<
" SensorModeType: " <<
1206 sensorMode->getSensorModeType().getName() << std::endl;
1208 Argus::Ext::IPwlWdrSensorMode* pwlMode =
1209 Argus::interface_cast<Argus::Ext::IPwlWdrSensorMode>(sensorModes[sensorModeIndex]);
1211 Argus::Ext::IDolWdrSensorMode* dolMode =
1212 Argus::interface_cast<Argus::Ext::IDolWdrSensorMode>(sensorModes[sensorModeIndex]);
1216 stream <<
" Piecewise Linear (PWL) WDR Extension supported with: " <<
1217 pwlMode->getControlPointCount() <<
" control points." << std::endl;
1218 std::vector< Argus::Point2D<float> > points;
1219 Argus::Status status = pwlMode->getControlPoints(&points);
1220 if (status != Argus::STATUS_OK)
1221 ORIGINATE_ERROR(
"Error obtaining control points");
1222 stream <<
" - Control Points: " << std::endl;
1223 for (uint32_t j = 0; j < pwlMode->getControlPointCount(); j++)
1225 stream <<
" (" << points[j].x() <<
", " <<
1226 points[j].y() <<
")" << std::endl;
1231 stream <<
" Digital Overlap (DOL) WDR Extension supported with: " << std::endl <<
1232 " - Number of Exposures: " <<
1233 dolMode->getExposureCount() << std::endl <<
1234 " - Number of Optical Black Lines per exposure: " <<
1235 dolMode->getOpticalBlackRowCount() << std::endl <<
1236 " - Number of Line Info marker pixels per row per exposure: " <<
1237 dolMode->getLineInfoMarkerWidth() << std::endl <<
1238 " - Number of margin pixels on left per row per exposure: " <<
1239 dolMode->getLeftMarginWidth() << std::endl <<
1240 " - Number of margin pixels on right per row per exposure: " <<
1241 dolMode->getRightMarginWidth() << std::endl;
1243 std::vector<u_int32_t> verticalBlankPeriodRowCounts;
1244 Argus::Status status =
1245 dolMode->getVerticalBlankPeriodRowCount(&verticalBlankPeriodRowCounts);
1246 if (status != Argus::STATUS_OK)
1247 ORIGINATE_ERROR(
"Error obtaining vertical blank period offsets per exposure");
1248 stream <<
" - Vertical blank period section row counts per exposure: "
1250 for (uint32_t j = 0; j < verticalBlankPeriodRowCounts.size(); j++)
1252 stream <<
" - VBP-section[" << j <<
"] : "
1253 << verticalBlankPeriodRowCounts[j] << std::endl;
1256 stream <<
" - Physical Resolution: " <<
1257 dolMode->getPhysicalResolution().width() <<
"x" <<
1258 dolMode->getPhysicalResolution().height() << std::endl;
1261 stream << std::endl;
1265 info = stream.str();
1275 ORIGINATE_ERROR(
"Invalid sensor mode index");
1305 uint32_t deviceIndex)
1310 ORIGINATE_ERROR(
"Invalid device index");
1317 Argus::UniqueObj<Argus::CaptureSession> newSession(
1320 ORIGINATE_ERROR(
"Failed to create CaptureSession");
1322 PROPAGATE_ERROR(session.
reset(newSession.release(),
this));
1332 Argus::Ext::IDebugCaptureSession *iDebugCaptureSession =
1333 Argus::interface_cast<Argus::Ext::IDebugCaptureSession>(it->m_session);
1334 if (!iDebugCaptureSession)
1335 ORIGINATE_ERROR(
"DebugCaptureSession extension not supported");
1337 const Argus::Status status = iDebugCaptureSession->dump(STDOUT_FILENO);
1338 if (status != Argus::STATUS_OK)
1339 ORIGINATE_ERROR(
"Failed to get dump runtime info");
1378 if (it->m_session == session)
1385 ORIGINATE_ERROR(
"Session not found");
1389 Argus::CaptureSession *session)
1398 Argus::IEventProvider *iEventProvider = Argus::interface_cast<Argus::IEventProvider>(session);
1399 if (!iEventProvider)
1400 ORIGINATE_ERROR(
"Failed to get iEventProvider interface");
1403 const Argus::Status status = iEventProvider->waitForEvents(eventQueue, timeout.
toNSec());
1404 if ((status != Argus::STATUS_OK) && (status != Argus::STATUS_TIMEOUT))
1405 ORIGINATE_ERROR(
"Failed to get events");
1411 Argus::CaptureIntent captureIntent, Argus::CaptureSession *session)
1420 Argus::ICaptureSession *iCaptureSession =
1421 Argus::interface_cast<Argus::ICaptureSession>(session);
1422 if (!iCaptureSession)
1423 ORIGINATE_ERROR(
"Failed to get ICaptureSession interface");
1426 Argus::UniqueObj<Argus::Request> newRequest =
1427 Argus::UniqueObj<Argus::Request>(iCaptureSession->createRequest(captureIntent));
1429 ORIGINATE_ERROR(
"Failed to create request");
1432 Argus::IRequest *iRequest = Argus::interface_cast<Argus::IRequest>(newRequest);
1434 ORIGINATE_ERROR(
"Failed to get IRequest interface");
1437 Argus::ISourceSettings *iSourceSettings =
1438 Argus::interface_cast<Argus::ISourceSettings>(iRequest->getSourceSettings());
1439 if (!iSourceSettings)
1440 ORIGINATE_ERROR(
"Failed to get ISourceSettings interface");
1446 Argus::IAutoControlSettings *iAutoControlSettings =
1447 Argus::interface_cast<Argus::IAutoControlSettings>(iRequest->getAutoControlSettings());
1448 if (!iAutoControlSettings)
1449 ORIGINATE_ERROR(
"Failed to get IAutoControlSettings interface");
1455 Argus::IDenoiseSettings *iDenoiseSettings =
1456 Argus::interface_cast<Argus::IDenoiseSettings>(newRequest);
1457 if (!iDenoiseSettings)
1458 ORIGINATE_ERROR(
"Failed to get IDenoiseSettings interface");
1462 Argus::IEdgeEnhanceSettings *iEdgeEnhanceSettings =
1463 Argus::interface_cast<Argus::IEdgeEnhanceSettings>(newRequest);
1464 if (!iEdgeEnhanceSettings)
1465 ORIGINATE_ERROR(
"Failed to get IEdgeEnhanceSettings interface");
1471 Argus::Ext::IDeFogSettings *iDeFogSettings =
1472 Argus::interface_cast<Argus::Ext::IDeFogSettings>(newRequest);
1480 PROPAGATE_ERROR(request.
reset(newRequest.release(),
this));
1492 Argus::IRequest *iRequest = Argus::interface_cast<Argus::IRequest>(request);
1494 ORIGINATE_ERROR(
"Failed to get IRequest interface");
1497 Argus::ISourceSettings *iSourceSettings =
1498 Argus::interface_cast<Argus::ISourceSettings>(iRequest->getSourceSettings());
1499 if (!iSourceSettings)
1500 ORIGINATE_ERROR(
"Failed to get ISourceSettings interface");
1506 Argus::IAutoControlSettings *iAutoControlSettings =
1507 Argus::interface_cast<Argus::IAutoControlSettings>(iRequest->getAutoControlSettings());
1508 if (!iAutoControlSettings)
1509 ORIGINATE_ERROR(
"Failed to get IAutoControlSettings interface");
1515 Argus::IDenoiseSettings *iDenoiseSettings =
1516 Argus::interface_cast<Argus::IDenoiseSettings>(request);
1517 if (!iDenoiseSettings)
1518 ORIGINATE_ERROR(
"Failed to get IDenoiseSettings interface");
1522 Argus::IEdgeEnhanceSettings *iEdgeEnhanceSettings =
1523 Argus::interface_cast<Argus::IEdgeEnhanceSettings>(request);
1524 if (!iEdgeEnhanceSettings)
1525 ORIGINATE_ERROR(
"Failed to get IEdgeEnhanceSettings interface");
1531 Argus::Ext::IDeFogSettings *iDeFogSettings =
1532 Argus::interface_cast<Argus::Ext::IDeFogSettings>(request);
1544 Argus::UniqueObj<Argus::EventQueue>& eventQueue, Argus::CaptureSession *session)
1553 Argus::IEventProvider *iEventProvider =
1554 Argus::interface_cast<Argus::IEventProvider>(session);
1555 if (!iEventProvider)
1556 ORIGINATE_ERROR(
"Failed to get IEventProvider interface");
1558 Argus::EventQueue *newEventQueue = iEventProvider->createEventQueue(eventTypes);
1560 ORIGINATE_ERROR(
"Failed to create eventQueue");
1562 eventQueue.reset(newEventQueue);
1576 Argus::ICaptureSession *iCaptureSession =
1577 Argus::interface_cast<Argus::ICaptureSession>(session);
1578 if (!iCaptureSession)
1579 ORIGINATE_ERROR(
"Failed to get ICaptureSession interface");
1581 if (iCaptureSession->capture(request, Argus::TIMEOUT_INFINITE) == 0)
1582 ORIGINATE_ERROR(
"Failed to submit the still capture request");
1596 Argus::ICaptureSession *iCaptureSession =
1597 Argus::interface_cast<Argus::ICaptureSession>(session);
1598 if (!iCaptureSession)
1599 ORIGINATE_ERROR(
"Failed to get ICaptureSession interface");
1601 if (iCaptureSession->repeat(request) != Argus::STATUS_OK)
1602 ORIGINATE_ERROR(
"Failed to submit repeating capture request");
1609 if (it->m_session == session)
1611 it->m_requests.push_back(request);
1617 ORIGINATE_ERROR(
"Did not find the session in the list of active sessions");
1623 Argus::CaptureSession *session)
1632 Argus::ICaptureSession *iCaptureSession =
1633 Argus::interface_cast<Argus::ICaptureSession>(session);
1634 if (!iCaptureSession)
1635 ORIGINATE_ERROR(
"Failed to get ICaptureSession interface");
1637 if (iCaptureSession->repeatBurst(requestList) != Argus::STATUS_OK)
1638 ORIGINATE_ERROR(
"Failed to submit repeating burst request");
1645 if (it->m_session == session)
1647 it->m_requests.insert(it->m_requests.end(), requestList.begin(), requestList.end());
1653 ORIGINATE_ERROR(
"Did not find the session in the list of active sessions");
1667 Argus::ICaptureSession *iCaptureSession =
1668 Argus::interface_cast<Argus::ICaptureSession>(session);
1669 if (!iCaptureSession)
1670 ORIGINATE_ERROR(
"Failed to get ICaptureSession interface");
1672 iCaptureSession->stopRepeat();
1679 if (it->m_session == session)
1681 it->m_requests.clear();
1687 ORIGINATE_ERROR(
"Did not find the session in the list of active sessions");
1697 if (!it->m_requests.empty())
1699 Argus::ICaptureSession *iCaptureSession =
1700 Argus::interface_cast<Argus::ICaptureSession>(it->m_session);
1701 if (!iCaptureSession)
1702 ORIGINATE_ERROR(
"Failed to get ICaptureSession interface");
1704 iCaptureSession->stopRepeat();
1706 if (iCaptureSession->repeatBurst(it->m_requests) != Argus::STATUS_OK)
1707 ORIGINATE_ERROR(
"Failed to submit repeating burst request");
1723 Argus::ICaptureSession *iCaptureSession =
1724 Argus::interface_cast<Argus::ICaptureSession>(session);
1725 if (!iCaptureSession)
1727 REPORT_ERROR(
"Failed to get ICaptureSession interface");
1731 return iCaptureSession->maxBurstRequests();
1743 Argus::ICaptureSession *iCaptureSession =
1744 Argus::interface_cast<Argus::ICaptureSession>(session);
1745 if (!iCaptureSession)
1746 ORIGINATE_ERROR(
"Failed to get ICaptureSession interface");
1748 if (iCaptureSession->waitForIdle() != Argus::STATUS_OK)
1749 ORIGINATE_ERROR(
"Waiting for idle failed");
1762 Argus::ISensorMode *sensorMode =
1765 ORIGINATE_ERROR(
"Failed to get ISensorMode interface");
1766 *size = sensorMode->getResolution();
1777 Argus::UniqueObj<Argus::OutputStream> &stream, Argus::CaptureSession *session)
1786 Argus::IRequest *iRequest = Argus::interface_cast<Argus::IRequest>(request);
1788 ORIGINATE_ERROR(
"Failed to get IRequest interface");
1790 Argus::Size2D<uint32_t> outputSize;
1793 Argus::ICaptureSession *iCaptureSession =
1794 Argus::interface_cast<Argus::ICaptureSession>(session);
1795 if (!iCaptureSession)
1796 ORIGINATE_ERROR(
"Failed to get ICaptureSession interface");
1798 Argus::UniqueObj<Argus::OutputStreamSettings> outputStreamSettings(
1799 iCaptureSession->createOutputStreamSettings(Argus::STREAM_TYPE_EGL));
1800 Argus::IEGLOutputStreamSettings* iEGLOutputStreamSettings =
1801 Argus::interface_cast<Argus::IEGLOutputStreamSettings>(outputStreamSettings);
1802 if (!iEGLOutputStreamSettings)
1803 ORIGINATE_ERROR(
"Failed to get IEGLOutputStreamSettings interface");
1806 iEGLOutputStreamSettings->setResolution(outputSize);
1808 iEGLOutputStreamSettings->setMetadataEnable(enableMetadata);
1810 Argus::UniqueObj<Argus::OutputStream> outputStream(
1811 iCaptureSession->createOutputStream(outputStreamSettings.get()));
1813 ORIGINATE_ERROR(
"Failed to create OutputStream");
1815 stream.reset(outputStream.release());
1822 Argus::IRequest *iRequest = Argus::interface_cast<Argus::IRequest>(request);
1824 ORIGINATE_ERROR(
"Failed to get IRequest interface");
1827 if (iRequest->enableOutputStream(stream) != Argus::STATUS_OK)
1828 ORIGINATE_ERROR(
"Failed to enable the output stream");
1835 Argus::IRequest *iRequest = Argus::interface_cast<Argus::IRequest>(request);
1837 ORIGINATE_ERROR(
"Failed to get IRequest interface");
1840 if (iRequest->disableOutputStream(stream) != Argus::STATUS_OK)
1841 ORIGINATE_ERROR(
"Failed to disable the output stream");
1848 UniquePointer<DenoiseSettingsObserver> denoiseSettings;
1851 if (!denoiseSettings)
1852 ORIGINATE_ERROR(
"Out of memory");
1854 m_observers.push_front(denoiseSettings.release());
1860 UniquePointer<EdgeEnhanceSettingsObserver> edgeEnhanceSettings;
1863 if (!edgeEnhanceSettings)
1864 ORIGINATE_ERROR(
"Out of memory");
1866 m_observers.push_front(edgeEnhanceSettings.release());
1872 UniquePointer<SourceSettingsObserver> sourceSettings;
1875 if (!sourceSettings)
1876 ORIGINATE_ERROR(
"Out of memory");
1884 UniquePointer<AutoControlSettingsObserver> autoControlSettings;
1887 if (!autoControlSettings)
1888 ORIGINATE_ERROR(
"Out of memory");
1890 m_observers.push_front(autoControlSettings.release());
1896 UniquePointer<DeFogSettingsObserver> deFogSettings;
1900 ORIGINATE_ERROR(
"Out of memory");
1908 for (std::list<IObserverForInterface*>::iterator it =
m_observers.begin();
1911 if ((*it)->isInterface(interface))
1919 ORIGINATE_ERROR(
"Observer not found");
1928 va_start(list, msg);
1930 if (vprintf(msg, list) < 0)
1933 ORIGINATE_ERROR(
"Failed to print message");