![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python
Python图像识别
这个作者很懒,什么都没留下…
展开
-
安装 vs2019 一闪而过
问题原因:电脑windows系统为英文系统,而我下载的vs2019是中文版。原创 2023-02-13 17:42:44 · 241 阅读 · 0 评论 -
python 截取视频片段
【代码】python 截取视频片段。原创 2023-01-11 18:22:19 · 777 阅读 · 0 评论 -
python 操作vizrt
【代码】python 操作vizrt。原创 2023-01-11 17:53:34 · 224 阅读 · 1 评论 -
python os模块
【代码】python os模块。原创 2023-01-11 17:32:55 · 179 阅读 · 0 评论 -
python 读写json
【代码】python 读写json。原创 2023-01-06 19:40:17 · 180 阅读 · 0 评论 -
python 文件名排序(自然排序、常规排序)
【代码】python 文件名排序 lambada表达式。原创 2023-01-06 19:31:28 · 2126 阅读 · 0 评论 -
python OpenCV 视频处理
【代码】python OpenCV 视频处理。原创 2022-12-29 19:37:32 · 276 阅读 · 0 评论 -
cv2.error: Unknown C++ exception from OpenCV code
ndarray经过切片后,会出现内存不连续的情况,当不连续时,保存就会报错。利用 ascontiguousarray ,将其变为连续的即可。原创 2022-08-30 17:47:52 · 1532 阅读 · 0 评论 -
python parser.add_argument()用法
B站视频讲解官方文档https://docs.python.org/zh-cn/3/library/argparse.html#argumentparser-objects运行结果: 使用的三个步骤:1、创建一个解析器——创建 ArgumentParser() 对象2、添加参数——调用 add_argument() 方法添加参数3、解析参数——使用 parse_args() 解析添加的参数ArgumentParser.add_argument(name or flags...[, action].原创 2022-05-31 21:40:11 · 3449 阅读 · 2 评论 -
python 读取NDI
ndi-python 相关知识原创 2022-04-26 15:55:15 · 3755 阅读 · 1 评论 -
python json文件写入到excel
# -*- coding: utf-8 -*-import xlwtimport jsondef json_excel(data): # 创建excel工作表 workbook = xlwt.Workbook(encoding='utf-8') worksheet = workbook.add_sheet('skiing') # 写表头 for index, val in enumerate(data[0].keys()): workshee原创 2022-02-11 15:39:32 · 1941 阅读 · 0 评论 -
python 替换图片中的某部分
将图片1和图片2中的小人,叠加到background.jpg图片中。此方法是用> 223像素值,进行提取的,实际使用时,可自行调整。原创 2022-02-10 12:00:30 · 5910 阅读 · 0 评论 -
python接收不到udp发送的信息 windows10
问题描述:需要在本机设备上接收其他设备发送过来的消息(udp方式),但是接收不到。自己检查 IP 及 端口号都没有问题,然后自己在本地写了测试程序,发现本机发送udp消息,本机可以接收到。唯独其他设备发送的消息接收不到。自己测试的udp代码如下:server端:#!/usr/bin/env pythonimport socketaddress=('192.168.2.61', 9999)s=socket.socket(socket.AF_INET,socket.SOCK_DGRAM)s.bi原创 2021-12-29 11:37:26 · 2694 阅读 · 0 评论 -
列表字典格式数据转换
def lst_foot_all_to_every(lst_foot_all): ''' 将:[{'id': 1, "Y": 24.1, "frame_time": 0.0, "sign": ""}, {'id': 1, "Y": 24.5, "frame_time": 0.0, "sign": ""}, {'id': 2, "Y": 24.6, "frame_time": 0.0, "sign": ""}] .原创 2021-09-24 19:09:13 · 192 阅读 · 0 评论 -
对比两张图片的相似度
1.cosin相似度(余弦相似度)from PIL import Imagefrom numpy import average, linalg, dotdef get_thumbnail(image, size=(30, 30), greyscale=False): image = image.resize(size, Image.ANTIALIAS) if greyscale: image = image.convert('L') return image原创 2021-08-31 09:40:24 · 5489 阅读 · 1 评论 -
git使用
git提交: # 创建md测试文件 touch README.md # 初始化git git init # 添加需要上传的文件夹或者文件 git add 1 # 添加注释 git commit -m "first commit" # 链接git地址 git remote add origin http://192.168.0.110:3000/folders/Image_algorithm.git # 提交 git push -u orig原创 2021-08-27 15:55:18 · 150 阅读 · 0 评论 -
tkinter 界面播放视频
from tkinter import *from PIL import ImageTk, Imageimport cv2root = Tk()# Create a frameapp = Frame(root, bg="white")app.grid()# Create a label in the framelmian = Label(app)lmian.grid()# Capture from cameracap = cv2.VideoCapture('video331.mp4原创 2021-05-17 15:57:28 · 4712 阅读 · 2 评论 -
tkinter 设置背景图片 和 label显示位置以及label设置显示图片
from tkinter import *import tkinter as tkfrom PIL import ImageTkfrom PIL import Imagedef get_img(filename, width, height): im = Image.open(filename).resize((width, height)) im = ImageTk.PhotoImage(im) return imdef main(): ''' 注意:原创 2021-05-17 15:51:24 · 19907 阅读 · 6 评论 -
NumPy 高维数组降维方法详细分析
import numpy as npa = np.arange(64).reshape([4,4,4])# [[[ 0 1 2 3]# [ 4 5 6 7]# [ 8 9 10 11]# [12 13 14 15]]## [[16 17 18 19]# [20 21 22 23]# [24 25 26 27]# [28 29 30 31]]## [[32 33 34 35]# [36 37 38 39]# [40 41 42 .原创 2021-05-12 15:00:35 · 1729 阅读 · 0 评论 -
NumPy中的索引-详解
import numpy as npaaa = np.arange(8).reshape([2, 4])# [[0 1 2 3]# [4 5 6 7]]print(aaa)# [0 1 2 3]print(aaa[0])# 取出第0行的第一列# 1print(aaa[0,1])# 取出所有行的第一列# [1, 5]print(aaa[:,1])# 取出所有行的第 1 列,输出同上面格式不同# [[1]# [5]]print(aaa[:,1:2])# 取出第1行的, 第原创 2021-05-12 14:05:51 · 424 阅读 · 0 评论 -
Python 任意点顺时针逆时针排序
from functools import reduceimport operatorimport mathcoords = [(0, 1), (1, 0), (1, 1), (0, 0), (2, 3)]center = tuple(map(operator.truediv, reduce(lambda x, y: map(operator.add, x, y), coords), [len(coords)] * 2))print(sorted(coords, key=lambda coord.原创 2020-12-28 11:24:03 · 3636 阅读 · 2 评论 -
Python 切割任意图片
import datetimeimport numpy as npimport cv2import osimport jsondef split_img_duo(path): count = 1 for root, dirs, files in os.walk(path): for file in files: if os.path.splitext(file)[-1] == '.json': with原创 2020-12-18 16:10:04 · 351 阅读 · 2 评论 -
Python 操作excel 读写、追加写
# coding=UTF-8import openpyxlimport xlrdfrom xlutils.copy import copydef write_excel_xlsx(path, sheet_name, value): """ 写入 """ index = len(value) workbook = openpyxl.Workbook() sheet = workbook.active sheet.title = sheet_na原创 2020-08-27 11:12:03 · 540 阅读 · 0 评论 -
python 从list中随机取值
import randomlist1 = ['佛山', '南宁', '北海', '杭州', '南昌', '厦门', '温州']# 随机返回只有4个值的listb = random.sample(list1, 4)print(b)结果:[‘南宁’, ‘温州’, ‘北海’, ‘杭州’]原创 2020-08-24 15:32:02 · 1299 阅读 · 0 评论 -
OpenCV、PIL 切割合并图片
import osimport cv2import numpy as npimport mathfrom PIL import Imagedef crop_one_picture(path,save_split_path,height_min,width_min): """ 切割图片 :param path: 原图路径 :param save_split_path: 切割小图保存路径 :param height_min: 切割尺寸 :param.原创 2020-07-30 16:52:25 · 355 阅读 · 0 评论 -
Python批量resize图片
from PIL import Imageimport os.pathimport globdef convertjpg(jpgfile,outdir,width=720,height=720): """ 修改图片大小 :param jpgfile: 输入原图片 :param outdir: 保存位置 :param width: 修改的宽度 :param height: 修改的高度 :return: """ img=Image.原创 2020-07-15 10:14:14 · 1256 阅读 · 0 评论 -
图像改为卡通图像
# -*- encoding: utf-8 -*-import cv2import osimport cv2def cartoonise(picture_name): print (picture_name) imgInput_FileName = r"C:\Users\admin\Desktop\mahua\u=3096483399,3656062313&fm=26&gp=0.jpg" imgOutput_FileName = r"C:\Users\adm原创 2020-07-13 10:51:14 · 595 阅读 · 0 评论 -
统计 python 列表中每种相同元素出现的次数
import collectionslst = ['Albatross', 'Albatross', 'Yellow_breasted_Chat', 'Albatross', 'Yellow_breasted_Chat', 'Yellow_breasted_Chat', 'Cuckoo', 'Cuckoo', 'Cuckoo', 'Cuckoo']dic = collections.Counter(lst)# Counter({'Cuckoo': 4, 'Albatross': 3, '原创 2020-05-23 15:48:02 · 2373 阅读 · 0 评论 -
Python操作文件夹、文件封装
代码是对文件、文件夹操作进行了简单封装,以满足相应的应用场景1. 文件复制包含对类型的判断,子文件夹等2. 修改文件名3. 修改文件后缀import osimport timeimport shutildef copyfiles_create_subfolder(sourceDir, targetDir, type='None'): """ 完全连子目录也会复制好,美观 :param sourceDir: 源文件夹 :param targetDir: 目原创 2020-05-16 09:32:23 · 581 阅读 · 0 评论 -
Python logging日志输出封装
import loggingimport osfrom logging import handlersimport timeclass Logger(object): level_mapping = { 'debug': logging.DEBUG, 'info': logging.INFO, 'warning': logging...原创 2020-04-01 11:06:11 · 195 阅读 · 0 评论 -
python window Linux 环境下实现 父进程退出 子进程跟着退出
当时实际需求环境:实际需求:父进程退出,子进程也跟着退出。Python 创建了1个界面窗口,点击开始训练后,创建4个进程,分别进行4个模型的训练,当点击窗口右上角的差号退出后,开始时,窗口关闭了,但是模型训练没有结束。也就是后台创建进程没有关闭(父进程退出了,子进程变为孤儿进程,由系统接收管理)解决思路:查资料好多都是让把创建的子进程的pid保存到文档,但这样做,太不雅了。我是把它保存到了队...原创 2020-03-31 18:22:09 · 1329 阅读 · 1 评论 -
python在windows和linux环境的进程支持对比
1.fork进程:(1)在windows系统中不可以用fork来创建进程,linux可以2.Process进程:import multiprocessing as msimport timeimport osclass MyProcess(ms.Process): def run(self): print("这是进程!", os.getpid()) ...原创 2020-03-28 17:35:37 · 523 阅读 · 0 评论 -
os.kill()Windows 和 Linux区别
os.kill() Linux环境下一般用于直接Kill掉进程,但是只能在linux平台上有效。基本原理:该函数是模拟传统的linux函数发信号给进程,其中包含两个参数:一个是进程名,即所要接收信号的进程;一个是所要进行的操作。操作(第二个参数)的常用取值为:SIGINT 终止进程 中断进程SIGTERM 终止进程 软件终止信号SIGKILL 终止进...原创 2020-03-28 17:24:45 · 4814 阅读 · 0 评论 -
tkinter 点击退出执行的程序
当点击右上角的差号时,程序进行弹框提示from tkinter import Tkfrom tkinter import messageboxroot = Tk()# 当点击右上角退出时,执行的程序def on_closing(): if messagebox.askokcancel("Quit", "Do you want to quit?"): root....原创 2020-03-28 16:46:44 · 9607 阅读 · 0 评论 -
Python操作文件夹封装
Python操作文件夹封装,中间进行了一些文件夹是否存在,也可连续创建多个文件夹,删除多个文件夹。后续会再进行封装。方便使用#!/usr/bin/env python3# -*- encoding: utf-8 -*-'''@File : shutil_mkdir.py@Contact : raogx.vip@hotmail.com@License : (C)Copy...原创 2020-03-27 17:29:53 · 518 阅读 · 0 评论 -
python生成requirements.txt环境打包,利用requirements.txt安装Python环境
requirement.txt原创 2019-12-12 13:15:31 · 12390 阅读 · 0 评论 -
Win10环境下python脚本定时运行(Windows自带的定时任务)
实现步骤:打开win10的计划任务控制面板\系统和安全\管理工具\任务计划程序打开创建基本任务向导打开计划任务程序后,在右边的操作栏选择 创建基本任务向导创建基本任务首先输入任务的名称,描述写不写无所谓,不过如果要长期运行还是最好写一下,便于之后快速了解这个任务是干吗的。填写完毕点击下一步触发器设定这里的触发器就是决定你的python脚本是怎么启动的。这里非常的关键...原创 2019-12-10 14:34:14 · 6420 阅读 · 0 评论 -
python 代码加密pyd
步骤:1.安装easycython包(pip install easycython)2.打开pycharm下面的命令行3.cd到py文件目录(a.选择磁盘e:,b.选择目录cd E:/DR/robot)注意不能识别中文路径,把文件保存到英文路径下4.手动把.py后缀改为.pyx5.命令行中输入(easycython a.pyx 或easycython *.pyx)6.其他生成文件可删...原创 2019-12-10 10:45:14 · 1051 阅读 · 0 评论