📄 readme.txt
字号:
VideoForWindows 程序练习说明
通过调用Vfw32.lib中的函数,可以实现摄像头的视频捕获。
所谓视频捕获,就是把摄像头显示到窗口的内容连续抓下来。
实现步骤如下:
AVICAP的主要功能是通过CaptureWindow实现的
1.建立采集窗口
capCreateCaptureWindow() 在CMainFrame 中 OnCreate 实现
2. 连接一个采集设备
CapDriverConnect ,如果有多个摄像头,则可以连接多个设备 CMainFrame 中OnCreate
3.获取窗口状态
CapDriverGetCaps 获取窗口状态信息 ,窗口状态被定义在一个叫做CAPSTATUS 的数据结构中,必须动态更新。
CMainFrame 中changesize 中调用。
*****************************************************
回调函数简介
******************
回调函数在程序初始化的时候制定,向设备驱动程序发出读写命令后,
回调函数被定时不定时地用来完成相应的通信功能,如视频流的回调
函数定时地从usb摄像头取回一帧数据以便回放,应用程序可以在采集
窗口中注册以下四种回调函数,它们的名字可由应用程序自己制定。
1.状态回调函数
LRESULT FAR PASCAL StatusCallbackProc(HWND hWnd,int nID,LPSTR lpStatusText)
2.错误回调函数
LRESULT CALLBACK EXPORT ErrorCallbackProc(HWND hWnd,int nErrID,LPSTR lpErrorText)
3.单帧采集回调函数
4.视频流采集回调函数
LRESULT FAR PASCAL VideoCallbackProc(HWND hWnd,LPVIDEOHDR lpVHdr)
函数定义在mainfrm.cpp中
函数注册在CMainFrame::OnCreate中
capSetCallbackOnError(m_WndCap,(FARPROC)ErrorCallbackProc);
capSetCallbackOnStatus(m_WndCap,(FARPROC)StatusCallbackProc);
capSetCallbackOnVideoStream(m_WndCap,(FARPROC)VideoCallbackProc);
就是开了3个线程,post_message给这几个回调函数处理,capSetCallbackOnError 是宏
************
视频的预览和采集
******
1.预览
capPreviewRate(hWndC,66) 1000/15 秒/15帧,hWndC CaputureWindow的hWnd
capPreview(hWndC,true) 开始
capPreview 初始化了Preview状态,然后开始调用VideoCallBack函数(自己定义的函数,vfw只是把数据块的指针给你了,具体怎么显示由自己决定)
VideoCallbackProc中
用memcopy把采集到的数据,复制到自定义结构体m_dibinfo中,然后invalidate View, 在CVideoCaptureView中的OnDraw 显示图像
此程序的capture data还没做好,更改图像大小的时候,窗口的显示的尺寸还没变。 需要调整。
欢迎与我联系:
pony1976@sina.com.cn
========================================================================
MICROSOFT FOUNDATION CLASS LIBRARY : VideoCapture
========================================================================
AppWizard has created this VideoCapture application for you. This application
not only demonstrates the basics of using the Microsoft Foundation classes
but is also a starting point for writing your application.
This file contains a summary of what you will find in each of the files that
make up your VideoCapture application.
VideoCapture.dsp
This file (the project file) contains information at the project level and
is used to build a single project or subproject. Other users can share the
project (.dsp) file, but they should export the makefiles locally.
VideoCapture.h
This is the main header file for the application. It includes other
project specific headers (including Resource.h) and declares the
CVideoCaptureApp application class.
VideoCapture.cpp
This is the main application source file that contains the application
class CVideoCaptureApp.
VideoCapture.rc
This is a listing of all of the Microsoft Windows resources that the
program uses. It includes the icons, bitmaps, and cursors that are stored
in the RES subdirectory. This file can be directly edited in Microsoft
Visual C++.
VideoCapture.clw
This file contains information used by ClassWizard to edit existing
classes or add new classes. ClassWizard also uses this file to store
information needed to create and edit message maps and dialog data
maps and to create prototype member functions.
res\VideoCapture.ico
This is an icon file, which is used as the application's icon. This
icon is included by the main resource file VideoCapture.rc.
res\VideoCapture.rc2
This file contains resources that are not edited by Microsoft
Visual C++. You should place all resources not editable by
the resource editor in this file.
/////////////////////////////////////////////////////////////////////////////
For the main frame window:
MainFrm.h, MainFrm.cpp
These files contain the frame class CMainFrame, which is derived from
CFrameWnd and controls all SDI frame features.
res\Toolbar.bmp
This bitmap file is used to create tiled images for the toolbar.
The initial toolbar and status bar are constructed in the CMainFrame
class. Edit this toolbar bitmap using the resource editor, and
update the IDR_MAINFRAME TOOLBAR array in VideoCapture.rc to add
toolbar buttons.
/////////////////////////////////////////////////////////////////////////////
AppWizard creates one document type and one view:
VideoCaptureDoc.h, VideoCaptureDoc.cpp - the document
These files contain your CVideoCaptureDoc class. Edit these files to
add your special document data and to implement file saving and loading
(via CVideoCaptureDoc::Serialize).
VideoCaptureView.h, VideoCaptureView.cpp - the view of the document
These files contain your CVideoCaptureView class.
CVideoCaptureView objects are used to view CVideoCaptureDoc objects.
/////////////////////////////////////////////////////////////////////////////
Other standard files:
StdAfx.h, StdAfx.cpp
These files are used to build a precompiled header (PCH) file
named VideoCapture.pch and a precompiled types file named StdAfx.obj.
Resource.h
This is the standard header file, which defines new resource IDs.
Microsoft Visual C++ reads and updates this file.
/////////////////////////////////////////////////////////////////////////////
Other notes:
AppWizard uses "TODO:" to indicate parts of the source code you
should add to or customize.
If your application uses MFC in a shared DLL, and your application is
in a language other than the operating system's current language, you
will need to copy the corresponding localized resources MFC42XXX.DLL
from the Microsoft Visual C++ CD-ROM onto the system or system32 directory,
and rename it to be MFCLOC.DLL. ("XXX" stands for the language abbreviation.
For example, MFC42DEU.DLL contains resources translated to German.) If you
don't do this, some of the UI elements of your application will remain in the
language of the operating system.
/////////////////////////////////////////////////////////////////////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -