Capture webcam without third party plugin?

Hello,
I am new and i am still evaluating the possibilities of this amazing IDE.

I am wondering if there is some way of capturing webcam but without using third party plugins. I am not
able to purchase any plugins at the moment.
I would like to implement video capture in my projects in the future, but i want to use built in Frameworks
in Mac and Windows if possible.

Thank you

Well, if you like to try our MBS Plugins, you can download a copy to test and let me know if it works for you.

Declares could be difficult and for AVFoundation with threaded callbacks quite difficult to do in Xojo.

Unfortunately i am afraid i am not able to purchase your plugins.

Is there any resource, tutorial or read available on interfacing mac and windows Frameworks in xojo projects ?
I would like to know how it is done.

Documentation on Declares

You can shell out to a helper app like this:

https://mattcollinge.wordpress.com/software/simple-webcam-capture/

Please try DirectShow plugin (Windows) and AVFoundation plugin (Mac).

Download here.

@Christian Schmitz Thank you ! I will definitely try them!
Still learning new things about xojo and all, but i can see already MBS plugins are far superior way of doing things.

http://c-studio.freevar.com/webcam.xojo_binary_project

for windows only

Regards,

Frederik Pot

@Frederik Pot Thank you for the download. I have been trying to create this video capture for a while, and the program only shows a black screen on my Windows Surface Pro. This seems to be a common problem on Windows with Xojo, Realbasic, and C++ and I have not been able to figure out a solution for Windows. Does anyone have some insight to a solution to the black screen video playback issue?

I’ve been working on a very simple webcam viewer (WIndows) for a quick portable school application. Using this thread and a couple of other threads I managed to get something that works on Win7 and Win10 almost all the time (using declares), I also just tried the MBS DirectShow and was able to get something up and running pretty quickly. I am uploading the original version (using declares) in case it helps someone down the line.
https://www.dropbox.com/s/dkhrs0hgy41wbxw/forum%20-%20webcam%20app.xojo_binary_project?dl=1

It depends the kind of webcam you want to use or connect to, but someones (WiFi, Ethernet) have and active http server you can query from Xojo in order to get the pictures every ‘n’ seconds. You don’t need the use of plug-ins for that… and it is multiplatform. For example, this is true with the ones provided by AXIS (and other manufacturers too…)

Javier

This thread and others were referring to either integrated webcams or ones plugged in via usb.

DirectShow plugin is what is required, I tried Christian’s DirectShow plugin and it works well.

I am trying to connect a camcorder via USB and Video2PC… https://www.ionaudio.com/products/details/video-2-pc-mkii

Something, maybe Declares, other than a plugin, for DirectShow is what I would like to have

Lennox

Thanks for the program @LangueR ,

The program doesn’t work on my Windows Book, and I modified some of the code, and its getting closer. Here is the modification from WindowMain.BtnConnect.Action:

Sub Action() Handles Action pCaptureDevice = WindowSelectDevice.getResult Soft Declare Function capCreateCaptureWindowA Lib "avicap32.dll" (lpszWindowName As Integer,dwStyle As Integer,x As Integer,y As Integer,nWidth As Integer,nHeight As Integer,hWndParent As Integer,nID As Integer)As Integer Soft Declare Function SendMessage Lib "user32" alias "SendMessageA"(hwnd As Integer,wMsg As Integer,wParam As Integer,lParam As Integer)As Integer If pCaptureWindow <> 0 Then Call SendMessage(pCaptureWindow,WM_CAP_DRIVER_DISCONNECT,pCaptureDevice,0) End If Const WS_CHILD As Integer = &H40000000 Const WS_VISIBLE As Integer = &H10000000 pCaptureWindow=capCreateCaptureWindowA(pCaptureDevice,BITOR(WS_VISIBLE,WS_CHILD),0,0,canvas1.Width,canvas1.Height,canvas1.handle,0) If SendMessage (pCaptureWindow,WM_CAP_DRIVER_CONNECT,pCaptureDevice,0)=1 Then //always sends zero Call SendMessage (pCaptureWindow,WM_CAP_SET_SCALE,1,0) Call SendMessage (pCaptureWindow,WM_CAP_SET_PREVIEWRATE,60,0) Call SendMessage (pCaptureWindow,WM_CAP_SET_PREVIEW,1,0) Call SendMessage (pCaptureWindow,WM_CAP_DLG_VIDEOFORMAT,1,0) Me.Enabled = False BtnDisconnect.Enabled = True BtnCapturePicture.Enabled = True System.DebugLog "Connected" Else System.DebugLog "Error connecting" End If End Sub

I placed the SendMessage … WM_CAP_DRIVER_CONNECT into an If-Else statement and it is always returning zero. If it connects then the returned value should be 1. Here is a link to WM_CAP_DRIVER_CONNECT information:

WM_CAP_DRIVER_CONNECT

I haven’t figured it out yet, and ran out of time, and I thought that I would share this with everyone. My Surface Book has a front and rear facing camera. Pressing the Start webcam… pushbutton displays the Select Capture Device window, and I select the only option of Microsoft WDM Image Capture (Win32). AFter pressing the OK button, then I get another window which is the Video Source and I am able to select one of two choices: 1) Microsoft Camera Front, 2) Microsoft Camera Rear. I select the front camera and Canvas1 is black and the System.DebugLog “Error connecting” message is shown in the IDE.

The driver is not connecting for some reason.

If you visit planet-source-code.com and look in the visual basic section, there’s examples using Windows API declares and you can pretty much copy, paste, edit the code where necessary (replacing & with + for string concatenations, etc.)…and wallah! :slight_smile: when I get to my computer later this evening I can post the code from my library.

Hi Matthew,

Any code for this as yet?

Thanks.

Lennox

Might need a little work for 64-bit, but this was done long ago for Windows in the Windows Functionality Suite
https://github.com/arbp/WFS/blob/master/Windows%20Functionality%20Suite/Graphics%20Helpers/Modules/WebCamWFS.rbbas

Hi Anthony,

I got everything else in but I do not know how to add this

#tag ViewBehavior
#tag ViewProperty
Name=“Index”
Visible=true
Group=“ID”
InitialValue="-2147483648"
InheritedFrom=“Object”
#tag EndViewProperty
#tag ViewProperty
Name=“Left”
Visible=true
Group=“Position”
InitialValue=“0”
InheritedFrom=“Object”
#tag EndViewProperty
#tag ViewProperty
Name=“Name”
Visible=true
Group=“ID”
InheritedFrom=“Object”
#tag EndViewProperty
#tag ViewProperty
Name=“Super”
Visible=true
Group=“ID”
InheritedFrom=“Object”
#tag EndViewProperty
#tag ViewProperty
Name=“Top”
Visible=true
Group=“Position”
InitialValue=“0”
InheritedFrom=“Object”
#tag EndViewProperty
#tag EndViewBehavior

Kindly advise.

I also checked the “Latest commit 8cf312b 17 days ago” on https://github.com/arbp/WFS and I do not see it in there.

Lennox

Don’t use mediafire. It’s riddled with ads, and they didn’t like your attempt at hacking the download key to hotlink an image.

Here is that screenshot uploaded to imgur

Thanks Tim,

I did not know that.

Lennox