MCPcopy Create free account
hub / github.com/cmauri/eviacam / SetUpCamera

Method SetUpCamera

src/viacamcontroller.cpp:174–279  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

172}
173
174CCamera* CViacamController::SetUpCamera()
175{
176 // Load app local data
177 ReadAppData(wxConfigBase::Get());
178
179 /*
180 Check if cameras detected
181 */
182 int driverId = 0;
183 for (; driverId < CCameraEnum::NUM_DRIVERS; driverId++) {
184 if (CCameraEnum::getNumDevices(driverId) > 0) break;
185 }
186
187 if (driverId == CCameraEnum::NUM_DRIVERS) {
188 /*
189 No cameras found, aborting.
190 */
191 wxMessageDialog errorMsg (NULL, _("Not detected any camera. Aborting"),
192 _T("Enable Viacam"), wxOK | wxICON_ERROR);
193 errorMsg.ShowModal();
194 return NULL;
195 }
196
197 /*
198 Try to find previously used camera with the same name
199 (only check native driver)
200 */
201 int camId = -1;
202 const char * camName= NULL;
203 if (m_cameraName.Length()> 0) {
204 SLOG_INFO("Previous used camera: %s... ", (const char *) m_cameraName.mb_str());
205 for (camId = 0; camId < CCameraEnum::getNumDevices(0); camId++) {
206 camName = CCameraEnum::getDeviceName(0, camId);
207 if (wxString(camName, wxConvLibc) == m_cameraName) {
208 SLOG_INFO("FOUND");
209 break;
210 }
211 }
212
213 if (camId == CCameraEnum::getNumDevices(0)) {
214 SLOG_INFO("NOT FOUND");
215 camId = -1;
216 }
217 }
218
219 /*
220 Show selection dialog when needed (use native driver names)
221 */
222 SLOG_INFO("Detected %d camera(s)", CCameraEnum::getNumDevices(0));
223 if (camId == -1) {
224 if (CCameraEnum::getNumDevices(0) > 1) {
225 wxArrayString strArray;
226
227 for (int i = 0; i < CCameraEnum::getNumDevices(0); i++) {
228 strArray.Add(wxString(CCameraEnum::getDeviceName(0, i), wxConvLibc));
229 }
230
231 wxSingleChoiceDialog choiceDlg(

Callers

nothing calls this directly

Calls 1

SetHorizontalFlipMethod · 0.80

Tested by

no test coverage detected