大家好,又见面了,我是你们的朋友全栈君。
Tips:本文仅用做探索记录(外行+新手),不保证正确性,慎读慎参考!
背景:无聊看到一个可以去除马赛克的工具,并有GitHub源码(短短几天10K+star,lsp警告🙃,我反正不是,没跑过Python代码,一次尝试而已)。
过程为本人第一视角,漏掉的部分请自行探索。
python depix.py -p images/testimages/testimage3_pixels.png -s images/searchimages/debruinseq_notepad_Windows10_closeAndSpaced.png -o output.png
执行代码后报错
Traceback (most recent call last): File “depix.py”, line 1, in from depixlib.LoadedImage import * File “/Users/bit_tea/Downloads/Depix-main/depixlib/LoadedImage.py”, line 1, in from PIL import Image ImportError: No module named PIL
百度。。。,结果意思是需要安装pillow命令。
pip install pillow
报错,没安装pip…
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
提示:
WARNING: The scripts pip, pip2 and pip2.7 are installed in ‘/Users/bit_tea/Library/Python/2.7/bin’ which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use –no-warn-script-location.
此问题需解决。。
python3 get-pip.py
Successfully installed pip-20.3.1
WARNING: You are using pip version 19.2.3; however, version 20.3.1 is available.
You should consider upgrading via the '/Applications/Xcode.app/Contents/Developer/usr/bin/python3 -m pip install --upgrade pip' command.
执行提示命令
/Applications/Xcode.app/Contents/Developer/usr/bin/python3 -m pip install --upgrade pip
至此,pip3安装成功。
pip3 install pillow
python3 depix.py -p images/testimages/testimage3_pixels.png -s images/searchimages/debruinseq_notepad_Windows10_closeAndSpaced.png -o output.png
稍作等待,最后一句完成,可以看到工程目录下多了一个output.png文件,大功告成~
INFO:root:Finding color rectangles from pixelated space INFO:root:Found 116 same color rectangles INFO:root:86 rectangles left after moot filter INFO:root:Found 1 different rectangle sizes INFO:root:Finding matches in search image INFO:root:Removing blocks with no matches INFO:root:Splitting single matches and multiple matches INFO:root:[10 straight matches | 76 multiple matches] INFO:root:Trying geometrical matches on single-match squares INFO:root:[15 straight matches | 71 multiple matches] INFO:root:Trying another pass on geometrical matches INFO:root:[17 straight matches | 69 multiple matches] INFO:root:Writing single match results to output INFO:root:Writing average results for multiple matches to output INFO:root:Saving output image to: output.png
结语:通过观察输入和输入,发现输入除了一个马赛克图片外,还需要一张对比(或者是预测结果参数)的图片,有很大的局限性(lsp哭了),之后再看看是不是除了示例还有其他功能。。。
细心的同学应该发现第3步还有一个问题没有解决。。。虽然pip3可以用,pip还是不行。
pip
-bash: pip: command not found
原因:(第3步有提示)pip没有添加到path环境里,所以在非其安装路径下是不可以执行pip相关命令。
WARNING: The scripts pip, pip2 and pip2.7 are installed in ‘/Users/bit_tea/Library/Python/2.7/bin’ which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use –no-warn-script-location.
解决:(PATH路径为以上第3步提示的路径,及默认安装到python2.7中的pip路径)。
echo 'export PATH=/Users/bit_tea/Library/Python/2.7/bin:$PATH' >>~/.bashrc
source ~/.bashrc
验证
pip
Usage:
pip <command> [options]
完成~
参考文章: https://blog.csdn.net/weixin_44037416/article/details/96842058 https://www.jianshu.com/p/96bfccc7c680
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/148072.html原文链接:https://javaforall.cn