Get the code snippet of the camera video in the VC

zhaozj2021-02-16  59

// 1. Head file declaration

// The header is included in the header, and guarantees VFW32.lib in the program directory.

#include

#pragma comment (Lib, "VFW32.LIB")

// Video device (camera) acquisition and initialization code snippet

// 2. Define class member variables

// defined variables defined in class members

HWND HcAptureWindow;

CButton M_Capturergn; // GrouPbox corresponds to how to CButton, very strange

// 3. Video Equipment (Camera) Get and Initialize Code

Rect CWRECT; CAPDRIVERCAPS CPS;

// m_capturergn is a pre-defined display video of the control (GroupBox) M_Capturergn.getClientRect (& CWRECT);

CWRECT.Right = CWRECT.LEFT 6400; CWRECT.BOTTOM = CWRECT.TOP 480;

if (hCaptureWindow) {capPreview (hCaptureWindow, FALSE); capDriverDisconnect (hCaptureWindow);} hCaptureWindow = capCreateCaptureWindow ( "video window", WS_CHILD | WS_VISIBLE, cwRect.left, cwRect.top, cwRect.right, cwRect.bottom, hCaptureRgn, ( int) 1); ASSERT (hCaptureWindow);! { "! connect the video input device error" MessageBox (); return;} if (capDriverConnect (hCaptureWindow, 0)) capDriverGetCaps (hCaptureWindow, & cps, sizeof (CAPDRIVERCAPS)); if ( ! cps.fcaptureinitialized) {MessageBox ("Video Enterprise initialization error!"); Return;}

if (cps.fHasDlgVideoSource) capDlgVideoSource (hCaptureWindow); if (cps.fHasDlgVideoFormat) capDlgVideoFormat (hCaptureWindow); if (cps.fHasDlgVideoDisplay) capDlgVideoDisplay (hCaptureWindow); capPreviewRate (hCaptureWindow, 20); capPreview (hCaptureWindow, TRUE); Invalidate () ;

// 4. Description: This article is used for reference when I write the code later, there are many problems.

// Please ask your master to pay for your personal attack!

转载请注明原文地址:https://www.9cbs.com/read-17803.html

New Post(0)