def make_barcode(barcodeData,topLabel,bottomLabel,barcode_folder):
        """Generate barcode for the barcodeData"""

        image_dir=f'{barcode_folder}\\{barcodeData}.png'
        # QRcode option
        barcode=qrcode.make(barcodeData)

        barcode.save(image_dir)
       
        labeled_barcode=label_the_barcode(barcodeData,topLabel,bottomLabel,image_dir)

        labeled_barcode.save(image_dir)

        # display_with_mat(f'image_store_2\{barcodeData}.png')

        return image_dir
Пример #2
0
 def set_barcode_image(self):
     # method to generate barcode and save it
     barcode = get_code128_barcode(self.uid)
     image = barcode.save(self.uid)
     image_object = Image.open("{uid}.svg".format(uid=self.uid))
     self.image = image_object
     self.save()
Пример #3
0
def downloadBarcodes():
    # To start the barcode
    import barcode
    ISBN = barcode.get_barcode_class('isbn13')
    excelFile = (
        "/mnt/c/Users/derri/Desktop/Coding/visStudioTest/testExcel.xls")
    wb = open_workbook(excelFile, "rb")
    sheet = wb.sheet_by_index(0)
    sheet.cell_value(0, 0)

    for i in range(sheet.nrows):
        if (sheet.cell_value(i, 0) != "STOCK CODE"
                and sheet.cell_value(i, 0) != ""):
            # print(sheet.cell_value(i,0))
            # print(type(sheet.cell_value(i,0)))
            # print(type('9781456123789'))
            num = sheet.cell_value(i, 0)
            barcode = ISBN(num, writer=ImageWriter())
            # filename = barcode.save("/mnt/c/Users/derri/Desktop/Coding/visStudioTest/Barcode"+sheet.cell_value(i,0))
            filename = barcode.save(sheet.cell_value(i, 0))

        else:
            #just skip to the next one
            print("No isbn")

    moveBarcodesToFolder()
Пример #4
0
for image_path in glob.glob("*.png"):
    file_path = os.path.join(path, image_path)
    os.unlink(file_path)
if os.path.exists(os.path.join(path, 'labels.txt')):
    os.unlink(os.path.join(path, 'labels.txt'))
os.chdir("../")
coder = barcode.get_barcode_class(barcode_type)

T = TransformUtils(w=WIDTH, h=HEIGHT)
labels = np.array([np.zeros((nb_img, 10), dtype=np.bool_)] * 10)
for k in range(nb_img):
    nb = rd.randint(0, max_barcode_number)
    nb_digits = len(str(max_barcode_number))
    nb = str(nb).zfill(nb_digits)
    barcode = coder(nb, ImageWriter(), add_checksum=False)
    barcode.save("./" + generation_folder + '/temp', options=barcode_options)
    temp = cv2.imread("./" + generation_folder + '/temp.png',
                      cv2.IMREAD_GRAYSCALE)
    ##########################################################
    ################### DATA AUGMENTATION ####################
    ##########################################################
    if rd.random() < 0.5:
        temp = T.updown(temp)
    temp = T.occlusion(temp)
    temp = T.translation(temp)
    temp = T.rotation(temp)
    if rd.random() < 0.66:
        if rd.random() < 0.5:
            temp = T.darken(temp)
        else:
            temp = T.brighten(temp)
Пример #5
0
##pip install python-barcode

import barcode
from barcode.writer import ImageWriter
barcode = barcode.get('Code39', '08302004', writer=ImageWriter())
save = barcode.save('barcode')