臻昱鈕
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    2
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # 條碼進化論 ![](https://i.imgur.com/hhbqUAE.png) ## 二進位 世界上可以分成 10 種人,懂二進位的人,以及不懂二進位的人。 ## 條碼(barcode) -- 一維條碼 ### 掃描原理 想要辨識條碼就要經過 掃描 與 解碼 兩個過程。 ![](https://i.imgur.com/3WiUGF9.jpg) 掃描: 當掃描器(有光筆、感光耦合元件(CCD)、雷射三種)光源發出的光在條碼上反射後,反射光照到掃描器內部的光電轉換器上,光電轉換器根據強弱不同的光訊號,轉換成相應的電訊號。 解碼: 電訊號輸出到放大電路增強訊號之後,再送到整形電路將類比訊號轉換成數位訊號。 ___ ### 商品條碼的結構與編碼方式 ![](https://i.imgur.com/Whxz4rZ.jpg) ▲ 以EAN-13來舉例 #### 條碼的結構 靜區:空白區域,除了能防止條碼周圍被占用,左空白也能讓掃描設備做好掃描準備,右空白則是保證掃描設備正確識別條碼的結束標記。 起始字元:第一位字元,具有特殊結構,當掃描器讀取到該字元時,就代表正式讀取代碼了。 資料字元:條碼的資料內容。(不同條碼種類有不同的編碼規則,甚至同種也會有不同的編碼規則) 校驗字元:檢驗讀取到的資料是否正確。(不同條碼種類可能會有不同的校驗規則) 終止字元:最後一位字元,具有特殊結構,掃描器讀取到該字元時,表示代碼掃描完畢,甚至還能作為二次校驗。 #### 編碼方式 ![](https://i.imgur.com/Hk2LLsr.png) ▲ EAN-13的各代碼意義 ##### EAN條碼之字元編碼構造 ![](https://i.imgur.com/GgbjY7o.jpg) ##### 左資料碼與右資料碼 ![](https://i.imgur.com/PO89UDM.jpg) ##### 檢查碼 |4|7|1|0|0|1|8|1|6|5|1|0|8| |-|-|-|-|-|-|-|-|-|-|-|-|-| |B13|B12|B11|B10|B9|B8|B7|B6|B5|B4|B3|B2|C| 1. 先將B2,B4,B6,B8,B10,B12的值相加起來,然後乘以3 (0+5+1+1+0+7)*3=42 2. 將B3,B5,B7,B9,B11,B13的值相加起來 (1+6+8+0+1+4)=20 3. 將步驟1的值 加上 步驟2的值,取其個位數 42+20=62, 取個位數2 4. 用10去減掉步驟3取到的個位數 10-2=8 ___ ### 常見的條碼種類(每個編碼方式不一定相同喔) - Code39 常用於: 帳單 範例圖: ![](https://i.imgur.com/kG8zrVA.jpg) - Code 128 常用於: 身分證 範例圖: ![](https://i.imgur.com/QJ0JeEY.jpg) - EAN-13 常用於: 商品 屬於國際標準條碼,在GS1系統稱之為GTIN-13條碼 範例圖: ![](https://i.imgur.com/UpyQyEy.png) - EAN-8 常用於: 面積比較小的商品 屬於國際標準條碼,在GS1系統稱之為GTIN-8條碼 範例圖: ![](https://i.imgur.com/LQ1c1dv.jpg) - ITF-14 常用於: 外箱 只能用於標識非零售商品外箱 範例圖: ![](https://i.imgur.com/h0w2DwI.png) - ISBN 常用於: 書籍 國際標準書號長度為13碼或者10碼(在2007年1月1日之前)數字 範例圖: ![](https://i.imgur.com/lonxJOO.jpg) - ISSN 常用於: 雜誌書刊 範例圖: ![](https://i.imgur.com/TjkeJT6.jpg) ## 二維條碼(two-dimensional barcode) ### 為什麼要二維條碼 ![](https://i.imgur.com/QfDFSCI.png) ### QR code(Quick Response Code) #### 尺寸 QR Code的尺寸越大,能夠承載的資訊量也就越多 ![](https://i.imgur.com/AUr9clO.jpg) #### 容錯能力 - L(低):可修正7%的字碼。 - M(中):可修正15%的字碼。 - Q(中高):可修正25%的字碼。 - H(高):可修正30%的字碼。 ![](https://i.imgur.com/7rbbRRl.png) ▲ 此圖為H等級容錯 #### 最大容量 容錯能力越高,同等級的QR Code能夠容量的資訊量就越少 就版本40和容錯等級L而言,最多可以存 ![](https://i.imgur.com/W4N0anJ.png) #### 結構 ![](https://i.imgur.com/94yW40l.jpg) #### 掩碼(Masking) 編碼結束之後,為了避免資料區域出現連續的空白、連續的黑色區域、或是和定位點相似的圖形,還會再進行掩碼程序,透過演算法,選擇合適的掩碼圖案 ![](https://i.imgur.com/imgvD90.png) #### 編碼方式 ![](https://i.imgur.com/lZ2tt3F.jpg) 每個Version的QR Code訊息編排順序都不同,容錯等級也牽涉到QR Code的訊息編排方式,因此就算是同樣的訊息,也會產生不同的QR Code。 ### 常見種類 - PDF417 (注意此為堆疊式條形碼) ![](https://i.imgur.com/m2WxrGu.png) - QR code (矩陣條形碼) ![](https://i.imgur.com/UNeejPk.png) - Data Matrix (矩陣條形碼) 常用於: 美國商品的廠商或檢驗單位 ![](https://i.imgur.com/2BlI56j.png) - MaxiCode (矩陣條形碼) 常用於: 美國的快遞公司 ![](https://i.imgur.com/Uq4bym1.png) - CrontoSign (矩陣條形碼) 常用於: 瑞士銀行的電子銀行訪問和交易身份驗證 ![](https://i.imgur.com/3jK3xjp.png) ## 條碼小實作 請先安裝python圖像庫([pip install Pillow](https://pypi.org/project/Pillow/)) 商品條碼 ([pip install python-barcode](https://pypi.org/project/python-barcode/)) ```python= from barcode import EAN13 from barcode.writer import ImageWriter your_data = '4710088412539' with open('barcode.png', 'wb') as f: EAN13(your_data, writer=ImageWriter()).write(f) ``` ![](https://i.imgur.com/Ij28YjW.png) qr code ([pip install qrcode](https://pypi.org/project/qrcode/)) ```python= import qrcode your_data = 'something' qr = qrcode.QRCode( version=1, error_correction=qrcode.constants.ERROR_CORRECT_L, box_size=10, border=4, ) qr.add_data(your_data) qr.make(fit=True) img = qr.make_image() img.save("qrcode.png") ``` ![](https://i.imgur.com/zWTHOAZ.png) 另一個qr套件 ([pip intall MyQR](https://pypi.org/project/MyQR/)) ```python= from MyQR import myqr myqr.run(words = 'hi my friend', picture='rick-roll-rick-ashley.gif', version = 6, level = 'H', colorized = True, save_name = '動態qrcode.gif') ``` ![](https://i.imgur.com/ityZCUb.gif) 甚至可以利用容錯特性加上logo ![](https://i.imgur.com/Z9BwImF.gif) ## 參考資料 [Andy的條碼世界](http://www.appsbarcode.com/index.php) [Barcoding Frequently Asked Questions (FAQ)](https://www.barcodesinc.com/faq/) [線上生成條碼,條碼生成器](https://www.gaitubao.com/hk/barcode) [商品條碼的運作原理 | 一探啾竟 第9集 | 啾啾鞋](https://youtu.be/L4YNWUJD8Do) [QR Code發展與歷史介紹:運作原理、特色、編碼結構分析](https://www.cool3c.com/article/150348)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully