35 #include "UniquePointer.h"
37 namespace ArgusSamples
41 : m_exposureStepsRange(3)
42 , m_exposureSteps(new ValidatorRange<uint32_t>(&m_exposureStepsRange), 3)
44 new ValidatorRange<Argus::Range<float> >(
45 Argus::Range<float>(-10.0f, 10.0f),
46 Argus::Range<float>(-10.0f, 10.0f)),
47 Argus::Range<float>(-2.0f, 2.0f))
48 , m_initialized(false)
51 , m_prevRunning(false)
75 PROPAGATE_ERROR(dispatcher.
createRequest(m_request, Argus::CAPTURE_INTENT_STILL_CAPTURE));
77 Argus::IRequest *iRequest = Argus::interface_cast<Argus::IRequest>(m_request.get());
79 ORIGINATE_ERROR(
"Failed to get IRequest interface");
82 Argus::IAutoControlSettings *iAutoControlSettings =
83 Argus::interface_cast<Argus::IAutoControlSettings>(iRequest->getAutoControlSettings());
84 if (!iAutoControlSettings)
85 ORIGINATE_ERROR(
"Failed to get IAutoControlSettings interface");
88 if (iAutoControlSettings->setAeLock(
true) != Argus::STATUS_OK)
89 ORIGINATE_ERROR(
"Failed to set AE lock");
92 if (iAutoControlSettings->setExposureCompensation(exposureCompensation) != Argus::STATUS_OK)
93 ORIGINATE_ERROR(
"Failed to set exposure compensation");
96 PROPAGATE_ERROR(dispatcher.
createOutputStream(m_request.get(),
false, m_outputStream));
98 Argus::IStream *iStream = Argus::interface_cast<Argus::IStream>(m_outputStream.get());
100 ORIGINATE_ERROR(
"Failed to get IStream interface");
103 PROPAGATE_ERROR(composer.
bindStream(iStream->getEGLStream()));
105 const Argus::Size2D<uint32_t> streamSize = iStream->getResolution();
107 (float)streamSize.width() / (float)streamSize.height()));
110 PROPAGATE_ERROR(dispatcher.
enableOutputStream(m_request.get(), m_outputStream.get()));
126 m_outputStream.get()));
128 Argus::IStream *iStream = Argus::interface_cast<Argus::IStream>(m_outputStream);
130 REPORT_ERROR(
"Failed to get IStream interface");
133 iStream->disconnect();
136 PROPAGATE_ERROR_CONTINUE(composer.
unbindStream(iStream->getEGLStream()));
138 m_outputStream.reset();
142 PROPAGATE_ERROR_CONTINUE(m_request.reset());
159 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_deviceOpen.registerObserver(
this,
163 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_outputSize.registerObserver(
this,
179 PROPAGATE_ERROR(
stop());
187 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_outputSize.unregisterObserver(
this,
191 PROPAGATE_ERROR_CONTINUE(dispatcher.
m_deviceOpen.unregisterObserver(
this,
207 PROPAGATE_ERROR_CONTINUE(expLevel->
shutdown());
220 PROPAGATE_ERROR(
stop());
221 PROPAGATE_ERROR(
start());
228 const bool isOpen =
static_cast<const Value<bool>&
>(source).
get();
235 PROPAGATE_ERROR(
stop());
245 PROPAGATE_ERROR(
start());
254 const bool isTrue =
static_cast<const Value<bool>&
>(source).
get();
261 PROPAGATE_ERROR(
stop());
267 PROPAGATE_ERROR(
start());
279 PROPAGATE_ERROR(
stop());
283 PROPAGATE_ERROR(
start());
291 ORIGINATE_ERROR(
"Not initialized");
297 std::ostringstream message;
299 message <<
"Creating " <<
m_exposureSteps <<
" streams with exposure compensation set to ";
302 for (uint32_t requestIndex = 0; requestIndex <
m_exposureSteps; ++requestIndex)
304 UniquePointer<ExpLevel> expLevel(
new ExpLevel);
307 ORIGINATE_ERROR(
"Out of memory");
309 const float exposureCompensation =
310 ((float)requestIndex / (
float)(m_exposureSteps - 1)) *
314 PROPAGATE_ERROR(expLevel->initialize(exposureCompensation));
318 if (requestIndex != 0)
320 message << exposureCompensation <<
" ev";
323 message <<
". " << std::endl;
328 std::vector<const Argus::Request*> requests;
334 Argus::interface_cast<Argus::IStream>(expLevel->
m_outputStream)->getEGLStream(),
true));
349 ORIGINATE_ERROR(
"Not initialized");
362 PROPAGATE_ERROR(composer.setStreamActive(
363 Argus::interface_cast<Argus::IStream>(expLevel->
m_outputStream)->getEGLStream(),
false));