資源簡介
基于selective_search源碼對手寫數字串進行過濾分割,并基于tensorflow在mnist訓練好的模型進行識別。
環境:Windows10 + tensorflow1.2 + python3.5 + cv2
程序:
example/demo.py---對手寫數字圖片的分割,并將每個數字做成28*28的黑底白字圖片,保存在本地image_data.npy
example/mnist_model.py---對手寫體mnist數據集進行訓練,訓練好后讀取數據進行識別
example/camera.py---是調用計算機攝像頭獲取圖片用的,按q退出拍照
selectivesearch/selectivesearch.py---是選擇性搜索的源代碼
注意:手寫數字的圖片盡量不要太大(太大會顯得數字寫的太細,調大數字粗細度),每個數字大小不要差太多,可以在畫板上寫的一個數字長寬在50像素左右效果不錯,其他的沒有測試過。

代碼片段和文件信息
import?cv2
def?my_camera():
????#?從攝像頭中取得視頻
????cap?=?cv2.VideoCapture(0)
????#?獲取視頻播放界面長寬
????width?=?int(cap.get(cv2.CAP_PROP_frame_WIDTH)?+?0.5)
????height?=?int(cap.get(cv2.CAP_PROP_frame_HEIGHT)?+?0.5)
????#?定義編碼器?創建?VideoWriter?對象
????#?Be?sure?to?use?the?lower?case
????fourcc?=?cv2.VideoWriter_fourcc(*‘mp4v‘)
????#?out?=?cv2.VideoWriter(‘output.mp4‘?fourcc?20.0?(width?height))
????while?cap.isOpened():
????????#?讀取幀攝像頭
????????ret?frame?=?cap.read()
????????if?ret:
????????????#?輸出當前幀
????????????#?out.write(frame)
????????????cv2.imshow(‘My?Camera‘?frame)
????????????#?鍵盤按?Q?退出
????????????if?(cv2.waitKey(1)?&?0xFF)?==?ord(‘q‘):
????????????????break
????????else:
????????????break
????cv2.imwrite(“a.png“?frame)
????#?釋放資源
????#?out.release()
????cap.release()
????cv2.destroyAllWindows()
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????227??2017-08-02?20:56??selectivesearch-develop\.idea\misc.xm
?????文件????????298??2017-08-02?20:56??selectivesearch-develop\.idea\modules.xm
?????文件????????459??2017-08-02?20:56??selectivesearch-develop\.idea\selectivesearch-develop.iml
?????文件??????43312??2017-08-03?13:04??selectivesearch-develop\.idea\workspace.xm
?????文件???????5782??2017-08-03?13:01??selectivesearch-develop\example\1.png
?????文件????????948??2017-08-03?12:08??selectivesearch-develop\example\camera.py
?????文件???????6350??2017-08-03?12:41??selectivesearch-develop\example\demo.py
?????文件???????4297??2017-08-03?12:43??selectivesearch-develop\example\mnist_model.py
?????文件??????27613??2017-08-02?16:53??selectivesearch-develop\example\number.png
?????文件????????676??2017-08-03?17:03??selectivesearch-develop\example\ReadMe.txt
?????文件????????158??2017-08-03?12:32??selectivesearch-develop\example\__pycache__\example.cpython-35.pyc
?????文件???????8864??2017-08-02?15:33??selectivesearch-develop\selectivesearch\selectivesearch.py
?????文件????????109??2017-08-03?12:35??selectivesearch-develop\selectivesearch\__init__.py
?????文件???????8652??2017-08-02?15:34??selectivesearch-develop\selectivesearch\__pycache__\selectivesearch.cpython-35.pyc
?????文件????????227??2017-08-03?12:41??selectivesearch-develop\selectivesearch\__pycache__\__init__.cpython-35.pyc
?????目錄??????????0??2017-08-03?16:54??selectivesearch-develop\example\__pycache__
?????目錄??????????0??2017-08-03?16:54??selectivesearch-develop\selectivesearch\__pycache__
?????目錄??????????0??2017-08-03?16:54??selectivesearch-develop\.idea
?????目錄??????????0??2017-08-03?17:03??selectivesearch-develop\example
?????目錄??????????0??2017-08-03?16:54??selectivesearch-develop\selectivesearch
?????目錄??????????0??2017-08-03?17:06??selectivesearch-develop
-----------?---------??----------?-----??----
???????????????107972????????????????????21
評論
共有 條評論