Downloading Barcode Images from Google for SDK Test

Xiao Ling
2 min readSep 4, 2019

--

When evaluating an image processing and recognition SDK, image dataset is vital for benchmarking the performance. Google is absolutely the best place for finding and downloading required images. An automation tool would be handy for getting amounts of image files rapidly. In this article, I will share how to use a Python to download barcode images from Google, as well as how to test Dynamsoft Barcode Reader SDK with the image set.

Barcode Images from Google

Install Google Images Download (a Python open-source project) via pip:

pip install google_images_download

Here is the primary API usage of downloading barcode images from Google:

from google_images_download import google_images_downloadresponse = google_images_download.googleimagesdownload()arguments = { }paths = response.download(arguments)print(paths)

By default, image files will be saved to ./downloads/<keyword>.

What we need to do next is to specify the arguments. My configuration is as follows:

keyword = "barcode on box"arguments = {"keywords": keyword, "limit": 10, "format": "jpg", "usage_rights": "labeled-for-reuse", "time_range": '{"time_min": "01/01/2010", "time_max": "01/01/2019"}'}

Keywords

I only used one keyword ‘ barcode on box’. If you have more than one keyword, use comma to separate them, like ‘ barcode on box, QR code, dynamsoft’.

Limit

Denote I want to download ten images.

Format

Set ‘jpg’ as the specific image type. If you omit the argument, the downloader will crawl any available images, including jpeg, gif, and png.

Usage_rights

This argument is crucial for copyrights. To avoid copyright violation, I used labeled-for-reuse. For detail information about image usage rights, please refer to https://support.google.com/websearch/answer/29508?hl=en.

Time_range

Comply with the format “time_range”: ‘{“time_min”: “MM/DD/YYYY”, “time_max”: “ MM/DD/YYYY “}’.

Barcode SDK Testing with Barcode Images

Install Python barcode extension built with Dynamsoft Barcode Reader.

Get a free trial license of Dynamsoft Barcode Reader and set the LICENSE-KEY in app.py:

dbr.initLicense('LICENSE-KEY')

Decoding barcode images one by one:

images = paths[0][keyword]for filename in images:    print("-------------------------------------------------\n")    print(filename)    decodeFile(filename)

The full code:

Run the app:

python app.py

I got ten barcode images and corresponding barcode results.

Reference

Source Code

https://github.com/yushulx/download-read-barcode-image

Originally published at https://www.codepool.biz on September 4, 2019.

--

--

Xiao Ling
Xiao Ling

Written by Xiao Ling

Manager of Dynamsoft Open Source Projects | Tech Lover

No responses yet