اذهب إلى المحتوى
  • 0

كيف اعرف نوع الباركود هل هو D1 أو D2

Naser ناصر

السؤال

مساء الخير
عندي قارئ باركود يقرأ النوعين :

D1 الباركود  العادي الشريط

D2 الذي هو QR

كيف اعرف برمجيا بعد ان يمسح المستخدم باركود المنتح بالقارئ  في حقل الباركود ان ما تم مسحه هو من النوع D1 أو من النوع D2 

رابط هذا التعليق
شارك على الشبكات الإجتماعية

Recommended Posts

  • 0

ستحتاج إلى مكتبة برمجية لتحليل البيانات التي تم قراءتها من الباركود، ويوجد مكتبة zxing في بايثون، وإليك مثال بسيط:

from zxing import BarCodeReader

def detect_barcode_type(barcode_data):
    if barcode_data.startswith("D1"):
        return "D1"
    elif barcode_data.startswith("D2"):
        return "D2"
    else:
        return "Unknown"

def scan_barcode(barcode_image_path):
    reader = BarCodeReader()
    barcode_result = reader.decode(barcode_image_path)
    
    if barcode_result and barcode_result.valid:
        barcode_data = barcode_result.data
        barcode_type = detect_barcode_type(barcode_data)
        return barcode_type
    else:
        return "No barcode found"

# استخدام الدالة لتحديد نوع الباركود
barcode_image_path = "barcode/image.png"
result = scan_barcode(barcode_image_path)

print(f"نوع الباركود: {result}")

وبالطبع عليك تثبيت مكتبة zxing باستخدام الأمر التالي:

pip install zxing

وإذا أردت مكتبة PHP ابحث عن php qr code decoder.

رابط هذا التعليق
شارك على الشبكات الإجتماعية

انضم إلى النقاش

يمكنك أن تنشر الآن وتسجل لاحقًا. إذا كان لديك حساب، فسجل الدخول الآن لتنشر باسم حسابك.

زائر
أجب على هذا السؤال...

×   لقد أضفت محتوى بخط أو تنسيق مختلف.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   جرى استعادة المحتوى السابق..   امسح المحرر

×   You cannot paste images directly. Upload or insert images from URL.

  • إعلانات

  • تابعنا على



×
×
  • أضف...