I'm trying to create an Applet that will capture images from my Webcam.
I saw an sample in this thread but the import
s don't work in my class. They weren't recognized.
I'm a newbie with Java, so, what i'm doing wrong ?
I'm trying to create an Applet that will capture images from my Webcam.
I saw an sample in this thread but the import
s don't work in my class. They weren't recognized.
I'm a newbie with Java, so, what i'm doing wrong ?
You must include the required external libraries (.jar) in your project in order for the compiler to find its imports.
In the answer you refer to, JavaCV is the API of choice, and also in the answer is a tutorial on configuring JavaCV for use.
In Webcam Capture project source code you can find webcam applet example and the working demo available here. This example does not require any additional JARs since it's shaded while the build. Shading is a process which packs all classes, from all dependent JARs, together, in only one file, referred then as shaded JAR. If you share all JARs you don;t have to build classpath since all imports are packed together.
From the code perspective there is no difference from using webcam API provided within Webcam Capture project in JFrame
or JApplet
. It contains WebcamPanel
class which can be easily used to display image from camera in real time. For more details please check other examples.
The one important think you have to do, is to sigh your applet. This is required operation if you like to access host hardware. Without signing you would have to specify set of appropriate permissions, but I never did this, since, from my perspective JAR shading and signing with Maven a way easier.