|
Note: This is an unedited contribution. If this article is inappropriate,
needs attention or copies someone else's work without reference then please
Report This Article
Introduction
This is a simple program and can be use to access webcam from the visual basic 6.
This program checks whether webcam is available or not. If not available simple gives
a message otherwise capture from the webcam and displays in picture box.
This program has 3 diffrent functionality.
- Capture from the webcam
- Close the webcam
- Format the video
Source Code 'This program check whether webcam is available or not ' if available then capture and displays in picture box
'Created by Dixanta Bahadur Shrestha 'Created Date: 12-March-2006
'Programmer does not garuntees if not functions well
Global Const ws_child As Long = &H40000000 Global Const ws_visible As Long = &H10000000
Global Const WM_USER = 1024 Global Const wm_cap_driver_connect = WM_USER + 10 Global Const wm_cap_set_preview = WM_USER + 50 Global Const WM_CAP_SET_PREVIEWRATE = WM_USER + 52 Global Const WM_CAP_DRIVER_DISCONNECT As Long = WM_USER + 11 Global Const WM_CAP_DLG_VIDEOFORMAT As Long = WM_USER + 41 Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long Declare Function capCreateCaptureWindow Lib "avicap32.dll" Alias "capCreateCaptureWindowA" (ByVal a As String, ByVal b As Long, ByVal c As Integer, ByVal d As Integer, ByVal e As Integer, ByVal f As Integer, ByVal g As Long, ByVal h As Integer) As Long
Dim hwdc As Long Dim startcap As Boolean Private Sub cmdCapture_Click() Dim temp As Long
hwdc = capCreateCaptureWindow("Dixanta Vision System", ws_child Or ws_visible, 0, 0, 320, 240, Picture1.hWnd, 0) If (hwdc <> 0) Then temp = SendMessage(hwdc, wm_cap_driver_connect, 0, 0) temp = SendMessage(hwdc, wm_cap_set_preview, 1, 0) temp = SendMessage(hwdc, WM_CAP_SET_PREVIEWRATE, 30, 0) startcap = True Else MsgBox ("No Webcam found") End If End Sub
Private Sub cmdClose_Click() Dim temp As Long If startcap = True Then temp = SendMessage(hwdc, WM_CAP_DRIVER_DISCONNECT, 0&, 0&) startcap = False End If End Sub
Private Sub cmdVideoFormat_Click() Dim temp As Long If startcap = True Then temp = SendMessage(hwdc, WM_CAP_DLG_VIDEOFORMAT, 0&, 0&) End If End Sub
Feel free to contact me at dixanta@hotmail.com
| You must Sign In to use this message board. |
|
| | Msgs 1 to 10 of 10 (Total in Forum: 10) (Refresh) | FirstPrevNext |
|
 |
|
|
i'm looking for a clue on how to bring up the webcam properties window, like the video format window but to set brightness, contrast, hue, sharpness etc. i'm writing in VB6. i've been googling about but just cannot seem to find anything at all! any help would be v.much appreciated  '#######################################
found it! in desperation i used a command button to just keep adding 1 to my testnumber ! eg:
'cmn = cmn+1 'testnumber = (1024 + cmn) '--> 5 causes error outside of VB even with error trap! 'testme = SendMessage( mCapHwnd, testnumber, 0&, 0& )
'#############################################
nice value for cmn, it was the answer to life the universe and everything !! --> 42 !
why ain't computers telepathic yet? life would be so much nore fun! modified on Tuesday, March 25, 2008 9:07 AM
<div class="ForumMod">modified on Tuesday, March 25, 2008 9:17 AM</div>
|
| Sign In·View Thread·PermaLink | 4.00/5 (1 vote) |
|
|
|
 |
|
|
 |
|
|
"Please send me the vb 6 code for accessing webcam captures into image control & also send me the code to save the images." - GHANASHYAM
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Hi,
can someone please help me with that code??
I can copy it and it works but I don't understand how and why ... What does that "user32.dll /SendMessageA" normally do (and what do the parameters mean?) and how works "avicap32" ? Can you write: hwdc = capCreateCaptureWindow("blabla", "&H40000000" Or "&H10000000" , 0, 0, 320, 240, Picture1.hWnd, 0) instead of hwdc = capCreateCaptureWindow("blabla", ws_child Or ws_visible, 0, 0, 320, 240, Picture1.hWnd, 0)??? 
Additionally: Do you know how to save that stream into a ?AVI?-File ???
thanks
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
I am using VB Express and i get an error on the code that creates the capture window:
hwdc = capCreateCaptureWindow("Dixanta Vision System", _ ws_child Or ws_visible, 0, 0, 320, 240, Picture1.hWnd, 0)
the error is that hWnd is not a member of Picturebox. Can you tell me what this member is (and perhaps what it maps to in the newer version of VB)?
thnx
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
 |
|
|
how to capture & then save it in image format such BMP or JPEG. Please, I really need your help. Thank you.....
-- modified at 18:45 Saturday 29th April, 2006
|
| Sign In·View Thread·PermaLink | 1.50/5 (4 votes) |
|
|
|
 |
|
|
 |
|
|
Hi, Do you really success in having a frame every 30 msec? I can not have better then 5 or 6 frames /sec...
I use a callback function and can get real rate. It's then same render than with your code, so...
|
| Sign In·View Thread·PermaLink | 3.50/5 (2 votes) |
|
|
|
 |
|
|
The code may be useful to some but sadly as an article this sucks. It has no content and explains nothing. It is nothing more than a code snippet and is doubtfull that it is much use to a begginer without any other form of documentation.
If you re-write it and flesh it out a bit you may get more interest than the 1 votes you are getting at the moment (I voted you a 1 by the way but at least i left a comment so you know why. Many will not).
Jonathan
-- modified at 10:45 Monday 13th March, 2006
|
| Sign In·View Thread·PermaLink | 2.00/5 (3 votes) |
|
|
|
 |
|
|
General News Question Answer Joke Rant Admin
|