The goal of this class is to control a webcam. There is a free software project called Webcam Capture (Generic Webcam Java API). The data of the author of this API are:
Bartosz Firyn.
Web
GitHub
This class directly accesses to some functions of the Webcam Capture Api.
Instructions:
1. Copy this
files (Link) to the folder defalut libs of the B4J:
2. In the project add the references to the libs like the image below:
3.- Check the JavaObject library like the image below:
4.- Use the class
Class: Webcam
Author of the class: @somed3v3loper
Version: 1.0
The available methods are:
- getDefaultCam
- SetDimension (cam As JavaObject, width As Int, height As Int)
- OpenCam (cam As JavaObject)
- TakePicture(cam As JavaObject, filename As String)
Example:
Code:
#Region Project Attributes
#MainFormWidth: 600
#MainFormHeight: 400
#AdditionalJar : webcam-capture-0.3.10
#AdditionalJar : slf4j-api-1.7.2
#AdditionalJar : bridj-0.6.2
#End Region
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Dim cam As Webcam
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
'MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file.
MainForm.Show
cam.Initialize
Dim defaultCam As JavaObject=cam.defaultCam
cam.setDimension(defaultCam,640,480)
cam.OpenCam(defaultCam)
cam.TakePicture(defaultCam,"test1.png")
End Sub
This class comes from the information provided in the discussion of the following thread:
https://www.b4x.com/android/forum/threads/web-camera.36098/
Thanks to:
@somed3v3loper (he is the initial autor of the class), I'm just gathering information and putting it pretty
I hope that the class is going to expand soon with the other functions. Any comments or contribution is welcome