![](https://img-blog.csdnimg.cn/20191023141825458.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
python
Python基础
linghugoogle1
Show me the code.
展开
-
Python3读取视频&保存视频
1、目标读取视频对每一帧进行处理保存视频2、环境Python3Windows3、官方文档&参考Getting Started with Videos Reading and Writing Video Opencv-Python cv2.CV_CAP_PROP_FPS error4、代码import cv2cap = cv2.Video...原创 2018-07-23 11:54:44 · 15218 阅读 · 2 评论 -
【python图像处理】单张图像拼接与批量图片拼接
一、效果 二、代码1、单张图片拼接# 图片拼接from PIL import Image# pil paste可以进行图片拼接import cv2import numpy as nppath="F:/out/"+str(0)+".jpg"img_out=cv2.imread(path)num=5for i in range(1,num): pa...原创 2019-01-07 10:53:39 · 33238 阅读 · 9 评论 -
【python图像处理】单张图像裁剪与批量图片裁剪
一、效果二、代码1、单张图片裁剪# 将单张图片分成5张import cv2import numpy as npsrcImg = cv2.imread("F:/test.jpg")cv2.imshow("[srcImg]",srcImg)# shap[0] height,shape[1] widthprint(srcImg.shape)hei=srcImg.sh...原创 2019-01-07 10:53:37 · 33316 阅读 · 7 评论 -
python安装包的离线安装方法
说明:python的离线安装有时候,由于不同模块有很多依赖包,所以很容易出错。python在线安装只需要“pip install 包名”会自动安装依赖包,所以一般不会出现安装问题。1、Linux主要提供Linux版本的后缀是".whl"和“.tar.gz”,可以搜索相关的包https://pypi.org/2、Windows主要提供Windows版本的后缀是".whl",可以直接...转载 2018-11-12 11:46:45 · 6733 阅读 · 0 评论 -
【Python】国内的pythoner强烈建议使用豆瓣的pypi源
python国内豆瓣源豆瓣:https://pypi.doubanio.com/simple/# 直接在后面添加 -i "https://pypi.doubanio.com/simple/"# 例如安装 keraspip install keras# 变成pip install keras -i "https://pypi.doubanio.com/simple/"个人...转载 2018-11-12 11:43:08 · 20988 阅读 · 3 评论 -
【Python】TypeError: a bytes-like object is required, not 'str'
1、报错自己python3.+,使用别人python2.的代码报错:rs = pow(int(binascii.hexlify(text), 16), int(pubKey, 16), int(modulus, 16))TypeError: a bytes-like object is required, not 'str'2、原因因为python3是bytes-like的,只...原创 2018-11-15 14:40:59 · 4666 阅读 · 0 评论 -
【Python3】 ord() expected string of length 1, but int found
File "C:\home\chardet\chardet\codingstatemachine.py", line 43, in next_state byteCls = self._mModel['classTable'][ord(c)]TypeError: ord() expected string of length 1, but int foundOK,因为c是int...转载 2018-11-15 14:37:01 · 27188 阅读 · 1 评论 -
【python】numpy中的tile函数
tile函数 在看机器学习实战这本书时,遇到numpy.tile(A,B)函数,愣是没看懂怎么回事,装了numpy模块后,实验了几把,原来是这样子:重复A,B次,这里的B可以时int类型也可以是远组类型。>>> import numpy>>> numpy.tile([0,0],5)#在列方向上重复[0,0]5次,默认行1次arra...转载 2018-11-09 19:13:56 · 168 阅读 · 0 评论 -
python numpy中数组.min()
import numpy as npa = np.array([[1,5,3],[4,2,6]])print(a.min()) #无参,所有中的最小值print(a.min(0)) # axis=0; 每列的最小值print(a.min(1)) # ax'''结果:1[1 2 3][1 2]''' ...转载 2018-11-09 18:48:26 · 710 阅读 · 0 评论 -
python scatter
1 函数原型2 代码#第一个参数是横坐标,第二个纵坐标,第三个颜色,第四个大小ax.scatter(datingDataMat[:, 0], datingDataMat[:, 1], 15.0*array(datingLabels), array(datingLabels))使用pandasdf=pd.read_csv("AiLearning\\db\\2.KNN...原创 2018-11-09 18:15:39 · 417 阅读 · 0 评论 -
【笨方法学PAT】1050 String Subtraction (20 分)
一、题目The task is really simple: given N exits on a highway which forms a simple cycle, you are supposed to tell the shortest distance between any pair of exits.Input Specification:Each input file...原创 2019-01-07 10:54:13 · 109 阅读 · 0 评论 -
Python将图片转为视频
1、目的将一帧帧的图片“组合”成为视频2、代码import cv2img_root = 'F:\\test\\'#这里写你的文件夹路径,比如:/home/youname/data/img/,注意最后一个文件夹要有斜杠fps = 30 #保存视频的FPS,可以适当调整size=(960,544)#可以用(*'DVIX')或(*'X264'),如果都不行先装ffmepg...原创 2018-07-23 14:50:16 · 27593 阅读 · 6 评论 -
Python将视频转为图片
1、目的将视频一帧帧提取出来,存起来2、代码import cv2cap = cv2.VideoCapture('F:\\1.mp4')fourcc = cv2.VideoWriter_fourcc(*'XVID')fps =cap.get(cv2.CAP_PROP_FPS)size = (int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)), int...原创 2018-07-23 14:12:43 · 10449 阅读 · 2 评论 -
【python】TypeError: 'NoneType' object is not subscriptable
一、原因调用变量为空二、解决print,查看原创 2019-01-12 10:19:09 · 105243 阅读 · 6 评论