Webcam / Video Capture - Dialogless Camera Select?
hi guys...
im using the AVICap code to open up a view of a webcam - then setting the parent "window" of the image to on my form - so it appears my application owns the image etc...
Microsoft WDM Image Capture (Win32) < the "Driver" being used to capture the image...
Starting video like this....
vBCode Code:
Dim lpszName As String * 100
Dim lpszVer As String * 100
Dim Caps As CAPDRIVERCAPS
'//Create Capture Window
capGetDriverDescriptionA 0, lpszName, 100, lpszVer, 100 '// Retrieves driver info
lwndC = capCreateCaptureWindowA(lpszName, WS_CHILD Or WS_VISIBLE, 0, 0, 160, 120, lgOwner, 0)
'// Connect the capture window to the driver
capDriverConnect lwndC, 0
'// Get the capabilities of the capture driver
capDriverGetCaps lwndC, VarPtr(Caps), Len(Caps)
'// Set the video stream callback function
capSetCallbackOnVideoStream lwndC, AddressOf MyVideoStreamCallback
capSetCallbackOnFrame lwndC, AddressOf MyFrameCallback
'// Set the preview rate in milliseconds
capPreviewRate lwndC, 66
'// Start previewing the image from the camera
capPreview lwndC, True
'// Resize the capture window to show the whole image
ResizeCaptureWindow lwndC
' say we are viewing the video
bViewVideo = True
and disabling the video like this:
vbcode Code:
'// Disable all callbacks
capSetCallbackOnStatus lwndC, vbNull
capSetCallbackOnYield lwndC, vbNull
capSetCallbackOnFrame lwndC, vbNull
capSetCallbackOnVideoStream lwndC, vbNull
capSetCallbackOnWaveStream lwndC, vbNull
capSetCallbackOnCapControl lwndC, vbNull
capSetCallbackOnError lwndC, vbNull
DoEvents
bViewVideo = False
all working great... EXCEPT:
am i correct in thinking i also need to DESTROY the window that was created using this code...
vbcode Code:
lwndC = capCreateCaptureWindowA(lpszName, WS_CHILD Or WS_VISIBLE, 0, 0, 160, 120, lgOwner, 0)
just got wondering this, since the last visible image from the camera remains on my form, even though the window should of closed? (not a problem, since i hide this control anyway, but would be nice to keep the resources free)
and secondly.. i have two cameras that i can select... - i dont suppose there is a dialogless way to select either camera is there
i have searched the forums and have come to the conclusing the dialog is required, but would be nice just for confirmation of this. Cheers.
Re: Webcam / Video Capture - Dialogless Camera Select?
Quote:
and secondly.. i have two cameras that i can select... - i dont suppose there is a dialogless way to select either camera is there
i have searched the forums and have come to the conclusing the dialog is required, but would be nice just for confirmation of this. Cheers.
i spent a time looking and did not find a way
Re: Webcam / Video Capture - Dialogless Camera Select?
thats what most of the posts ive found suggest - there being no way to do it. but surely there must be some way?
- maybe hide the visible dialog and choose the option via code maybe?
do you have an answer about destroying the window created? - if view the cam a second time it asks me to select the source [ displaying the dialog ] ... this also leads me to feel that the first video is still open? - would a "Close Window" message suffice for terminating the camera processes?
Re: Webcam / Video Capture - Dialogless Camera Select?
You could do it programatically by using FindWindow/FindWindowEx, and even enumerate items in the dropdown list (probably using SendMessage API) and simulate a key press on the Ok button.
I've never had to do this before so I'm not exactly sure how.
Re: Webcam / Video Capture - Dialogless Camera Select?
Quote:
do you have an answer about destroying the window created? - if view the cam a second time it asks me to select the source [ displaying the dialog ] ... this also leads me to feel that the first video is still open? - would a "Close Window" message suffice for terminating the camera processes?
i was just using
SendMessage hCapWin, WM_CAP_DRIVER_DISCONNECT, 0, 0
to stop the webcam
have you looked if there is any registry setting for current webcam?
Re: Webcam / Video Capture - Dialogless Camera Select?
I think selecting the webcam source via code is possible, I have seen some threads about it when I googled it a few weeks back. It involves reading the registry for the code of the webcam, the samples I have seen are for .Net but the codes are applicable to VB6.
Re: Webcam / Video Capture - Dialogless Camera Select?
- well this is strange, i posted a reply yesterday that hasnt shown up :S.
well just to let you know...
i use the
DestroyWindow lhwndC
code to destroy the window
and on reading westconn's reply, also added the disconnect driver command prior to this. :P got rid of the last image from my form, AND no long shows the dialog on the second run of the code on the same app instatance..
ill try google for some code for reading from registry. :)
- although, i will use a settings form initially to "Select Camera 1" > get input from dialog > save input
then camera1_click > get setting > [im guessing i then need to send this to the CAPTURE Driver, and not my Preview window?]
ill have a look for some code for this... im guessing i have all the api i need for it already in my code... but its not a major thing YET as the main camera i need to use is the rear camera i can just set this up as default, and only need to change for a front view.