python
佐倉
皆さん、こんにちは。私は桜と申しますが、故郷は河南です。ソフトウェアが大好きだなあ。時間があれば一緒に勉強しましょう!よろしく、お願い致します!
展开
-
python日志、异常和装饰器的结合
基础日志级别:与 logging 模块类似,loguru 也支持多种日志级别,如 DEBUG, INFO, WARNING, ERROR, 和 CRITICAL。日志格式:loguru 会自动输出格式化的日志信息,包括时间、级别、消息等,可以自定义格式。日志轮转:可以轻松设置日志文件的轮转规则,例如基于文件大小、时间或其他条件。异步支持:loguru 可以异步记录日志,适合在高并发环境中使用。颜色支持:loguru 在控制台输出时,默认带有颜色标注,便于阅读。原创 2024-08-16 09:43:49 · 316 阅读 · 0 评论 -
python 算法加密
python 5种加密方式原创 2022-12-12 15:52:30 · 3779 阅读 · 1 评论 -
PyQt 自定义进度条
PyQt自定义样式进度条原创 2022-11-10 14:21:26 · 1238 阅读 · 0 评论 -
Python 功能装饰器
1. 函数日志功能2. 函数运行计时3. 函数提示功能4. 装饰器使用原创 2022-06-28 17:27:51 · 208 阅读 · 0 评论 -
cv2嵌入PyQt显示图像与视频
import sys, osfrom PyQt5 import QtCore, QtWidgets, QtGuifrom PyQt5.QtWidgets import *from PyQt5.QtGui import *import cv2class CV2_PYQT_Window(QDialog): def __init__(self,src,target="video",parent=None): super(CV2_PYQT_Window,self).__init原创 2021-10-12 10:49:46 · 3239 阅读 · 0 评论 -
图片处理后进行Kmeans聚类
import randomfrom sklearn import datasetsimport numpy as npimport matplotlib.pyplot as pltfrom mpl_toolkits.mplot3d import Axes3Dimport cv2import numpy as npimport matplotlib.pyplot as pltimport pandas as pdfrom sklearn.cluster import KMeansfrom原创 2021-10-01 11:59:50 · 237 阅读 · 0 评论 -
Python必会操作
命令行参数import sysimport cv2def show_pic(img): cv2.imshow('image',img) cv2.waitKey(0) cv2.destroyAllWindows()def main(): print("start") print (sys.argv) image_1 = sys.argv[1] image_2 = sys.argv[2] src = cv2.imread(image_1) show_原创 2021-07-24 07:42:37 · 191 阅读 · 2 评论 -
tcp/ip 实现局域网内设备通信
客户端单向控制服务器服务器# -*- coding:utf-8 -*-import socketimport osimport timehost = '192.168.1.105'port = 12345def main(): while True: ret = str(conn.recv(1024), encoding="utf-8") if ('End' in ret) or (ret==""): print('客户端断原创 2021-06-28 16:18:09 · 931 阅读 · 1 评论 -
手写数据集自动生成
手写数字生成import randomimport osfrom PIL import Image, ImageDraw, ImageFontrandom.seed(3)path_img = "data/"def generate_single(): im_50_blank = Image.new('RGB', (50, 50), (255, 255, 255)) draw = ImageDraw.Draw(im_50_blank) num = str(random.r原创 2021-05-15 22:59:22 · 194 阅读 · 0 评论 -
opencv目标追踪
# -*- coding:utf-8 -*-import numpy as npimport argparseimport cv2points=[]opencv_object_trckers = { "csrt": cv2.TrackerCSRT_create, "kcf": cv2.TrackerKCF_create, "boosting": cv2.TrackerBoosting_create, "mil": cv2.TrackerMIL_create,原创 2021-05-10 08:26:21 · 215 阅读 · 0 评论 -
caffe 模型训练
import caffefrom caffe import layers as Limport osimport numpy as npfrom matplotlib import pyplot as pltSolver_PATH = 'auto_solver_.prototxt'def change_env(): root = os.path.dirname(__file__) os.chdir(root) print ("current work root:->",root)原创 2021-05-07 10:33:40 · 107 阅读 · 0 评论 -
caffe简单训练案例
import caffefrom caffe import layers as Limport osimport numpy as npSolver_PATH = 'auto_solver.prototxt'def change_env(): root = os.path.dirname(__file__) os.chdir(root) print ("current work root:->",root)def net(img_list,batch_size,mean_val原创 2021-05-05 16:55:21 · 184 阅读 · 0 评论 -
第一个caffe案例
caffe案例import caffefrom caffe import layers as Lfrom caffe import params as P def net(dbfile,batch_size,mean_value=0): d = caffe.NetSpec() d.data, d.label=L.Data(source=dbfile, backend = P.Data.LMDB, batch_size=batch_size, ntop=2, transform_param=d原创 2021-05-05 10:44:30 · 172 阅读 · 0 评论 -
caffe 案例测试
运行方法VS2015打开Caffe.sln点击生成解决方案最终,得到caffe.exe,利用它进行案例测试。最好配置到环境变量里。案例数据准备下载链接:https://pan.baidu.com/s/10CmpZUdEVmma4A0mziu9dw提取码:dmjr复制这段内容后打开百度网盘手机App,操作更方便哦解压后放到data/mnist进入C:\Windows\System32\WindowsPowerShell\v1.0管理员运行PowerShellPS F:\caff原创 2021-05-04 14:57:41 · 7492 阅读 · 3 评论 -
基于SSD模型的目标追踪
调用SSD模型# -*- coding: utf-8 -*-from tensorflow.python.keras.preprocessing.image import img_to_arrayfrom tensorflow.python.keras.applications.imagenet_utils import preprocess_inputimport cv2 as cvimport numpy as npfrom nets.ssd_net import SSD300from原创 2021-04-27 19:29:30 · 548 阅读 · 0 评论 -
目标检测数据集预处理
数据集:http://host.robots.ox.ac.uk:8080/pascal/VOC/voc2011/index.html说明:本文使用2012工程目录datasets|_____commodity______Annotations||__________JPEGImages数据预处理from xml.etree import ElementTree as ET from collections import OrderedDict as Dictimport num原创 2021-04-25 11:17:56 · 344 阅读 · 0 评论 -
基于dlib的眼睛检测
# -*- coding=utf-8 -*-import numpy as np import cv2import dlibfrom scipy.spatial import distanceimport osfrom imutils import face_utilsimg_eye = cv2.imread("eye.png")switch = FalseVECTOR_SIZE = 3def queue_in(queue, data): ret = None if l原创 2021-04-16 12:51:07 · 1240 阅读 · 0 评论 -
光流估计
# -*- coding:utf-8 -*-import cv2import numpy as npdef video_operate(): capture = cv2.VideoCapture("test.avi") feature_param = dict(maxCorners =100,qualityLevel = 0.3,minDistance= 7) lk_param = dict(winSize=(15,15),maxLevel=2) color_ ..原创 2021-04-13 15:44:32 · 134 阅读 · 0 评论 -
背景建模
# -*- coding:utf-8 -*-import cv2import numpy as npdef video_operate(): capture = cv2.VideoCapture("test.avi") kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE,(3,3)) fbgb = cv2.createBackgroundSubtractorMOG2()# 混合高斯模型建模 while Tru...原创 2021-04-13 10:20:02 · 129 阅读 · 0 评论 -
PyQt获取某天之前后的n天日期
核心功能函数import datetimedef getday(time,n): y,m,d = time.split("-") y,m,d = int(y),int(m),int(d) n = int(n) the_date = datetime.datetime(y,m,d) result_date = the_date + datetime.timedelta(days=n) time = result_date.strftime('%Y-%m-%d原创 2021-04-10 13:12:20 · 259 阅读 · 2 评论 -
傅里叶变换
低通滤波# -*- coding:utf-8 -*-import numpy as npimport cv2from matplotlib import pyplot as pltdef display(img): cv2.imshow("img",img) cv2.waitKey() cv2.destroyAllWindows()def operate(img): img_float32 = np.float32(img) dft = cv2.dft(img_float32,f..原创 2021-04-09 20:28:47 · 116 阅读 · 0 评论 -
直方图操作
图像直方图def img_dislay(img): hist = cv2.calcHist([img],[0],None,[256],[0,256]) plt.hist(img.ravel(),256) plt.show()图像rgb信息def rgb_display(img):#图像输入必须rgb类型 color = ('b','g','r') for i,col in enumerate(color): histr = cv2.calc原创 2021-04-09 20:22:03 · 107 阅读 · 0 评论 -
图像梯度
Sobel算子def sobel_(src): sobel_x = cv2.Sobel(src,cv2.CV_64F,1,0,ksize=3) sobel_y = cv2.Sobel(src,cv2.CV_64F,0,1,ksize=3) sobel_x = cv2.convertScaleAbs(sobel_x) sobel_y = cv2.convertScaleAbs(sobel_y) sobel_xy = cv2.addWeighted(sobel_x,原创 2021-04-07 21:23:14 · 103 阅读 · 1 评论 -
形态学操作
显示图像def display(img): cv2.imshow("img",img) cv2.waitKey() cv2.destroyAllWindows()腐蚀操作def erode_(img): kernel = np.ones((5,5),np.uint8) erodesion = cv2.erode(img,kernel,iterations=4) display(erodesion)膨胀操作def dilate_(img): kernel = np.ones((原创 2021-04-06 16:43:02 · 156 阅读 · 0 评论 -
opengl读取文件建立模型
from OpenGL.GL import *from OpenGL.GLU import *from OpenGL.GLUT import *angle = 0move = 0size = 1def read_txt(file): f = open(file,"r") all_list = f.readlines()[:] vertex_list=[] face_list=[] normal_list=[] texture_list = []原创 2021-04-06 13:10:21 · 382 阅读 · 0 评论 -
opengl实现鼠标键盘事件
from OpenGL.GL import *from OpenGL.GLU import *from OpenGL.GLUT import *angle = 0move = 0size = 1def perp(): glClearColor(0.0, 0.0, 0.0,0.0) glClear(GL_COLOR_BUFFER_BIT) glMatrixMode(GL_PROJECTION) glLoadIdentity() gluPerspect原创 2021-04-06 13:02:35 · 450 阅读 · 0 评论 -
常用滤波器
# -*- coding: utf-8 -*-import cv2 as cvimport numpy as npdef display_img(img): cv.imshow('image',img) cv.waitKey(0) cv.destroyAllWindows()def average_(filepath):#均值滤波,适用于去除通过扫描得到的图像中的颗粒噪声 img = cv.imread(filepath) blur = cv.blur(i原创 2021-04-05 10:44:58 · 230 阅读 · 0 评论 -
二值化处理
import cv2 as cvimport matplotlib.pyplot as pltthresh_type = [ cv.THRESH_BINARY, cv.THRESH_BINARY_INV, cv.THRESH_TRUNC, cv.THRESH_TOZERO, cv.THRESH_TOZERO_INV ]title = [ "ORIGNAL", "BINARY", ".原创 2021-04-05 10:14:04 · 643 阅读 · 0 评论 -
目标跟踪
目标跟踪源码# -*- ending:utf-8 -*-import dlibimport numpy as npimport argparseimport cv2points=[]def show_info(frame,tracking_status): pos1 = (10,20) pos2 = (10,40) pos3 = (10,60) info1 = "click selct an area,start tracking" info2 = "'原创 2021-04-03 14:25:24 · 104 阅读 · 3 评论 -
全景图片拼接
图片对比import cv2 as cvimport numpy as npdef display_img(img): cv.imshow('image',img) cv.waitKey(0) cv.destroyAllWindows()def double_img(file1,file2): img1 = cv.imread(file1) img2 = cv.imread(file2) res = np.hstack((img1,img2))原创 2021-04-03 11:47:54 · 128 阅读 · 1 评论 -
模拟太阳系
from OpenGL.GL import *from OpenGL.GLU import *from OpenGL.GLUT import *import timefrom math import *day=0PI=3.1415def shikou(): glMatrixMode(GL_PROJECTION) glLoadIdentity() gluPerspective(80,1,1,400000000) glMatrixMode(GL_MODELVI..原创 2021-04-02 11:46:41 · 125 阅读 · 0 评论 -
正交投影和透视投影
glOrtho 正交投影glOrtho(GLdouble left,GLdouble right,GLdouble bottom,GLdouble top,GLdouble near,GLdouble far)六个参数,x,y,z轴的范围,min与max例如x ,-10,10y,-10,10z,-10,10glOrtho(-10,10,-10,10,-10,10)正交投影from OpenGL.GL import *from OpenGL.GLU import *from OpenG原创 2021-04-02 11:38:48 · 529 阅读 · 0 评论 -
图片文字透视变换及ocr识别
pytesseract 模块安装https://digi.bib.uni-mannheim.de/tesseract/tesseract-ocr-w64-setup-v4.0.0-beta.1.20180414.exe安装后配置安装目录环境变量到path轮廓检测def contours_img(image): gray = cv.cvtColor(image,cv.COLOR_BGR2GRAY) threshold = cv.threshold(gray,160,255,cv.TH原创 2021-04-01 10:12:55 · 365 阅读 · 0 评论 -
基本几何物体
物体种类glutWireCube(GLdouble); //画线框立方体glutWireSphere(GLdouble,GLint,GLint); //画线框球体glutWireCone(GLdouble,GLdouble,GLint,GLint); //画线框圆锥体glutWireCylinder(G原创 2021-03-30 10:19:09 · 436 阅读 · 0 评论 -
银行卡识别
代码import numpy as npimport cv2def cv_display(name,img): cv2.imshow(name,img) cv2.waitKey(0) cv2.destroyAllWindows()def read_template(template_file): template = cv2.imread(template_file) gray = cv2.cvtColor(template,cv2.COLOR_BGR原创 2021-03-29 19:24:41 · 100 阅读 · 1 评论 -
python3.5 caffe配置
下载caffe(C++)https://github.com/BVLC/caffe下载 CMakehttps://cmake.org/download/下载python3.5https://www.python.org/downloads/windows/下载Visual studio2015,并安装http://download.microsoft.com/download/B/4/8/B4870509-05CB-447C-878F-2F80E4CB464C/vs2015.com_ch原创 2021-03-28 20:52:02 · 231 阅读 · 0 评论 -
openGL基础
OpenGl图元的模式GL_POINTS,点GL_LINES,线 GL_LINE_STRIP,条带线 GL_LINE_LOOP, 循环线 GL_TRIANGLES,立三角形 GL_TRIANGLE_STRIP, 三角形条带 GL_TRIANGLE_FAN,三角形扇面 GL_QUADS,四边形面 GL_QUADS原创 2021-03-27 10:21:01 · 238 阅读 · 0 评论 -
Python自动化获取页面信息
from selenium import webdriver def get_url_data(url): driver=webdriver.Chrome() driver.get(url) html_text=driver.page_source print(driver.title) driver.quit() #print html_text return html_texturl="https://www.baidu.co原创 2020-07-18 21:36:03 · 533 阅读 · 0 评论 -
图像特征
import cv2 as cvimport numpy as npimport matplotlib.pyplot as pltdef display_img(img): cv.imshow('image',img) cv.waitKey(0) cv.destroyAllWindows()def operate_img(file): ######得到特征点###### img = cv.imread(file) gray = cv.cvtColor原创 2021-03-26 17:31:20 · 79 阅读 · 2 评论 -
边缘角点检测
import cv2 as cvimport numpy as npimport matplotlib.pyplot as pltdef display_img(label,img): cv.imshow(label,img) cv.waitKey(0) cv.destroyAllWindows() def all_operate(file:"image"): img = cv.imread(file) img_gray = cv.cvt.原创 2021-03-26 14:50:46 · 83 阅读 · 0 评论