美文网首页
ZXing识别本地图片二维码 识别率低

ZXing识别本地图片二维码 识别率低

作者: 桔子橙子柚子_F | 来源:发表于2020-04-01 16:43 被阅读0次

对图片做压缩处理 压缩到300左右识别率比较高(不知道原理)

- (UIImage *)commpressionImage:(UIImage *)theImage {
    UIImage* bigImage = theImage;
    float actualHeight = bigImage.size.height;
    float actualWidth = bigImage.size.width;
    float newWidth =0;
    float newHeight =0;
    if(actualWidth > actualHeight) {
        //宽图
        newHeight = 300;
        newWidth = actualWidth / actualHeight * newHeight;
    }
    else
    {
        //长图
        newWidth = 300;
        newHeight = actualHeight / actualWidth * newWidth;
    }
    CGRect rect =CGRectMake(0.0,0.0, newWidth, newHeight);
    UIGraphicsBeginImageContext(rect.size);
    [bigImage drawInRect:rect];// scales image to rect
    theImage =UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    //RETURN
    return theImage;
}

相关文章

网友评论

      本文标题:ZXing识别本地图片二维码 识别率低

      本文链接:https://www.haomeiwen.com/subject/mgisyctx.html