This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pip install python-barcode pylibdmtx opencv-python | |
from PIL import Image | |
from pylibdmtx.pylibdmtx import encode, decode | |
import cv2 | |
import numpy | |
from barcode import UPCA | |
from barcode.writer import ImageWriter | |
number = 10000000000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
''' | |
Usage: | |
barcode_scanning.py <license.txt> | |
Keyboard shortcuts: | |
ESC - exit | |
''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from dbr import * | |
# Initialize Dynamsoft Barcode Reader | |
reader = BarcodeReader() | |
# Apply for a trial license: https://www.dynamsoft.com/customer/license/trialLicense | |
license_key = "LICENSE KEY" | |
reader.init_license(license_key) | |
def decodeframe(frame, left, top, right, bottom): | |
settings = reader.reset_runtime_settings() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def postprocess(frame, outs): | |
frameHeight, frameWidth = frame.shape[:2] | |
classIds = [] | |
confidences = [] | |
boxes = [] | |
for out in outs: | |
for detection in out: | |
scores = detection[5:] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void decode_barcode_buffer(void* barcodeReader, const unsigned char *data, int width, int height, int channel, boolean has_region, int left, int right, int top, int bottom) | |
{ | |
if (has_region) | |
{ | |
PublicRuntimeSettings settings; | |
char errorMessage[256]; | |
int errorCode = DBR_GetRuntimeSettings(barcodeReader, &settings); | |
settings.region.regionLeft = left; | |
settings.region.regionRight = right; | |
settings.region.regionTop = top; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try: | |
text_results = reader.decode_file(self.filePath) | |
if text_results != None: | |
for text_result in text_results: | |
print("Barcode Format :") | |
print(text_result.barcode_format_string) | |
self.prevLabelText = text_result.barcode_format_string | |
print("Barcode Text :") | |
print(text_result.barcode_text) | |
print("Localization Points : ") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from google_images_download import google_images_download | |
import argparse | |
ap = argparse.ArgumentParser() | |
ap.add_argument("-k", "--keywords", required=True, | |
help="The keywords/key phrases you want to search for.") | |
ap.add_argument("-l", "--limit", required=True, | |
help="The number of images that you want to download.") | |
args = vars(ap.parse_args()) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
overlay.addEventListener('mouseup', e => { | |
if (isDrawing) { | |
isDrawing = false; | |
mousePosition.innerHTML = "Cursor: (" + e.offsetX + ", " + e.offsetY + ")"; | |
region.innerHTML = "Decode a region: (" + startX + ", " + startY + ", " + e.offsetX + ", " + e.offsetY + "). "; | |
overlay.style.cursor = "default"; | |
// Decode a region of the barcode image | |
(async () => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(async () => { | |
await barcodereader.resetRuntimeSettings(); | |
await barcodereader.updateRuntimeSettings('coverage'); // Mode: speed, balance, coverage | |
try { | |
await barcodereader.decode(name.files[0]).then((results) => { | |
let txts = []; | |
try { | |
for (let i = 0; i < results.length; ++i) { | |
txts.push(results[i].BarcodeText); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function clearOverlay() { | |
overlayCtx.clearRect(0, 0, overlay.width, overlay.height); | |
overlayCtx.strokeStyle = '#ff0000'; | |
overlayCtx.lineWidth = 5; | |
} | |
overlay.addEventListener('mousedown', e => { | |
startX = e.offsetX; | |
startY = e.offsetY; | |
isDrawing = true; |
NewerOlder