简要说明 |
| 提交人 | DrGraph 2013/04/25 | |
处理状态 | 处理完毕 | 同步状态 | ||
现象 | 视频模块 | |||
定位及调试过程 |
选项配置中,首先列出视频相关参数:视频设备、视频来源、分辨率、类型、渲染等
void __fastcall TMainForm::LoadAndApplyConfig() { // 重新读取配置文件并进行各种配置工作 // 因为只调用LoadConfig一次,所以把列表内容填充工作放在此处 LoadResources(); OptionForm->LoadConfig(FConfigXml); // 由OptionForm读取得到所有的选项配置 CBW_PREVENT_CHANGE_LOOP; RefreshByOption(); // 根据选项窗口进行刷新 }
if (OptionForm->ComboBox_VideoDevices->Items->Count > 1) { Button_OpenVideo->ButtonStyle = bsDropDown; Button_OpenVideo->DropDownMenu = PopupMenu_Video; for (int i = 0; i < OptionForm->ComboBox_VideoDevices->Items->Count; ++i) { TdxBarLargeButton * button = new TdxBarLargeButton(this); button->Caption = OptionForm->ComboBox_VideoDevices->Items->Strings[i]; button->LargeImageIndex = 1; button->OnClick = ChooseVideo; PopupMenu_Video->ItemLinks->Add()->Item = button; } } else Button_OpenVideo->ButtonStyle = bsChecked; 即多于一个摄像头时,相应按钮效果
而只有一个摄像头时,相应按钮效果
void __fastcall TMainForm::Button_OpenVideoClick(TObject *Sender) { Button_OpenVideo->Down = !Button_OpenVideo->Down; VideoVisibleFlag = Button_OpenVideo->Down; VideoGrabber->Visible = VideoVisibleFlag; if (VideoVisibleFlag) { VideoGrabber->StartPreview(); SetWorkMode(wmVideo); } else VideoGrabber->StopPreview(); FConfigXml->RootNode->AddBoolAttribute("videovisible", VideoVisibleFlag); FConfigXml->Save(); } 则对应的开启与关闭状态:
TdxBarLargeButton * button = dynamic_cast<TdxBarLargeButton*>(Sender); if (!button) return; VideoVisible = true; // 缺省视频可见 UnicodeString videoSource = button->Caption; if (SameText(OptionForm->ComboBox_VideoDevices->Text, videoSource)) return; // 以下为缺省自动操作 OptionForm->ComboBox_VideoSources->ItemIndex = 0; // 用户手动选择摄像头,则视频来源自动切换到摄像头模式 THelper::DefaultSelect(OptionForm->ComboBox_VideoSources); // 更新分辨率 THelper::DefaultSelect(OptionForm->ComboBox_VideoDevices, videoSource); // 选择设备,更新VideoDevice RefreshByOption();
UnicodeString info = THelper::FormatString("系统检测到%s摄像头 %s", IsDeviceArrival ? L"插入" : L"拔下", DeviceName.w_str()); THelper::MessageBox(info, false); if (IsDeviceArrival) OptionForm->ComboBox_VideoDevices->Items->Add(DeviceName); else OptionForm->ComboBox_VideoDevices->Items->Delete (OptionForm->ComboBox_VideoDevices->Items->IndexOf(DeviceName)); THelper::DefaultSelect(OptionForm->ComboBox_VideoDevices); // 如果拔掉,则会选择第一个 RefreshByOption();
所有参数回复初始状态 |