Zxing Scan Frame deformation problem

Source: Internet
Author: User

Look at the picture.

/** * Calculates the most appropriate preview interface size from the camera's supported resolution * * @param parameters * @param screenresolution * @return */private Point Findbestpreviewsiz Evalue (camera.parameters Parameters, point screenresolution) {list<camera.size> rawsupportedsizes = Parameters.    Getsupportedpreviewsizes (); if (rawsupportedsizes = = null) {LOG.W (TAG, "Device returned no supported preview sizes;        Using default ");        Camera.size defaultsize = Parameters.getpreviewsize ();    return new Point (Defaultsize.width, defaultsize.height); }//Sort by size, descending list<camera.size> supportedpreviewsizes = new Arraylist<camera.size> (rawSu    pportedsizes); Collections.sort (supportedpreviewsizes, New comparator<camera.size> () {@Override public int compare (C Amera.            Size A, camera.size b) {int apixels = a.height * a.width;            int bpixels = B.height * b.width;            if (Bpixels < apixels) {return-1; } if (bpixels> Apixels) {return 1;        } return 0; }    });

//if (Log.isloggable (TAG, Log.info)) {
//StringBuilder previewsizesstring = new StringBuilder ();
//For (Camera.size supportedpreviewsize:supportedpreviewsizes) {
//Previewsizesstring.append ( supportedpreviewsize.width). Append (' x '). Append (Supportedpreviewsize.height). Append (");
//}
//LOG.I (TAG, "Supported preview sizes:" + previewsizesstring);
//}

    Double screenaspectratio = (double) screenresolution.x/(double) screenresolution.y;    Remove sizes that is unsuitable iterator<camera.size> it = supportedpreviewsizes.iterator ();        while (It.hasnext ()) {Camera.size supportedpreviewsize = It.next ();        int realwidth = Supportedpreviewsize.width;        int realheight = Supportedpreviewsize.height;            if (Realwidth * Realheight < Min_preview_pixels) {it.remove ();        Continue        } Boolean iscandidateportrait = Realwidth < realheight; int maybeflippedwidth = iscandidateportrait?        Realheight:realwidth; int maybeflippedheight = iscandidateportrait?        Realwidth:realheight;        Double aspectratio = (double) maybeflippedwidth/(double) maybeflippedheight;        Double distortion = Math.Abs (aspectratio-screenaspectratio);            if (Distortion > Max_aspect_distortion) {it.remove ();        Continue } if (MaybeflippeDwidth = = Screenresolution.x && maybeflippedheight = = screenresolution.y) {Point exactpoint = new Poin            T (Realwidth, realheight);            LOG.I (TAG, "Found Preview size exactly matching screen size:" + exactpoint);        return exactpoint; }}//If No exact match, use largest preview size. This is a great//idea on older devices because//of the additional computation needed.    We ' re likely to get here on//newer Android 4+ devices, where//The CPUs are much more powerful.        if (!supportedpreviewsizes.isempty ()) {Camera.size Largestpreview = supportedpreviewsizes.get (0);        Point largestsize = new Point (Largestpreview.width, largestpreview.height);        LOG.I (TAG, "Using largest suitable preview size:" + largestsize);    return largestsize; }//If There is no at all suitable, return to current preview size camera.size Defaultpreview = Parameters.getpre    Viewsize (); Point defaultsize = new Point (dEfaultpreview.width, Defaultpreview.height);    LOG.I (TAG, "No suitable preview sizes, using default:" + defaultsize); return defaultsize;}

zxing Scan Box deformation 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.