Cash Loan (iii): docking overseas FaceId

Source: Internet
Author: User
"Preface"

Recently doing business overseas, some of which involve docking third parties (FaceId); In the process of docking encountered some pits, recorded, everyone in the docking of third parties can refer to. "Those things in the docking." first, the business scenario: 1, FaceId Overseas currently provides two interfaces: A. Detect how many heads in a picture "can be 0,1,2 ... Each result is given as a percentage "B. Provide a reference image, then live, to determine the relative results of living and reference pictures" in percent given "
2. Our business:
A. The user takes the head of the document, the document image as a parameter call FaceId the first interface, see if the picture has and only one head to let Pass; b. Let the user do live, live get pictures and the first interface gets a picture of a head as a parameter called FaceId's second Interface to obtain a comparison of the points;

second, the call head interface comparison success rate is very low

1, the test found in the process of testing, there are many cases of the identification of the head, and then we do the experiment found; if the photo is horizontal, the other angles do not pass

(1) Transverse Photo:


(2) Other directions:


(3) After checking with the third-party technician, it is necessary to use the rotation parameters when the interface is called, so that if no head is detected, the FaceId will be rotated 90 degrees 180 degrees counterclockwise, and then the head will be detected at any angle in the three angles. Returned to us to detect the head, and will tell how many degrees of rotation to get the head; for example (2) in the photo, FaceId got to find no head, then the picture is rotated 90 degrees counterclockwise (rotated image into (1)) detected head, this will give the return detected head, And the return value includes 90 degrees;

2, because we are aimed at overseas business, in the test not only for domestic mobile phones, but also for some overseas mobile phone models to test, the results found that overseas mobile phones generally have a relatively low success rate;

(1) After careful observation and faceid of the technical staff to test, found that the foreign mobile app photos taken by the pixel is too low (size: 3k, pixel length and width of less than 100 pixels), and then use the phone's own camera and the app to take photos to do the contrast, found that with the mobile phone to take the picture size of 1.5M or so, the pixel is enough, and the app has become smaller after the shooting, online find is because of the Android to prevent oom automatically compressed pictures, and the Android colleagues to do the adjustment will limit the release;

(2) found that the release of the pixel is too large, faceid maximum support 4096 pixels, so we have to compress the original picture can be; The following is the Android code for native image compression:

/** * Android Image compression * @param srcpath The path of the original picture * @return Compressed image */private Bitmap getimage (String srcpath) {Bi
        Tmapfactory.options newopts = new Bitmapfactory.options ();
        Start to read the picture, at this time set the Options.injustdecodebounds back to true newopts.injustdecodebounds = true;
        Bitmap Bitmap = Bitmapfactory.decodefile (Srcpath, newopts);//return BM At this time is empty newopts.injustdecodebounds = false;
        int w = newopts.outwidth;
        int h = newopts.outheight; Now the mainstream phone is more 800*480 resolution, so the height and width we set to float hh = 800f;//Here Set the height for 800f float ww = 480f;//here set width to 480f//Zoom Than. Because it is a fixed scale, only one of the data can be calculated as high or wide. int be = 1;//be=1 means no scaling if (W > H && w > ww) {//If the width is large, the size is fixed by the width
        Put be = (int) (NEWOPTS.OUTWIDTH/WW);
        } else if (W < h && h > hh) {//If height is high, scale is = (int) (NEWOPTS.OUTHEIGHT/HH) According to the fixed width size;
        } if (be <= 0) is = 1;
        Newopts.insamplesize = be;//Setting the zoom ratioRe-read into the picture, note that at this time the options.injustdecodebounds has been set back to false bitmap = Bitmapfactory.decodefile (Srcpath, newopts);
    Return Compressimage (bitmap);//compress good proportions and then mass compress}/** * Mass compression * @param image to be compressed picture * @return Quality compressed picture */
        Private Bitmap Compressimage (Bitmap image) {Bytearrayoutputstream BAOs = new Bytearrayoutputstream ();
        Image.compress (Bitmap.CompressFormat.JPEG, BAOs);//Quality compression method, here 100 means no compression, the compressed data stored in the BAOs int options = 100; while (Baos.tobytearray (). length/1024 > 40) {//cycle to determine if the image is larger than 100kb after compression, greater than the continued compression baos.reset ();//Reset BAOs Empty BAOs image.compress (Bitmap.CompressFormat.JPEG, Options, BAOs);//compress options% here, store compressed data into BAOs op tions-= 10;//each time the reduction of bytearrayinputstream ISBM = new Bytearrayinputstream (Baos.tobytearray ());//The compressed data BAOs stored in bytearrayinputstream Bitmap Bitmap = bitmapfactory.decodestream (ISBM, NULL, NULL);//Put Bytearrayinputstream number Generate Picture return bitmap; }

Third, live verification success rate is very low

After the completion of the human head found that the success rate of living is not improved, careful analysis after the discovery; the first interface to detect a document head is FaceId internal rotation, while in the body, the first document is required as a parameter, and the FaceId living interface does not provide rotation function At this time, we need to make a rotation of the image before calling the interface; rotate the image: Java Basics (v): Java implementation of the picture lossless arbitrary angle rotation. "Summary"

1, in the docking with the third party, there are doubts about the place, do not rely on their own guess, to see the third-party documents, and third-party technical people to confirm;

2, encountered problems can not be, do not find excuses for the problem, but to traced chase bottom to find the root of the problem.

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.