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.26k stars 1.11k forks source link

UnsatisfiedLinkError against OpenIMAJGrabber.startSession(IIILorg/bridj/Pointer;) #766

Open sarxos opened 4 years ago

sarxos commented 4 years ago

Opening Webcam cause this error on Linux machine:

21:02:21.519 [SwingWorker-pool-2-thread-1] DEBUG com.github.sarxos.webcam.Webcam - Webcam exception when opening
com.github.sarxos.webcam.WebcamException: Cannot execute task
    at com.github.sarxos.webcam.WebcamProcessor$AtomicProcessor.process(WebcamProcessor.java:72) ~[classes/:na]
    at com.github.sarxos.webcam.WebcamProcessor.process(WebcamProcessor.java:140) ~[classes/:na]
    at com.github.sarxos.webcam.WebcamTask.process(WebcamTask.java:46) ~[classes/:na]
    at com.github.sarxos.webcam.ds.cgt.WebcamOpenTask.open(WebcamOpenTask.java:20) ~[classes/:na]
    at com.github.sarxos.webcam.Webcam.open(Webcam.java:295) [classes/:na]
    at com.github.sarxos.webcam.Webcam.open(Webcam.java:250) [classes/:na]
    at com.github.sarxos.webcam.Webcam.open(Webcam.java:236) [classes/:na]
    at com.github.sarxos.webcam.WebcamPanel$1.doInBackground(WebcamPanel.java:840) [classes/:na]
    at com.github.sarxos.webcam.WebcamPanel$1.doInBackground(WebcamPanel.java:1) [classes/:na]
    at javax.swing.SwingWorker$1.call(SwingWorker.java:295) [na:1.8.0_201]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_201]
    at javax.swing.SwingWorker.run(SwingWorker.java:334) [na:1.8.0_201]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_201]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_201]
    at java.lang.Thread.run(Thread.java:748) [na:1.8.0_201]
Caused by: java.lang.UnsatisfiedLinkError: com.github.sarxos.webcam.ds.buildin.natives.OpenIMAJGrabber.startSession(IIILorg/bridj/Pointer;)Z
    at com.github.sarxos.webcam.ds.buildin.natives.OpenIMAJGrabber.startSession(Native Method) ~[classes/:na]
    at com.github.sarxos.webcam.ds.buildin.WebcamDefaultDevice.open(WebcamDefaultDevice.java:332) ~[classes/:na]
    at com.github.sarxos.webcam.ds.cgt.WebcamOpenTask.handle(WebcamOpenTask.java:38) ~[classes/:na]
    at com.github.sarxos.webcam.WebcamProcessor$AtomicProcessor.run(WebcamProcessor.java:81) ~[classes/:na]
    ... 3 common frames omitted
sarxos commented 4 years ago

Hi @kkieffer

This issue is caused by a method parameter signature being changed from double to int in your commit here:

https://github.com/sarxos/webcam-capture/pull/765/files#diff-492ecf2a3cddaf20cf2f0e1a230fa31d.

I initially thought it's a valid change since it's only normal to assume that FPS is int, but it looks like BridJ needs it to be double to link correct function exported in native library, thus I'm reverting it back to how it was before.

Can you please test newest 0.3.13-SNAPSHOT on your MacOS machine to verify if this change works well? I have no access to Apple boxes and can't verify it.

kkieffer commented 4 years ago

It won't compile correctly if it's a double. The native code wants an int. See the native source here, where reqMillisPerFrame is an int:

image
sarxos commented 4 years ago

@kkieffer

Ok, I understand now why you had to change it. Let me check why it's not linking on my Linux box. I suppose there is a bug somewhere else in the code or pom since OpenIMAJ also have int in OpenIMAJGrabber class.

sarxos commented 4 years ago

@kkieffer

Nailed it. The so files for x64 and x86 Linux are outdated (others probably as well). I will update them and change double to int as it should be.

sarxos commented 4 years ago

@kkieffer Thank you for your help. Everything should be working now. Can I ask you one more time to verify if the 0.3.13-SNAPSHOT is working well on Mac? I suppose it should be working but better be safe than sorry :) The latest snapshot is already deployed in Sonatype and available here.

kkieffer commented 4 years ago

Working!

sarxos commented 4 years ago

Great. Thank you!