VB同时连接两个USB摄像头1.docx

上传人:b****7 文档编号:11190387 上传时间:2023-02-25 格式:DOCX 页数:22 大小:19.27KB
下载 相关 举报
VB同时连接两个USB摄像头1.docx_第1页
第1页 / 共22页
VB同时连接两个USB摄像头1.docx_第2页
第2页 / 共22页
VB同时连接两个USB摄像头1.docx_第3页
第3页 / 共22页
VB同时连接两个USB摄像头1.docx_第4页
第4页 / 共22页
VB同时连接两个USB摄像头1.docx_第5页
第5页 / 共22页
点击查看更多>>
下载资源
资源描述

VB同时连接两个USB摄像头1.docx

《VB同时连接两个USB摄像头1.docx》由会员分享,可在线阅读,更多相关《VB同时连接两个USB摄像头1.docx(22页珍藏版)》请在冰豆网上搜索。

VB同时连接两个USB摄像头1.docx

VB同时连接两个USB摄像头1

VB同时连接两个USB摄像头1

窗体代码

DimCaps1AsCAPDRIVERCAPS

DimCapsAsCAPDRIVERCAPS

PrivateSubCommand1_Click()

capDlgVideoSourcelwndC

EndSub

PrivateSubCommand2_Click()

capDlgVideoSourcelwndC1

EndSub

PrivateSubForm_Load()

DimlpszNameAsString*100

DimlpszVerAsString*100

DimlpszName1AsString*100

DimlpszVer1AsString*100

capGetDriverDescriptionA0,lpszName,100,lpszVer,100'//Retrievesdriverinfo

'MsgBoxlpszVer,,lpszName

lwndC=capCreateCaptureWindowA(lpszName,WS_VISIBLEOrWS_CHILD,0,0,Picture1.Width,Picture1.Height,Picture1.hWnd,0)

IfcapDriverConnect(lwndC,0)Then

capDriverGetCapslwndC,VarPtr(Caps),Len(Caps)

capPreviewScalelwndC,True

capPreviewRatelwndC,66

capPreviewlwndC,True

capSetMCIDeviceNamelwndC,VarPtr(lpszName)

SetWindowPoslwndC,1,0,0,Picture1.Width,Picture1.Height,SWP_NOMOVEOrSWP_NOZORDER

EndIf

capGetDriverDescriptionA1,lpszName1,100,lpszVer1,100'//Retrievesdriverinfo

'MsgBoxlpszVer,,lpszName

lwndC1=capCreateCaptureWindowA(lpszName1,WS_VISIBLEOrWS_CHILD,0,0,Picture2.Width,Picture2.Height,Picture2.hWnd,0)

IfcapDriverConnect(lwndC1,0)Then

capDriverGetCapslwndC1,VarPtr(Caps1),Len(Caps1)

capPreviewScalelwndC1,True

capPreviewRatelwndC1,66

capPreviewlwndC1,True

SetWindowPoslwndC1,1,0,0,Picture2.Width,Picture2.Height,SWP_NOMOVEOrSWP_NOZORDER

EndIf

EndSub

模块1:

'//------------------------------------------------------------------

'//WindowsAPIConstants/Types/Declarations

'//------------------------------------------------------------------

PublicConstWM_USER=&H400

TypePOINTAPI

xAsLong

yAsLong

EndType

DeclareFunctionSendMessageLib"user32"Alias"SendMessageA"(ByValhWndAsLong,ByValwMsgAsLong,ByValwParamAsInteger,ByVallParamAsLong)AsLong

DeclareFunctionSendMessageSLib"user32"Alias"SendMessageA"(ByValhWndAsLong,ByValwMsgAsLong,ByValwParamAsInteger,ByVallParamAsString)AsLong

'//------------------------------------------------------------------

'//WindowMessagesWM_CAP...whichcanbesenttoanAVICAPwindow

'//------------------------------------------------------------------

'//Definesstartofthemessagerange

PublicConstWM_CAP_START=WM_USER

PublicConstWM_CAP_GET_CAPSTREAMPTR=WM_CAP_START+1

PublicConstWM_CAP_SET_CALLBACK_ERROR=WM_CAP_START+2

PublicConstWM_CAP_SET_CALLBACK_STATUS=WM_CAP_START+3

PublicConstWM_CAP_SET_CALLBACK_YIELD=WM_CAP_START+4

PublicConstWM_CAP_SET_CALLBACK_FRAME=WM_CAP_START+5

PublicConstWM_CAP_SET_CALLBACK_VIDEOSTREAM=WM_CAP_START+6

PublicConstWM_CAP_SET_CALLBACK_WAVESTREAM=WM_CAP_START+7

PublicConstWM_CAP_GET_USER_DATA=WM_CAP_START+8

PublicConstWM_CAP_SET_USER_DATA=WM_CAP_START+9

PublicConstWM_CAP_DRIVER_CONNECT=WM_CAP_START+10

PublicConstWM_CAP_DRIVER_DISCONNECT=WM_CAP_START+11

PublicConstWM_CAP_DRIVER_GET_NAME=WM_CAP_START+12

PublicConstWM_CAP_DRIVER_GET_VERSION=WM_CAP_START+13

PublicConstWM_CAP_DRIVER_GET_CAPS=WM_CAP_START+14

PublicConstWM_CAP_FILE_SET_CAPTURE_FILE=WM_CAP_START+20

PublicConstWM_CAP_FILE_GET_CAPTURE_FILE=WM_CAP_START+21

PublicConstWM_CAP_FILE_ALLOCATE=WM_CAP_START+22

PublicConstWM_CAP_FILE_SAVEAS=WM_CAP_START+23

PublicConstWM_CAP_FILE_SET_INFOCHUNK=WM_CAP_START+24

PublicConstWM_CAP_FILE_SAVEDIB=WM_CAP_START+25

PublicConstWM_CAP_EDIT_COPY=WM_CAP_START+30

PublicConstWM_CAP_SET_AUDIOFORMAT=WM_CAP_START+35

PublicConstWM_CAP_GET_AUDIOFORMAT=WM_CAP_START+36

PublicConstWM_CAP_DLG_VIDEOFORMAT=WM_CAP_START+41

PublicConstWM_CAP_DLG_VIDEOSOURCE=WM_CAP_START+42

PublicConstWM_CAP_DLG_VIDEODISPLAY=WM_CAP_START+43

PublicConstWM_CAP_GET_VIDEOFORMAT=WM_CAP_START+44

PublicConstWM_CAP_SET_VIDEOFORMAT=WM_CAP_START+45

PublicConstWM_CAP_DLG_VIDEOCOMPRESSION=WM_CAP_START+46

PublicConstWM_CAP_SET_PREVIEW=WM_CAP_START+50

PublicConstWM_CAP_SET_OVERLAY=WM_CAP_START+51

PublicConstWM_CAP_SET_PREVIEWRATE=WM_CAP_START+52

PublicConstWM_CAP_SET_SCALE=WM_CAP_START+53

PublicConstWM_CAP_GET_STATUS=WM_CAP_START+54

PublicConstWM_CAP_SET_SCROLL=WM_CAP_START+55

PublicConstWM_CAP_GRAB_FRAME=WM_CAP_START+60

PublicConstWM_CAP_GRAB_FRAME_NOSTOP=WM_CAP_START+61

PublicConstWM_CAP_SEQUENCE=WM_CAP_START+62

PublicConstWM_CAP_SEQUENCE_NOFILE=WM_CAP_START+63

PublicConstWM_CAP_SET_SEQUENCE_SETUP=WM_CAP_START+64

PublicConstWM_CAP_GET_SEQUENCE_SETUP=WM_CAP_START+65

PublicConstWM_CAP_SET_MCI_DEVICE=WM_CAP_START+66

PublicConstWM_CAP_GET_MCI_DEVICE=WM_CAP_START+67

PublicConstWM_CAP_STOP=WM_CAP_START+68

PublicConstWM_CAP_ABORT=WM_CAP_START+69

PublicConstWM_CAP_SINGLE_FRAME_OPEN=WM_CAP_START+70

PublicConstWM_CAP_SINGLE_FRAME_CLOSE=WM_CAP_START+71

PublicConstWM_CAP_SINGLE_FRAME=WM_CAP_START+72

PublicConstWM_CAP_PAL_OPEN=WM_CAP_START+80

PublicConstWM_CAP_PAL_SAVE=WM_CAP_START+81

PublicConstWM_CAP_PAL_PASTE=WM_CAP_START+82

PublicConstWM_CAP_PAL_AUTOCREATE=WM_CAP_START+83

PublicConstWM_CAP_PAL_MANUALCREATE=WM_CAP_START+84

'//FollowingaddedpostVFW1.1

PublicConstWM_CAP_SET_CALLBACK_CAPCONTROL=WM_CAP_START+85

'//Definesendofthemessagerange

PublicConstWM_CAP_END=WM_CAP_SET_CALLBACK_CAPCONTROL

'//------------------------------------------------------------------

'//Structures

'//------------------------------------------------------------------

TypeCAPDRIVERCAPS

wDeviceIndexAsLong'//Driverindexinsystem.ini

fHasOverlayAsLong'//Candeviceoverlay?

fHasDlgVideoSourceAsLong'//HasVideosourcedlg?

fHasDlgVideoFormatAsLong'//HasFormatdlg?

fHasDlgVideoDisplayAsLong'//HasExternaloutdlg?

fCaptureInitializedAsLong'//Driverreadytocapture?

fDriverSuppliesPalettesAsLong'//Candrivermakepalettes?

hVideoInAsLong'//DriverInchannel

hVideoOutAsLong'//DriverOutchannel

hVideoExtInAsLong'//DriverExtInchannel

hVideoExtOutAsLong'//DriverExtOutchannel

EndType

TypeCAPSTATUS

uiImageWidthAsLong'//Widthoftheimage

uiImageHeightAsLong'//Heightoftheimage

fLiveWindowAsLong'//NowPreviewingvideo?

fOverlayWindowAsLong'//NowOverlayingvideo?

fScaleAsLong'//Scaleimagetoclient?

ptScrollAsPOINTAPI'//Scrollposition

fUsingDefaultPaletteAsLong'//Usingdefaultdriverpalette?

fAudioHardwareAsLong'//Audiohardwarepresent?

fCapFileExistsAsLong'//Doescapturefileexist?

dwCurrentVideoFrameAsLong'//#ofvideoframescap'td

dwCurrentVideoFramesDroppedAsLong'//#ofvideoframesdropped

dwCurrentWaveSamplesAsLong'//#ofwavesamplescap'td

dwCurrentTimeElapsedMSAsLong'//Elapsedcaptureduration

hPalCurrentAsLong'//Currentpaletteinuse

fCapturingNowAsLong'//Captureinprogress?

dwReturnAsLong'//Errorvalueafteranyoperation

wNumVideoAllocatedAsLong'//Actualnumberofvideobuffers

wNumAudioAllocatedAsLong'//Actualnumberofaudiobuffers

EndType

TypeCAPTUREPARMS

dwRequestMicroSecPerFrameAsLong'//Requestedcapturerate

fMakeUserHitOKToCaptureAsLong'//Show"HitOKtocap"dlg?

wPercentDropForErrorAsLong'//Giveerrormsgif>(10%)

fYieldAsLong'//Captureviabackgroundtask?

dwIndexSizeAsLong'//Maxindexsizeinframes(32K)

wChunkGranularityAsLong'//Junkchunkgranularity(2K)

fUsingDOSMemoryAsLong'//UseDOSbuffers?

wNumVideoRequestedAsLong'//#videobuffers,If0,autocalc

fCaptureAudioAsLong'//Captureaudio?

wNumAudioRequestedAsLong'//#audiobuffers,If0,autocalc

vKeyAbortAsLong'//Virtualkeycausingabort

fAbortLeftMouseAsLong'//Abortonleftmouse?

fAbortRightMouseAsLong'//Abortonrightmouse?

fLimitEnabledAsLong'//UsewTimeLimit?

wTimeLimitAsLong'//Secondstocapture

fMCIControlAsLong'//UseMCIvideosource?

fStepMCIDeviceAsLong'//StepMCIdevice?

dwMCIStartTimeAsLong'//TimetostartinMS

dwMCIStopTimeAsLong'//TimetostopinMS

fStepCaptureAt2xAsLong'//Performspatialaveraging2x

wStepCaptureAverageFramesAsLong'//TemporalaveragenFrames

dwAudioBufferSizeAsLong'//Sizeofaudiobufs(0=default)

fDisableWriteCacheAsLong'//Attempttodisablewritecache

EndType

TypeCAPINFOCHUNK

fccInfoIDAsLong'//ChunkID,"ICOP"forcopyright

lpDataAsLong'//pointertodata

cbDataAsLong'//sizeoflpData

EndType

TypeVIDEOHDR

lpDataAsLong'//addressofvideobuffer

dwBufferLengthAsLong'//size,inbytes,oftheDatabuffer

dwBytesUsedAsLong'//seebelow

dwTimeCapturedAsLong'//seebelow

dwUserAsLong'//user-specificdata

dwFlagsAsLong'//seebelow

dwReserved(3)AsLong'//reserved;donotuse}

EndType

'//ThetwofunctionsexportedbyAVICap

DeclareFunctioncapCreateCaptureWindowALib"avicap32.dll"(_

ByVallpszWindowNameAsString,_

ByValdwStyleAsLong,_

ByValxAsLong,ByValyAsLong,ByValnWidthAsLong,ByValnHeightAsInteger,_

ByValhWndParentAsLong,ByValnIDAsLong)AsLong

DeclareFunctioncapGetDriverDescriptionALib"avicap32.dll"(_

ByValwDriverAsInteger,_

ByVallpszNameAsString,_

ByValcbNameAsLong,_

ByVallpszVerAsString,_

ByValcbVerAsLong)AsBoolean

'//------------------------------------------------------------------

'//StringIDsfromstatusanderrorcallbacks

'//------------------------------------------------------------------

PublicConstIDS_CAP_BEGIN=300'/*"CaptureStart"*/

PublicConstIDS_CAP_END=301'/*"CaptureEnd"*/

PublicConstIDS_CAP_INFO=401'/*"%s"*/

PublicConstIDS_CAP_OUTOFMEM

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 经管营销 > 经济市场

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1