![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python
AIOT魔法师
这个作者很懒,什么都没留下…
展开
-
Linux安装miniconda
光标切换到最后一行,按i键插入环境变量地址,环境变量地址在这里有。按ESC,再按:键输入wq保存退出。原创 2024-02-28 00:36:55 · 305 阅读 · 0 评论 -
Huggingface网页解析和下载爬虫
【代码】Huggingface网页解析和下载爬虫。原创 2023-11-08 00:50:14 · 1059 阅读 · 2 评论 -
opencv四坐标区域裁剪
图像区域裁剪原创 2023-01-14 19:59:51 · 236 阅读 · 0 评论 -
word分行写入Exlcel
word分行写入Exlcel原创 2022-11-08 20:30:01 · 96 阅读 · 0 评论 -
python从多个文件夹中找出照片
python从多个文件夹中找出照片原创 2022-08-19 22:49:37 · 543 阅读 · 0 评论 -
python获取日期之间的间隔天数
python获取日期之间的间隔天数原创 2022-08-19 22:43:24 · 1733 阅读 · 0 评论 -
检查voc数据集是否有空的标注框
voc找出空白框原创 2022-07-30 00:37:07 · 295 阅读 · 0 评论 -
yolov5 5.0的result的head代表含义
epoch gpu_mem box_loss obj_loss class total_loss labels_num img_size precision recall mAP0.5 mAP0.5-0.9 box_loss obj_loss class_los原创 2022-05-22 16:08:28 · 245 阅读 · 1 评论 -
html中div标签并列显示
首先用一个大的div将要并列的div包裹在一起,然后为要并列的div标签指定style为left即可。<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>Title</title></head> <body> <div> <原创 2022-05-07 12:00:06 · 1626 阅读 · 0 评论 -
tkinter选择文件或文件夹
1、选择文件:from tkinter import filedialogimg_path = filedialog.askopenfilename() 2、选择文件夹:from tkinter.filedialog import askdirectoryIMG_PATH = askdirectory()原创 2022-04-29 16:00:44 · 4835 阅读 · 0 评论 -
python生成不重复随机整数
python生成不重复随机整数import randomran = random.sample(range(1, 10),9 )print(type(ran))for i in ran: print(i, end=' ')原创 2022-04-13 10:47:11 · 2943 阅读 · 0 评论 -
Python二值化照片
import cv2import numpy as npimport matplotlib.pylab as plt img = cv2.imread('img.jpg',0)ret,thresh1 = cv2.threshold(img,127,255,cv2.THRESH_BINARY)ret,thresh2 = cv2.threshold(img,127,255,cv2.THRESH_BINARY_INV)ret,thresh3 = cv2.threshold(img,127,255,原创 2022-02-09 11:25:09 · 127 阅读 · 0 评论 -
Python高分辨率图像的分割与合并
分割: # 目标分割大小 DES_HEIGHT = 640 DES_WIDTH = 640 # 获取图像信息 path_img = r'G:\A_SCI_DATASET\poppy\voc_wait_cut\img\12.jpg' #获取原始高分辨的图像的属性信息 src = cv2.imread(path_img) height = src.shape[0] width = src.shape[1] # 把原始图像边缘填充至原创 2021-11-10 14:43:54 · 4046 阅读 · 0 评论 -
Python清空文件夹内容
def setDir(filepath): ''' 如果文件夹不存在就创建,如果文件存在就清空! :param filepath:需要创建的文件夹路径 :return: ''' if not os.path.exists(filepath): os.mkdir(filepath) else: shutil.rmtree(filepath) os.mkdir(filepath)...原创 2021-11-08 14:56:41 · 3364 阅读 · 0 评论 -
树莓派python录制视频
import cv2cap = cv2.VideoCapture(0)fourcc = cv2.VideoWriter_fourcc(*'XVID')out = cv2.VideoWriter('output2.avi', fourcc, 20.0, (640, 480))while (cap.isOpened()): ret, frame = cap.read() if ret == True: out.write(frame) cv2.im原创 2021-11-05 16:39:00 · 362 阅读 · 1 评论 -
matplotlib显示多张图
import osfrom PIL import Imageimport matplotlib.pyplot as pltimg = Image.open(r'E:\tomato\AAAAAAAA-example\Bacterial_spot.JPG')gray = img.convert('L')r,g,b = img.split()img_merged = Image.merge('RGB', (r, g, b))path=r'E:\tomato\AAAAAAAA-example'原创 2021-10-30 23:34:09 · 2861 阅读 · 0 评论 -
python生成随机字符串
def generate_random_str(randomlength=16): """ 生成一个指定长度的随机字符串 """ random_str = '' base_str = 'ABCDEFGHIGKLMNOPQRSTUVWXYZabcdefghigklmnopqrstuvwxyz0123456789' length = len(base_str) - 1 for i in range(randomlength): random_str += base_str[r原创 2021-09-28 14:34:29 · 193 阅读 · 0 评论 -
Python中retry简单用法
直到产生为5的随机数:import randomfrom retrying import retry@retrydef test(): K=random.randint(0, 10) if K !=5: print(K,end='--') print('!=5') raise else: print(K,end='--') print('=5') test()...原创 2021-09-01 10:30:27 · 499 阅读 · 0 评论 -
Pycharm不显示matplotlib的图
Pycharm不显示matplotlib的图取消勾选就显示了原创 2021-08-15 22:49:59 · 192 阅读 · 0 评论 -
Flask按钮调用python函数
flask页面按钮事件原创 2021-08-12 13:50:04 · 2900 阅读 · 0 评论 -
opencv图像Base64相互转换
将普通opencv图像转换成base64:def image_to_base64(image_np): image = cv2.imencode('.jpg',image_np)[1] image_code = str(base64.b64encode(image))[2:-1] return image_code将Bse64转换成Openc图像:def base64_to_image(base64_code): # base64解码 img_data原创 2021-08-09 18:10:02 · 1873 阅读 · 0 评论 -
Opencv压缩图像的长宽python
import cv2img = cv2.imread('test.jpg')img = cv2.resize(img, (img.shape[1]//2, img.shape[0]//2), interpolation=cv2.INTER_CUBIC)cv2.imwrite('lena2.jpg', img)cv2.imshow('image2', img)cv2.waitKey(0)原创 2021-08-09 10:52:49 · 310 阅读 · 0 评论 -
socket传照片java服务器python客户端
Java服务器package Socket;import java.io.File;import java.io.FileOutputStream;import java.io.InputStream;import java.net.ServerSocket;import java.net.Socket; public class SS { public static void main(String[] args) throws Exception{ ServerSocket原创 2021-08-05 22:46:07 · 288 阅读 · 1 评论 -
Python读取推流地址Rtsp、Rtmp、Http
import cv2capture = cv2.VideoCapture('http://ivi.bupt.edu.cn/hls/cctv1hd.m3u8')while True: ret, frame = capture.read() # frame = cv2.flip(frame,1) #镜像操作 cv2.imshow("video", frame) key = cv2.waitKey(50) #print(key) if key == ord原创 2021-07-23 22:48:05 · 1735 阅读 · 0 评论 -
Python创建CSV文件
import csv# 表头field_order = ["姓名", '年龄', '性别']with open("test.csv", 'w', encoding="utf-8", newline='') as csvfile: writer = csv.DictWriter(csvfile, field_order) writer.writeheader() writer.writerow(dict(zip(field_order, ["张三", 20, "男"])))原创 2021-07-23 22:05:31 · 1888 阅读 · 0 评论 -
UnicodeDecodeError: ‘utf-8‘ codec can‘t decode byte 0xb2 in position 14: invalid start byte
在decode里面加上那两个参数即可result = res.decode("utf8","ignore")原创 2021-07-07 23:24:02 · 378 阅读 · 0 评论 -
python Socket服务器转发
基于多线程Server:import socketimport threading#接收数据def recive(sock): while True: try: data = sock.recv(1024) print("Recive:{}".format(data.decode("utf-8"))) T_trans=threading.Thread(target=broadcast_data,ar原创 2021-06-29 20:09:07 · 1859 阅读 · 1 评论 -
.bdi-server文件查看
tensorboard --logdir=G:\RLcode --port=8008tensorboard可视化其中G:\RLcode是你events.out.tfevents文件所在的文件目录。后面–port=8008是开启可视化的“地址”,修改 --port= 后面的数字可以同时可视化多个不同的events.out.tfevents文件,如tensorboard --logdir=G:\DLcode --port=8006。终端输入后,会有提示的网址将其复制到火狐浏览器或者google浏览器即原创 2021-06-23 23:56:33 · 346 阅读 · 0 评论 -
Python合并多个单元格
import osimport pandas as pd# 将文件读取出来放一个列表里面pwd = 'Data' # 获取文件目录# 新建列表,存放文件名file_list = []# 新建列表存放每个文件数据(依次读取多个相同结构的Excel文件并创建DataFrame)dfs = []for root,dirs,files in os.walk(pwd): # 第一个为起始路径,第二个为起始路径下的文件夹,第三个是起始路径下的文件。 for file in files:原创 2021-06-08 15:35:35 · 1339 阅读 · 1 评论 -
centos from .cv2 import * ImportError: libGL.so.1: cannot open shared object file:
yum install libglvnd-glx原创 2021-06-04 20:25:54 · 884 阅读 · 0 评论 -
Java运行Python程序
原理:Java运行cmd窗口,使用python 运行py程序。bat文件(最好放在Python工程路径下)代码:@echo off F:cd F:\IDE\Anaconda\envs\torchstart python F:\Python\yolo5-Person\detectUI.pyexitjava调用程序:package ClassDesign;import java.io.BufferedReader;import java.io.IOException;import j原创 2021-06-03 23:29:58 · 505 阅读 · 1 评论 -
Python PIL获取图像
from PIL import Imageim = Image.open('F:\\ReMark\\7.jpg')#返回一个Image对象width=im.size[0]height=im.size[1]原创 2021-05-20 10:25:35 · 142 阅读 · 0 评论 -
Python flask传递照片
服务器端:这里的操作就是当客户端运行程序提交照片后,将客户端的照片保存在工程目录下,保存名称为01.pngfrom flask import request, Flaskimport base64import cv2import numpy as npapp = Flask(__name__)@app.route("/", methods=['POST','GET'])def get_frame(): #解析图片数据 img = base64.b64decode(str(r原创 2021-05-19 09:35:23 · 748 阅读 · 0 评论 -
python matplotlib画饼形图
我写的这个函数是画饼形图的,有两个参数,一个是字典,字典的内容例如’a’=7,就是前面是字符串后面是数字,运行完后会在当前路径下输入运行的结果图。def Plo2class(Dir,title): New_Dir=Dir.copy() Null_List=[] for k in New_Dir: if(New_Dir[k]==0): Null_List.append(k) for i in range(len(Null_List))原创 2021-05-17 16:47:29 · 218 阅读 · 0 评论 -
Python复制文件
import osimport shutildef mycopyfile(srcfile,dstpath): if not os.path.isfile(srcfile): print ("%s not exist!"%(srcfile)) else: shutil.copy(srcfile, dstpath) print ("copy %s -> %s"%(srcfile, d原创 2021-05-02 20:00:20 · 78 阅读 · 0 评论 -
PySide2选择文件
下面代码给按钮设置这个函数就可以实现打开浏览并选择文件的窗口如图,代码里面的fileName很有用。 def openFileNameDialog(self): options = QFileDialog.Options() options |= QFileDialog.DontUseNativeDialog fileName, _ = QFileDialog.getOpenFileName(self, "QFileDialog.getOpenFile原创 2021-04-29 14:18:53 · 2094 阅读 · 0 评论 -
PyQt、PySide2显示opencv照片
下面代码中self是在界面那个类中,frame就是cv2读取的照片,label_2是要显示照片的组件,修改成自己的即可。 def display_video_stream(self,frame): frame = cv2.cvtColor(frame, cv2.COLOR_RGB2BGR) frame = cv2.flip(frame, 1) image = QImage(frame, frame.shape[1], frame.shape[0],原创 2021-04-29 14:14:09 · 1370 阅读 · 0 评论 -
Python opencv镜像翻转
import numpy as npimport cv2img = cv2.imread("PIC/ww.jpeg")cv2.imshow("yuan", img)img1 = cv2.flip(img,1) #镜像'''参数2 必选参数。用于指定镜像翻转的类型,其中0表示绕×轴正直翻转,即垂直镜像翻转;1表示绕y轴翻转,即水平镜像翻转;-1表示绕×轴、y轴两个轴翻转,即对角镜像翻转。参数3 可选参数。用于设置输出数组,即镜像翻转后的图像数据,默认为与输入图像数组大小和类型都相同的数组。原创 2021-04-29 09:31:09 · 1125 阅读 · 1 评论 -
matplotlib画饼图
import matplotlib as mplimport matplotlib.pyplot as plt# 生成数据labels = ['A', 'B', 'C', 'D', '其他']share = [0.45, 0.25, 0.15, 0.05, 0.10]# 设置分裂属性explode = [0, 0.1, 0, 0, 0]# 分裂饼图plt.pie(share, explode = explode, labels = labels, autopct = '原创 2021-04-27 23:49:33 · 123 阅读 · 0 评论 -
把opencv的照片传到tk界面上
下面函数中image_label就是tk中要显示照片的组件具体设计参考其他tk的设计,把image_label替换成你自己的控件即可。def cvImg2Tk(cvImg): cv2image = cv2.cvtColor(cvImg, cv2.COLOR_BGR2RGBA) # 转换颜色从BGR到RGBA current_image = Image.fromarray(cv2image) # 将图像转换成Image对象 imgtk = ImageTk.PhotoImage(i原创 2021-04-27 20:47:34 · 521 阅读 · 0 评论