午夜剧场伦理_日本一道高清_国产又黄又硬_91黄色网战_女同久久另类69精品国产_妹妹的朋友在线

您的位置:首頁技術(shù)文章
文章詳情頁

Python識別處理照片中的條形碼

瀏覽:15日期:2022-07-05 13:09:11

最近一直在玩數(shù)獨,突發(fā)奇想實現(xiàn)圖像識別求解數(shù)獨,輸入到輸出平均需要0.5s。

整體思路大概就是識別出圖中數(shù)字生成list,然后求解。

輸入輸出demo

數(shù)獨采用的是微軟自帶的Microsoft sudoku軟件隨便截取的圖像,如下圖所示:

Python識別處理照片中的條形碼

經(jīng)過程序求解后,得到的結(jié)果如下圖所示:

Python識別處理照片中的條形碼

def getFollow(varset, terminalset, first_dic, production_list): follow_dic = {} done = {} for var in varset:follow_dic[var] = set()done[var] = 0 follow_dic['A1'].add('#') # for var in terminalset: # follow_dic[var]=set() # done[var] = 0 for var in follow_dic:getFollowForVar(var, varset, terminalset, first_dic, production_list, follow_dic, done) return follow_dic def getFollowForVar(var, varset, terminalset, first_dic, production_list, follow_dic, done): if done[var] == 1:return for production in production_list:if var in production.right: ##index這里在某些極端情況下有bug,比如多次出現(xiàn)var,index只會返回最左側(cè)的 if production.right.index(var) != len(production.right) - 1:follow_dic[var] = first_dic[production.right[production.right.index(var) + 1]] | follow_dic[var] # 沒有考慮右邊有非終結(jié)符但是為null的情況 if production.right[len(production.right) - 1] == var:if var != production.left[0]: # print(var, '吸納', production.left[0]) getFollowForVar(production.left[0], varset, terminalset, first_dic, production_list, follow_dic, done) follow_dic[var] = follow_dic[var] | follow_dic[production.left[0]] done[var] = 1

程序具體流程

程序整體流程如下圖所示:

Python識別處理照片中的條形碼

讀入圖像后,根據(jù)求解輪廓信息找到數(shù)字所在位置,以及不包含數(shù)字的空白位置,提取數(shù)字信息通過KNN識別,識別出數(shù)字;無數(shù)字信息的在list中置0;生成未求解數(shù)獨list,之后求解數(shù)獨,將信息在原圖中顯示出來。

def initProduction(): production_list = [] production = Production(['A1'], ['A'], 0) production_list.append(production) production = Production(['A'], ['E', 'I', '(', ')', '{', 'D', '}'], 1) production_list.append(production) production = Production(['E'], ['int'], 2) production_list.append(production) production = Production(['E'], ['float'], 3) production_list.append(production) production = Production(['D'], ['D', ';', 'B'], 4) production_list.append(production) production = Production(['B'], ['F'], 5) production_list.append(production) production = Production(['B'], ['G'], 6) production_list.append(production) production = Production(['B'], ['M'], 7) production_list.append(production) production = Production(['F'], ['E', 'I'], 8) production_list.append(production) production = Production(['G'], ['I', '=', 'P'], 9) production_list.append(production) production = Production(['P'], ['K'], 10) production_list.append(production) production = Production(['P'], ['K', '+', 'P'], 11) production_list.append(production) production = Production(['P'], ['K', '-', 'P'], 12) production_list.append(production) production = Production(['I'], ['id'], 13) production_list.append(production) production = Production(['K'], ['I'], 14) production_list.append(production) production = Production(['K'], ['number'], 15) production_list.append(production) production = Production(['K'], ['floating'], 16) production_list.append(production) production = Production(['M'], ['while', '(', 'T', ')', '{', 'D', ';', '}'], 18) production_list.append(production) production = Production(['N'], ['if', '(', 'T', ')', '{', 'D',';', '}', 'else', '{', 'D', ';','}'], 19) production_list.append(production) production = Production(['T'], ['K', 'L', 'K'], 20) production_list.append(production) production = Production(['L'], ['>'], 21) production_list.append(production) production = Production(['L'], ['<'], 22) production_list.append(production) production = Production(['L'], ['>='], 23) production_list.append(production) production = Production(['L'], ['<='], 24) production_list.append(production) production = Production(['L'], ['=='], 25) production_list.append(production) production = Production(['D'], ['B'], 26) production_list.append(production) production = Production(['B'], ['N'], 27) production_list.append(production) return production_list source = [[5, 'int', ' 關(guān)鍵字'], [1, 'lexicalanalysis', ' 標識符'], [13, '(', ' 左括號'], [14, ')', ' 右括號'], [20, '{', ' 左大括號'], [4, 'float', ' 關(guān)鍵字'], [1, 'a', ' 標識符'], [15, ';', ' 分號'], [5, 'int', ' 關(guān)鍵字'], [1, 'b', ' 標識符'], [15, ';', ' 分號'], [1, 'a', ' 標識符'], [12, '=', ' 賦值號'], [3, '1.1', ' 浮點數(shù)'], [15, ';', ' 分號'], [1, 'b', ' 標識符'], [12, '=', ' 賦值號'], [2, '2', ' 整數(shù)'], [15, ';', ' 分號'], [8, 'while', ' 關(guān)鍵字'], [13, '(', ' 左括號'], [1, 'b', ' 標識符'], [17, '<', ' 小于號'], [2, '100', ' 整數(shù)'], [14, ')', ' 右括號'], [20, '{', ' 左大括號'], [1, 'b', ' 標識符'], [12, '=', ' 賦值號'], [1, 'b', ' 標識符'], [9, '+', ' 加 號'], [2, '1', ' 整數(shù)'], [15, ';', ' 分號'], [1, 'a', ' 標識符'], [12, '=', ' 賦值號'], [1, 'a', ' 標識符'], [9, '+', ' 加號'], [2, '3', ' 整數(shù)'], [15, ';', ' 分號'], [21, '}', ' 右大括號'], [15, ';', ' 分號'], [6, 'if', ' 關(guān)鍵字'], [13, '(', ' 左括號'], [1, 'a', ' 標識符'], [16, '>', ' 大于號'], [2, '5', ' 整數(shù)'], [14, ')', ' 右括號'], [20, '{', ' 左大括號'], [1, 'b', ' 標識符'], [12, '=', ' 賦值號'], [1, 'b', ' 標識符'], [10, '-', ' 減號'], [2, '1', ' 整數(shù)'], [15, ';', ' 分號'], [21, '}', ' 右大括號'], [7, 'else', ' 關(guān)鍵字'], [20, '{', ' 左大括號'], [1, 'b', ' 標識符'], [12, '=', ' 賦值號'], [1, 'b', ' 標識符'], [9, '+', ' 加號'], [2, '1', ' 整數(shù)'], [15, ';', ' 分號'], [21, '}', ' 右大括號'], [21, '}', ' 右大括號']]

以上就是Python識別處理照片中的條形碼的詳細內(nèi)容,更多關(guān)于python 識別條形碼的資料請關(guān)注好吧啦網(wǎng)其它相關(guān)文章!

標簽: Python 編程
相關(guān)文章:
主站蜘蛛池模板: 亚洲福利久久 | 久久久久网站 | 91在线成人 | 亚洲国产网址 | 日本人亚洲人jjzzjjz | 久久性片 | 色多多在线观看视频 | 欧美在线不卡视频 | 国产激情网站 | 五月在线视频 | www.久久综合 | 成人午夜视频免费看 | 精品一区二三区 | 国产老头老太做爰视频 | 丁香婷婷综合激情五月色 | 一区二区三区免费看 | 国产三级91| 日韩视频免费看 | 麻豆91在线观看 | 一区二区三区在线免费观看视频 | 久久8 | 撕开她情趣内裤让她呻吟视频 | 亚洲欧美午夜 | 国产视频1区2区 | 超碰免费在线 | 欧美色道| 操极品 | 亚洲精品在线不卡 | 国产又爽又黄又嫩又猛又粗 | 午夜影院h | 在线日韩一区二区 | 看毛片的网址 | 黄色成人一级片 | 成人福利在线观看 | 好吊妞在线观看 | 国产精品最新 | 二区三区在线观看 | 激情四射av | 99re在线精品视频 | 国产精品久久久久久久久久久免费看 | 国产日产亚洲精品 |