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>
53 namespace ArgusSamples
69 virtual bool isInterface(Argus::Interface *interface)
const = 0;
83 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_denoiseMode.registerObserver(
this,
84 static_cast<IObserver::CallbackFunction>(
87 static_cast<IObserver::CallbackFunction>(
96 static_cast<IObserver::CallbackFunction>(
98 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_denoiseMode.unregisterObserver(
this,
99 static_cast<IObserver::CallbackFunction>(
116 ORIGINATE_ERROR(
"Failed to set the denoising mode");
132 ORIGINATE_ERROR(
"Failed to set the denoise strength");
155 static_cast<IObserver::CallbackFunction>(
158 static_cast<IObserver::CallbackFunction>(
167 static_cast<IObserver::CallbackFunction>(
170 static_cast<IObserver::CallbackFunction>(
189 ORIGINATE_ERROR(
"Failed to set the edge enhancement mode");
206 ORIGINATE_ERROR(
"Failed to set the edge enhancement strength");
228 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_vstabMode.registerObserver(
this,
229 static_cast<IObserver::CallbackFunction>(
237 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_vstabMode.unregisterObserver(
this,
238 static_cast<IObserver::CallbackFunction>(
257 ORIGINATE_ERROR(
"Failed to set the video stabilization mode");
281 static_cast<IObserver::CallbackFunction>(
283 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_gainRange.registerObserver(
this,
284 static_cast<IObserver::CallbackFunction>(
287 static_cast<IObserver::CallbackFunction>(
289 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_frameRate.registerObserver(
this,
290 static_cast<IObserver::CallbackFunction>(
292 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_focusPosition.registerObserver(
this,
293 static_cast<IObserver::CallbackFunction>(
301 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_focusPosition.unregisterObserver(
this,
302 static_cast<IObserver::CallbackFunction>(
304 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_frameRate.unregisterObserver(
this,
305 static_cast<IObserver::CallbackFunction>(
308 static_cast<IObserver::CallbackFunction>(
310 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_gainRange.unregisterObserver(
this,
311 static_cast<IObserver::CallbackFunction>(
314 static_cast<IObserver::CallbackFunction>(
333 ORIGINATE_ERROR(
"Failed to set exposure time range");
348 ORIGINATE_ERROR(
"Failed to set gain range");
361 Argus::SensorMode *sensorMode = NULL;
365 ORIGINATE_ERROR(
"Failed to set sensor mode");
381 ORIGINATE_ERROR(
"Failed to set focus position");
395 Argus::Range<uint64_t> frameDurationRangeNs(0);
401 Argus::SensorMode *sensorMode = NULL;
405 Argus::ISensorMode *iSensorMode =
406 Argus::interface_cast<Argus::ISensorMode>(sensorMode);
408 frameDurationRangeNs = iSensorMode->getFrameDurationRange();
413 frameDurationRangeNs =
417 if (
m_iSourceSettings->setFrameDurationRange(frameDurationRangeNs) != Argus::STATUS_OK)
418 ORIGINATE_ERROR(
"Failed to set frame duration range");
441 static_cast<IObserver::CallbackFunction>(
443 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_aeLock.registerObserver(
this,
444 static_cast<IObserver::CallbackFunction>(
446 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_awbLock.registerObserver(
this,
447 static_cast<IObserver::CallbackFunction>(
449 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_awbMode.registerObserver(
this,
450 static_cast<IObserver::CallbackFunction>(
453 static_cast<IObserver::CallbackFunction>(
456 static_cast<IObserver::CallbackFunction>(
466 static_cast<IObserver::CallbackFunction>(
469 static_cast<IObserver::CallbackFunction>(
471 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_awbMode.unregisterObserver(
this,
472 static_cast<IObserver::CallbackFunction>(
474 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_awbLock.unregisterObserver(
this,
475 static_cast<IObserver::CallbackFunction>(
477 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_aeLock.unregisterObserver(
this,
478 static_cast<IObserver::CallbackFunction>(
481 static_cast<IObserver::CallbackFunction>(
500 ORIGINATE_ERROR(
"Failed to set the AE antibanding mode");
512 assert(&source == &dispatcher.
m_aeLock);
515 ORIGINATE_ERROR(
"Failed to set the AE lock");
526 assert(&source == &dispatcher.
m_awbLock);
529 ORIGINATE_ERROR(
"Failed to set the AWB lock");
540 assert(&source == &dispatcher.
m_awbMode);
543 ORIGINATE_ERROR(
"Failed to set the AWB mode");
559 ORIGINATE_ERROR(
"Failed to set the exposure compensation");
576 ORIGINATE_ERROR(
"Failed to set the Isp Digital Gain Range");
598 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_deFogEnable.registerObserver(
this,
600 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_deFogAmount.registerObserver(
this,
602 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_deFogQuality.registerObserver(
this,
610 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_deFogQuality.unregisterObserver(
this,
612 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_deFogAmount.unregisterObserver(
this,
614 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_deFogEnable.unregisterObserver(
this,
644 ORIGINATE_ERROR(
"Failed to set the DeFog amount");
658 ORIGINATE_ERROR(
"Failed to set the DeFog quality");
669 static const ValidatorEnum<Argus::DenoiseMode>::ValueStringPair s_denoiseModes[] =
671 { Argus::DENOISE_MODE_OFF,
"off" },
672 { Argus::DENOISE_MODE_FAST,
"fast" },
673 { Argus::DENOISE_MODE_HIGH_QUALITY,
"highquality" }
677 static const ValidatorEnum<Argus::EdgeEnhanceMode>::ValueStringPair s_edgeEnhanceModes[] =
679 { Argus::EDGE_ENHANCE_MODE_OFF,
"off" },
680 { Argus::EDGE_ENHANCE_MODE_FAST,
"fast" },
681 { Argus::EDGE_ENHANCE_MODE_HIGH_QUALITY,
"highquality" }
685 static const ValidatorEnum<Argus::VideoStabilizationMode>::ValueStringPair s_vstabModes[] =
687 { Argus::VIDEO_STABILIZATION_MODE_OFF,
"off" },
688 { Argus::VIDEO_STABILIZATION_MODE_ON,
"on" }
692 static const ValidatorEnum<Argus::AeAntibandingMode>::ValueStringPair s_aeAntibandingModes[] =
694 { Argus::AE_ANTIBANDING_MODE_OFF,
"off" },
695 { Argus::AE_ANTIBANDING_MODE_AUTO,
"auto" },
696 { Argus::AE_ANTIBANDING_MODE_50HZ,
"50hz" },
697 { Argus::AE_ANTIBANDING_MODE_60HZ,
"60hz" }
701 static const ValidatorEnum<Argus::AwbMode>::ValueStringPair s_awbModes[] =
703 { Argus::AWB_MODE_OFF,
"off" },
704 { Argus::AWB_MODE_AUTO,
"auto" },
705 { Argus::AWB_MODE_INCANDESCENT,
"incandescent" },
706 { Argus::AWB_MODE_FLUORESCENT,
"fluorescent" },
707 { Argus::AWB_MODE_WARM_FLUORESCENT,
"warmfluorescent" },
708 { Argus::AWB_MODE_DAYLIGHT,
"daylight" },
709 { Argus::AWB_MODE_CLOUDY_DAYLIGHT,
"cloudydaylight" },
710 { Argus::AWB_MODE_TWILIGHT,
"twilight" },
711 { Argus::AWB_MODE_SHADE,
"shade" },
712 { Argus::AWB_MODE_MANUAL,
"manual" }
716 static const ValidatorEnum<VideoPipeline::VideoFormat>::ValueStringPair s_videoFormats[] =
724 static const ValidatorEnum<VideoPipeline::VideoFileType>::ValueStringPair s_videoFileTypes[] =
733 static const Argus::Size2D<uint32_t> s_outputSizes[] =
735 Argus::Size2D<uint32_t>(0, 0),
736 Argus::Size2D<uint32_t>(176, 144),
737 Argus::Size2D<uint32_t>(320, 240),
738 Argus::Size2D<uint32_t>(640, 480),
739 Argus::Size2D<uint32_t>(1280, 720),
740 Argus::Size2D<uint32_t>(1920, 1080),
741 Argus::Size2D<uint32_t>(3840, 2160),
745 : m_deviceFocusPositionRange(0)
746 , m_deviceExposureCompensationRange(0.0f)
747 , m_deviceIspDigitalGainRange(Argus::Range<float>(0.0f))
748 , m_sensorExposureTimeRange(Argus::Range<uint64_t>(0))
749 , m_sensorAnalogGainRange(Argus::Range<float>(0.0f))
750 , m_sensorFrameRateRange(0.0f)
751 , m_deviceIndex(new ValidatorStdVector<uint32_t, Argus::CameraDevice*>(&m_cameraDevices), 0)
752 , m_deviceOpen(false)
755 , m_exposureTimeRange(new ValidatorRange<Argus::Range<uint64_t> >(&m_sensorExposureTimeRange),
756 Argus::Range<uint64_t>(0))
757 , m_gainRange(new ValidatorRange<Argus::Range<float > >(&m_sensorAnalogGainRange),
758 Argus::Range<float>(0.0f))
759 , m_sensorModeIndex(new ValidatorEnum<uint32_t>(), 0)
760 , m_frameRate(new ValidatorRange<float>(&m_sensorFrameRateRange), 0.0f)
761 , m_focusPosition(new ValidatorRange<int32_t>(&m_deviceFocusPositionRange), 0)
762 , m_denoiseMode(new ValidatorEnum<Argus::DenoiseMode>(
763 s_denoiseModes, sizeof(s_denoiseModes) / sizeof(s_denoiseModes[0])),
764 Argus::DENOISE_MODE_FAST)
765 , m_denoiseStrength(new ValidatorRange<float>(-1.0f, 1.0f), -1.0f)
766 , m_edgeEnhanceMode(new ValidatorEnum<Argus::EdgeEnhanceMode>(
767 s_edgeEnhanceModes, sizeof(s_edgeEnhanceModes) / sizeof(s_edgeEnhanceModes[0])),
768 Argus::EDGE_ENHANCE_MODE_FAST)
769 , m_edgeEnhanceStrength(new ValidatorRange<float>(-1.0f, 1.0f), -1.0f)
770 , m_vstabMode(new ValidatorEnum<Argus::VideoStabilizationMode>(
771 s_vstabModes, sizeof(s_vstabModes) / sizeof(s_vstabModes[0])),
772 Argus::VIDEO_STABILIZATION_MODE_OFF)
773 , m_aeAntibandingMode(new ValidatorEnum<Argus::AeAntibandingMode>(
774 s_aeAntibandingModes, sizeof(s_aeAntibandingModes) / sizeof(s_aeAntibandingModes[0])),
775 Argus::AE_ANTIBANDING_MODE_AUTO)
778 , m_awbMode(new ValidatorEnum<Argus::AwbMode>(
779 s_awbModes, sizeof(s_awbModes) / sizeof(s_awbModes[0])),
780 Argus::AWB_MODE_AUTO)
781 , m_exposureCompensation(new ValidatorRange<float>(&m_deviceExposureCompensationRange), 0.0f)
782 , m_ispDigitalGainRange(new ValidatorRange<Argus::Range<float> >(&m_deviceIspDigitalGainRange),
783 Argus::Range<float>(1.0f))
784 , m_videoFormat(new ValidatorEnum<
VideoPipeline::VideoFormat>(
785 s_videoFormats, sizeof(s_videoFormats) / sizeof(s_videoFormats[0])),
787 , m_videoFileType(new ValidatorEnum<
VideoPipeline::VideoFileType>(
788 s_videoFileTypes, sizeof(s_videoFileTypes) / sizeof(s_videoFileTypes[0])),
790 , m_videoBitRate(new ValidatorRange<uint32_t>(0, std::numeric_limits<uint32_t>::max()), 0)
791 , m_outputSize(new ValidatorSize2D<uint32_t>(s_outputSizes,
792 sizeof(s_outputSizes) / sizeof(s_outputSizes[0]), true ),
793 Argus::Size2D<uint32_t>(0, 0))
795 , m_deFogEnable(false)
796 , m_deFogAmount(new ValidatorRange<float>(0.0f, 1.0f), 0.9f)
797 , m_deFogQuality(new ValidatorRange<float>(0.0f, 1.0f), 0.14285f)
798 , m_initialized(false)
799 , m_iCameraProvider(NULL)
807 REPORT_ERROR(
"Failed to shutdown");
812 static InitOnce initOnce;
815 if (initOnce.begin())
824 REPORT_ERROR(
"Initalization failed");
837 m_cameraProvider = Argus::UniqueObj<Argus::CameraProvider>(Argus::CameraProvider::create());
839 if (!m_iCameraProvider)
840 ORIGINATE_ERROR(
"Failed to create CameraProvider");
841 printf(
"Argus Version: %s\n", m_iCameraProvider->getVersion().c_str());
848 ORIGINATE_ERROR(
"No cameras available");
855 PROPAGATE_ERROR_CONTINUE(
m_deviceIndex.registerObserver(
this,
871 PROPAGATE_ERROR_CONTINUE(
m_deviceIndex.unregisterObserver(
this,
885 assert(
static_cast<const Value<uint32_t>&
>(source).
get() ==
m_deviceIndex);
899 const Argus::ICameraProperties *iCameraProperties =
901 if (!iCameraProperties)
902 ORIGINATE_ERROR(
"Failed to get ICameraProperties interface");
905 if (iCameraProperties->getAllSensorModes(&
m_sensorModes) != Argus::STATUS_OK)
906 ORIGINATE_ERROR(
"Failed to get sensor modes");
909 ORIGINATE_ERROR(
"No sensor modes found");
915 Argus::Range<float> digitalGainRange = iCameraProperties->getIspDigitalGainRange();
916 Argus::Range<float> deviceExposureCompensationRange =
917 iCameraProperties->getExposureCompensationRange();
926 Argus::Range<float> unifiedDigitalGainRange(0);
927 unifiedDigitalGainRange.min() =
929 unifiedDigitalGainRange.max() =
932 Argus::Range<float> unifiedExposureCompensationRange(0);
933 unifiedExposureCompensationRange.min() =
935 deviceExposureCompensationRange.min());
936 unifiedExposureCompensationRange.max() =
938 deviceExposureCompensationRange.max());
941 Argus::Range<Argus::Range<float> >(unifiedDigitalGainRange)));
943 Argus::Range<float> (unifiedExposureCompensationRange)));
951 digitalGainRange, digitalGainRange)));
953 deviceExposureCompensationRange)));
957 std::vector<ValidatorEnum<uint32_t>::ValueStringPair> valueStringPairs;
959 for (
size_t index = 0; index <
m_sensorModes.size(); ++index)
961 Argus::ISensorMode *sensorMode =
962 Argus::interface_cast<Argus::ISensorMode>(
m_sensorModes[index]);
964 valueStringPairs[index].value = (uint32_t)index;
966 std::ostringstream stream;
967 stream << index <<
": "
968 << sensorMode->getResolution().width() <<
"x" << sensorMode->getResolution().height();
970 Argus::Ext::IPwlWdrSensorMode* pwlMode =
971 Argus::interface_cast<Argus::Ext::IPwlWdrSensorMode>(
m_sensorModes[index]);
974 stream <<
" @" << sensorMode->getInputBitDepth() <<
"bpp -> " <<
975 sensorMode->getOutputBitDepth() <<
"bpp";
979 stream <<
" @" << sensorMode->getOutputBitDepth() <<
"bpp";
981 valueStringPairs[index].string = stream.str();
984 ValidatorEnum<uint32_t> *validator =
986 PROPAGATE_ERROR(validator->setValidValues(valueStringPairs.data(), valueStringPairs.size()));
1002 Argus::ISensorMode *iSensorMode =
1005 ORIGINATE_ERROR(
"Failed to get ISensorMode interface");
1008 Argus::Range<uint64_t> sensorExposureTimeRange = iSensorMode->getExposureTimeRange();
1009 Argus::Range<float> sensorAnalogGainRange = iSensorMode->getAnalogGainRange();
1010 Argus::Range<TimeValue> sensorFrameDurationRange(
1013 Argus::Range<float> sensorFrameRateRange(
1014 sensorFrameDurationRange.max().toCyclesPerSec(),
1015 sensorFrameDurationRange.min().toCyclesPerSec());
1018 Argus::Range<uint64_t> unifiedSensorExposureTimeRange(0);
1019 unifiedSensorExposureTimeRange.min() =
1021 unifiedSensorExposureTimeRange.max() =
1023 Argus::Range<float> unifiedSensorAnalogGainRange(0);
1024 unifiedSensorAnalogGainRange.min() =
1026 unifiedSensorAnalogGainRange.max() =
1028 Argus::Range<float> unifiedSensorFrameRateRange(0.0f);
1029 unifiedSensorFrameRateRange.min() =
1031 unifiedSensorFrameRateRange.max() =
1035 Argus::Range<Argus::Range<uint64_t> >(unifiedSensorExposureTimeRange)));
1037 Argus::Range<Argus::Range<float> >(unifiedSensorAnalogGainRange)));
1042 PROPAGATE_ERROR(
m_gainRange.set(sensorAnalogGainRange));
1043 PROPAGATE_ERROR(
m_frameRate.set(sensorFrameRateRange.max()));
1047 sensorExposureTimeRange, sensorExposureTimeRange)));
1049 sensorAnalogGainRange, sensorAnalogGainRange)));
1062 std::ostringstream stream;
1066 stream <<
"Argus extensions:" << std::endl;
1067 stream <<
" BayerSharpnessMap: " <<
1069 "supported" :
"not supported") << std::endl;
1070 stream <<
" DebugCaptureSession: " <<
1072 "supported" :
"not supported") << std::endl;
1073 stream <<
" DeFog: " <<
1075 "supported" :
"not supported") << std::endl;
1076 stream <<
" FaceDetect: " <<
1078 "supported" :
"not supported") << std::endl;
1079 stream <<
" InternalFrameCount: " <<
1081 "supported" :
"not supported") << std::endl;
1082 stream <<
" SensorPrivateMetadata: " <<
1084 "supported" :
"not supported") << std::endl;
1086 stream <<
"Number of camera devices: " <<
m_cameraDevices.size() << std::endl;
1088 for (uint32_t deviceIndex = 0; deviceIndex <
m_cameraDevices.size(); ++deviceIndex)
1090 stream <<
"Device: " << deviceIndex << std::endl;
1092 const Argus::ICameraProperties *iCameraProperties =
1093 Argus::interface_cast<Argus::ICameraProperties>(
m_cameraDevices[deviceIndex]);
1094 if (!iCameraProperties)
1095 ORIGINATE_ERROR(
"Failed to get ICameraProperties interface");
1097 stream <<
" Max AE Regions: " <<
1098 iCameraProperties->getMaxAeRegions() << std::endl;
1099 stream <<
" Max AWB Regions: " <<
1100 iCameraProperties->getMaxAwbRegions() << std::endl;
1101 stream <<
" Focus Position Range: " <<
1102 iCameraProperties->getFocusPositionRange().min() <<
" - " <<
1103 iCameraProperties->getFocusPositionRange().max() << std::endl;
1104 stream <<
" Lens Aperture Range: " <<
1105 iCameraProperties->getLensApertureRange().min() <<
" - " <<
1106 iCameraProperties->getLensApertureRange().max() << std::endl;
1107 stream <<
" Isp Digital Gain Range: " <<
1108 iCameraProperties->getIspDigitalGainRange().min() <<
" - " <<
1109 iCameraProperties->getIspDigitalGainRange().max() << std::endl;
1112 std::vector<Argus::SensorMode*> sensorModes;
1113 iCameraProperties->getAllSensorModes(&sensorModes);
1114 stream <<
" Number of sensor modes: " << sensorModes.size() << std::endl;
1115 for (uint32_t sensorModeIndex = 0; sensorModeIndex < sensorModes.size(); ++sensorModeIndex)
1117 Argus::ISensorMode *sensorMode =
1118 Argus::interface_cast<Argus::ISensorMode>(sensorModes[sensorModeIndex]);
1120 ORIGINATE_ERROR(
"Failed to get ISensorMode interface");
1124 sensorMode->getFrameDurationRange().min()).toCyclesPerSec();
1126 sensorMode->getFrameDurationRange().max()).toCyclesPerSec();
1128 stream <<
" Sensor mode: " << sensorModeIndex << std::endl;
1129 stream <<
" Resolution: " <<
1130 sensorMode->getResolution().width() <<
"x" <<
1131 sensorMode->getResolution().height() << std::endl;
1132 stream <<
" Exposure time range: " <<
1133 sensorMode->getExposureTimeRange().min() <<
" - " <<
1134 sensorMode->getExposureTimeRange().max() <<
" ns" << std::endl;
1135 stream <<
" Frame duration range: " <<
1136 sensorMode->getFrameDurationRange().min() <<
" - " <<
1137 sensorMode->getFrameDurationRange().max() <<
" ns" << std::endl;
1138 stream <<
" Framerate range: " <<
1139 minimum_fps <<
" - " <<
1140 maximum_fps <<
" fps" << std::endl;
1141 stream <<
" InputBitDepth: " <<
1142 sensorMode->getInputBitDepth() << std::endl;
1143 stream <<
" OutputBitDepth: " <<
1144 sensorMode->getOutputBitDepth() << std::endl;
1145 stream <<
" Analog gain range: " <<
1146 sensorMode->getAnalogGainRange().min() <<
" - " <<
1147 sensorMode->getAnalogGainRange().max() << std::endl;
1149 stream <<
" SensorModeType: " <<
1150 sensorMode->getSensorModeType().getName() << std::endl;
1152 Argus::Ext::IPwlWdrSensorMode* pwlMode =
1153 Argus::interface_cast<Argus::Ext::IPwlWdrSensorMode>(sensorModes[sensorModeIndex]);
1156 stream <<
" Piecewise Linear WDR Extension supported with: " <<
1157 pwlMode->getControlPointCount() <<
" control points." << std::endl;
1158 std::vector< Argus::Point2D<float> > points;
1159 Argus::Status status = pwlMode->getControlPoints(&points);
1160 if (status != Argus::STATUS_OK)
1161 ORIGINATE_ERROR(
"Error obtaining control points");
1162 stream <<
" Control Points: " << std::endl;
1163 for (uint32_t j = 0; j < pwlMode->getControlPointCount(); j++)
1165 stream <<
" (" << points[j].x() <<
", " <<
1166 points[j].y() <<
")" << std::endl;
1170 stream << std::endl;
1174 info = stream.str();
1184 ORIGINATE_ERROR(
"Invalid sensor mode index");
1204 uint32_t deviceIndex)
1209 ORIGINATE_ERROR(
"Invalid device index");
1216 Argus::UniqueObj<Argus::CaptureSession> newSession(
1219 ORIGINATE_ERROR(
"Failed to create CaptureSession");
1221 PROPAGATE_ERROR(session.
reset(newSession.release(),
this));
1231 Argus::Ext::IDebugCaptureSession *iDebugCaptureSession =
1232 Argus::interface_cast<Argus::Ext::IDebugCaptureSession>(it->m_session);
1233 if (!iDebugCaptureSession)
1234 ORIGINATE_ERROR(
"DebugCaptureSession extension not supported");
1236 const Argus::Status status = iDebugCaptureSession->dump(STDOUT_FILENO);
1237 if (status != Argus::STATUS_OK)
1238 ORIGINATE_ERROR(
"Failed to get dump runtime info");
1277 if (it->m_session == session)
1284 ORIGINATE_ERROR(
"Session not found");
1288 Argus::CaptureSession *session)
1297 Argus::IEventProvider *iEventProvider = Argus::interface_cast<Argus::IEventProvider>(session);
1298 if (!iEventProvider)
1299 ORIGINATE_ERROR(
"Failed to get iEventProvider interface");
1302 const Argus::Status status = iEventProvider->waitForEvents(eventQueue, timeout.
toNSec());
1303 if ((status != Argus::STATUS_OK) && (status != Argus::STATUS_TIMEOUT))
1304 ORIGINATE_ERROR(
"Failed to get events");
1310 Argus::CaptureIntent captureIntent, Argus::CaptureSession *session)
1319 Argus::ICaptureSession *iCaptureSession =
1320 Argus::interface_cast<Argus::ICaptureSession>(session);
1321 if (!iCaptureSession)
1322 ORIGINATE_ERROR(
"Failed to get ICaptureSession interface");
1325 Argus::UniqueObj<Argus::Request> newRequest =
1326 Argus::UniqueObj<Argus::Request>(iCaptureSession->createRequest(captureIntent));
1328 ORIGINATE_ERROR(
"Failed to create request");
1331 Argus::IRequest *iRequest = Argus::interface_cast<Argus::IRequest>(newRequest);
1333 ORIGINATE_ERROR(
"Failed to get IRequest interface");
1336 Argus::ISourceSettings *iSourceSettings =
1337 Argus::interface_cast<Argus::ISourceSettings>(iRequest->getSourceSettings());
1338 if (!iSourceSettings)
1339 ORIGINATE_ERROR(
"Failed to get ISourceSettings interface");
1345 Argus::IAutoControlSettings *iAutoControlSettings =
1346 Argus::interface_cast<Argus::IAutoControlSettings>(iRequest->getAutoControlSettings());
1347 if (!iAutoControlSettings)
1348 ORIGINATE_ERROR(
"Failed to get IAutoControlSettings interface");
1354 Argus::IDenoiseSettings *iDenoiseSettings =
1355 Argus::interface_cast<Argus::IDenoiseSettings>(newRequest);
1356 if (!iDenoiseSettings)
1357 ORIGINATE_ERROR(
"Failed to get IDenoiseSettings interface");
1361 Argus::IEdgeEnhanceSettings *iEdgeEnhanceSettings =
1362 Argus::interface_cast<Argus::IEdgeEnhanceSettings>(newRequest);
1363 if (!iEdgeEnhanceSettings)
1364 ORIGINATE_ERROR(
"Failed to get IEdgeEnhanceSettings interface");
1368 Argus::IVideoStabilizationSettings *iVideoStabilizationSettings =
1369 Argus::interface_cast<Argus::IVideoStabilizationSettings>(newRequest);
1370 if (!iVideoStabilizationSettings)
1371 ORIGINATE_ERROR(
"Failed to get IVideoStabilizationSettings interface");
1377 Argus::Ext::IDeFogSettings *iDeFogSettings =
1378 Argus::interface_cast<Argus::Ext::IDeFogSettings>(newRequest);
1386 PROPAGATE_ERROR(request.
reset(newRequest.release(),
this));
1398 Argus::IRequest *iRequest = Argus::interface_cast<Argus::IRequest>(request);
1400 ORIGINATE_ERROR(
"Failed to get IRequest interface");
1403 Argus::ISourceSettings *iSourceSettings =
1404 Argus::interface_cast<Argus::ISourceSettings>(iRequest->getSourceSettings());
1405 if (!iSourceSettings)
1406 ORIGINATE_ERROR(
"Failed to get ISourceSettings interface");
1412 Argus::IAutoControlSettings *iAutoControlSettings =
1413 Argus::interface_cast<Argus::IAutoControlSettings>(iRequest->getAutoControlSettings());
1414 if (!iAutoControlSettings)
1415 ORIGINATE_ERROR(
"Failed to get IAutoControlSettings interface");
1421 Argus::IDenoiseSettings *iDenoiseSettings =
1422 Argus::interface_cast<Argus::IDenoiseSettings>(request);
1423 if (!iDenoiseSettings)
1424 ORIGINATE_ERROR(
"Failed to get IDenoiseSettings interface");
1428 Argus::IEdgeEnhanceSettings *iEdgeEnhanceSettings =
1429 Argus::interface_cast<Argus::IEdgeEnhanceSettings>(request);
1430 if (!iEdgeEnhanceSettings)
1431 ORIGINATE_ERROR(
"Failed to get IEdgeEnhanceSettings interface");
1435 Argus::IVideoStabilizationSettings *iVideoStabilizationSettings =
1436 Argus::interface_cast<Argus::IVideoStabilizationSettings>(request);
1437 if (!iVideoStabilizationSettings)
1438 ORIGINATE_ERROR(
"Failed to get IVideoStabilizationSettings interface");
1444 Argus::Ext::IDeFogSettings *iDeFogSettings =
1445 Argus::interface_cast<Argus::Ext::IDeFogSettings>(request);
1457 Argus::UniqueObj<Argus::EventQueue>& eventQueue, Argus::CaptureSession *session)
1466 Argus::IEventProvider *iEventProvider =
1467 Argus::interface_cast<Argus::IEventProvider>(session);
1468 if (!iEventProvider)
1469 ORIGINATE_ERROR(
"Failed to get IEventProvider interface");
1471 Argus::EventQueue *newEventQueue = iEventProvider->createEventQueue(eventTypes);
1473 ORIGINATE_ERROR(
"Failed to create eventQueue");
1475 eventQueue.reset(newEventQueue);
1489 Argus::ICaptureSession *iCaptureSession =
1490 Argus::interface_cast<Argus::ICaptureSession>(session);
1491 if (!iCaptureSession)
1492 ORIGINATE_ERROR(
"Failed to get ICaptureSession interface");
1494 if (iCaptureSession->capture(request, Argus::TIMEOUT_INFINITE) == 0)
1495 ORIGINATE_ERROR(
"Failed to submit the still capture request");
1509 Argus::ICaptureSession *iCaptureSession =
1510 Argus::interface_cast<Argus::ICaptureSession>(session);
1511 if (!iCaptureSession)
1512 ORIGINATE_ERROR(
"Failed to get ICaptureSession interface");
1514 if (iCaptureSession->repeat(request) != Argus::STATUS_OK)
1515 ORIGINATE_ERROR(
"Failed to submit repeating capture request");
1522 if (it->m_session == session)
1524 it->m_requests.push_back(request);
1530 ORIGINATE_ERROR(
"Did not find the session in the list of active sessions");
1536 Argus::CaptureSession *session)
1545 Argus::ICaptureSession *iCaptureSession =
1546 Argus::interface_cast<Argus::ICaptureSession>(session);
1547 if (!iCaptureSession)
1548 ORIGINATE_ERROR(
"Failed to get ICaptureSession interface");
1550 if (iCaptureSession->repeatBurst(requestList) != Argus::STATUS_OK)
1551 ORIGINATE_ERROR(
"Failed to submit repeating burst request");
1558 if (it->m_session == session)
1560 it->m_requests.insert(it->m_requests.end(), requestList.begin(), requestList.end());
1566 ORIGINATE_ERROR(
"Did not find the session in the list of active sessions");
1580 Argus::ICaptureSession *iCaptureSession =
1581 Argus::interface_cast<Argus::ICaptureSession>(session);
1582 if (!iCaptureSession)
1583 ORIGINATE_ERROR(
"Failed to get ICaptureSession interface");
1585 iCaptureSession->stopRepeat();
1592 if (it->m_session == session)
1594 it->m_requests.clear();
1600 ORIGINATE_ERROR(
"Did not find the session in the list of active sessions");
1610 if (!it->m_requests.empty())
1612 Argus::ICaptureSession *iCaptureSession =
1613 Argus::interface_cast<Argus::ICaptureSession>(it->m_session);
1614 if (!iCaptureSession)
1615 ORIGINATE_ERROR(
"Failed to get ICaptureSession interface");
1617 iCaptureSession->stopRepeat();
1619 if (iCaptureSession->repeatBurst(it->m_requests) != Argus::STATUS_OK)
1620 ORIGINATE_ERROR(
"Failed to submit repeating burst request");
1636 Argus::ICaptureSession *iCaptureSession =
1637 Argus::interface_cast<Argus::ICaptureSession>(session);
1638 if (!iCaptureSession)
1640 REPORT_ERROR(
"Failed to get ICaptureSession interface");
1644 return iCaptureSession->maxBurstRequests();
1656 Argus::ICaptureSession *iCaptureSession =
1657 Argus::interface_cast<Argus::ICaptureSession>(session);
1658 if (!iCaptureSession)
1659 ORIGINATE_ERROR(
"Failed to get ICaptureSession interface");
1661 if (iCaptureSession->waitForIdle() != Argus::STATUS_OK)
1662 ORIGINATE_ERROR(
"Waiting for idle failed");
1675 Argus::ISensorMode *sensorMode =
1678 ORIGINATE_ERROR(
"Failed to get ISensorMode interface");
1679 *size = sensorMode->getResolution();
1690 Argus::UniqueObj<Argus::OutputStream> &stream, Argus::CaptureSession *session)
1699 Argus::IRequest *iRequest = Argus::interface_cast<Argus::IRequest>(request);
1701 ORIGINATE_ERROR(
"Failed to get IRequest interface");
1703 Argus::Size2D<uint32_t> outputSize;
1706 Argus::ICaptureSession *iCaptureSession =
1707 Argus::interface_cast<Argus::ICaptureSession>(session);
1708 if (!iCaptureSession)
1709 ORIGINATE_ERROR(
"Failed to get ICaptureSession interface");
1711 Argus::UniqueObj<Argus::OutputStreamSettings> outputStreamSettings(
1712 iCaptureSession->createOutputStreamSettings());
1713 Argus::IOutputStreamSettings* iOutputStreamSettings =
1714 Argus::interface_cast<Argus::IOutputStreamSettings>(outputStreamSettings);
1715 if (!iOutputStreamSettings)
1716 ORIGINATE_ERROR(
"Failed to get IOutputStreamSettings interface");
1718 iOutputStreamSettings->setPixelFormat(Argus::PIXEL_FMT_YCbCr_420_888);
1719 iOutputStreamSettings->setResolution(outputSize);
1721 iOutputStreamSettings->setMetadataEnable(enableMetadata);
1723 Argus::UniqueObj<Argus::OutputStream> outputStream(
1724 iCaptureSession->createOutputStream(outputStreamSettings.get()));
1726 ORIGINATE_ERROR(
"Failed to create OutputStream");
1728 stream.reset(outputStream.release());
1735 Argus::IRequest *iRequest = Argus::interface_cast<Argus::IRequest>(request);
1737 ORIGINATE_ERROR(
"Failed to get IRequest interface");
1740 if (iRequest->enableOutputStream(stream) != Argus::STATUS_OK)
1741 ORIGINATE_ERROR(
"Failed to enable the output stream");
1748 Argus::IRequest *iRequest = Argus::interface_cast<Argus::IRequest>(request);
1750 ORIGINATE_ERROR(
"Failed to get IRequest interface");
1753 if (iRequest->disableOutputStream(stream) != Argus::STATUS_OK)
1754 ORIGINATE_ERROR(
"Failed to disable the output stream");
1761 UniquePointer<DenoiseSettingsObserver> denoiseSettings;
1764 if (!denoiseSettings)
1765 ORIGINATE_ERROR(
"Out of memory");
1767 m_observers.push_front(denoiseSettings.release());
1773 UniquePointer<EdgeEnhanceSettingsObserver> edgeEnhanceSettings;
1776 if (!edgeEnhanceSettings)
1777 ORIGINATE_ERROR(
"Out of memory");
1779 m_observers.push_front(edgeEnhanceSettings.release());
1785 UniquePointer<VideoStabilizationSettingsObserver> vStabSettings;
1789 ORIGINATE_ERROR(
"Out of memory");
1797 UniquePointer<SourceSettingsObserver> sourceSettings;
1800 if (!sourceSettings)
1801 ORIGINATE_ERROR(
"Out of memory");
1809 UniquePointer<AutoControlSettingsObserver> autoControlSettings;
1812 if (!autoControlSettings)
1813 ORIGINATE_ERROR(
"Out of memory");
1815 m_observers.push_front(autoControlSettings.release());
1821 UniquePointer<DeFogSettingsObserver> deFogSettings;
1825 ORIGINATE_ERROR(
"Out of memory");
1833 for (std::list<IObserverForInterface*>::iterator it =
m_observers.begin();
1836 if ((*it)->isInterface(interface))
1844 ORIGINATE_ERROR(
"Observer not found");
1853 va_start(list, msg);
1855 if (vprintf(msg, list) < 0)
1858 ORIGINATE_ERROR(
"Failed to print message");