Barcode and 2D code recognition algorithm