Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webcam CyberLink Webcam Splitter 0 has already been locked #174

Closed
ajay154 opened this issue Feb 4, 2014 · 8 comments
Closed

Webcam CyberLink Webcam Splitter 0 has already been locked #174

ajay154 opened this issue Feb 4, 2014 · 8 comments

Comments

@ajay154
Copy link

ajay154 commented Feb 4, 2014

when I executed DetectMotionExample.java it give me error::

Exception in thread "main" com.github.sarxos.webcam.WebcamLockException: Webcam CyberLink Webcam Splitter 0 has already been locked
    at com.github.sarxos.webcam.WebcamLock.lock(WebcamLock.java:224)
    at com.github.sarxos.webcam.Webcam.open(Webcam.java:181)
    at com.github.sarxos.webcam.Webcam.open(Webcam.java:147)
    at com.github.sarxos.webcam.WebcamMotionDetector.start(WebcamMotionDetector.java:186)
    at DetectMotionExample.<init>(DetectMotionExample.java:22)
    at DetectMotionExample.main(DetectMotionExample.java:31)
@sarxos
Copy link
Owner

sarxos commented Feb 5, 2014

Hi @ajay154, which webcam capture version are you using?

@ajay154
Copy link
Author

ajay154 commented Feb 5, 2014

@sarxos i am using webcam-capture-0.3.10-RC4 version

@sarxos
Copy link
Owner

sarxos commented Feb 5, 2014

@ajay154, thank you for the clarification. Can you please try with RC6? There were fixes introduced within the locking mechanism after RC4 in regards to #65, #128 and #131.

Please also check if you are not running the same process in parallel - locking mechanism has been created to prevent such situations (when one webcam capture process has camera open and the second one is trying to open it again).

@ajay154
Copy link
Author

ajay154 commented Feb 5, 2014

@sarxos thank you...now its working,but in eclipse
import sun.misc.Signal;
import sun.misc.SignalHandler; gives
"Access restriction: The type Signal is not accessible due to restriction on required library C:\Program Files\Java\jdk1.7.0_45\jre\lib\rt.jar", how to resolve it.
and I want to make a speedcam which can calculate speed of a moving object by taking subsequent snapshots , how to do it.

@sarxos
Copy link
Owner

sarxos commented Feb 5, 2014

HI @ajay154,

Access restriction: The type Signal is not accessible due to restriction on required library C:\Program Files\Java\jdk1.7.0_45\jre\lib\rt.jar

The Signal API is restricted, but it should not give you any errors. This is most likely your Eclipse setting problem - please google for the solution or change the settings as described here.

I want to make a speedcam which can calculate speed of a moving object by taking subsequent snapshots , how to do it.

Well, there are dozens of possible solutions. E.g. the naive one - assume you know the scale ratio between the image size and real view dimension (e.g. 640 px = 2 meters), you can get the COG (center-of-gravity) point of motion detector, which may be used to calculate the distance between two consecutive frames. Let PCOG1(x1,y1) be a center-of-gravity point of frame 1 and PCOG2(x2,y2) a center-of-gravity point of frame 2, and the distance the object moved on the image is Δpx = √(|x2 - x1|2 + |y2 - y1|2), which may be translated to view dimension by multiplying by scale factor s defined as s = dm/dpx [m/px] where dpx and dm are corresponding distances from image and real view. Multiplication gives you the number of meters per single pixel unit. If you assume that t is a time difference between two snapshots, you can calculate the object speed as v = Δpx * s / t [m/s]

Please note that this is naive approach and not super accurate - you have to assume that only measured object is moving and its geometry is constant. Otherwise COG will be calculated incorrectly. If you are looking for other, more advanced solution, you may use features tracking, e.g. from awesome OpenIMAJ framework.

To implement naive approach using Webcam Capture API only, you will need to change the WebcamMotionDetector source code so it pass lastMotionTimestamp variable into the WebcamMotionEvent - you will need it to calculate time different. You can of course use this class to write your own motion detector where you pimp your algorithm and drop all unnecessary things from the original one - feel free to experiment - I would do that myself, but have no time lately :( ...

@ajay154
Copy link
Author

ajay154 commented Feb 5, 2014

Thanks,I want to use image difference between consecutive images as it is done here http://morefunscience.blogspot.in/2012/05/calculating-speed-using-webcam.html .

@sarxos
Copy link
Owner

sarxos commented Feb 5, 2014

Yup, exactly the same method, but bounds used instead of COG.

Good luck :)

@sarxos sarxos closed this as completed Feb 5, 2014
@UrviT
Copy link

UrviT commented Aug 28, 2020

How to change the version through maven dependency?
Currently: 0.3.10
How to get RC6 here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants