前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >记录使用Depix过程(小白文)

记录使用Depix过程(小白文)

作者头像
全栈程序员站长
发布2022-09-07 11:17:01
1.6K0
发布2022-09-07 11:17:01
举报
文章被收录于专栏:全栈程序员必看

大家好,又见面了,我是你们的朋友全栈君。

Tips:本文仅用做探索记录(外行+新手),不保证正确性,慎读慎参考!

背景:无聊看到一个可以去除马赛克的工具,并有GitHub源码(短短几天10K+star,lsp警告🙃,我反正不是,没跑过Python代码,一次尝试而已)。

过程为本人第一视角,漏掉的部分请自行探索。

  1. 下载源码,cd到根目录,执行文档(README.d)中的Example代码。到这里,目前还不明白这行代码的意思,不过可以看到两个图片路径,都在示例代码中出现,最后一个看名字就知道,工程根目录输出一个output.png图片。猜测为执行depix.py脚本,后面为‘参数’和输出结果。(这里默认已安装python工具,可以执行python命令)
代码语言:javascript
复制
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命令。

  1. 安装pillow
代码语言:javascript
复制
pip install pillow

报错,没安装pip…

  1. 安装pip
代码语言:javascript
复制
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.

此问题需解决。。

代码语言:javascript
复制
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.

执行提示命令

代码语言:javascript
复制
/Applications/Xcode.app/Contents/Developer/usr/bin/python3 -m pip install --upgrade pip

至此,pip3安装成功。

  1. 回头执行第2步,安装pillow(注意:用pip3)
代码语言:javascript
复制
pip3 install pillow
  1. 回头执行第1步(注意:用python3)
代码语言:javascript
复制
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还是不行。

代码语言:javascript
复制
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路径)。

代码语言:javascript
复制
echo 'export PATH=/Users/bit_tea/Library/Python/2.7/bin:$PATH' >>~/.bashrc    
source ~/.bashrc 

验证

代码语言:javascript
复制
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

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档