91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

如何編寫發一段開啟攝像頭的代碼

發布時間:2021-10-14 15:46:22 來源:億速云 閱讀:126 作者:柒染 欄目:編程語言

本篇文章給大家分享的是有關如何編寫發一段開啟攝像頭的代碼,小編覺得挺實用的,因此分享給大家學習,希望大家閱讀完這篇文章后可以有所收獲,話不多說,跟著小編一起來看看吧。


//---------------------------------------------------------------------------

#pragma hdrstop

#include "Unit1.h"
#include "vfw.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
HWND hWndC;
CAPDRIVERCAPS CapDrvCaps;
CAPSTATUS CapStatus;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
    : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormShow(TObject *Sender)
{
    char szDeviceName[80];
    char szDeviceVersion[80];

    for (int wIndex = 0; wIndex < 10; wIndex++)
    {
        if (capGetDriverDescription (wIndex, szDeviceName,
            sizeof (szDeviceName), szDeviceVersion,
            sizeof (szDeviceVersion)))
        {
            ComboBox1->Items->Add(szDeviceName);
        }
    }
    
    if(ComboBox1->Items->Count>0)
        ComboBox1->ItemIndex=0;
    else
    {
        ShowMessage("沒有找到視頻軟件");
        Close();
    }
    Button1Click(NULL);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
    hWndC = capCreateCaptureWindow (
        (LPSTR) "My Capture Window", // window name if pop-up
        WS_CHILD | WS_VISIBLE, // window style
        0, 0, 160, 120, // window position and dimensions
        (HWND)Panel2->Handle,//(HWND)Application->Handle,//(HWND) hwndParent,
        ComboBox1->ItemIndex+1);//(int) nID /* child ID */);

    //連接設備:
    capDriverConnect(hWndC,0);
    capPreviewRate(hWndC, 50); // rate, in milliseconds
    capPreview(hWndC, TRUE); // starts preview

    //獲取視頻驅動相關性能
    capDriverGetCaps(hWndC, &CapDrvCaps, sizeof (CAPDRIVERCAPS));

    //獲取捕獲窗口狀態
    capGetStatus(hWndC, &CapStatus, sizeof (CAPSTATUS));
    SetWindowPos(hWndC, NULL,
        0,
        0,
        CapStatus.uiImageWidth,
        CapStatus.uiImageHeight, SWP_NOZORDER | SWP_NOMOVE);
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
    if(hWndC)
    {
        capPreview(hWndC, FALSE); // starts preview
        capDriverDisconnect (hWndC);
    }
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button2Click(TObject *Sender)
{
    // Video format dialog box.
    if (CapDrvCaps.fHasDlgVideoFormat)
    {
        capDlgVideoFormat(hWndC);
        // Are there new image dimensions?
        capGetStatus(hWndC, &CapStatus, sizeof (CAPSTATUS));
        SetWindowPos(hWndC, NULL,
            0,
            0,
            CapStatus.uiImageWidth,
            CapStatus.uiImageHeight, SWP_NOZORDER | SWP_NOMOVE);
    }
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button3Click(TObject *Sender)
{
    // Video source dialog box.
    if (CapDrvCaps.fHasDlgVideoSource)
        capDlgVideoSource(hWndC);
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button4Click(TObject *Sender)
{
    //設置相關參數
    CAPTUREPARMS CaptureParms;
    float FramesPerSec = 30.0;

    capCaptureGetSetup(hWndC, &CaptureParms, sizeof(CAPTUREPARMS));

    CaptureParms.dwRequestMicroSecPerFrame = (DWORD) (1.0e6 /
        FramesPerSec);
    capCaptureSetSetup(hWndC, &CaptureParms, sizeof (CAPTUREPARMS));
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button5Click(TObject *Sender)
{
    //設置預覽時的比例
    capPreviewScale(hWndC, 1);
    //設置預覽時的幀頻率
    capPreviewRate(hWndC,66);
    //如果要捕獲視頻流,則要使用函數指定不生成文件。否則將會自動生成AVI文件
    capCaptureSequenceNoFile(hWndC);
    //指定是否使用疊加模式,使用為1,否則為0
    capOverlay(hWndC, 1);
    
    //Video display dialog box.
    if (CapDrvCaps.fHasDlgVideoDisplay)
        capDlgVideoDisplay(hWndC);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button6Click(TObject *Sender)
{
    if(SaveDialog2->Execute())
        capFileSaveDIB( hWndC, (SaveDialog2->FileName+".bmp").c_str() ); //截取當前幀
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button7Click(TObject *Sender)
{
    if(Button7->Caption == "開始捕獲")
    {
        if(SaveDialog1->Execute())
        {
            // Set up the capture operation.
            capCaptureSequence(hWndC);
            // Capture.
            capFileSaveAs(hWndC, (SaveDialog1->FileName+".avi").c_str());//視頻
        }
        Button7->Caption="停止捕獲";
    }
    else
    {
        Button7->Caption="開始捕獲";
        capCaptureStop(hWndC);
    }
}
//---------------------------------------------------------------------------

以上就是如何編寫發一段開啟攝像頭的代碼,小編相信有部分知識點可能是我們日常工作會見到或用到的。希望你能通過這篇文章學到更多知識。更多詳情敬請關注億速云行業資訊頻道。

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

土默特右旗| 新郑市| 湖南省| 桓台县| 遵义县| 互助| 开阳县| 盘山县| 龙川县| 信丰县| 庐江县| 福安市| 宣城市| 岳普湖县| 元氏县| 林甸县| 沈阳市| 理塘县| 旌德县| 黄平县| 台安县| 青田县| 电白县| 华阴市| 丰县| 金乡县| 黔西县| 绥德县| 大关县| 化州市| 庐江县| 洪泽县| 额济纳旗| 彩票| 揭东县| 光泽县| 苏尼特右旗| 卫辉市| 循化| 巩留县| 慈利县|