-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Strange conflict between JavaFx MediaPlayer and OpenCVFrameGrabber after Windows wakes up after Sleep mode #947
Comments
Looks like a bug in OpenCV. Could you report this issue upstream? Alternatively, you could try to use VideoInputFrameGrabber or FFmpegFrameGrabber. They usually work better than OpenCV. |
I don't know how to test FfmegFrameGrabber. It doesn't work with device int number. I tried to get list of devices with
but I've got an error:
|
https://trac.ffmpeg.org/wiki/DirectShow
You forgot the "video=" prefix and the double quotes.
|
The same result: "Could not open input..." |
Does it work with the ffmpeg program? |
This code works fine: ffmpeg -f dshow -i video="Logitech HD Pro Webcam C920" out.avi |
And this is with JavaCV 1.4.1-SNAPSHOT? |
|
Apparently the magic string would be "video=Logitech HD Pro Webcam C920", without the double quotes: |
I tested FFmpegFrameGrabber. The same problem. Stuck on start after sleep. |
What about VideoInputFrameGrabber?
|
Stuck. |
So, bug in JavaFX? File an issue over there: https://github.com/javafxports/openjdk-jfx/issues |
All works except JavaCv. MedeaPlayer works fine after sleep. I noticed that I could workaround this with invoking dispose() for player after it's played a sound. I'm not sure but I suppose that this bug belongs to JavaCv project. Or maybe JavaFx and JavaCv use some native unsafe methods deep inside. |
What other library are you using to capture from your webcam? |
The class in code that I posted above is the only. I created an empty test project and reproduced error in it. |
You mean it happens without JavaFX? Sounds like a bug in your webcam driver. Could you try another application that captures from your camera like Skype? |
The only problem is that Grabber hangs on start(). It happens only when there is allocated JavaFx's MediaPlayer. And it happens only after Windows wakeup after sleep mode. App restarting removes this bug. Other components (JavaFx) and programs (Skype) works fine. |
Ok, so it's most likely a bug in JavaFX. |
But why it happens only here? org.bytedeco.javacpp.opencv_videoio$VideoCapture.allocate(opencv_videoio.java) |
I thought you said it also happened with FFmpeg and videoInput. Please use FFmpegFrameGrabber and VideoInputFrameGrabber instead. Like I said, they usually work better than OpenCV. |
It's not a driver because I tested it on many different cameras and PCs. And I actually don't believe that JavaFX developers will agree that this is bug of JavaFX because JavaFX works fine. It doesn't stuck. VideoInputFrameGrabber
FFmpegFrameGrabber
|
It happens not only in JavaFX Thread. I changed code. Now grabber starts in new thread after button click. I pressed two times and got this:
|
It's highly unlikely that OpenCV, FFmpeg, and videoInput all have the same bug, and you say this only happens with JavaFX, so... |
But it's not raw cpp OpenCV, FFmpeg... It's wrapped. |
So, sure, I've been telling to try to capture from the webcam with another library. I'm pretty sure it will do the same thing, but it's up to you whether you want to debug this or not! |
For example, what happens when capturing with Webcam Capture? |
I will test it on opencv java and on this. |
BTW, the JavaCPP Presets for OpenCV now bundle the official Java API as well too: |
I tried it with org.opencv.core.Core and got the same result. Probably it's JavaFx's bug. |
See also: javafxports/openjdk-jfx#56 |
Steps to reproduce:
Run code:
Press "test": works fine.
Sleep/Wake up Windows.
Press "test": stuck on start().
Stack:
The text was updated successfully, but these errors were encountered: