Argus Camera Sample Argus Camera Sample

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
AppModuleMultiExposure.cpp
Go to the documentation of this file.
1 /*
2 * Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of NVIDIA CORPORATION nor the names of its
13 * contributors may be used to endorse or promote products derived
14 * from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
24 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29 #include "AppModuleMultiExposure.h"
30 #include "Options.h"
31 #include "Error.h"
32
33 namespace ArgusSamples
34 {
35
36 AppModuleMultiExposure::AppModuleMultiExposure()
37 : m_initialized(false)
38 , m_running(false)
39 , m_guiContainerConfig(NULL)
40 , m_guiConfig(NULL)
41 {
42 }
43
44 AppModuleMultiExposure::~AppModuleMultiExposure()
45 {
46 shutdown();
47 }
48
49 bool AppModuleMultiExposure::initialize(Options &options)
50 {
51 if (m_initialized)
52 return true;
53
54 PROPAGATE_ERROR(m_multiExposure.initialize());
55
56 PROPAGATE_ERROR(options.addOption(
57 createValueOption("exposurerange", 0, "RANGE", "set the exposure range to RANGE.",
58 m_multiExposure.m_exposureRange)));
59 PROPAGATE_ERROR(options.addOption(
60 createValueOption("exposuresteps", 0, "COUNT", "sample the exposure range at COUNT steps.",
61 m_multiExposure.m_exposureSteps)));
62
63 m_initialized = true;
64
65 return true;
66 }
67
68 bool AppModuleMultiExposure::shutdown()
69 {
70 if (!m_initialized)
71 return true;
72
73 PROPAGATE_ERROR_CONTINUE(stop());
74
75 PROPAGATE_ERROR_CONTINUE(m_multiExposure.shutdown());
76
77 delete m_guiConfig;
78 m_guiConfig = NULL;
79
80 m_guiContainerConfig = NULL;
81
82 m_initialized = false;
83
84 return true;
85 }
86
87 bool AppModuleMultiExposure::start(Window::IGuiMenuBar *iGuiMenuBar,
88 Window::IGuiContainer *iGuiContainerConfig)
89 {
90 if (m_running)
91 return true;
92
93 // initialize the GUI
94 if (iGuiContainerConfig && !m_guiConfig)
95 {
96 // initialize the GUI
97
98 // create a grid container
99 PROPAGATE_ERROR(Window::IGuiContainerGrid::create(&m_guiConfig));
100
101 // create the elements
102 UniquePointer<Window::IGuiElement> element;
103
104 Window::IGuiContainerGrid::BuildHelper buildHelper(m_guiConfig);
105
106 #define CREATE_GUI_ELEMENT(_NAME, _VALUE) \
107 PROPAGATE_ERROR(Window::IGuiElement::createValue(&_VALUE, &element)); \
108 PROPAGATE_ERROR(buildHelper.append(_NAME, element.get())); \
109 element.release();
110
111 CREATE_GUI_ELEMENT("Exposure Range", m_multiExposure.m_exposureRange);
112 CREATE_GUI_ELEMENT("Exposure Steps", m_multiExposure.m_exposureSteps);
113
114 #undef CREATE_GUI_ELEMENT
115
116 m_guiContainerConfig = iGuiContainerConfig;
117 }
118
119 if (m_guiContainerConfig)
120 PROPAGATE_ERROR(m_guiContainerConfig->add(m_guiConfig));
121
122 PROPAGATE_ERROR(m_multiExposure.start());
123
124 m_running = true;
125
126 return true;
127 }
128
129 bool AppModuleMultiExposure::stop()
130 {
131 if (!m_running)
132 return true;
133
134 PROPAGATE_ERROR(m_multiExposure.stop());
135
136 if (m_guiContainerConfig)
137 PROPAGATE_ERROR(m_guiContainerConfig->remove(m_guiConfig));
138
139 m_running = false;
140
141 return true;
142 }
143
144 }; // namespace ArgusSamples