简体   繁体   中英

Capturing image from webcam

I'm trying to capture images by using webcam in an applet. The applet makes use of JMF. But I managed to run applet without actually installing JMF. I kept a button in HTML webpage so that when the button gets clicked, the applet should capture the image.

But for me it is giving a java.lang.RuntimeException: No permission to capture from applets . How can this exception be resolved so an applet can capture image using webcam in HTML page?

In order to capture images in an applet, it is necessary:

  1. For you to digitally sign the code.
  2. For the user to click "OK" when prompted to run the signed code.
  3. If the functionality is being called from a button using JavaScript, wrap the Java code in one of the AccessController.doPrivileged(PrivilegedAction) variants.
  4. AFAIR the installer for JMF does not have the 'allow capture from applets' checked by default. That needs to be reconfigured in the JMF options. I forget how.

Update

I dont want to give client package to extra overhead of the installation of JMF.

That is just silly.

  1. The components of the JMF must be available on the run-time class-path of the applet, for it to function. If they are downloaded by the JRE using the applet element (or whatever), then the user has incurred that 'overhead'.
  2. But perhaps you mean you don't want to make the end user run the installer that advises to 'reboot' at the end. In that case, you are missing my point while avoiding answering my question. That question, again, is "How did you get the DLL?" .

This question asked Too many times in this forum.. Anyways..Here is the solution: Java swing Program to capture webcam images you have to modify it for applet which takes only 30 minutes

Applets run with very limited permissions and that might be causing the issue.. Here is an old post which has information about signing an applet to get the necessary permissions..hope this helps

I think flash is a much better option. There are really easy solutions for that even using Javascript + Flash. Take a look at this: http://www.xarg.org/project/jquery-webcam-plugin/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM