VideoCapture.h
资源名称:VideoMove.rar [点击查看]
上传用户:czshopping
上传日期:2022-05-22
资源大小:5430k
文件大小:3k
源码类别:
视频捕捉/采集
开发平台:
Visual C++
- // VideoCapture.h: interface for the CVideoCapture class.
- //
- //////////////////////////////////////////////////////////////////////
- #if !defined(AFX_VIDEOCAPTURE_H__FE7832C0_025A_11D5_9451_00E04C66EADC__INCLUDED_)
- #define AFX_VIDEOCAPTURE_H__FE7832C0_025A_11D5_9451_00E04C66EADC__INCLUDED_
- #if _MSC_VER > 1000
- #pragma once
- #endif // _MSC_VER > 1000
- #include <vfw.h>
- #include <comdef.h>
- #include "MoveTrace.h"
- class CVideoCapture
- {
- public:
- friend LRESULT FAR PASCAL FrameCallbackProc(HWND hWnd, LPVIDEOHDR lpVHdr);
- friend LRESULT FAR PASCAL VideoCallbackProc(HWND hWnd, LPVIDEOHDR lpVHdr);
- public:
- CVideoCapture();
- virtual ~CVideoCapture();
- BOOL SetOverlay(bool bOverlay); //是否允许画图
- void SetOverlayShape(int nShape); //设置Overlay形状0-椭圆 1-圆 2-矩形
- void SetOverlayColor(int nColor); //设置Overlay颜色0-红色 1-绿色 2-蓝色
- BOOL SetPreviewRate(int rate=30);
- BOOL CaptureInit(HWND hwndParent);
- void CaptureEnd();
- BOOL EnableVideo(long nDriver);
- BOOL EnableAnyVideo();
- void DisableVideo();
- BOOL StretchVideo(BOOL bStretch);
- long GetVideoDriverCount(); //返回可用设备数
- BSTR GetDriverName(long nDriver);
- long GetCurrentDriver(); //获取当前设置的设备号
- BOOL SetVideoFormat(int Width=320,int Height=240);
- void GetVideoFormat();
- int GetVideoWidth(); //视频宽度
- int GetVideoHeight(); //视频高度
- void MoveWindow(int x,int y,int nWidth,int nHeight);
- void ShowVideoFormatDialog();
- void ShowVideoSourceDialog();
- BOOL GrabVideo(unsigned char *pImageData);
- BOOL m_bStorageData;//要求保存扑捉
- public:
- void SaveImage(LPVIDEOHDR lpVHdr);
- void OverlayDraw(RECT rect); //画图
- BOOL WriteAsBMP(char* szFileName,unsigned char* pImgData,int nWidth,int nHeight);
- //BOOL WriteAsJPG(char *szFileName, BYTE *pImgData, int nWidth, int nHeight, short shQuality);
- void GetImage(unsigned char *pImageData);
- CMoveTrace m_MoveTrace;
- private:
- BOOL ConnectDev(long DriverId=-1);
- BOOL SetScrollPos(LPPOINT pos);
- BOOL Preview(BOOL onoff);
- void DisConnectDev();
- BOOL InitVideoBuffer();
- private:
- int m_iHeight;
- int m_iWidth; //视频的宽高
- int m_iConnectedDriverID; //当前设置的设备号
- BOOL m_bHasOverlay; //硬件是否支持Overlay
- int m_PreViewRate; //预揽帧数
- int m_bitCount; //扑捉的图片颜色位数
- _bstr_t m_bstr;
- CBitmap m_Bitmap;
- PBYTE m_pRotateBuffer;
- private:
- HWND m_hCapWnd; //产生的扑捉的窗口句柄
- HWND m_hParentWnd;//用于扑捉的窗口句柄
- CDC *m_pDC;
- CDC m_MemDC;
- int m_iMaxCapFrame; //连续扑捉的帧数
- unsigned char * m_pBuffer; //保存帧的缓冲
- DWORD m_dwBufferSize;
- BOOL m_bInit; //连接视频成功
- BOOL m_bCapture; //正在扑捉
- int nOverlayColor; //抓图表识颜色
- int nOverlayShape; //抓图表识形状
- };
- //LRESULT FAR PASCAL FrameCallbackProc(HWND hWnd, LPVIDEOHDR lpVHdr);
- //LRESULT FAR PASCAL VideoCallbackProc(HWND hWnd, LPVIDEOHDR lpVHdr);
- static CVideoCapture* lpVideo = NULL;
- #endif // !defined(AFX_VIDEOCAPTURE_H__FE7832C0_025A_11D5_9451_00E04C66EADC__INCLUDED_)