要编写一个播放摄像头视频流的VB程序,书上参考的这个程序,CAPDRIVERCAPS之类的说没定义。
求助,谁能解释下这个程序cap……函数是要自己编写的吗?还是系统有的?OptionExplicitDimlwndCAsLong'捕捉窗口的句柄DimlNFramesAsL...
求助,谁能解释下这个程序cap……函数是要自己编写的吗?还是系统有的?
Option Explicit
Dim lwndC As Long '捕捉窗口的句柄
Dim lNFrames As Long '捕捉的帧数
Sub RexizeCaptureWindow(ByVal lwnd As Long)
Dim CAPSTATUS As CAPSTATUS
'获取捕捉窗口的大小
capGetStatus lwnd, VarPtr(CAPSTATUS), Len(CAPSTATUS)
'重新设置捕捉窗口的大小
SetWindowPos lwnd, HWND_BOTTOM, 0, 0, CAPSTATUS.uiImageWidth, CAPSTATUS.uiImageHeight, SWP_NOMOVE Or SWP_NOZORDER
End Sub
Private Sub Form_Load()
Dim lpszName As String * 100
Dim lpszVer As String * 100
Dim Caps As CAPDRIVERCAPS
'创建捕捉窗口
capGetDriverDescriptionA 0, lpszName, 100, lpszVer, 100 '//Retrieves driver info
lwndC = capCreateCaptureWindowA(lpszName, WS_CHILD Or WS_VISIBLE, 0, 0, 160, 120, Me.hwnd, 0)
'获取驱动程序
capDriverConnect lwndC, 0
CAPDRIVERGETCAPS lwndC, VarPtr(Caps), Len(Caps)
'如果未找到驱动程序
If Caps.fHasDlgVideoSource = 0 Then mnuSource.Enabled = False
If Caps.fHasDlgVideoFormat = 0 Then mnuFormat.Enabled = False
If Caps.fHasDlgVideoDisplay = 0 Then mnuDisplay.Enabled = False
'设置视频流回调函数
capSetCallbackOnVideoStream lwndC, AddressOf MyVideoStreamCallback
capSetCallbackOnFrame lwndC, AddressOf MyFrameCallback
'设置预览的速度
capPreviewRate lwndC, 66
'开始预览捕捉的视频
capPreview lwndC, True
ResizeCaptureWindow lwndC
End Sub
Private Sub Form_Unload(Cancel As Integer)
'释放回调函数
capSetCallbackOnError lwndC, vbNull
capSetCallbackOnStatus lwndC, vbNull
capSetCallbackOnYield lwndC, vbNull
capSetCallbackOnFrame lwndC, vbNull
capSetCallbackOnVideoStream lwndC, vbNull
capSetCallbackOnWaveStream lwndC, vbNull
capSetCallbackOnCapControl lwndC, vbNull
End Sub
Private Sub mnuCompression_Click()
capDlgVideoCompression lwndC '显示压缩窗口
End Sub
Private Sub mnuDisplay_Click()
capDlgVideoDisplay lwndC '显示播放窗口
End Sub
Private Sub mnuExit_Click()
Unload Me '退出程序
End Sub
Private Sub mnuFormat_Click()
capDlgVideoFormat lwndC '设置视频捕捉参数
ResizeCaptureWindow lwndC
End Sub
'确定是否预览视频
Private Sub mnuPreview_Click()
mnuPreview.Checked = Not (mnuPreview.Checked)
capPreview lwndC, mnuPreview.Checked
End Sub
Private Sub mnuSource_Click()
capDlgVideoSource lwndC '显示视频来源窗口
End Sub
Private Sub mnuStart_Click()
lNFrames = 0
capCaptureSequenceNoFile lwndC '开始播放
End Sub 展开
Option Explicit
Dim lwndC As Long '捕捉窗口的句柄
Dim lNFrames As Long '捕捉的帧数
Sub RexizeCaptureWindow(ByVal lwnd As Long)
Dim CAPSTATUS As CAPSTATUS
'获取捕捉窗口的大小
capGetStatus lwnd, VarPtr(CAPSTATUS), Len(CAPSTATUS)
'重新设置捕捉窗口的大小
SetWindowPos lwnd, HWND_BOTTOM, 0, 0, CAPSTATUS.uiImageWidth, CAPSTATUS.uiImageHeight, SWP_NOMOVE Or SWP_NOZORDER
End Sub
Private Sub Form_Load()
Dim lpszName As String * 100
Dim lpszVer As String * 100
Dim Caps As CAPDRIVERCAPS
'创建捕捉窗口
capGetDriverDescriptionA 0, lpszName, 100, lpszVer, 100 '//Retrieves driver info
lwndC = capCreateCaptureWindowA(lpszName, WS_CHILD Or WS_VISIBLE, 0, 0, 160, 120, Me.hwnd, 0)
'获取驱动程序
capDriverConnect lwndC, 0
CAPDRIVERGETCAPS lwndC, VarPtr(Caps), Len(Caps)
'如果未找到驱动程序
If Caps.fHasDlgVideoSource = 0 Then mnuSource.Enabled = False
If Caps.fHasDlgVideoFormat = 0 Then mnuFormat.Enabled = False
If Caps.fHasDlgVideoDisplay = 0 Then mnuDisplay.Enabled = False
'设置视频流回调函数
capSetCallbackOnVideoStream lwndC, AddressOf MyVideoStreamCallback
capSetCallbackOnFrame lwndC, AddressOf MyFrameCallback
'设置预览的速度
capPreviewRate lwndC, 66
'开始预览捕捉的视频
capPreview lwndC, True
ResizeCaptureWindow lwndC
End Sub
Private Sub Form_Unload(Cancel As Integer)
'释放回调函数
capSetCallbackOnError lwndC, vbNull
capSetCallbackOnStatus lwndC, vbNull
capSetCallbackOnYield lwndC, vbNull
capSetCallbackOnFrame lwndC, vbNull
capSetCallbackOnVideoStream lwndC, vbNull
capSetCallbackOnWaveStream lwndC, vbNull
capSetCallbackOnCapControl lwndC, vbNull
End Sub
Private Sub mnuCompression_Click()
capDlgVideoCompression lwndC '显示压缩窗口
End Sub
Private Sub mnuDisplay_Click()
capDlgVideoDisplay lwndC '显示播放窗口
End Sub
Private Sub mnuExit_Click()
Unload Me '退出程序
End Sub
Private Sub mnuFormat_Click()
capDlgVideoFormat lwndC '设置视频捕捉参数
ResizeCaptureWindow lwndC
End Sub
'确定是否预览视频
Private Sub mnuPreview_Click()
mnuPreview.Checked = Not (mnuPreview.Checked)
capPreview lwndC, mnuPreview.Checked
End Sub
Private Sub mnuSource_Click()
capDlgVideoSource lwndC '显示视频来源窗口
End Sub
Private Sub mnuStart_Click()
lNFrames = 0
capCaptureSequenceNoFile lwndC '开始播放
End Sub 展开
展开全部
很多API函数没定义,例如:
Declare Function capCreateCaptureWindowA Lib "avicap32.dll" ( _
ByVal lpszWindowName As String, _
ByVal dwStyle As Long, _
ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Integer, _
ByVal hWndParent As Long, ByVal nID As Long) As Long
还有CAPSTATUS是怎么样的数据结构?
给你一个参考:http://blog.163.com/zlx_p/blog/static/97754982011016105644464/
Declare Function capCreateCaptureWindowA Lib "avicap32.dll" ( _
ByVal lpszWindowName As String, _
ByVal dwStyle As Long, _
ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Integer, _
ByVal hWndParent As Long, ByVal nID As Long) As Long
还有CAPSTATUS是怎么样的数据结构?
给你一个参考:http://blog.163.com/zlx_p/blog/static/97754982011016105644464/
追问
我在API浏览器上找不到cap之类的函数,我有在一个模块上声明了一些类似lstrcpy之类的函数,但问题一直出在cap上,都是没定义的函数,实在不知道怎么搞。。。
追答
很明显, capCreateCaptureWindowA 函数来自于 "avicap32.dll" ,并非windows自带的API,所以你在API浏览器上找不到,所有cap打头的函数和数据结构基本上都来自于这个动态库,你必须在引用里面加上这个动态库。
意法半导体(中国)投资有限公司
2023-06-12 广告
2023-06-12 广告
为你找到的单片机视频教程如下:1. 杜鹃花 :《单片机视频教程全集》是一部很好的单片机学习教程,全面系统地介绍了 AVR、STM8、STC89C52、STM32 等单片机的视频教程。2. 云课堂 :《单片机教学视频大全》是一套系统、全面、深...
点击进入详情页
本回答由意法半导体(中国)投资有限公司提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询