VMR_Capture.h
资源名称:VideoMove.rar [点击查看]
上传用户:czshopping
上传日期:2022-05-22
资源大小:5430k
文件大小:3k
源码类别:
视频捕捉/采集
开发平台:
Visual C++
- //////////////////////////////////////////////////////////////////////
- //
- // This class is designed to provide simple interface for
- // simultaneous Video Capture & Preview using DirectShow
- //
- //////////////////////////////////////////////////////////////////////
- //
- // References: MS DirectShow Samples
- //
- //
- //////////////////////////////////////////////////////////////////////
- //
- // This class was written by Sagar K.R .
- // Use of this class is not restricted in any
- // way whatsoever.Please report the bugs to krssagar@firsteccom.co.kr
- //
- // Special thanks to all the members at The Code Project!
- // (www.codeproject.com)
- //
- //////////////////////////////////////////////////////////////////////
- // VMR_Capture.h: interface for the CVMR_Capture class.
- //
- //////////////////////////////////////////////////////////////////////
- #if !defined(AFX_VMR_CAPTURE_H__186091F3_30FA_4FAA_AC8B_EF25E8463B9A__INCLUDED_)
- #define AFX_VMR_CAPTURE_H__186091F3_30FA_4FAA_AC8B_EF25E8463B9A__INCLUDED_
- #if _MSC_VER > 1000
- #pragma once
- #endif // _MSC_VER > 1000
- //#include <streams.h> //要访问DirectShow的接口必须包含该头文件
- //#pragma comment(lib,"StrmBase.lib")
- #include <dshow.h>
- #include <d3d9.h>
- #include <vmr9.h>
- #include <atlbase.h>
- //#pragma comment(lib, "Quartz.lib")
- //#pragma comment(lib,"Strmiids.lib")
- #define WM_GRAPHNOTIFY WM_USER+13
- enum PLAYSTATE {Stopped, Paused, Running, Init};
- #include "MoveTrace.h"
- class CVMR_Capture
- {
- public:
- CVMR_Capture();
- int EnumDevices(HWND hList);
- HRESULT Init(int iDeviceID,HWND hWnd,int iWidth,int iHeight);
- DWORD GetFrame(BYTE ** pFrame);
- BOOL Pause();
- DWORD ImageCapture(LPCTSTR szFile);
- DWORD GrabFrame();
- BOOL Trace(BYTE *pImageByte);
- BOOL m_bStorageData;
- virtual ~CVMR_Capture();
- CMoveTrace m_MoveTrace;
- void MoveWindow(int x,int y,int nWidth,int nHeight);
- BOOL CVMR_Capture::WriteAsBMP(char* szFileName,unsigned char* pImgData,int nWidth,int nHeight);
- protected:
- IGraphBuilder *m_pGB ;
- IMediaControl *m_pMC;
- IMediaEventEx *m_pME ;
- //IMediaEvent *pME ;
- IVMRWindowlessControl9 *m_pWC;
- IPin * m_pCamOutPin;
- IBaseFilter *m_pDF;
- PLAYSTATE m_psCurrent;
- int m_nWidth;
- int m_nHeight;
- BYTE *m_pFrame;
- long m_nFramelen;
- bool BindFilter(int deviceId, IBaseFilter **pFilter);
- HRESULT InitializeWindowlessVMR(HWND hWnd);
- HRESULT InitVideoWindow(HWND hWnd,int width, int height);
- void StopCapture();
- void CloseInterfaces(void);
- void DeleteMediaType(AM_MEDIA_TYPE *pmt);
- bool Convert24Image(BYTE *p32Img,BYTE *p24Img,DWORD dwSize32);
- CBitmap m_Bitmap;
- int m_iHeight;
- int m_iWidth; //视频的宽高
- private:
- HWND m_hCapWnd; //产生的扑捉的窗口句柄
- HWND m_hParentWnd;//用于扑捉的窗口句柄
- CDC *m_pDC;
- CDC m_MemDC;
- };
- static CVMR_Capture* lpVideo = NULL;
- #endif // !defined(AFX_VMR_CAPTURE_H__186091F3_30FA_4FAA_AC8B_EF25E8463B9A__INCLUDED_)