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

Cannot open local webcam on NetBeans JavaFX 8 Project #1618

Open
Adi-18 opened this issue Apr 3, 2021 · 9 comments
Open

Cannot open local webcam on NetBeans JavaFX 8 Project #1618

Adi-18 opened this issue Apr 3, 2021 · 9 comments

Comments

@Adi-18
Copy link

Adi-18 commented Apr 3, 2021

I use new version 1.5.5 with example code JavaFxPlayVideo.java on JavaFX 8

For grabbing local webcam I use FrameGrabber grabber = new OpenCVFrameGrabber(1); because FFmpegFrameGrabber grabber = FFmpegFrameGrabber.createDefault(1); is no more possible (yes 1 is correct).

In normal Java-Project I can run this example, but when I create it with NetBeans as a JavaFX project, I get an exception:

Exception in thread "Thread-5" java.lang.ExceptionInInitializerError
at org.bytedeco.javacv.OpenCVFrameGrabber.(OpenCVFrameGrabber.java:95)
at camtest.JavaFxPlayVideo.lambda$start$1(JavaFxPlayVideo.java:55)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
at sun.reflect.annotation.AnnotationParser.parseClassArray(AnnotationParser.java:724)
at sun.reflect.annotation.AnnotationParser.parseArray(AnnotationParser.java:531)
at sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:355)
at sun.reflect.annotation.AnnotationParser.parseAnnotation2(AnnotationParser.java:286)
at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:120)
at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:72)
at java.lang.Class.createAnnotationData(Class.java:3521)
at java.lang.Class.annotationData(Class.java:3510)
at java.lang.Class.createAnnotationData(Class.java:3526)
at java.lang.Class.annotationData(Class.java:3510)
at java.lang.Class.createAnnotationData(Class.java:3526)
at java.lang.Class.annotationData(Class.java:3510)
at java.lang.Class.getAnnotation(Class.java:3415)
at java.lang.reflect.AnnotatedElement.isAnnotationPresent(AnnotatedElement.java:258)
at java.lang.Class.isAnnotationPresent(Class.java:3425)
at org.bytedeco.javacpp.Loader.checkPlatform(Loader.java:994)
at org.bytedeco.javacpp.Loader.load(Loader.java:1171)
at org.bytedeco.javacpp.Loader.load(Loader.java:1148)
at org.bytedeco.javacv.OpenCVFrameConverter.(OpenCVFrameConverter.java:43)
... 3 more

@saudet
Copy link
Member

saudet commented Apr 3, 2021

It looks like the main JAR file for JavaCPP is missing from the class path. Make sure all JAR files are in the class path.

@Adi-18
Copy link
Author

Adi-18 commented Apr 5, 2021

Thank you for the replay. I have already included JavaCPP. The problem is only, if I start demo as JavaFX-Project in my NetBeans 8.2. As "normal" project it works (also when I start code by context menu -> run file on that file).

image

@saudet
Copy link
Member

saudet commented Apr 6, 2021

If you're trying to use the javafx-maven-plugin, be aware that it's still not fully functional, see issue #1435.
If you need to use that plugin, make sure it's set to use the class path, and not the module path.

/cc @johanvos

@Adi-18
Copy link
Author

Adi-18 commented Apr 6, 2021

I don't use javafx-maven-plugin. Its on Java 8 in Netbeans 8.2.

@saudet
Copy link
Member

saudet commented Apr 6, 2021

Sounds like a bug in JavaFX 8... Time to upgrade maybe? It's a 6-year-old release that is no longer supported.

@Adi-18
Copy link
Author

Adi-18 commented Apr 6, 2021

Since JavaFX is out of jdk and not easy to porting my project with many of unknowns, this is not an option at the moment

Same Problem while calling this:
private static OpenCVFrameConverter.ToIplImage iplConv = new OpenCVFrameConverter.ToIplImage(); for converting to ImageView.

BTW: bevore I used FmpegFrameGrabber grabber = FFmpegFrameGrabber.createDefault(1); and this worked perfectly for WebCam. Why this is no more possible?

@saudet
Copy link
Member

saudet commented Apr 7, 2021

BTW: bevore I used FmpegFrameGrabber grabber = FFmpegFrameGrabber.createDefault(1); and this worked perfectly for WebCam. Why this is no more possible?

That never worked. FFmpeg needs a String, not an int.

@Adi-18
Copy link
Author

Adi-18 commented Apr 7, 2021

Yes, I know, that's why I have had to use the factory method FFmpegFrameGrabber.createDefault(int deviceNumber)
-> http://bytedeco.org/javacv/apidocs/org/bytedeco/javacv/OpenCVFrameGrabber.html

@saudet
Copy link
Member

saudet commented Apr 7, 2021

What you're probably talking about is FrameGrabber.createDefault(1) and that probably returns you an OpenCVFrameGrabber, yes.

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

No branches or pull requests

2 participants