[已解决]利用易语言VedioCapture.dll控制摄像头录像
本帖最后由 king8462 于 2021-9-22 14:26 编辑下载了这个帖子的源码:https://www.autoitx.com/forum.ph ... =%C9%E3%CF%F1%CD%B7
可以实现摄像头拍照,百度查到该dll可以支持录像,但不会写语法,请高手帮忙,谢谢。
这是易语言源码链接:https://down.easck.com/code/64783.html
#region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_UseX64=n
#endregion ;**** 参数创建于 ACNWrapper_GUI ****
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 325, 319, 112)
$Pic1 = GUICtrlCreatePic("", 264, 8, 321, 233)
$List1 = GUICtrlCreateList("", 10, 8, 241, 238, 0)
$Button1 = GUICtrlCreateButton("枚举摄像头", 24, 264, 75, 25)
$Button2 = GUICtrlCreateButton("开启摄像头", 112, 264, 75, 25)
$Button3 = GUICtrlCreateButton("关闭摄像头", 200, 264, 75, 25)
$Button4 = GUICtrlCreateButton("截图", 288, 264, 75, 25)
GUICtrlCreateLabel("截图默认放在d:\1.bmp", 24, 296, 199, 17)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
$dll = DllOpen("VedioCapture.dll")
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$list = DllCall($dll, "str", "GetCameraList")
If $list <> "" Then
$t = 0
$CameraList = StringSplit($list, "|")
For $s = 1 To $CameraList/2
GUICtrlSetData($List1, $CameraList[$t+1] & "*" & $CameraList[$t + 2])
$t += 2
Next
EndIf
Case $Button2
$ID = StringSplit(GUICtrlRead ( $List1 ),"*")
MsgBox(0,"",$ID)
DllCall($dll, "int", "SetCameraID","int",$ID)
DllCall($dll, "int", "StartCamera","hwnd",GUICtrlGetHandle($Pic1))
Case $Button3
$ID = StringSplit(GUICtrlRead ( $List1 ),"*")
DllCall($dll, "int", "CloseCamera","int",$ID)
Case $Button4
;DllCall($dll, "int", "SaveBmp","hwnd",GUICtrlGetHandle($Pic1),"str","d:\1.bmp")
DllCall($dll, "int", "RecordVideo","hwnd",GUICtrlGetHandle($Pic1),"str","d:\1.avi")
Sleep(1000*30)
DllCall($dll, "int", "StopRecord","int",$ID)
Sleep(1000)
EndSwitch
WEnd
无法录像,看精易论坛的好多都反馈无法录像,还是考虑用DirectShow吧 似乎这个dll并不能录像,不管语言的事 本帖最后由 繁星 于 2021-9-18 23:55 编辑
研究了下可以录像调用很简单,然并卵,底层需要微软MPEG-4解码器才能工作,
网上找了一圈没找到,去老外那边找到一个20年前的驱动安装完就可以使用了,可惜只支持32位系统,而且效果很差
https://www.helloimg.com/images/2021/09/18/CWtI6z.gif
inf右键安装
#region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_UseX64=n
#endregion ;**** 参数创建于 ACNWrapper_GUI ****
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <Date.au3>
#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 325)
$Pic1 = GUICtrlCreatePic("", 264, 8, 321, 233)
$List1 = GUICtrlCreateList("", 10, 8, 241, 238, 0)
$Button1 = GUICtrlCreateButton("枚举摄像头", 10, 264, 75, 25)
$Button2 = GUICtrlCreateButton("开启摄像头", 95, 264, 75, 25)
$Button3 = GUICtrlCreateButton("关闭摄像头", 180, 264, 75, 25)
$Button4 = GUICtrlCreateButton("截图", 265, 264, 75, 25)
$Button5 = GUICtrlCreateButton('开始录制', 350, 264, 75, 25)
$Button6 = GUICtrlCreateButton('停止录制', 435, 264, 75, 25)
$Button7 = GUICtrlCreateButton('生成视频', 520, 264, 75, 25)
GUICtrlCreateLabel("截图默认放在d:\1.bmp", 24, 296, 199, 17)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
$dll = DllOpen(@ScriptDir & "\VedioCapture.dll")
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$list = DllCall($dll, "str", "GetCameraList")
If $list <> "" Then
$t = 0
$CameraList = StringSplit($list, "|")
For $s = 1 To $CameraList/2
GUICtrlSetData($List1, $CameraList[$t+1] & "*" & $CameraList[$t + 2])
$t += 2
Next
EndIf
Case $Button2
$ID = StringSplit(GUICtrlRead ($List1),"*")
DllCall($dll, "int", "SetCameraID","int",$ID)
DllCall($dll, "int", "StartCamera","hwnd",GUICtrlGetHandle($Pic1))
Case $Button3
$ID = StringSplit(GUICtrlRead ( $List1 ),"*")
DllCall($dll, "int", "CloseCamera","int",$ID)
Case $Button4 ;截图(多截几张不然生成的视频太短了)
For $i = 1 To 10
DllCall($dll, "int", "SaveBmp","hwnd",GUICtrlGetHandle($Pic1),"str", @ScriptDir & "\" & $i & ".bmp")
Sleep(1000)
Next
Case $Button5
DllCall($dll, "int", "RecordVideo","hwnd",GUICtrlGetHandle($Pic1),"str", @ScriptDir & "\Video.avi")
Case $Button6
DllCall($dll, "int", "StopRecord","hwnd",GUICtrlGetHandle($Pic1))
Case $Button7
DllCall($dll, 'int', 'CreateVideoByFiles', 'str', @ScriptDir & '\', 'str', @ScriptDir & '\bmp.avi', 'str', 'bmp', 'int', '15')
EndSwitch
WEnd
感谢楼上各位!
页:
[1]