php识别二维码和条形码

使用php-zxing,github地址:https://github.com/dsiddharth2/php-zxing

在使用之前先确保已安装java环境

另外参考链接:

https://blog.csdn.net/mrwangweijin/article/details/79145677

https://zxing.org/w/decode.jspx

经过本人测试,识别率不是很高,需要离得近才容易识别,而且不能反光

本地代码大概如下:

use PHPZxing\PHPZxingDecoder;

    public function test()
    {
        $config = array(
            'try_harder' => true,
        );
        $decoder = new PHPZxingDecoder($config);
        $decoder->setJavaPath('java');
        $decodedData = $decoder->decode(ROOT_PATH . 'public/upload/extend/qrcode/58e35c6b-f34e-41e2-9fe1-7595ec927f48.jpg');
        echo $decodedData->getImageValue();
    }

猜你喜欢

转载自blog.csdn.net/xiaoxinshuaiga/article/details/84062468
今日推荐