I am to present my project recently.This is very important you see I can't proceed with my project because I am not able to capture a video in my VB form from a video device attached to a PC using USB. How can I do that please help me.

Dani AI

Generated

As suggested checking the COM port: that only helps if the USB device actually exposes a serial/virtual‑COM interface (some capture dongles do). Most USB webcams are USB Video Class (UVC) devices and are presented to Windows as video‑capture devices, not COM ports—they are consumed through DirectShow or Media Foundation APIs rather than a serial COM control. (learn.microsoft.com)

For Visual Basic today the common, practical approaches are:

  • VB.NET: use a maintained wrapper rather than rolling raw DirectShow COM calls. Popular options are AForge.Video.DirectShow or the Accord.NET video packages (both available on NuGet) for quick preview and frame events; for new development Microsoft recommends using Media Foundation for capture/encoding on modern Windows.
  • Recording: either use Media Foundation’s capture/sink writer or delegate encoding to ffmpeg (many projects capture frames then hand them to ffmpeg).
  • VB6: you’ll need an ActiveX/OCX or to consume the native DirectShow samples (legacy), which is more work.
    These libraries and platform notes are documented on the projects and Microsoft pages linked below. ()

Troubleshooting checklist (fast): confirm the camera appears under Device Manager (Imaging devices), test it with the built‑in Windows Camera app or the DirectShow sample apps (PlayCap/AmCap) to prove OS-level capture works, check Windows camera privacy settings and that no other app has exclusive control, and ensure your app’s platform target (x86 vs x64) matches any native filters/wrappers you use. Many “doesn’t show” problems are drivers, privacy settings, or bitness mismatches. (learn.microsoft.com)

Suggested quick plan to get a demo working before your presentation: 1) plug camera in and verify it in Device Manager and the Windows Camera app; 2) in a VB.NET test project add AForge.Video.DirectShow (or Accord.Video.DirectShow) from NuGet and enumerate devices to show a preview; 3) if you must record, prototype by piping frames to ffmpeg or use Media Foundation Sink Writer; 4) if you’re stuck on VB6 consider a small helper app (or a wrapper/OCX) that streams to your form. The links below point to official docs and the NuGet packages for these options. ()

References (quick): Media Foundation capture docs (Microsoft), UVC/usbvideo.sys notes, , , FFmpeg devices docs, DirectShow samples (AmCap/PlayCap), Handle camera privacy.

Recommended Answers

All 2 Replies

Your project requires first a com control component to sniff the USB port, where you have connected your video device. Try to use the Microsoft Comm Control component. If you know that it is very easy. Another way is to use thw Window API

which has the following code to open.

Dim MyPortID as integer
Dim MyComStatus as long
Dir MyComError as string
Dim MyData as string


MyPortId=1 ' or 2 or 3 etc representing com1,com2 etc.

MyComStatus=CommOpen(MyPortID, "COM" & CStr(mytPortID), _
"baud=9600 parity=N data=8 stop=1")
If MyComStatus <> 0 then
'call Error handler
MyComStatus = commGetError(MyComError)
MsgBox "COM ERROR : " & MyComError
end sub
endif

'SET MODEM CONTROL LINES

MyComStatus = CommSetLine(MyPortID, LINE_RTS, True)
MyComStatus = CommSetLine(MytPortID, LINE_DTR, True)

'Read max 64 bytes from the port

MyComStatus = CommRead(MyPortID, MyData, 64)
If MyStatus > 0 Then
' Process data.
ElseIf MyStatus < 0 Then
' Handle error.
End If

' RESET MODEM CONTROL LINES.

MyComStatus = CommSetLine(MyPortID, LINE_RTS, False)
MyComStatus = CommSetLine(MyPortID, LINE_DTR, False)

' Close communications.
Call CommClose(MyPortID)


Please Do not ask this type of help from the forum. As you require the project very badly, I am sending this code to begin it.

Happy Programming.


AV Manoharan

the easiest way to do this is (i'm using visual basic 2008 express edition)

project>add reference
click browse
browse to the folder where touchlesslib.dll is and add it (can't remember if you need webcamlib.dll, so add it too)

then declare camcapture publicly (that is, not inside a sub)

to do this, type dim camcapture as new touchlesslib.touchlessmgr

then on the form_load event, type camcapture.currentcamera = camcapture.cameras.first 'you may modify this to choose a different camera

finally, on timer1_tick event, type dim snapshot = camcapture.currentcamera.getcurrentimage

picturebox1.image = snapshot


obviously, you have to set the timer to enabled, and the interval to 1 to prevent slow refresh rate.

if you don't have, or can't find the dynamic link libraries (.dll file) mentioned above, download them from:

http://sites.google.com/site/freecustomprograms/custom-software-downloads


EDITED: this is to display a live feed from a webcam in a picturebox. i don't know how to record videos, but i can save pictures

commented: better reply to more recent questions, this question is in VB 6 forum not .net. -3
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.