
python
Frank(Zhiyang-Dou)
A Ph.D. candidate at HKU. Mainly focus on CG.
展开
-
Realsense获取内参
环境Windows10python3.7代码import pyrealsense2 as rspipeline = rs.pipeline()config = rs.config()config.enable_stream(rs.stream.depth, 640, 480, rs.format.z16, 30)config.enable_stream(rs.stream.color, 640, 480, rs.format.rgb8, 30)cfg = pipeline.start(co原创 2022-03-18 19:43:10 · 1599 阅读 · 0 评论 -
读取txt到numpy array
备份读取txt 为标准shape的numpy array gt_data = [] f2 = open(gt_path,"r") lines = f2.readlines() for line3 in lines: print(line3) cur = line3.strip().split(" ") gt_data.append(cur) gt_data原创 2021-02-21 19:45:13 · 333 阅读 · 0 评论 -
error: command ‘clang‘ failed with exit status 1
Step1 设置路径:brew info opensslStep2: 运行export LDFLAGS="-L/opt/homebrew/opt/openssl@1.1/lib"export CPPFLAGS="-I/opt/homebrew/opt/openssl@1.1/include" 再运行你的安装步骤即可.原创 2021-02-06 22:53:45 · 1871 阅读 · 0 评论 -
AttributeError: module ‘scipy.misc‘ has no attribute ‘imread‘
综述最近使用一些老版本的代码主要集中在 python2,遇到如下错误:AttributeError: module 'scipy.misc' has no attribute 'imread'解决pip uninstall scipypip install scipy==1.2.1原创 2021-01-17 18:13:39 · 348 阅读 · 0 评论 -
python文件解压
综述python文件解压。代码备份一波。步骤安装pip install zipfile代码#-*-coding: UTF-8 -*-import zipfiledef file_unzipper(input_path,output_path): file_to_unzip = zipfile.ZipFile(input_path, "r") for f in file_to_unzip.namelist(): file_to_unzip.extract原创 2020-10-10 21:56:15 · 199 阅读 · 0 评论 -
Could not connect to any X display.
综述Could not connect to display local host:Could not connect to any X display.原因因为我的代码里有:plt.imshow(images[0, ..., :3].cpu().numpy())暂时无法显示。因为我没有配置服务器图形化界面。原创 2020-10-07 16:15:42 · 3829 阅读 · 0 评论 -
python import 同级文件出错
问题python import 同级文件出错解决添加:__init__.py 里面什么都不用写即可。原创 2020-10-02 14:56:27 · 886 阅读 · 0 评论 -
Numpy精度设置
综述近期遇到了一个很有意思的问题,在这里记录一下:一般来说我们设置numpy的精度: np.round(V,decimals=6)而我们也知道在保存txt时候,np.savetxt(cur_dir+"/imgs/V0_.txt",V,fmt='%1.6f')可以使用fmt参数来设置。但是使用这种方式:np.savetxt(cur_dir+"/imgs/V0_.txt", np....原创 2020-05-08 11:34:13 · 6133 阅读 · 0 评论 -
python3.7 调用 Matlab
综述python3.7 调用Matlab。步骤首先找到 MATLAB 文件夹的路径。启动 MATLAB,并在命令行窗口中键入 matlabroot。复制 matlabroot 所返回的路径。在 Windows 操作系统提示符下:cd "matlabroot"\extern\engines\pythonpython setup.py install在 macOS 或 Linux 操作...原创 2020-05-07 15:03:39 · 3979 阅读 · 5 评论 -
numpy生成正态分布随机数组
综述Numpy生成正态分布随机数组。代码下面分别生成均值为10,方差为0.2 大小为1024*1的矩阵。注意我们最后使用round四舍五入到小数点后2位。import numpy#生成正态分布x = numpy.round(numpy.random.normal(10, 0.2, size=(1024,1)),2)x2 = numpy.round(numpy.random.norma...原创 2020-05-06 12:18:22 · 14807 阅读 · 2 评论 -
python读取文件去除换行
综述python读取文件去除换行解决网上一些replace的方法试过后效果不行。正解:line = f.readline()line = line.strip('\n')原创 2020-04-24 19:56:14 · 582 阅读 · 0 评论 -
Ubuntu16安装openCV
Ubuntu16安装opencv:https://blog.youkuaiyun.com/cocoaqin/article/details/78163171转载 2020-04-20 20:13:06 · 378 阅读 · 0 评论 -
python2.7安装opendr
pyhon安装opendrsudo apt install libosmesa6-devsudo apt-get install build-essentialsudo apt-get install libgl1-mesa-devsudo apt-get install libglu1-mesa-devsudo apt-get install freeglut3-devsu...原创 2020-04-20 18:36:55 · 1423 阅读 · 0 评论 -
pip 报错 socket.gaierror: [Errno -2] Name or service not known
综述pip 报错 socket.gaierror: [Errno -2] Name or service not known解决方法cd \etcsudo vim hosts找到你的名字:比如我的是原创 2020-03-14 00:07:33 · 5373 阅读 · 2 评论 -
pycharm invalid authentication data, Push failed: fatal
问题Push failed: fatal: Authentication failed for 'httpspycharm invalid authentication data couldn’t kickstart handshaking解决原创 2020-03-11 23:49:21 · 3762 阅读 · 0 评论 -
python-列表list的差集运算
综述有时候我们希望得到一个集合C,该集合C的元素可以被描述为元素在集合A中而不在集合B中。即:差集。代码基于setA = [1,2,3]B = [1,5]C = set(A) - set(B)但是这样结果也是set类型基于推导式 A = [1,2,3]B = [1,5]C =[i for i in A if not i in B]...原创 2019-09-22 22:07:23 · 3961 阅读 · 0 评论 -
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.al
综述在判断numpy数据相等的时候报错:ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()解决例如判断:向量a=b(所有位置相应元素相等)可以通过:if (a==b).all()来判断.此外还有any()函数这个是判断的...原创 2019-09-10 10:44:34 · 3255 阅读 · 0 评论 -
pip3安装报错AttributeError: module 'enum' has no attribute 'IntFlag'
问题综述mac下使用pip3安装包的时候报错:Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site.py", line 544, in <module> main() File "/Librar...原创 2018-05-02 22:33:35 · 7294 阅读 · 3 评论 -
python-支持中文编码
python十分好用。使用python很久了,但是关于中文设置老是记不住,还要上网搜,干脆自己博客记录一下。# -*- coding: utf-8 -*- print "支持一下中文!"原创 2018-05-10 19:30:44 · 908 阅读 · 0 评论 -
python-nltk语料库安装报错SSL错误
综述使用nltk下载wordnet语料库的时候,出现了ssl报错。import nltknltk.download()环境pycharm maxos解决第一种方式首先进入Python 3.6文件夹 cd /Applications/Python\ 3.6/运行命令./Install\ Certificates.command然后再安装就没...原创 2018-06-09 13:17:11 · 1237 阅读 · 0 评论 -
UnicodeEncodeError: 'ascii' codec can't encode character u'\xa0' in position 20: ordinal not in rang
综述使用tornado完成异步非堵塞服务器的开发(数据库课程设计),中间遇到了关于编码的问题,特别是在sql与python中文对接的时候。错误UnicodeEncodeError: 'ascii' codec can't encode character u'\xa0' in position 20: ordinal not in range(128)错误原因您应该是使用了py...原创 2018-06-16 21:39:52 · 2040 阅读 · 0 评论 -
Error Number: 1267 Illegal mix of collations (latin1_swedish_ci...解决方案(Django)
基本配置数据库还是Mysql(不过如果是Tornado的话最好还是PostgreSQL)开发环境:Pycharm基本配置包问题Error Number: 1267 Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '='原因其实是数...原创 2018-11-22 15:07:53 · 1167 阅读 · 0 评论 -
Pycharm删除键、复制粘贴键失灵解决方案
综述Pycharm删除键、复制粘贴键失灵解决方案解决方法Tools–>Vim Emulator取消勾选原创 2019-07-25 14:42:31 · 5075 阅读 · 2 评论 -
python错误:module 'shutil' has no attribute 'copy'
综述python错误:module ‘shutil’ has no attribute ‘copy’解决这多半是因为:你创建了一个和系统库重名的py文件例如copy.py所以将其重命名即可。原创 2019-07-28 19:42:09 · 3538 阅读 · 0 评论 -
python从图片到视频
综述python 从图片变为视频代码import cv2import numpy as npimport osfrom os.path import isfile, joinpathIn= './im3/' # img sequence 注意: 您的index应该为诸如 : 1.png 2.png 之类pathOut = 'videoscans_10000_smooth_7.av...原创 2019-08-18 16:18:45 · 305 阅读 · 0 评论 -
python遍历文件夹
综述python遍历文件夹代码import osfrom os.path import isfile, joinpathIn = "im1"files = [f for f in os.listdir(pathIn) if isfile(join(pathIn, f))]print(files)原创 2019-08-18 16:21:08 · 344 阅读 · 0 评论 -
python对文件排序、遍历
综述python对文件排序、遍历方法首先遍历,然后排序:files.sort(key= lambda x:int(x[:-4]))注意这里处理的是形如: 0.txt 12.txt 这样的文件命名代码import osfrom os.path import isfile, joinpathIn = "im1"files = [f for f in os.listdir(path...原创 2019-08-18 16:22:54 · 1472 阅读 · 0 评论 -
python读写npz文件
综述python读写npz文件代码存储import numpy as npcon = np.zeros(10)np.savez('con.npz',mycon = con)读取con = np.load('con.npz')['mycon']print(con)原创 2019-08-24 12:50:59 · 5894 阅读 · 0 评论 -
Numpy-删除指定行、列
综述留作记录备用。代码假设我们的数组是x,我们要删除第i行:x = numpy.delete(x,i, axis = 0)假设我们的数组是x,我们要删除第i列:x = numpy.delete(x,i, axis = 1)...原创 2019-08-24 12:55:21 · 12121 阅读 · 0 评论 -
python pickle UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xe8 in position 0: ordinal not in
综述python3中使用pickle报错:UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xe8 in position 0: ordinal not in range(128)解决方案将原: dict = pickle.load(open(file))改为: dict = pickle.load(open(file,...原创 2019-08-22 11:42:08 · 1778 阅读 · 0 评论 -
Pycharm赋予root权限执行程序PermissionError: [Errno 13] Permission denied:
综述linux 上Pycharm运行程序报错:PermissionError: [Errno 13] Permission denied:解决为pycharm赋予权限:以python3.6为例sudo gedit /usr/bin/python3.6_sudo.sh 在python3.6_sudo.sh写入#! /bin/bash sudo python3.6 $* 赋...原创 2019-09-04 21:10:07 · 5208 阅读 · 0 评论 -
python多线程总结
关于python多线程的语法以及使用总结如有错误 请多指正!翻译 2017-04-28 10:20:42 · 702 阅读 · 0 评论