
python
文章平均质量分 74
Elag
勿以恶小而为之 勿以善小而不为
展开
-
python中argparse模块用法实例详解
# -*- coding: utf-8 -*- import argparse args = "-f hello.txt -n 1 2 3 -x 100 -y b -z a -q hello @args.txt i_am_bar -h".split() # 使用@args.txt要求fromfile_prefix_chars="@" # args.txt文件中应该一行一个参数,想改变行为参转载 2017-11-24 11:07:40 · 956 阅读 · 0 评论 -
Tensorflow-API :tf.where
返回输入矩阵中true的索引位置,x和y必须同时有(维度必须相同)或没有import tensorflow as tfwhere = tf.where([True,False,True,False,True,True])where1 = tf.where([True,False,True,False,True,True],x=[1.,0.2,0.5,0.,2.,3.],y=[1,2,3,...原创 2018-05-23 16:36:37 · 448 阅读 · 0 评论 -
OpenCV 形态学转换
综述OpenCV中的形态学转换操作有七种:腐蚀,膨胀,开运算,闭运算,形态学梯度,礼帽,黑帽。API参照表 中文名 英文名 api 原理 个人理解 腐蚀 erode erosion = cv2.erode(src=girl_pic, kernel=kernel) 在窗中,只要含有0,则窗内全变为0,可以去浅色噪点 浅色成分被腐蚀 ...转载 2018-06-11 12:59:36 · 390 阅读 · 0 评论 -
Tensorflow-API :tf.stack()和tf.unstack()
tf.stack():矩阵拼接tf.unstack():矩阵分解import tensorflow as tfa = tf.reshape(tf.range(0, 12), [3, 4])b = tf.reshape(tf.range(100, 112), [3, 4])# 按第0维拼接stack0 = tf.stack([a, b], axis=0)# 按第1维拼接...原创 2018-05-24 06:37:06 · 563 阅读 · 0 评论 -
Tensorflow-API :tf.cond
tf.cond()是一个条件函数,根据条件返回的True或False 返回相应的结果 第一个参数是条件 bool 类型,第2个和第3个参数是返回的值,如果条件是True 返回第二个参数,如果条件是False 则返回第三个参数import tensorflow as tfa = tf.constant(2)b = tf.constant(3)x = tf.constant(4)y =...原创 2018-05-24 10:22:10 · 459 阅读 · 0 评论 -
OpenCV 视频植入广告
import cv2import osimport random# 广告列表video_dir = 'C:\\Elag\\video\\'video_list = os.listdir(video_dir)random.shuffle(video_list)video_capture = cv2.VideoCapture('C:\\Users\\user\\PycharmProjec...原创 2018-06-05 16:24:56 · 884 阅读 · 5 评论 -
gif动态图合成
import imageiodef create_gif(image_list, gif_name): frames = [] for image_name in image_list: frames.append(imageio.imread(image_name)) # Save them as frames into a gif ...原创 2018-06-06 13:19:47 · 183127 阅读 · 0 评论 -
OpenCV VideoCapture.get()参数详解
param define cv2.VideoCapture.get(0) 视频文件的当前位置(播放)以毫秒为单位 cv2.VideoCapture.get(1) 基于以0开始的被捕获或解码的帧索引 cv2.VideoCapture.get(2) 视频文件的相对位置(播放):0=电影开始,1=影片的结尾。 cv2.VideoCapture....原创 2018-06-07 09:45:57 · 33837 阅读 · 3 评论 -
OpenCV-切割视频
import cv2video_capture = cv2.VideoCapture('C:\\Users\\user\\Desktop\\Bing_S01E60_Wellies.mp4') # 读入视频文件c = 10fps = video_capture.get(5)print(video_capture.isOpened())print("fps", video_capture...原创 2018-05-31 13:39:24 · 7967 阅读 · 0 评论 -
Python 下载文件
import urllib.requesturllib.request.urlretrieve('http://...hxbl.rar','hxbl.rar')原创 2018-05-31 15:19:04 · 1936 阅读 · 0 评论 -
Tensorflow-API :比较函数
比较两个数,返回一个 bool 类型的张量import tensorflow as tf#判断每一个数是否大于0.5greater = tf.greater([1.,0.2,0.5,0.,2.,3.], 0.5)#判断每一个数是否小于0.5less = tf.less([1.,0.2,0.5,0.,2.,3.], 0.5)#判断每一个数是否大于等于0.5greater_equal=...原创 2018-05-23 16:22:43 · 6830 阅读 · 0 评论 -
Tensorflow-API : tf.gather
tf.gather 根据索引从参数轴上收集切片,索引必须是任何维度的整数张量 (通常为 0-D 或 1-D)import tensorflow as tft1 = tf.reshape(tf.range(0,16),[2,2,4])# [[[ 0 1 2 3]# [ 4 5 6 7]]## [[ 8 9 10 11]# [12 13 14 15]...原创 2018-05-23 16:05:26 · 407 阅读 · 0 评论 -
NMS-非极大值抑制-Python实现
首先选定一个IOU阈值,例如为0.4。然后将所有3个窗口(bounding box)按照得分由高到低排序。然后选中得分最高的窗口,遍历计算剩余的2个窗口与该窗口的重叠面积比例(IOU),如果IOU大于阈值0.4,则将窗口删除。然后,再从剩余的窗口中选中一个得分最高的,重复上述过程。直至所有窗口都被处理。假定这张图片上有3个候选框,如下图所示 那么如果IOU阀值设置为0.4后最终结果为 ...原创 2018-04-27 13:54:05 · 8492 阅读 · 3 评论 -
No module named yaml
pip install PyYAML原创 2018-05-16 16:20:45 · 16306 阅读 · 3 评论 -
tensorflow-命令行参数
from tensorflow import appfrom tensorflow.python.platform import flagsFLAGS = flags.FLAGS# yapf: disableflags.DEFINE_integer('task', 0, 'The Task ID. This value is used whe...原创 2018-05-23 10:25:16 · 760 阅读 · 0 评论 -
tensorflow-保存和恢复变量
保存import tensorflow as tf# Create some variables.v1 = tf.get_variable("v1", shape=[3], initializer = tf.zeros_initializer)v2 = tf.get_variable("v2", shape=[5], initializer = tf.zeros_initializer)...原创 2018-05-23 10:37:10 · 528 阅读 · 0 评论 -
tensorflow-Tensorboard
Tensorboard 是 Tensorflow 官方推出的可视化工具,他可以将模型训练过程中的各种汇总数据展示出来,如标量(Scalars)、图片(image)、音频(Audio)、计算图(Graph)、数据分布(Distributions)、直方图(Histograms)和嵌入向量(Embeddings)。我们在使用TensorFlow训练大型深度学习神经网络时,中间的计算过程可能非常复杂...原创 2018-05-23 13:37:04 · 993 阅读 · 0 评论 -
OpenCV-坐标转换
在目标检测中,图像标注一般是4个顶点坐标或者是bbox的中心坐标、宽高和旋转角度,在特定的处理函数中会用到不同的标注方法,这时就需要对坐标进行转换,具体方法如下# -*- coding: utf-8 -*-from __future__ import absolute_importfrom __future__ import divisionfrom __future__ impo...原创 2018-05-23 14:59:04 · 5248 阅读 · 0 评论 -
tensorflow-tfrecord
在深度学习训练中,如果训练数据较小可以使用feed_dict 方式喂数据,但如果数据量较大,一般采用tensorflow 自己的数据格式tfrecord,一个是避免内存不足以存储所有训练数据,另一个是对数据的读取进行提速,因为tfrecord格式的数据读取时异步的。下面用PASCAL VOC数据集格式进行转换# -*- coding: utf-8 -*-from __future__ i...原创 2018-05-23 15:17:01 · 663 阅读 · 6 评论 -
tensorflow-自定义op
在处理数据时需要自定义处理方法,这时就可以使用tf.py_func(func, inp, Tout, stateful=True, name=None)来进行处理具体例子import tensorflow as tfimport cv2import numpy as npdef forward_convert(coordinate, with_label=True): ...原创 2018-05-23 15:29:24 · 759 阅读 · 0 评论 -
opencv python 轮廓特征/凸包/外接矩形/外接圆/拟合矩形/拟合直线/拟合圆
1.图像的矩cv2.moments()图像的矩可以帮助计算物体的某些特征,如对象的质心,对象的区域等.import cv2import numpy as npimg = cv2.imread('img7.png',0)ret,thresh = cv2.threshold(img,127,255,0)im2,contours,hierarchy = cv2.findContours(...原创 2018-12-25 17:44:31 · 5856 阅读 · 0 评论