python 图片二值化,自动获threshold
因工作原因,需要处理视频,并把帧图二值化,ocr后按照一定的格式输出成一个word。
这里主要记录打包遇到的问题,其他不多说。
其中二值化参考:
https://blog.csdn.net/t8116189520/article/details/80271804
因为是批量的 threshold值不能固定,用到了skimage这个库
把上面链接里面代码的 threshold = 200 改为
threshold = filters.threshold_otsu(img_thresh)
otsu算法确定最佳分割阈值
前提交代的差不多了,代码撸好打包到exe后 发现毫无反应后 发现提示问题 You may load I/O plugins with the skimage.io.use_plugin
command
经过百度查资料 找到解决方法:链接
https://stackoverflow.com/questions/34761862/pyinstaller-you-may-load-i-o-plugins-with-the-skimage-io-use-plugin/35043355
修改正常打包的.spec 把图中
from PyInstaller.utils.hooks import collect_data_files, collect_submodules
datas = collect_data_files(“skimage.io._plugins”)
hiddenimports = collect_submodules(‘skimage.io._plugins’)
几句添加修改进去。
然后再对 spec打包,就解决了问题。