本文整理汇总了C++中CCamera::Close方法的典型用法代码示例。如果您正苦于以下问题:C++ CCamera::Close方法的具体用法?C++ CCamera::Close怎么用?C++ CCamera::Close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCamera
的用法示例。
在下文中一共展示了CCamera::Close方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetUpCamera
CCamera* CViacamController::SetUpCamera()
{
CCamera* cam;
int numDevices;
int camId= -1;
// Load app local data
ReadAppData(wxConfigBase::Get());
numDevices= CCameraEnum::GetNumDevices ();
if (numDevices== 0) {
wxMessageDialog errorMsg (NULL, _("Not detected any camera. Aborting"), _T("Enable Viacam"), wxOK | wxICON_ERROR);
errorMsg.ShowModal();
return NULL;
}
// Try to find previously used camera
if (m_cameraName.Length()> 0) {
for (camId= 0; camId< numDevices; camId++)
if (wxString(CCameraEnum::GetDeviceName (camId), wxConvLibc)== m_cameraName) break;
if (camId== numDevices) camId= -1; // Not found
}
// Show selection dialog when needed
if (camId== -1) {
if(numDevices > 1) {
wxArrayString strArray;
for (camId= 0; camId< numDevices; camId++)
strArray.Add (wxString(CCameraEnum::GetDeviceName (camId), wxConvLibc));
wxSingleChoiceDialog choiceDlg(NULL, _("Choose the camera to use"), _T("Enable Viacam"), strArray,
NULL, wxDEFAULT_DIALOG_STYLE | wxOK | wxCANCEL | wxCENTRE);
if (choiceDlg.ShowModal ()!= wxID_OK) return NULL;
camId= choiceDlg.GetSelection();
m_cameraName= choiceDlg.GetStringSelection ();
}
else {
camId= 0;
m_cameraName= wxString(CCameraEnum::GetDeviceName (camId), wxConvLibc);
}
}
cam= CCameraEnum::GetCamera(camId);
if (!cam) return NULL;
cam->SetHorizontalFlip (true);
// Try to open the camera to ensure it works
if (!cam->Open ()) {
wxMessageDialog errorMsg (NULL, _("Can not initialize the camera.\nPerhaps is being used by other application."), _T("Enable Viacam"), wxOK | wxICON_ERROR);
errorMsg.ShowModal();
delete cam;
cam= NULL;
ChangeCamera();
}
else
cam->Close();
WriteAppData(wxConfigBase::Get());
wxConfigBase::Get()->Flush();
return cam;
}