JSP credential Implementation Code

Source: Internet
Author: User
The following ideas are implemented:

1. Set the camera background, such as the use of red cloth or blue, etc., white walls can also.

2. Select HD camera, such as Logitech and other high-definition cameras, the higher the resolution, the better.

3. Use Imagecaponweb to process the photo.

4. Call the control's Start method to get the webcam video

5. Call the CAP () method to take a picture

6. Call the Selectrect method to select the Avatar area, not satisfied with the words can be manually fine-tuned.

7. Call the Cutselected method crop using the selected area

8. Save the photo results.

The code is as follows:

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<%@ page contenttype= "text/html; Charset=utf-8 "language=" java "import=" java.sql.*,java.io.* "errorpage=" "%><%string savePath= Config.getservletcontext (). Getrealpath ("/") + "//"; File Tmp_path=new file (Savepath); Tmp_path.mkdirs (); System.out.println ("Photo Data save path:" +savepath); String pic_base_64_data=request.getparameter ("Picdata"), or//if the following code output True indicates the need to adjust the server software operating parameters to address the size limit of the accept post data, for example// Tomcat would need to configure maxpostsize= "0" in server.xml to unblock the upload data size limit <connector port= "8080" protocol= "http/1.1"//Conne ctiontimeout= "20000"//redirectport= "8443" maxpostsize= "0"/>//System.out.println (null==pic_base_64_data ); System.out.println ("Base64 string length:" +pic_base_64_data.length ()); String fileformat=request.getparameter ("Picext"); Sun.misc.BASE64Decoder decode=new Sun.misc.BASE64Decoder (); byte[ ] Datas=decode.decodebuffer (Pic_base_64_data); String filename=string.valueof (System.currenttimemillis ()) +fileformat; File File=new file (savepath+filename); OutputStream fos=new FILEOUTPUTStream (file); System.out.println ("Picture file name:" +filename); Fos.write (datas); Fos.close (); Out.print ("<a href=" + Request.getcontextpath () + "/" + filename + "' >click here</a>"); Out.flush (); Out.close ();%>
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.