sarxos / webcam-capture

The goal of this project is to allow integrated or USB-connected webcams to be accessed directly from Java. Using provided libraries users are able to read camera images and detect motion. Main project consist of several sub projects - the root one, which contains required classes, build-in webcam driver compatible with Windows, Linux and Mac OS, which can stream images as fast as your camera can serve them (up to 50 FPS). Main project can be used standalone, but user is able to replace build-in driver with different one - such as OpenIMAJ, GStreamer, V4L4j, JMF, LTI-CIVIL, FMJ, etc.
http://webcam-capture.sarxos.pl
MIT License
2.27k stars 1.11k forks source link

Access Webcam from Tomcat Webapplication #512

Open hoestreich opened 7 years ago

hoestreich commented 7 years ago

Hello,

we are using your webcam-capture framework in our project where we model workflows via bpmn (business process modelling and notation) which are then executed in another framework called Camunda.

There are two ways to built the process execution framework: Option 1 - Build a standalone java application, this works fine with your framework. Option 2 - Build a war file and deploy it to a tomcat webserver which is running the camunda framework. This leads to problems if we try to access the webcam within a process step. I then get exceptions as shown in the attached log file.

I am afraid this has to do with some security features from tomcat. Does someone know how to solve this?

Best regards and thanks in advance for any help, Hendrik catalina.2016-11-25.txt

sarxos commented 7 years ago

Hi @hoestreich,

In the stack trace I see that root cause is this exception:

Caused by: java.lang.UnsatisfiedLinkError: org.bridj.Platform.sizeOf_ptrdiff_t()I
    at org.bridj.Platform.sizeOf_ptrdiff_t(Native Method)
    at org.bridj.Platform.<clinit>(Platform.java:232)
    at com.github.sarxos.webcam.ds.buildin.natives.OpenIMAJGrabber.<clinit>(OpenIMAJGrabber.java:59)
    at com.github.sarxos.webcam.ds.buildin.WebcamDefaultDriver$WebcamNewGrabberTask.handle(WebcamDefaultDriver.java:55)
    at com.github.sarxos.webcam.WebcamProcessor$AtomicProcessor.run(WebcamProcessor.java:81)
    ... 3 more

The UnsatisfiedLinkError is in most cases caused by a native library not being loaded into runtime. I never tested how it behaves when packaged to war. Normally BridJ founds JAR and extract library from it, but here it may be failing. Can you enable BridJ debug logs to see what is happening under the hood? The following properties needs to be passed into JVM:

-Dwebcam.debug=true
-Dbridj.veryVerbose=true
-Dbridj.quiet=false
-Dbridj.logCalls=true
-Dbridj.debug=true