- 博客(29)
- 收藏
- 关注
原创 windows环境下pycharm专业版远程连接昇腾服务器
FAQ:如果出现如下报错,是因为pycharm与远程服务器映射的环境没有包含cann相关的环境,需要将cann里面的一些python包copy到我们要配置的远程环境。step3:将step1的id_rsa.pub里面的内容复制到昇腾服务器的host文件里,保存并关闭。4.2配置远程python路径及本地工程与远程环境工程的映射路径。windows环境下pycharm专业版远程连接昇腾服务器。step2:登陆到昇腾服务器,打开host文件。step4:开启pycharm远程连接的配置。4.1 填写相关信息。
2024-08-07 10:13:13
147
原创 np使用gpu加速
import numpy as npimport cupy as cpimport time#安装指定的cuda版本的 cp### Numpy and CPUs = time.time()x_cpu = np.ones((100,100,100))e = time.time()print("cpu",e - s)### CuPy and GPUs = time.time()x_gpu = cp.ones((100,100,100))e = time.time()print("gpu
2022-03-09 14:31:09
981
原创 测试cv2 Umat
import cv2import time # 引入time模块t0 = time.time()def UMat_cal(img): img = cv2.UMat(img) img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) print(img) img = cv2.GaussianBlur(img, (7, 7), 1.5) img = cv2.Canny(img, 0, 50) img = cv2.UMa
2022-03-08 19:56:36
799
原创 np数组与base64互转
import cv2import base64import numpy as npdef np2base64(npimg): img_str = cv2.imencode('.jpg', npimg)[1].tostring() # 将图片编码成流数据,放到内存缓存中,然后转化成string格式 b64_code = base64.b64encode(img_str) data = str(b64_code, 'utf-8') return datadef ba
2022-02-21 13:31:17
2250
原创 python字典遍历
#字典遍历a = {'a': '1', 'b': '2', 'c': '3'}#遍历keyfor i in a: print(i)for i in a.keys(): print(i)#遍历valuefor i in a.values(): print(i)#遍历组员for i in a.items(): print(i)for key,value in a.items(): print(key,value)...
2021-12-12 12:12:58
522
原创 python部分简写方法
https://blog.csdn.net/weixin_35757704/article/details/90234427#for简写alist = ["123", "456"][print(i) for ylist in alist for i in ylist]#if简写y = 1x = 1 if y > 0 else -1print(x)#for if 简写组合x = [1,2,3,4,5,6,7][print(i) for i in x if i > 3 ]
2021-12-12 12:12:09
707
原创 乱码转正常
//乱码转正常string StringToUtf(string strValue){ int nwLen = MultiByteToWideChar(CP_UTF8, 0, strValue.c_str(), -1, NULL, 0); wchar_t * pwBuf = new wchar_t[nwLen + 1];//加上末尾'\0' memset(pwBuf, 0, nwLen * 2 + 2); MultiByteToWideChar(CP_UTF8, 0, strValue.c_s.
2021-09-15 10:55:14
221
原创 python日志记录
import timeimport loggingimport osclass Writelog(): def __init__(self,fileNode): startname = time.strftime(fileNode + '%Y%m%d%H%M', time.localtime(time.time())) if not os.path.isdir("log"): os.makedirs("log") sel
2021-09-01 11:08:11
1564
1
原创 pd Excel操作
import pandas as pdimport timeprint(“转化开始”)t0 = time.clock()excelname = “PREDICTEDDATA20216-8(1).xls”sheet0 = pd.read_excel(excelname, sheet_name =0)sheet1 = pd.read_excel(excelname, sheet_name =1)SLAB_NO = sheet1[“SLAB_NO”]sheet1IDdic = {}for Sin
2021-08-31 00:52:05
1225
原创 npwhere遍历
not0loc = np.where(img!=0)for idex in range(len(not0loc[0])): locx = not0loc[0][idex] locy = not0loc[1][idex] img[locx, locy] = 255
2021-08-17 10:07:10
253
原创 K均值
import cv2import numpy as npimport matplotlib.pyplot as pltimg = cv2.imread('ZSData\\192.168.1.13_01_20210104142818445.jpg',0)#image read be 'gray'plt.subplot(121),plt.imshow(img,'gray'),plt.title('original')plt.xticks([]),plt.yticks([])#change img
2021-01-09 21:31:58
85
原创 cv2连通域分割
import cv2import osimport randomimport numpy as npdef connectedComponent(img): binary_img = img ret, binary_img = cv2.threshold(binary_img, 127, 255, cv2.THRESH_BINARY) # binary_img = SprayPredeal(img) # binary_img = Predeal(img) #
2021-01-02 18:25:58
767
原创 选择性搜索
# -*- coding: utf-8 -*-import skimage.ioimport skimage.featureimport skimage.colorimport skimage.transformimport skimage.utilimport skimage.segmentationimport numpyimport cv2def _generate_segments(im_orig, scale, sigma, min_size): """
2021-01-01 15:04:05
158
原创 骨骼细化
# -*- coding: utf-8 -*-"""Created on Sat May 12 16:36:06 2018@author: lele"""import cv2# 细化函数,输入需要细化的图片(经过二值化处理的图片)和映射矩阵array# 这个函数将根据算法,运算出中心点的对应值def Thin(image, array): h, w = image.shape iThin = image for i in range(h): fo
2021-01-01 15:03:33
131
原创 分水岭
import numpy as npimport cv2from matplotlib import pyplot as pltdef imshow(imgname,img): h ,w = img.shape[:2] cv2.namedWindow(imgname, cv2.WINDOW_NORMAL) cv2.resizeWindow(imgname, int(w * 0.3), int(h * 0.3)) cv2.imshow(imgname, img)de
2021-01-01 15:02:44
97
原创 滑窗法
# -*- coding: utf-8 -*import cv2def imshow(imgname,img): h ,w = img.shape[:2] cv2.namedWindow(imgname, cv2.WINDOW_NORMAL) cv2.resizeWindow(imgname, int(w * 0.3), int(h * 0.3)) cv2.imshow(imgname, img)def SlidWindow(img,winSize,winStep)
2021-01-01 15:01:41
134
原创 python-opencv 满水填充
import cv2import numpy as npdef imshow(imgname,img): h ,w = img.shape[:2] cv2.namedWindow(imgname, cv2.WINDOW_NORMAL) cv2.resizeWindow(imgname, int(w * 0.5), int(h * 0.5)) cv2.imshow(imgname, img)def fill_color_demo(image): copyIma
2021-01-01 15:00:42
211
原创 python opencv连通域分割后彩色显示
def showConnectedComponents(binary_img): w, h = binary_img.shape color = [] color.append((0, 0, 0)) img_color = np.zeros((w, h, 3), dtype=np.uint8) retval, labels, stats, centroids = cv2.connectedComponentsWithStats(binary_img) for
2021-01-01 14:17:29
1469
1
原创 稠密光流法
import cv2import numpy as npcap = cv2.VideoCapture("F:\\project\\ch12_20200602155217_20200602174954.mp4")ret, frame1 = cap.read()prvs = cv2.cvtColor(frame1,cv2.COLOR_BGR2GRAY)hsv = np.zeros_like(frame1)hsv[...,1] = 255while(1): ret, frame2 = c
2020-12-31 17:28:43
786
原创 共享内存
写入import osimport mmapimport cv2import numpy as npimg = cv2.imread("two\\tt18.jpg",0)img_encode = cv2.imencode('.jpg', img)[1]print(img_encode)data_encode = np.array(img_encode)str_encode = data_encode.tostring()print(type(str_encode))mmap_file
2020-12-31 17:27:19
84
原创 Lucas-Kanade光流
import numpy as npimport cv2# cap = cv2.VideoCapture('vtest.avi')cap = cv2.VideoCapture("F:\\project\\ch12_20200602155217_20200602174954.mp4")# params for ShiTomasi corner detectionfeature_params = dict( maxCorners = 100, qual
2020-12-31 17:24:56
101
原创 数据增强
import osfrom PIL import Imagefrom PIL import ImageEnhanceimport cv2import tensorflow as tfimport numpy as np"""1、对比度:白色画面(最亮时)下的亮度除以黑色画面(最暗时)下的亮度;2、色彩饱和度::彩度除以明度,指色彩的鲜艳程度,也称色彩的纯度;3、色调:向负方向调节会显现红色,正方向调节则增加黄色。适合对肤色对象进行微调;4、锐度:是反映图像平面清晰度和图像边缘锐利程度的.
2020-12-31 17:23:50
152
原创 自适应阈值
import cv2import numpy as npfrom matplotlib import pyplot as plt# img = cv2.imread('20200608\\202006081838126.jpg', 0)img = cv2.imread('20200608\\1mini.jpg', 0)# 中值滤波img = cv2.medianBlur(img, 5)ret, th1 = cv2.threshold(img, 127, 255, cv2.THRESH_BI
2020-12-31 17:22:40
375
原创 CFS连通域分割法
import queueimport cv2from PIL import Imagedef cfs(img): """传入二值化后的图片进行连通域分割""" pixdata = img.load() w,h = img.size visited = set() q = queue.Queue() offset = [(-1,-1),(0,-1),(1,-1),(-1,0),(1,0),(-1,1),(0,1),(1,1)] cuts = []
2020-12-31 17:21:51
818
原创 cv2常用算法
形态学import cv2import numpy as npkernel = np.ones((5,5),np.uint8)erosion = cv2.erode(img,kernel,iterations = 1)#膨胀dilation = cv2.dilate(img,kernel,iterations = 1)#腐蚀显示小窗口图像def showimg(imgname,img): cv2.namedWindow(imgname,0) cv2.imshow(imgnam
2020-12-31 17:21:06
328
原创 python遍历文件夹
多层文件夹import ospath = r"path" # 查找文件的路径for fpathe, dirname, fnames in os.walk(path): for fname in fnames: print(os.path.join(fpathe, fname)) print(fname)单层文件夹import osfilelist = os.listdir(tpath) for file in filelist:
2020-12-31 17:13:39
54
原创 python调用tesseract
1 下载tesseract https://github.com/UB-Mannheim/tesseract/wiki2 pip install pytesseract3 pytesseract.py 改 tesseract_cmd = r’E:\Tesseract-OCR\tesseract.exe’4 添加环境变量TESSDATA_PREFIX = E:\Tesseract-OCR\tessdatapath中 E:\Tesseract-OCR\tessdata E:\Tesseract
2020-12-31 17:08:29
664
转载 python opencv 图像增强算法
python opencv 图像增强算法import cv2import numpy as npimport mathdef LinearTransform(img):#线性变换 out = 2.0 * img # 进行数据截断,大于255的值截断为255 out[out > 255] = 255 # 数据类型转换 out = np.around(out) out = out.astype(np.uint8) return outde
2020-12-31 17:04:47
1010
原创 列表式显示图像
import matplotlib.pyplot as pltfrom PIL import Imageimport cv2img = cv2.imread("bkdData//100012.jpg")image = Image.fromarray(np.uint8(img))# image = Image.open("bkdData//100012.jpg")images = []titles = []for i in range(4): plt.subplot(2, 2, i
2020-12-31 17:04:19
210
1
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人