If you can please release your library.I now have the image from the webcam appearing in a javafx canvas object.
It requires VLC to be installed on the machine, but that's probably 90% of users anyway.
Maybe in the future. If there is an open source Java project that already implements it then it will be more feasible.
Erel, there is a Java project open source (MIT Licence) called Webcam Capture:
Page: http://webcam-capture.sarxos.pl/
Github: https://github.com/sarxos/webcam-capture
This library allows you to use your build-in or external webcam directly from Java. It's designed to abstract commonly used camera features and support multiple capturing farmeworks.
This may help anything? Is it possible to make a library of this?
#AdditionalJar : webcam-capture-0.3.10
#AdditionalJar : slf4j-api-1.7.2
#AdditionalJar : bridj-0.6.2
Sub JustToTest
Private WebCam,ImageIO,BufferedImage,FileIO,Dimension As JavaObject
FileIO= FileIO.InitializeNewInstance("java.io.File",Array("test1.png"))
ImageIO.InitializeStatic("javax.imageio.ImageIO")
WebCam.InitializeStatic("com.github.sarxos.webcam.Webcam")
Try
WebCam=WebCam.RunMethod("getDefault",Null)
Log("Default cam : "&WebCam)
Catch
Log(LastException.Message)
End Try
Try
WebCam.RunMethod("setViewSize",Array(Dimension.InitializeNewInstance("java.awt.Dimension",Array(640,480))))
Log("Open: "&WebCam.RunMethod("open",Null))
Catch
Log(LastException.Message)
End Try
BufferedImage.InitializeStatic("java.awt.image.BufferedImage")
BufferedImage=WebCam.RunMethod("getImage",Null)
ImageIO.RunMethod("write",Array(BufferedImage, "PNG", FileIO))
Log("Close: "&WebCam.RunMethod("close",Null))
End Sub
my god!, it works perfectly with my webcam on my lap (generic i tink)... Sorry for my image, the web cam that would not advise taking the pictureI had some success using this library through JavaObject Library :
This is an example from their website converted to B4J .
Do not forget to copy webcam-capture-0.3.10.jar , bridj-0.6.2.jar and slf4j-api-1.7.2.jar to Library folder .
Add references :
B4X:#AdditionalJar : webcam-capture-0.3.10 #AdditionalJar : slf4j-api-1.7.2 #AdditionalJar : bridj-0.6.2
And use this sub
B4X:Sub JustToTest Private WebCam,ImageIO,BufferedImage,FileIO,Dimension As JavaObject FileIO= FileIO.InitializeNewInstance("java.io.File",Array("test1.png")) ImageIO.InitializeStatic("javax.imageio.ImageIO") WebCam.InitializeStatic("com.github.sarxos.webcam.Webcam") Try WebCam=WebCam.RunMethod("getDefault",Null) Log("Default cam : "&WebCam) Catch Log(LastException.Message) End Try Try WebCam.RunMethod("setViewSize",Array(Dimension.InitializeNewInstance("java.awt.Dimension",Array(640,480)))) Log("Open: "&WebCam.RunMethod("open",Null)) Catch Log(LastException.Message) End Try BufferedImage.InitializeStatic("java.awt.image.BufferedImage") BufferedImage=WebCam.RunMethod("getImage",Null) ImageIO.RunMethod("write",Array(BufferedImage, "PNG", FileIO)) Log("Close: "&WebCam.RunMethod("close",Null)) End Sub
My CyberLink built-in YouCam must be started or I will get their logo and a message instead of my face.
![]()
Starting step: Compiling Java code.
javac 1.8.0_40
C:\Users\Ricardo\Desktop\SimpleLibraryCompiler\WebCam\src\com\github\sarxos\webcam\WebcamSignalHandler.java:6: warning: Signal is internal proprietary API and may be removed in a future release
import sun.misc.Signal;
^
C:\Users\Ricardo\Desktop\SimpleLibraryCompiler\WebCam\src\com\github\sarxos\webcam\WebcamSignalHandler.java:7: warning: SignalHandler is internal proprietary API and may be removed in a future release
import sun.misc.SignalHandler;
^
C:\Users\Ricardo\Desktop\SimpleLibraryCompiler\WebCam\src\com\github\sarxos\webcam\WebcamSignalHandler.java:17: warning: SignalHandler is internal proprietary API and may be removed in a future release
final class WebcamSignalHandler implements SignalHandler {
^
C:\Users\Ricardo\Desktop\SimpleLibraryCompiler\WebCam\src\com\github\sarxos\webcam\WebcamSignalHandler.java:23: warning: SignalHandler is internal proprietary API and may be removed in a future release
private SignalHandler handler = null;
^
C:\Users\Ricardo\Desktop\SimpleLibraryCompiler\WebCam\src\com\github\sarxos\webcam\WebcamSignalHandler.java:26: warning: Signal is internal proprietary API and may be removed in a future release
handler = Signal.handle(new Signal("TERM"), this);
^
C:\Users\Ricardo\Desktop\SimpleLibraryCompiler\WebCam\src\com\github\sarxos\webcam\WebcamSignalHandler.java:26: warning: Signal is internal proprietary API and may be removed in a future release
handler = Signal.handle(new Signal("TERM"), this);
^
C:\Users\Ricardo\Desktop\SimpleLibraryCompiler\WebCam\src\com\github\sarxos\webcam\WebcamSignalHandler.java:30: warning: Signal is internal proprietary API and may be removed in a future release
public void handle(Signal signal) {
^
C:\Users\Ricardo\Desktop\SimpleLibraryCompiler\WebCam\src\com\github\sarxos\webcam\log\WebcamLogConfigurator.java:44: error: package ch.qos.logback.classic does not exist
ch.qos.logback.classic.LoggerContext context = (ch.qos.logback.classic.LoggerContext) LoggerFactory.getILoggerFactory();
^
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
7 warnings
Error.
Thanks for the interest. I'll check the attachment in a few moments more.I do not think we need Java files to make it work .
You can check attached file which I think can be compiled to library if you want .
But anyway I beleive we need to reference library 3 JARs .
I would be glad to test this solution, as I am struggling quite some time with fswebcam. See my post Problem with file exists
Some basic questions:
Where to store the libs ? In additional libraries and or in the project folder.
How to reference those libs? They do not appear in the libs list.
Harry
I do not think we need Java files to make it work .
You can check attached file which I think can be compiled to library if you want .
But anyway I beleive we need to reference library 3 JARs .