当前位置: 首页>>代码示例>>C++>>正文


C++ CCamera::Close方法代码示例

本文整理汇总了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;
}
开发者ID:mvancompernolle,项目名称:ai_project,代码行数:67,代码来源:viacamcontroller.cpp


注:本文中的CCamera::Close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。