39 #include "UniquePointer.h"
43 #include "Validator.h"
44 #include <Argus/Ext/BayerSharpnessMap.h>
45 #include <Argus/Ext/DebugCaptureMetadata.h>
46 #include <Argus/Ext/DebugCaptureSession.h>
47 #include <Argus/Ext/DeFog.h>
48 #include <Argus/Ext/FaceDetect.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>(
95 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_denoiseMode.unregisterObserver(
this,
96 static_cast<IObserver::CallbackFunction>(
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>(
302 static_cast<IObserver::CallbackFunction>(
304 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_gainRange.unregisterObserver(
this,
305 static_cast<IObserver::CallbackFunction>(
308 static_cast<IObserver::CallbackFunction>(
310 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_frameRate.unregisterObserver(
this,
311 static_cast<IObserver::CallbackFunction>(
313 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_focusPosition.unregisterObserver(
this,
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>(
468 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_aeLock.unregisterObserver(
this,
469 static_cast<IObserver::CallbackFunction>(
471 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_awbLock.unregisterObserver(
this,
472 static_cast<IObserver::CallbackFunction>(
474 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_awbMode.unregisterObserver(
this,
475 static_cast<IObserver::CallbackFunction>(
478 static_cast<IObserver::CallbackFunction>(
481 static_cast<IObserver::CallbackFunction>(
501 ORIGINATE_ERROR(
"Failed to set the AE antibanding mode");
513 assert(&source == &dispatcher.
m_aeLock);
516 ORIGINATE_ERROR(
"Failed to set the AE lock");
527 assert(&source == &dispatcher.
m_awbLock);
530 ORIGINATE_ERROR(
"Failed to set the AWB lock");
541 assert(&source == &dispatcher.
m_awbMode);
544 ORIGINATE_ERROR(
"Failed to set the AWB mode");
560 ORIGINATE_ERROR(
"Failed to set the exposure compensation");
577 ORIGINATE_ERROR(
"Failed to set the Isp Digital Gain Range");
599 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_deFogEnable.registerObserver(
this,
601 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_deFogAmount.registerObserver(
this,
603 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_deFogQuality.registerObserver(
this,
611 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_deFogEnable.unregisterObserver(
this,
613 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_deFogAmount.unregisterObserver(
this,
615 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_deFogQuality.unregisterObserver(
this,
645 ORIGINATE_ERROR(
"Failed to set the DeFog amount");
659 ORIGINATE_ERROR(
"Failed to set the DeFog quality");
670 static const ValidatorEnum<Argus::DenoiseMode>::ValueStringPair s_denoiseModes[] =
672 { Argus::DENOISE_MODE_OFF,
"off" },
673 { Argus::DENOISE_MODE_FAST,
"fast" },
674 { Argus::DENOISE_MODE_HIGH_QUALITY,
"highquality" }
678 static const ValidatorEnum<Argus::EdgeEnhanceMode>::ValueStringPair s_edgeEnhanceModes[] =
680 { Argus::EDGE_ENHANCE_MODE_OFF,
"off" },
681 { Argus::EDGE_ENHANCE_MODE_FAST,
"fast" },
682 { Argus::EDGE_ENHANCE_MODE_HIGH_QUALITY,
"highquality" }
686 static const ValidatorEnum<Argus::VideoStabilizationMode>::ValueStringPair s_vstabModes[] =
688 { Argus::VIDEO_STABILIZATION_MODE_OFF,
"off" },
689 { Argus::VIDEO_STABILIZATION_MODE_ON,
"on" }
693 static const ValidatorEnum<Argus::AeAntibandingMode>::ValueStringPair s_aeAntibandingModes[] =
695 { Argus::AE_ANTIBANDING_MODE_OFF,
"off" },
696 { Argus::AE_ANTIBANDING_MODE_AUTO,
"auto" },
697 { Argus::AE_ANTIBANDING_MODE_50HZ,
"50hz" },
698 { Argus::AE_ANTIBANDING_MODE_60HZ,
"60hz" }
702 static const ValidatorEnum<Argus::AwbMode>::ValueStringPair s_awbModes[] =
704 { Argus::AWB_MODE_OFF,
"off" },
705 { Argus::AWB_MODE_AUTO,
"auto" },
706 { Argus::AWB_MODE_INCANDESCENT,
"incandescent" },
707 { Argus::AWB_MODE_FLUORESCENT,
"fluorescent" },
708 { Argus::AWB_MODE_WARM_FLUORESCENT,
"warmfluorescent" },
709 { Argus::AWB_MODE_DAYLIGHT,
"daylight" },
710 { Argus::AWB_MODE_CLOUDY_DAYLIGHT,
"cloudydaylight" },
711 { Argus::AWB_MODE_TWILIGHT,
"twilight" },
712 { Argus::AWB_MODE_SHADE,
"shade" },
713 { Argus::AWB_MODE_MANUAL,
"manual" }
717 static const ValidatorEnum<VideoPipeline::VideoFormat>::ValueStringPair s_videoFormats[] =
725 static const ValidatorEnum<VideoPipeline::VideoFileType>::ValueStringPair s_videoFileTypes[] =
734 static const Argus::Size2D<uint32_t> s_outputSizes[] =
736 Argus::Size2D<uint32_t>(0, 0),
737 Argus::Size2D<uint32_t>(176, 144),
738 Argus::Size2D<uint32_t>(320, 240),
739 Argus::Size2D<uint32_t>(640, 480),
740 Argus::Size2D<uint32_t>(1280, 720),
741 Argus::Size2D<uint32_t>(1920, 1080),
742 Argus::Size2D<uint32_t>(3840, 2160),
746 : m_deviceFocusPositionRange(0)
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_OFF)
765 , m_denoiseStrength(new ValidatorRange<float>(0.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_OFF)
769 , m_edgeEnhanceStrength(new ValidatorRange<float>(0.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>(-10.0f, 10.0f), 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");
847 ORIGINATE_ERROR(
"No cameras available");
854 PROPAGATE_ERROR_CONTINUE(
m_deviceIndex.registerObserver(
this,
874 assert(
static_cast<const Value<uint32_t>&
>(source).
get() ==
m_deviceIndex);
888 const Argus::ICameraProperties *iCameraProperties =
890 if (!iCameraProperties)
891 ORIGINATE_ERROR(
"Failed to get ICameraProperties interface");
894 if (iCameraProperties->getAllSensorModes(&
m_sensorModes) != Argus::STATUS_OK)
895 ORIGINATE_ERROR(
"Failed to get sensor modes");
898 ORIGINATE_ERROR(
"No sensor modes found");
904 Argus::Range<float> digitalGainRange = iCameraProperties->getIspDigitalGainRange();
907 Argus::Range<float> unifiedDigitalGainRange(0);
908 unifiedDigitalGainRange.min() =
910 unifiedDigitalGainRange.max() =
914 Argus::Range<Argus::Range<float> >(unifiedDigitalGainRange)));
921 digitalGainRange, digitalGainRange)));
924 std::vector<ValidatorEnum<uint32_t>::ValueStringPair> valueStringPairs;
926 for (
size_t index = 0; index <
m_sensorModes.size(); ++index)
928 Argus::ISensorMode *sensorMode =
929 Argus::interface_cast<Argus::ISensorMode>(
m_sensorModes[index]);
931 valueStringPairs[index].value = (uint32_t)index;
933 std::ostringstream stream;
934 stream << index+1 <<
": "
935 << sensorMode->getResolution().width() <<
"x" << sensorMode->getResolution().height();
937 Argus::Ext::IPwlWdrSensorMode* pwlMode =
938 Argus::interface_cast<Argus::Ext::IPwlWdrSensorMode>(
m_sensorModes[index]);
941 stream <<
" @" << sensorMode->getInputBitDepth() <<
"bpp -> " <<
942 sensorMode->getOutputBitDepth() <<
"bpp";
946 stream <<
" @" << sensorMode->getOutputBitDepth() <<
"bpp";
948 valueStringPairs[index].string = stream.str();
951 ValidatorEnum<uint32_t> *validator =
953 PROPAGATE_ERROR(validator->setValidValues(valueStringPairs.data(), valueStringPairs.size()));
969 Argus::ISensorMode *iSensorMode =
972 ORIGINATE_ERROR(
"Failed to get ISensorMode interface");
975 Argus::Range<uint64_t> sensorExposureTimeRange = iSensorMode->getExposureTimeRange();
976 Argus::Range<float> sensorAnalogGainRange = iSensorMode->getAnalogGainRange();
977 Argus::Range<TimeValue> sensorFrameDurationRange(
980 Argus::Range<float> sensorFrameRateRange(
981 sensorFrameDurationRange.max().toCyclesPerSec(),
982 sensorFrameDurationRange.min().toCyclesPerSec());
985 Argus::Range<uint64_t> unifiedSensorExposureTimeRange(0);
986 unifiedSensorExposureTimeRange.min() =
988 unifiedSensorExposureTimeRange.max() =
990 Argus::Range<float> unifiedSensorAnalogGainRange(0);
991 unifiedSensorAnalogGainRange.min() =
993 unifiedSensorAnalogGainRange.max() =
995 Argus::Range<float> unifiedSensorFrameRateRange(0.0f);
996 unifiedSensorFrameRateRange.min() =
998 unifiedSensorFrameRateRange.max() =
1002 Argus::Range<Argus::Range<uint64_t> >(unifiedSensorExposureTimeRange)));
1004 Argus::Range<Argus::Range<float> >(unifiedSensorAnalogGainRange)));
1009 PROPAGATE_ERROR(
m_gainRange.set(sensorAnalogGainRange));
1010 PROPAGATE_ERROR(
m_frameRate.set(sensorFrameRateRange.max()));
1014 sensorExposureTimeRange, sensorExposureTimeRange)));
1016 sensorAnalogGainRange, sensorAnalogGainRange)));
1029 std::ostringstream stream;
1033 stream <<
"Argus extensions:" << std::endl;
1034 stream <<
" BayerSharpnessMap: " <<
1036 "supported" :
"not supported") << std::endl;
1037 stream <<
" DebugCaptureMetadata: " <<
1039 "supported" :
"not supported") << std::endl;
1040 stream <<
" DebugCaptureSession: " <<
1042 "supported" :
"not supported") << std::endl;
1043 stream <<
" DeFog: " <<
1045 "supported" :
"not supported") << std::endl;
1046 stream <<
" FaceDetect: " <<
1048 "supported" :
"not supported") << std::endl;
1049 stream <<
" SensorPrivateMetadata: " <<
1051 "supported" :
"not supported") << std::endl;
1053 stream <<
"Number of camera devices: " <<
m_cameraDevices.size() << std::endl;
1055 for (uint32_t deviceIndex = 0; deviceIndex <
m_cameraDevices.size(); ++deviceIndex)
1057 stream <<
"Device: " << deviceIndex << std::endl;
1059 const Argus::ICameraProperties *iCameraProperties =
1060 Argus::interface_cast<Argus::ICameraProperties>(
m_cameraDevices[deviceIndex]);
1061 if (!iCameraProperties)
1062 ORIGINATE_ERROR(
"Failed to get ICameraProperties interface");
1064 stream <<
" Max AE Regions: " <<
1065 iCameraProperties->getMaxAeRegions() << std::endl;
1066 stream <<
" Max AWB Regions: " <<
1067 iCameraProperties->getMaxAwbRegions() << std::endl;
1068 stream <<
" Focus Position Range: " <<
1069 iCameraProperties->getFocusPositionRange().min() <<
" - " <<
1070 iCameraProperties->getFocusPositionRange().max() << std::endl;
1071 stream <<
" Lens Aperture Range: " <<
1072 iCameraProperties->getLensApertureRange().min() <<
" - " <<
1073 iCameraProperties->getLensApertureRange().max() << std::endl;
1074 stream <<
" Isp Digital Gain Range: " <<
1075 iCameraProperties->getIspDigitalGainRange().min() <<
" - " <<
1076 iCameraProperties->getIspDigitalGainRange().max() << std::endl;
1079 std::vector<Argus::SensorMode*> sensorModes;
1080 iCameraProperties->getAllSensorModes(&sensorModes);
1081 stream <<
" Number of sensor modes: " << sensorModes.size() << std::endl;
1082 for (uint32_t sensorModeIndex = 0; sensorModeIndex < sensorModes.size(); ++sensorModeIndex)
1084 Argus::ISensorMode *sensorMode =
1085 Argus::interface_cast<Argus::ISensorMode>(sensorModes[sensorModeIndex]);
1087 ORIGINATE_ERROR(
"Failed to get ISensorMode interface");
1091 sensorMode->getFrameDurationRange().min()).toCyclesPerSec();
1093 sensorMode->getFrameDurationRange().max()).toCyclesPerSec();
1095 stream <<
" Sensor mode: " << sensorModeIndex << std::endl;
1096 stream <<
" Resolution: " <<
1097 sensorMode->getResolution().width() <<
"x" <<
1098 sensorMode->getResolution().height() << std::endl;
1099 stream <<
" Exposure time range: " <<
1100 sensorMode->getExposureTimeRange().min() <<
" - " <<
1101 sensorMode->getExposureTimeRange().max() <<
" ns" << std::endl;
1102 stream <<
" Frame duration range: " <<
1103 sensorMode->getFrameDurationRange().min() <<
" - " <<
1104 sensorMode->getFrameDurationRange().max() <<
" ns" << std::endl;
1105 stream <<
" Framerate range: " <<
1106 minimum_fps <<
" - " <<
1107 maximum_fps <<
" fps" << std::endl;
1108 stream <<
" InputBitDepth: " <<
1109 sensorMode->getInputBitDepth() << std::endl;
1110 stream <<
" OutputBitDepth: " <<
1111 sensorMode->getOutputBitDepth() << std::endl;
1112 stream <<
" Analog gain range: " <<
1113 sensorMode->getAnalogGainRange().min() <<
" - " <<
1114 sensorMode->getAnalogGainRange().max() << std::endl;
1116 stream <<
" SensorModeType: " <<
1117 sensorMode->getSensorModeType().getName() << std::endl;
1119 Argus::Ext::IPwlWdrSensorMode* pwlMode =
1120 Argus::interface_cast<Argus::Ext::IPwlWdrSensorMode>(sensorModes[sensorModeIndex]);
1123 stream <<
" Piecewise Linear WDR Extension supported with: " <<
1124 pwlMode->getControlPointCount() <<
" control points." << std::endl;
1125 std::vector< Argus::Point2D<float> > points;
1126 Argus::Status status = pwlMode->getControlPoints(&points);
1127 if (status != Argus::STATUS_OK)
1128 ORIGINATE_ERROR(
"Error obtaining control points");
1129 stream <<
" Control Points: " << std::endl;
1130 for (uint32_t j = 0; j < pwlMode->getControlPointCount(); j++)
1132 stream <<
" (" << points[j].x() <<
", " <<
1133 points[j].y() <<
")" << std::endl;
1137 stream << std::endl;
1141 info = stream.str();
1151 ORIGINATE_ERROR(
"Invalid sensor mode index");
1171 uint32_t deviceIndex)
1176 ORIGINATE_ERROR(
"Invalid device index");
1183 Argus::UniqueObj<Argus::CaptureSession> newSession(
1186 ORIGINATE_ERROR(
"Failed to create CaptureSession");
1188 PROPAGATE_ERROR(session.
reset(newSession.release(),
this));
1198 Argus::Ext::IDebugCaptureSession *iDebugCaptureSession =
1199 Argus::interface_cast<Argus::Ext::IDebugCaptureSession>(it->m_session);
1200 if (!iDebugCaptureSession)
1201 ORIGINATE_ERROR(
"DebugCaptureSession extension not supported");
1203 const Argus::Status status = iDebugCaptureSession->dump(STDOUT_FILENO);
1204 if (status != Argus::STATUS_OK)
1205 ORIGINATE_ERROR(
"Failed to get dump runtime info");
1244 if (it->m_session == session)
1251 ORIGINATE_ERROR(
"Session not found");
1255 Argus::CaptureSession *session)
1264 Argus::IEventProvider *iEventProvider = Argus::interface_cast<Argus::IEventProvider>(session);
1265 if (!iEventProvider)
1266 ORIGINATE_ERROR(
"Failed to get iEventProvider interface");
1269 const Argus::Status status = iEventProvider->waitForEvents(eventQueue, timeout.
toNSec());
1270 if ((status != Argus::STATUS_OK) && (status != Argus::STATUS_TIMEOUT))
1271 ORIGINATE_ERROR(
"Failed to get events");
1277 Argus::CaptureIntent captureIntent, Argus::CaptureSession *session)
1286 Argus::ICaptureSession *iCaptureSession =
1287 Argus::interface_cast<Argus::ICaptureSession>(session);
1288 if (!iCaptureSession)
1289 ORIGINATE_ERROR(
"Failed to get ICaptureSession interface");
1292 Argus::UniqueObj<Argus::Request> newRequest =
1293 Argus::UniqueObj<Argus::Request>(iCaptureSession->createRequest(captureIntent));
1295 ORIGINATE_ERROR(
"Failed to create request");
1298 Argus::IRequest *iRequest = Argus::interface_cast<Argus::IRequest>(newRequest);
1300 ORIGINATE_ERROR(
"Failed to get IRequest interface");
1303 Argus::ISourceSettings *iSourceSettings =
1304 Argus::interface_cast<Argus::ISourceSettings>(iRequest->getSourceSettings());
1305 if (!iSourceSettings)
1306 ORIGINATE_ERROR(
"Failed to get ISourceSettings interface");
1312 Argus::IAutoControlSettings *iAutoControlSettings =
1313 Argus::interface_cast<Argus::IAutoControlSettings>(iRequest->getAutoControlSettings());
1314 if (!iAutoControlSettings)
1315 ORIGINATE_ERROR(
"Failed to get IAutoControlSettings interface");
1321 Argus::IDenoiseSettings *iDenoiseSettings =
1322 Argus::interface_cast<Argus::IDenoiseSettings>(newRequest);
1323 if (!iDenoiseSettings)
1324 ORIGINATE_ERROR(
"Failed to get IDenoiseSettings interface");
1328 Argus::IEdgeEnhanceSettings *iEdgeEnhanceSettings =
1329 Argus::interface_cast<Argus::IEdgeEnhanceSettings>(newRequest);
1330 if (!iEdgeEnhanceSettings)
1331 ORIGINATE_ERROR(
"Failed to get IEdgeEnhanceSettings interface");
1335 Argus::IVideoStabilizationSettings *iVideoStabilizationSettings =
1336 Argus::interface_cast<Argus::IVideoStabilizationSettings>(newRequest);
1337 if (!iVideoStabilizationSettings)
1338 ORIGINATE_ERROR(
"Failed to get IVideoStabilizationSettings interface");
1344 Argus::Ext::IDeFogSettings *iDeFogSettings =
1345 Argus::interface_cast<Argus::Ext::IDeFogSettings>(newRequest);
1353 PROPAGATE_ERROR(request.
reset(newRequest.release(),
this));
1365 Argus::IRequest *iRequest = Argus::interface_cast<Argus::IRequest>(request);
1367 ORIGINATE_ERROR(
"Failed to get IRequest interface");
1370 Argus::ISourceSettings *iSourceSettings =
1371 Argus::interface_cast<Argus::ISourceSettings>(iRequest->getSourceSettings());
1372 if (!iSourceSettings)
1373 ORIGINATE_ERROR(
"Failed to get ISourceSettings interface");
1379 Argus::IAutoControlSettings *iAutoControlSettings =
1380 Argus::interface_cast<Argus::IAutoControlSettings>(iRequest->getAutoControlSettings());
1381 if (!iAutoControlSettings)
1382 ORIGINATE_ERROR(
"Failed to get IAutoControlSettings interface");
1388 Argus::IDenoiseSettings *iDenoiseSettings =
1389 Argus::interface_cast<Argus::IDenoiseSettings>(request);
1390 if (!iDenoiseSettings)
1391 ORIGINATE_ERROR(
"Failed to get IDenoiseSettings interface");
1395 Argus::IEdgeEnhanceSettings *iEdgeEnhanceSettings =
1396 Argus::interface_cast<Argus::IEdgeEnhanceSettings>(request);
1397 if (!iEdgeEnhanceSettings)
1398 ORIGINATE_ERROR(
"Failed to get IEdgeEnhanceSettings interface");
1402 Argus::IVideoStabilizationSettings *iVideoStabilizationSettings =
1403 Argus::interface_cast<Argus::IVideoStabilizationSettings>(request);
1404 if (!iVideoStabilizationSettings)
1405 ORIGINATE_ERROR(
"Failed to get IVideoStabilizationSettings interface");
1411 Argus::Ext::IDeFogSettings *iDeFogSettings =
1412 Argus::interface_cast<Argus::Ext::IDeFogSettings>(request);
1424 Argus::UniqueObj<Argus::EventQueue>& eventQueue, Argus::CaptureSession *session)
1433 Argus::IEventProvider *iEventProvider =
1434 Argus::interface_cast<Argus::IEventProvider>(session);
1435 if (!iEventProvider)
1436 ORIGINATE_ERROR(
"Failed to get IEventProvider interface");
1438 Argus::EventQueue *newEventQueue = iEventProvider->createEventQueue(eventTypes);
1440 ORIGINATE_ERROR(
"Failed to create eventQueue");
1442 eventQueue.reset(newEventQueue);
1456 Argus::ICaptureSession *iCaptureSession =
1457 Argus::interface_cast<Argus::ICaptureSession>(session);
1458 if (!iCaptureSession)
1459 ORIGINATE_ERROR(
"Failed to get ICaptureSession interface");
1461 if (iCaptureSession->capture(request, Argus::TIMEOUT_INFINITE) == 0)
1462 ORIGINATE_ERROR(
"Failed to submit the still capture request");
1476 Argus::ICaptureSession *iCaptureSession =
1477 Argus::interface_cast<Argus::ICaptureSession>(session);
1478 if (!iCaptureSession)
1479 ORIGINATE_ERROR(
"Failed to get ICaptureSession interface");
1481 if (iCaptureSession->repeat(request) != Argus::STATUS_OK)
1482 ORIGINATE_ERROR(
"Failed to submit repeating capture request");
1489 if (it->m_session == session)
1491 it->m_requests.push_back(request);
1497 ORIGINATE_ERROR(
"Did not find the session in the list of active sessions");
1503 Argus::CaptureSession *session)
1512 Argus::ICaptureSession *iCaptureSession =
1513 Argus::interface_cast<Argus::ICaptureSession>(session);
1514 if (!iCaptureSession)
1515 ORIGINATE_ERROR(
"Failed to get ICaptureSession interface");
1517 if (iCaptureSession->repeatBurst(requestList) != Argus::STATUS_OK)
1518 ORIGINATE_ERROR(
"Failed to submit repeating burst request");
1525 if (it->m_session == session)
1527 it->m_requests.insert(it->m_requests.end(), requestList.begin(), requestList.end());
1533 ORIGINATE_ERROR(
"Did not find the session in the list of active sessions");
1547 Argus::ICaptureSession *iCaptureSession =
1548 Argus::interface_cast<Argus::ICaptureSession>(session);
1549 if (!iCaptureSession)
1550 ORIGINATE_ERROR(
"Failed to get ICaptureSession interface");
1552 iCaptureSession->stopRepeat();
1559 if (it->m_session == session)
1561 it->m_requests.clear();
1567 ORIGINATE_ERROR(
"Did not find the session in the list of active sessions");
1577 if (!it->m_requests.empty())
1579 Argus::ICaptureSession *iCaptureSession =
1580 Argus::interface_cast<Argus::ICaptureSession>(it->m_session);
1581 if (!iCaptureSession)
1582 ORIGINATE_ERROR(
"Failed to get ICaptureSession interface");
1584 iCaptureSession->stopRepeat();
1586 if (iCaptureSession->repeatBurst(it->m_requests) != Argus::STATUS_OK)
1587 ORIGINATE_ERROR(
"Failed to submit repeating burst request");
1603 Argus::ICaptureSession *iCaptureSession =
1604 Argus::interface_cast<Argus::ICaptureSession>(session);
1605 if (!iCaptureSession)
1607 REPORT_ERROR(
"Failed to get ICaptureSession interface");
1611 return iCaptureSession->maxBurstRequests();
1623 Argus::ICaptureSession *iCaptureSession =
1624 Argus::interface_cast<Argus::ICaptureSession>(session);
1625 if (!iCaptureSession)
1626 ORIGINATE_ERROR(
"Failed to get ICaptureSession interface");
1628 if (iCaptureSession->waitForIdle() != Argus::STATUS_OK)
1629 ORIGINATE_ERROR(
"Waiting for idle failed");
1642 Argus::ISensorMode *sensorMode =
1645 ORIGINATE_ERROR(
"Failed to get ISensorMode interface");
1646 *size = sensorMode->getResolution();
1657 Argus::UniqueObj<Argus::OutputStream> &stream, Argus::CaptureSession *session)
1666 Argus::IRequest *iRequest = Argus::interface_cast<Argus::IRequest>(request);
1668 ORIGINATE_ERROR(
"Failed to get IRequest interface");
1670 Argus::Size2D<uint32_t> outputSize;
1673 Argus::ICaptureSession *iCaptureSession =
1674 Argus::interface_cast<Argus::ICaptureSession>(session);
1675 if (!iCaptureSession)
1676 ORIGINATE_ERROR(
"Failed to get ICaptureSession interface");
1678 Argus::UniqueObj<Argus::OutputStreamSettings> outputStreamSettings(
1679 iCaptureSession->createOutputStreamSettings());
1680 Argus::IOutputStreamSettings* iOutputStreamSettings =
1681 Argus::interface_cast<Argus::IOutputStreamSettings>(outputStreamSettings);
1682 if (!iOutputStreamSettings)
1683 ORIGINATE_ERROR(
"Failed to get IOutputStreamSettings interface");
1685 iOutputStreamSettings->setPixelFormat(Argus::PIXEL_FMT_YCbCr_420_888);
1686 iOutputStreamSettings->setResolution(outputSize);
1689 Argus::UniqueObj<Argus::OutputStream> outputStream(
1690 iCaptureSession->createOutputStream(outputStreamSettings.get()));
1692 ORIGINATE_ERROR(
"Failed to create OutputStream");
1694 stream.reset(outputStream.release());
1701 Argus::IRequest *iRequest = Argus::interface_cast<Argus::IRequest>(request);
1703 ORIGINATE_ERROR(
"Failed to get IRequest interface");
1706 if (iRequest->enableOutputStream(stream) != Argus::STATUS_OK)
1707 ORIGINATE_ERROR(
"Failed to enable the output stream");
1714 Argus::IRequest *iRequest = Argus::interface_cast<Argus::IRequest>(request);
1716 ORIGINATE_ERROR(
"Failed to get IRequest interface");
1719 if (iRequest->disableOutputStream(stream) != Argus::STATUS_OK)
1720 ORIGINATE_ERROR(
"Failed to disable the output stream");
1727 UniquePointer<DenoiseSettingsObserver> denoiseSettings;
1730 if (!denoiseSettings)
1731 ORIGINATE_ERROR(
"Out of memory");
1733 m_observers.push_front(denoiseSettings.release());
1739 UniquePointer<EdgeEnhanceSettingsObserver> edgeEnhanceSettings;
1742 if (!edgeEnhanceSettings)
1743 ORIGINATE_ERROR(
"Out of memory");
1745 m_observers.push_front(edgeEnhanceSettings.release());
1751 UniquePointer<VideoStabilizationSettingsObserver> vStabSettings;
1755 ORIGINATE_ERROR(
"Out of memory");
1763 UniquePointer<SourceSettingsObserver> sourceSettings;
1766 if (!sourceSettings)
1767 ORIGINATE_ERROR(
"Out of memory");
1775 UniquePointer<AutoControlSettingsObserver> autoControlSettings;
1778 if (!autoControlSettings)
1779 ORIGINATE_ERROR(
"Out of memory");
1781 m_observers.push_front(autoControlSettings.release());
1787 UniquePointer<DeFogSettingsObserver> deFogSettings;
1791 ORIGINATE_ERROR(
"Out of memory");
1799 for (std::list<IObserverForInterface*>::iterator it =
m_observers.begin();
1802 if ((*it)->isInterface(interface))
1810 ORIGINATE_ERROR(
"Observer not found");
1819 va_start(list, msg);
1821 if (vprintf(msg, list) < 0)
1824 ORIGINATE_ERROR(
"Failed to print message");