当前位置:首页 » 其他

DrGraph软件升级:视频处理

2013-04-25 23:40 本站整理 浏览(3)

简要说明视频处理提交人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();

检测USB口摄像头插拔

    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();

复位

所有参数回复初始状态