atesting.ru Новости Как сканировать qr-коды на android?

Как сканировать qr-коды на android?

Молния QR-сканер

Данный сканер работает с ISBN, EAN, UPC, матрицами данных и многими другими видами QR-кодов. В этой программе есть функция масштабирования, что очень удобно, когда коды очень маленькие и рассмотреть их достаточно непросто.

Для работы необходимо разрешить приложению работать с камерой. Скорость расшифровывания кода очень высокая, что достаточно приятно.

Не зря у приложения «Молния QR-сканер» самый высокий рейтинг (4.7) среди всех сканеров на Google Play.

Кстати, у первого и третьего сканеров в нашем рейтинге такая же оценка. 

Рис. №2. Молния QR-сканер

Другие особенности Молния QR-сканер:

  • приложение очень нетребовательное – пользователю не нужно будет выравнивать свое устройство, чтобы код был считан правильно;
  • есть история, которая понадобится если Вы захотите со временем просмотреть отсканированные коды;
  • имеется фонарик;
  • бесплатный доступ к коду приложения (полезно для разработчиков).

Как самому создать QR-код на Андроид

Чтобы создать кьюар-код самостоятельно, потребуется воспользоваться специальными программами либо перейти на один из перечисленных ниже сайтов.

http://qrcoder.ru/

Данный веб-ресурс, выполненный в стиле минимализма, достаточно удобный. В левой части окна можно вводить текст, а в правой области будет отображен QR-code. Сайт может работать достаточно быстро.

http://www.qrcc.ru/generator.php

Веб-ресурс дает возможность каждому желающему создавать QR-code. Меню содержит возможность использования нескольких видов целей кодировки (зашифровку информацию с визиток, сайтов, СМС-сообщений, координат Гугл карт и т. д.).

QR Droid Code Scanner

Приложение позволяет формировать QR-code каждому желающему. Основное меню программы содержит иконку «Создать», нажав на которую будут предложены различные варианты. При создании ссылок потребуется ввести необходимую информацию либо личные контакты и кликнуть на флажок.

Информация, описанная в статье, позволит владельцу смартфона выбрать наиболее подходящий способ сканирования QR-кода. Основная часть сервисов для считки зашифрованных изображений предоставляется для использования без оплаты. Благодаря широким функциональным возможностям, приложения помогают не только сканировать код, но и зашифровывать собственные данные.

Usage

Create a element where the web cam video stream should get rendered:

<video><video>
constqrScanner=newQrScanner(videoElem,result=>console.log('decoded qr code:', result));

As an optional third parameter an error handler to be invoked on decoding errors can be specified. The default is .

As an optional fourth parameter a specific resolution that should be worked on can be specified. The default is 400.

As an optional fifth parameter a preference for the camera to use can be specified. Allowed values are and . The default is .

To use the default value for an optional parameter, omit it or use .

qrScanner.start();

Call it when you’re ready to scan, for example on a button click or directly on page load.
It will prompt the user for permission to use a camera.
Note: to read from a Web Cam stream, your page must be served via HTTPS.

qrScanner.stop();

If you want, you can stop scanning anytime and resume it by calling again.

QrScanner.scanImage(image).then(result=>console.log(result)).catch(error=>console.log(error ||'No QR code found.'));

As an optional second parameter a region defined by , , and can be specified to which the search for a QR code should be restricted. By default, the region spans the whole image.

As an optional third parameter a manually created QR scanner engine instance to be reused can be specified. This improves performance if you’re scanning a lot of images. An engine can be manually created via (async). By default, no engine is reused for single image scanning.

As an optional fourth parameter a manually created canvas to be reused can be specified. This improves performance if you’re scanning a lot of images. A canvas can be manually created via a tag in your markup or . By default, no canvas is reused for single image scanning.

As an optional fifth parameter you can request a provided canvas for reuse to not be resized, irrespective of the source image or source region dimensions. Note that the canvas and source region should have the same aspect ratio to avoid that the image to scan gets distorted which could make detecting QR codes impossible. By default, the canvas size is adapted to the source region dimensions for single image scanning.

To use the default value for an optional parameter, omit it or use .

This library provides a utility method for checking whether the device has a camera. This can be useful for determining whether to offer the QR web cam scanning functionality to a user.

QrScanner.hasCamera();

The scanner by default scans for dark QR codes on a bright background. You can change this behavior to scan for bright QR codes on dark background or for both at the same time:

qrScanner.setInversionMode(inversionMode);

Where can be , or .
The default for web cam scanning is and for single image scanning .

Change the weights for red, green and blue in the grayscale computation to improve contrast for QR codes of a
specific color:

qrScanner.setGrayscaleWeights(red, green, blue, useIntegerApproximation =true);

On supported browsers, you can check whether the used camera has a flash and turn it on or off. Note that has to be called and awaited first.

qrScanner.hasFlash();qrScanner.isFlashOn();qrScanner.turnFlashOn();qrScanner.turnFlashOff();qrScanner.toggleFlash();

You can destroy the QR scanner if you don’t need it anymore:

qrScanner.destroy();qrScanner =null;

This will stop the camera stream and web worker and cleans up event listeners.

Usage

Web Cam Scanning

Create a element where the web cam video stream should get rendered:

<video></video>

2. Create a QrScanner Instance

const qrScanner = new QrScanner(videoElem, result => console.log('decoded qr code:', result));

As an optional third parameter an error handler to be invoked on decoding errors can be specified. The default is .

As an optional fourth parameter a method can be provided that determines a region to which scanning should be restricted as a performance improvement. This region can optionally also be scaled down before performing the scan as an additional performance improvement. The region is specified as , , and ; the dimensions for the downscaled region as and . Note that the aspect ratio between and and and should remain the same. By default, the scan region is restricted to a centered square of two thirds of the video width or height, whichever is smaller, and scaled down to a 400×400 square.

As an optional fifth parameter a preference for the camera to use can be specified. Allowed values are and . The default is .

To use the default value for an optional parameter, omit it or use .

3. Start scanning

qrScanner.start();

Call it when you’re ready to scan, for example on a button click or directly on page load.
It will prompt the user for permission to use a camera.
Note: to read from a Web Cam stream, your page must be served via HTTPS.

4. Stop scanning

qrScanner.stop();

If you want, you can stop scanning anytime and resume it by calling again.

Single Image Scanning

QrScanner.scanImage(image)
    .then(result => console.log(result))
    .catch(error => console.log(error || 'No QR code found.'));

As an optional second parameter a region defined by , , and can be specified to which the search for a QR code should be restricted. As a performance improvement this region can be scaled down before performing the scan by providing a and . By default, the region spans the whole image and is not scaled down.

As an optional third parameter a manually created QR scanner engine instance to be reused can be specified. This improves performance if you’re scanning a lot of images. An engine can be manually created via (async). By default, no engine is reused for single image scanning.

As an optional fourth parameter a manually created canvas to be reused can be specified. This improves performance if you’re scanning a lot of images. A canvas can be manually created via a tag in your markup or . By default, no canvas is reused for single image scanning.

As an optional fifth parameter you can request a provided canvas for reuse to not be resized, irrespective of the source image or source region dimensions. Note that the canvas and source region should have the same aspect ratio to avoid that the image to scan gets distorted which could make detecting QR codes impossible. By default, the canvas size is adapted to the source region dimensions for single image scanning.

To use the default value for an optional parameter, omit it or use .

Checking for Camera availability

This library provides a utility method for checking whether the device has a camera. This can be useful for determining whether to offer the QR web cam scanning functionality to a user.

QrScanner.hasCamera(); // async

Color Inverted Mode

The scanner by default scans for dark QR codes on a bright background. You can change this behavior to scan for bright QR codes on dark background or for both at the same time:

qrScanner.setInversionMode(inversionMode);

Where can be , or .
The default for web cam scanning is and for single image scanning .

Color Correction

Change the weights for red, green and blue in the grayscale computation to improve contrast for QR codes of a
specific color:

qrScanner.setGrayscaleWeights(red, green, blue, useIntegerApproximation = true);

Flashlight support

On supported browsers, you can check whether the used camera has a flash and turn it on or off. Note that has to be called and awaited first.

qrScanner.hasFlash(); // check whether the browser and used camera support turning the flash on; async.
qrScanner.isFlashOn(); // check whether the flash is on
qrScanner.turnFlashOn(); // turn the flash on if supported; async
qrScanner.turnFlashOff(); // turn the flash off if supported; async
qrScanner.toggleFlash(); // toggle the flash if supported; async.

You can destroy the QR scanner if you don’t need it anymore:

qrScanner.destroy();
qrScanner = null;

This will stop the camera stream and web worker and cleans up event listeners.