/bncode

BN code is a type of data storage as an image

Primary LanguagePythonMIT LicenseMIT

BNCODE

A BN code (an initialism for Boon code) is a type of data storage as an image that design for low resolution work with low data quality. in this version it can be store 32 bit or 4 bytes that can store number from 0 upto 4,294,967,295

Design

BN code is detected by a 2-dimensuinal digital image sensor and program.

Normal QRcode

BNcode version 1, 8x8 pixel

Storage Capacity with version 1

Input Mode Max. Capacity
Numeric 0 - 4,294,967,295
Character 4 characters (8 bit per char)

Encoding

The format information records two things: bit data and ref bit. bit data is your data and bit ref is bit that the scanner will compare with the bit data.

border section

border section

data section

data section

mirror blocking

mirror blocking

color black and white refer to 0,1 in binary the decoder will read color on image from top-down,left to right

why mirror blocking is important because BNcode store binary directly to image the flipped image with cause a worng data reading

Decoding

read the encoding section ---

Installation

pip install bncode

Example Code

Read and write

from bncode import create, scan
import cv2

cv2.imwrite("bncode.png",create(123456)) # create image
print(scan(cv2.imread('bncode.png'))) # scan image

Scan from camera

from bncode import create, scan
import cv2

cam = cv2.VideoCapture(0)
while True:
    c,img = cam.read() # read image from camera
    print(scan(img)) # scan image
    cv2.waitKey(1)