# 溫濕度數字辨識 ###### tags: `app`, `tessract`, `windows` 由於先前的 [PMS5003T](https://hackmd.io/cjrLXigiSA6SydNYkPH1jw) 掛掉惹 就隨便買個電子溫度計來用用 但是沒有接入數據真是有點麻煩 ## seven-segment display ![](https://i.imgur.com/KstJAQn.png) ## 使用ffmpeg來照相 ``` rem 列出USB名稱 ffmpeg -list_devices true -f dshow -i dummy ffmpeg -f dshow -i "video=HD Pro Webcam C920" -frames:v 1 %filename% ``` ## 使用imageMagick來處理圖片 ``` rem 灰階影像 convert %filename% -grayscale Brightness %filename% rem 切割影像 加入外框 convert %filename% -crop 135x110+290+79 -bordercolor white -border 50x50 z:\snap_temp_.png convert %filename% -crop 135x120+290+200 -bordercolor white -border 50x50 z:\snap_humi_.png rem 圖像圖像二值化 convert z:\snap_temp_.png -threshold 43%% z:\snap_temp.png convert z:\snap_humi_.png -threshold 25%% z:\snap_humi.png ``` ## 圖片定位 `magick compare -metric RMSE -subimage-search compare.png locate.png z:\diff.png` ![](https://i.imgur.com/zfSpydc.png) ## 畫框 `convert.exe -stroke red -strokewidth 3 -fill none -draw "rectangle 370,79 535,219" z:\Temp\snap\04261800.png z:\Temp\snap_04261800.png` ![](https://i.imgur.com/JFt7NJU.png) ## 數值辨識 https://github.com/Shreeshrii/tessdata_ssd ``` tesseract.exe --psm 8 -l ssd_int z:\snap_temp.png stdout ``` ## 效果 ![](https://i.imgur.com/cnX796h.png) ![](https://i.imgur.com/xt6vwVc.png)