Using the vlcj library, it is possible to get a live web camera image to display on a Canvas object.
The vlcj library is capable of much more than just displaying a web cam live feed. It can play dvd's , play http streams, stream video and a few more things.
This library (jWebCam) is a very rough implementation of using a web cam.
You will need to know the name of your webcam ( on windows device manager will tell you).
You will need to download three vlc library files.
You also need Videolan VLC installed somewhere on the machine.
When you start the demo prog, it will ask you to find the VLC folder (so it can find the .dll's)
It will save this information in a properties file (jWebCam.properties), and on subsequent runs , won't request the info again.
Two things to be aware of:
1, The mainform_CloseRequest line webcam.release is VERY important. If you don't release the webcam, it will continue in background as it is on a separate thread.
2. The pause button... I was tempted to remove it. During pause, it still buffers the images, the longer you pause, the more memory you will lose. If you leave it on pause, expect to see lots (and I mean lots) of low memory warnings. Leave it paused too long and IT WILL KILL THE VM.
I have included the source for the library in the zip.
(The latest version I am using [will upload soon] works as an excellent media player - trying to find something it can't play )
jWebCamLibrary-1:
This has some refinements on the first. Nothing major.
You can do this with it
The first line will cause a file selector to appear, just point it at an avi/mkv/divx movie and it will play it in canvas1, whilst showing the input from the webcam in canvas2. Obviously you need to dim 2 jWebCam objects.
VERY IMPORTANT : if you use extra feeds, add the 'release' to MainForm_CloseRequest sub to free up the resources they use.
jWebCamLibrary-2:
new function added
"movie" is entered as is, not the name of the film etc.
"E:/" is the drive letter of the dvd drive you want to play from.
add a button that calls webcam.playDVD and it will play the dvd in the canvas object.
In debug mode you will see messages from VLC, nothing I can do about them at present.
The vlcj library is capable of much more than just displaying a web cam live feed. It can play dvd's , play http streams, stream video and a few more things.
This library (jWebCam) is a very rough implementation of using a web cam.
You will need to know the name of your webcam ( on windows device manager will tell you).
You will need to download three vlc library files.
You also need Videolan VLC installed somewhere on the machine.
When you start the demo prog, it will ask you to find the VLC folder (so it can find the .dll's)
It will save this information in a properties file (jWebCam.properties), and on subsequent runs , won't request the info again.
Two things to be aware of:
1, The mainform_CloseRequest line webcam.release is VERY important. If you don't release the webcam, it will continue in background as it is on a separate thread.
2. The pause button... I was tempted to remove it. During pause, it still buffers the images, the longer you pause, the more memory you will lose. If you leave it on pause, expect to see lots (and I mean lots) of low memory warnings. Leave it paused too long and IT WILL KILL THE VM.
I have included the source for the library in the zip.
(The latest version I am using [will upload soon] works as an excellent media player - trying to find something it can't play )
jWebCamLibrary-1:
This has some refinements on the first. Nothing major.
You can do this with it
B4X:
webcam.Initialize(canvas1,"dshow://","")
webcam1.Initialize(canvas2,"dshow://","vdev="&Chr(34)&"Live! Cam Vista IM"&Chr(34))
The first line will cause a file selector to appear, just point it at an avi/mkv/divx movie and it will play it in canvas1, whilst showing the input from the webcam in canvas2. Obviously you need to dim 2 jWebCam objects.
VERY IMPORTANT : if you use extra feeds, add the 'release' to MainForm_CloseRequest sub to free up the resources they use.
jWebCamLibrary-2:
new function added
B4X:
webcam.Initialize(canvas1,"movie","E:/")
"E:/" is the drive letter of the dvd drive you want to play from.
add a button that calls webcam.playDVD and it will play the dvd in the canvas object.
In debug mode you will see messages from VLC, nothing I can do about them at present.
Attachments
Last edited: