Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Barcode Recognition / pharmacode-decoder
Search
shun74
November 26, 2022
Programming
1.1k
0
Share
Barcode Recognition / pharmacode-decoder
Pharmacodeリーダーを製作しました。
アルゴリズムなどの解説資料です。
shun74
November 26, 2022
More Decks by shun74
See All by shun74
深度推定モデルの自己教師あり学習/self-supervised-depth
shun74
0
510
GPUでステレオマッチング / Stereo-matching with GPU
shun74
0
1.1k
卒業研究の進め方 / How to preceed with the research
shun74
1
580
Vision Transformer講座 / Vision Transformer Presentation
shun74
1
750
ニューラルネットの1bit化 / 1bit-neural-network
shun74
0
970
Defocus Map Estimation From a Single Image Based on Two-Parameter Defocus Model / two-parameter-defocus-model
shun74
0
400
理解してほしいVision Transformer / plz-understand-ViT
shun74
0
790
Other Decks in Programming
See All in Programming
RTSPクライアントを自作してみた話
simotin13
0
290
ユニットテストの先へ:テスト技法で要求・仕様を整理するJava開発実践 / Beyond_Unit_Testing_Practical_Java_Development_Techniques_for_Organizing_Requirements_and_Specifications
shimashima35
0
260
Inside Stream API
skrb
1
240
OSもどきOS
arkw
0
250
Oxcを導入して開発体験が向上した話
yug1224
4
220
AI駆動開発勉強会 広島支部 第一回勉強会 AI駆動開発概要とワークショップ
hayatoshimiu
0
400
TypeScriptだけでAIエージェントを作る フロント・エージェント・インフラのフルスタック実践
har1101
6
1.1k
Spec-Driven Development with AI-Agents: From High-Level Requirements to Working Software
antonarhipov
2
380
[KCD Czech] eBPF Meets the GPU: Future of AI Infra Observability
doniacld
0
110
These Five Tricks Can Make Your Apps Greener, Cheaper, & Nicer
hollycummins
0
220
Technical Debt: Understanding it Rightly, Engaging it Rightly #LaravelLiveJP
shogogg
0
160
JavaDoc 再入門
nagise
0
170
Featured
See All Featured
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.9k
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
290
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
5.8k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.1k
Designing Powerful Visuals for Engaging Learning
tmiket
1
380
Building Adaptive Systems
keathley
44
3k
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.1k
What's in a price? How to price your products and services
michaelherold
247
13k
Exploring anti-patterns in Rails
aemeredith
3
370
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
210
My Coaching Mixtape
mlcsv
0
130
Transcript
バーコード認識の実装 RICORA - shun74
扱うバーコード Pharmacode (ファーマコード) • 医薬品業界向けバーコードの世界標準 • {太い、細い}黒線の2種類を組み合わせるシンプルな設計 Pharmacodeの例 • 決まった長さを持たない
• ある番号を表す(アルファベットを含まない)
Pharmacodeのデコード • Pharmacodeは右から順に計算することでデコードできる 1. 一番右から0, 1, 2…と線に番号を付ける 2. i番目の線が太かったら2^(i+1)を細かったら2^iを足す •
画像のPharmacodeは計算すると... 2^0 + 2^1 + 2^3 + 2^4 + 2^5 + 2^5 = 1 + 2 + 8 + 16 + 32 + 32 = 91
バーコード認識アルゴリズム 以下のステップで認識を行う 1. 画像のグレイスケール化⇢白黒化 ⇣ 2. 白黒画像のパターンの取得 ⇣ 3. パターンのデコード
⇣ 4. デコード結果の結合 ⇣ 5. バーコード部分を塗りつぶして2に戻る ⇣ 6. すべてのバーコードを検出したら終了
画像のグレイスケール化⇢白黒化 • 画像を加工して特徴を捉えやすくする ⇢ ⇢ 元画像(RGB) グレイスケール画像 白黒画像 • 白黒の2値にすることで処理が簡単に!
白=255、黒=0となっている 白黒画像のパターンの取得 • 白黒画像のバーコードを値のパターンから検出する • バーコードのあるラインには特定のパターンが発生する
白黒画像のパターンの取得 パターンを検出する方針 1. 同じ幅の白区間が複数並んでいる場所を検出 2. 白と黒の幅を比較して太い線か細い線かを判定 • 白区間の幅に外れ値がないかをチェック ⇢ ノイズを排除しやすくなる
• 予め白区間の幅を指定しない ⇢ 様々な大きさのバーコードを検出可能
パターンのデコード • 取得できたパターンからpharmacodeの値を計算 • このラインからは755が検出される • パターンがない場合は0としておく
デコード結果の結合 • 各ラインの結果を統合してバーコード領域を特定 • 緑の線の範囲はデコード結果が755と なっているはず • 同じ数値が一番長く続いた区間を検 出結果とする
複数バーコードがある場合は? • 検出された部分を塗りつぶして検出をやりなおす ⇢⇢⇢ • バーコードが検出されなくなるまで繰り返すことで全て検出可能
検出結果 バーコード領域をきれいに検出できている!
その他工夫 • 画像にガンマ補正+鮮明化の前処理を行う ⇢ ブレに強くなる • 白黒化はラインごとに行う ⇢ よりノイズに強い白黒化 •
ラインごとの処理を並列化 ⇢ 並列化により処理を高速化
実装 GitHub:https://github.com/shun74/Barcode-Recognition