khanamiryan / php-qrcode-detector-decoder

This is a PHP library to detect and decode QR-codes. This is first and only QR code reader that works without extensions.
Apache License 2.0
1.37k stars 325 forks source link

Is it possible to get the QR Code coordinates? #48

Open carloshc opened 6 years ago

carloshc commented 6 years ago

If so, how can get it? Thank you and congratulations for your work.

alvaro-octal commented 5 years ago

Hi,

You can obtain the center of the 3 corners of a QR Code from the Result Object.

$qrcode = new Zxing\QrReader('image.png');

if ($qrcode && $text = $qrcode->text()) {
    $result = $qrcode->getResult();
    print_r($result->getResultPoints());
} echo 'no-data';

Output would be like:

Array
(
    [0] => Zxing\Qrcode\Detector\FinderPattern Object
        (
            [estimatedModuleSize:Zxing\Qrcode\Detector\FinderPattern:private] => 3.2857142857143
            [count:Zxing\Qrcode\Detector\FinderPattern:private] => 2
            [x:Zxing\ResultPoint:private] => 407.5
            [y:Zxing\ResultPoint:private] => 232
        )

    [1] => Zxing\Qrcode\Detector\FinderPattern Object
        (
            [estimatedModuleSize:Zxing\Qrcode\Detector\FinderPattern:private] => 3.2857142857143
            [count:Zxing\Qrcode\Detector\FinderPattern:private] => 2
            [x:Zxing\ResultPoint:private] => 407.5
            [y:Zxing\ResultPoint:private] => 186.5
        )

    [2] => Zxing\Qrcode\Detector\FinderPattern Object
        (
            [estimatedModuleSize:Zxing\Qrcode\Detector\FinderPattern:private] => 3.2857142857143
            [count:Zxing\Qrcode\Detector\FinderPattern:private] => 2
            [x:Zxing\ResultPoint:private] => 453
            [y:Zxing\ResultPoint:private] => 186.5
        )

)