python
竹子熊猫
easy come easy go
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
python cv2利用掩膜将图片透明背景
python cv2 利用掩膜将图片透明背景原创 2022-07-25 19:02:20 · 3637 阅读 · 0 评论 -
meanshift
import numpy as np from sklearn.cluster import MeanShift, estimate_bandwidth def meanShift(features): ''' ''' features = np.array(features).astype(np.float64) '''本质上就是求平均最远k近邻距离, quantile的值表示进行近邻搜索时候的近邻占样本的比例''' bandwidth = estim..原创 2022-01-13 16:00:38 · 607 阅读 · 0 评论 -
抠图-仿射变换-贴图 简易代码段
import cv2 import numpy as np from PIL import Image from PIL import ImageDraw obliq_img = cv2.imread('1.png') #倾斜影像,新的纹理 rows,cols,_ = obliq_img.shape # img_texture = cv2.imread('2.png') #原始纹理 img_texture = Image.open('3.png') print('img_texture.size:.原创 2021-11-15 20:43:25 · 2139 阅读 · 0 评论 -
python 提取骨架
参考: python 简单图像处理(16) 图像的细化(骨架抽取) - xiatwhu - 博客园图像的细化主要是针对二值图而言所谓骨架,可以理解为图像的中轴,,一个长方形的骨架,是它的长方向上的中轴线,圆的骨架是它的圆心,直线的骨架是它自身,孤立点的骨架也是自身。骨架的获取主要有两种方法:(1)https://www.cnblogs.com/xianglan/archive/2011/01/01/1923779.html import cv2 # 输入需要细化的图片(经过二值化处理的图片)和映射矩转载 2021-09-11 15:25:32 · 2950 阅读 · 0 评论 -
detectron2 测试训练好的模型并画出结果图
import numpy as np import cv2 import os from PIL import Image #from matplotlib import pyplot import matplotlib.pyplot as plt import random #from google.colab.patches import cv2_imshow import detectron2 from detectron2.utils.logger import setup_logger set.原创 2021-06-27 18:18:42 · 3477 阅读 · 1 评论 -
python 旋转图像和JSON坐标
# coding:utf-8 import cv2 import os import numpy as np import math import copy import json def rotate_about_center(src, angle, scale=1.): w = src.shape[1] h = src.shape[0] rangle = np.deg2rad(angle) #angle in radians nw = (abs(np.sin(ra.原创 2021-06-11 16:15:57 · 887 阅读 · 7 评论 -
python 最小二乘平面拟合
import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D import math # 从txt文档读取点 def readTxt(textfile): with open(textfile, 'r') as f: x2, y2, z2 = [], [], [] for line in f.readlines(): li.原创 2021-06-11 14:34:44 · 1380 阅读 · 0 评论 -
labelme 镜像扩充数据
# coding:utf-8 import cv2 import os import numpy as np import math import copy import json def enhancement_using_mirror(modes, ImagePath,AnnotationsPath,ImageSavePath,AnnotationsSavePath): #mirror for mode in modes: for imgfile in os.listdir(Image.原创 2021-05-25 20:10:49 · 495 阅读 · 0 评论 -
mmdetection # test and visualize test result
evaluation tools/dist_test.sh configs/swin/cascade_mask_rcnn_swin_base_patch4_window7_mstrain_480-800_giou_4conv1f_adamw_3x_coco.py latest.pth 1 --eval bbox segm save result refer to demo/image_demo.py (1) edit mmdet/apis/inference.py show_result_pyp.原创 2021-04-29 10:56:24 · 990 阅读 · 0 评论 -
mmcv版本过低 Error: ImportError: cannot import name ‘get_git_hash‘
mmcv error from mmcv.utils import get_git_hash ImportError: cannot import name ‘get_git_hash’ UNINSTALL mmcv-full 1.0.4 pip uninstall mmcv-full INSTALL mmcv-full 1.3.1 pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu101/torch1.5.0/ind原创 2021-04-21 20:06:09 · 11809 阅读 · 0 评论 -
labelme数据转coco instance segmentation
转数据参考:https://www.freesion.com/article/1518170289/ 需要安装pycocotools, 参考这里:https://blog.youkuaiyun.com/summermaoz/article/details/115969308?spm=1001.2014.3001.5501 可能需要根据自己的标注情况做一点点修改 labelme2coco.py #!/usr/bin/env python import argparse import collections import原创 2021-04-21 19:09:16 · 656 阅读 · 2 评论 -
windows 10 安装pycocotools 报错error: Microsoft Visual C++ 14.0 or greater is required.
windows, python3.6环境下安装pycocotools, : pip install pycocotools 会报错,和VS有关:“error: Microsoft Visual C++ 14.0 or greater is required.” 解决办法: 1.安装 VS2019 2. 参考这里https://docs.microsoft.com/en-us/answers/questions/136595/error-microsoft-visual-c-140-or-greater-i原创 2021-04-21 18:22:19 · 1519 阅读 · 0 评论 -
JSON2Mask
import json from PIL import Image from PIL import ImageDraw import PIL import os import numpy as np from labelme import utils import imgviz import yaml jsonfolder = './JSON/' out_folder = 'labelme_json' jsonfiles = os.listdir(jsonfolder) for jsonfile i.原创 2021-04-17 18:15:21 · 431 阅读 · 0 评论 -
Python SGBM
cv2.StereoSGBM_create([,minDisparity [,numDisparities [,blockSize [,P1 [,P2 [,disp12MaxDiff [,preFilterCap [,uniquenessRatio [,speckleWindowSize [,speckleRange [,mode]]]]]]]]]]]]) minDisparity 最小可能的差异值。通常情况下,它是零,但有时整流算法可能会改变图像,所以这个参数需要作相应的调整。 numDisp原创 2020-11-25 20:56:58 · 2581 阅读 · 0 评论 -
密集匹配SGM python
记录一下 代码参考:https://github.com/bkj/sgm 理论部分参考: https://www.cnblogs.com/wxxuan/p/13595014.html https://zhuanlan.zhihu.com/p/49272032 https://zhuanlan.zhihu.com/p/159055657 """ python implementation of the semi-global matching algorithm from Stereo Proc转载 2020-11-22 15:50:53 · 2068 阅读 · 2 评论 -
点云拟合平面-最小二乘法
参考:https://blog.youkuaiyun.com/qq_45427038/article/details/100139330 import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D import math # 从txt文档读取点 def readTxt(textfile): with open(textfile, 'r') as f: x2, y2, z原创 2020-11-18 17:23:33 · 3827 阅读 · 0 评论 -
Draw Feature map
import cv2 import time import os import matplotlib.pyplot as plt import torch from torch import nn import torchvision.models as models import torchvision.transforms as transforms import numpy as np savepath='./features_map' if not os.path.exists(savepath.原创 2020-11-06 09:28:57 · 460 阅读 · 1 评论 -
Python plot point cloud and max bounding box of point cloud.
# 点云显示 # 外接包围盒显示 import os from matplotlib import pyplot as plt from mpl_toolkits.mplot3d import Axes3D def displayPoint(data): #解决中文显示问题 # plt.rcParams['font.sans-serif']=['SimHei'] # plt.rcParams['axes.unicode_minus'] = False #散点图参数设置 fig=plt..原创 2020-10-05 21:13:56 · 606 阅读 · 1 评论 -
file format conversion: pcd2txt, txt2pcd
file format conversion, including pcd2txt, txt2pcd # file format conversion import math import os import pcl def txt2pcd(filename): xlist = [] ylist = [] zlist = [] with open(filename, 'r') as file_to_read: while True:原创 2020-10-04 21:27:14 · 351 阅读 · 0 评论 -
python cv2 LSD 修改参数
这个LSDhttps://github.com/primetang/pylsd是封装好的,不知道哪儿改参数,原始的LSD检测前会将图片缩小至80%,当图片很小是,之后检测的线会减少。 可以直接用opencv-python里面的createLineSegmentDetector()函数,用help查看用法,再根据需要修改参数。我这边选择检测前不缩放,那么_scale=1 LSD代码: im...原创 2020-01-03 22:21:40 · 6553 阅读 · 3 评论 -
Retina-net 实践 Keras版本
Tensorflow版本需要1.14.0及以上。之前用的是1.13.1,后面重装了1.14.0 1. github:https://github.com/fizyr/keras-retinanet git clonehttps://github.com/fizyr/keras-retinanet.git 2. follow README --> 编译环境 ①pip install ...原创 2019-12-16 17:49:39 · 370 阅读 · 0 评论 -
Cascade-Rcnn实践 Tensorflow版本
Cascade Github: ①Caffe版:https://github.com/zhaoweicai/cascade-rcnn ②Pytorch版:https://github.com/guoruoqian/cascade-rcnn_Pytorch ③Tensorflow版:https://github.com/DetectionTeamUCAS/Cascade-RCNN_Tenso...原创 2019-12-11 16:17:07 · 1349 阅读 · 0 评论 -
三角化求三维坐标 python
1. 利用2张影像上的匹配点确定特征点在三维模型中的位置 ORB-SLAM里面用的Triangulate函数可以求解(C++代码) void Initializer::Triangulate(const cv::KeyPoint &kp1, const cv::KeyPoint &kp2, const cv::Mat &P1, const cv::Mat &...原创 2019-11-30 14:37:06 · 2847 阅读 · 5 评论 -
D-linknet训练自己的数据
1. 数据准备 一直想用acrgis画标签,但是安装的arcgis有问题,就用了labelme做标签 D-linknet是做二分类,道路和其他。https://github.com/zlkanata/DeepGlobe-Road-Extraction-Challenge\ 用的是python2, pytroch image和label一起放在dataset文件夹下的trainl里面。...原创 2019-11-08 14:00:56 · 3121 阅读 · 8 评论 -
Ubuntu安装anaconda3+anaconda2
参考: 安装anaconda2+tensorflow:https://blog.youkuaiyun.com/wyz6666/article/details/78440272 在安装anaconda2之后安装anaconda3:https://blog.youkuaiyun.com/u014044032/article/details/82223932 我先装的anaconda3-->再安装的an...原创 2019-10-29 22:16:15 · 450 阅读 · 0 评论 -
Mask-rcnn训练自己的数据实践
Mask-rcnn训练自己的数据实践,这里只做了一类。 主要步骤: 1. 数据准备 (1)做标签:这里用的labelme,一张图片对应一个.json文件。数据大小1024×1024。 (2)转数据格式:在./labelme/cli/路径下找到 json_to_dataset.py,这里需要小改动一下,实现批量转格式。将步骤(1)中的.json转成训练需要的数据,一张图片对应5个文件,具体如...原创 2019-10-13 19:59:28 · 1794 阅读 · 3 评论 -
python PIL crop image
for img in os.listdir(imgfolder): imgname, Suff = os.path.splitext(img) im = Image.open(imgfolder + img) im_size = im.size width, height = im_size[0], im_size[1] xnum = int(width/cropsize)...原创 2019-09-23 17:24:16 · 1104 阅读 · 0 评论 -
Jupyter Note使用
依赖python环境 1. 安装jupyter note cmd --> pip install jupytrelab 2. 运行 cmd --> Jupyter notebook 3. 浏览器会弹出,找到文件就可查看了(.ipynb)会更美观 ...原创 2019-09-23 15:25:52 · 485 阅读 · 0 评论 -
pyinstaller pyqt5 打包
参考: https://blog.youkuaiyun.com/j_starry/article/details/82261807 https://www.jianshu.com/p/c451db99adca 一个小程序包括3个python文件,1个db文件。主窗口是login.py。help,hello是自建模块。用的python3.6,pyqt5.13.0 最后用的这个 pyinstaller...原创 2019-08-27 17:51:14 · 330 阅读 · 0 评论 -
python对PASCAL VOC标注数据进行统计
用于统计训练数据中的类别,以及所有目标的个数:# coding:utf-8 import xml.etree.cElementTree as ET import os from collections import Counter import shutil # Counter({'towCounter({'tower': 3074, 'windpower': 2014, 'thermalpow...原创 2018-04-04 11:32:36 · 1274 阅读 · 0 评论 -
python数据扩充:gamma+重采样+旋转+镜像
训练的时候因为数据出现问题,把做数据扩充的重新整理了一下,应该一步步检查的。1、gamma变换调节图像对比度""" ================================= Gamma and log contrast adjustment ================================= This example adjusts image contrast by p...原创 2018-04-03 13:33:21 · 2123 阅读 · 0 评论 -
Python, opencv, cv2
将代码放在师姐电脑上跑的时候,用的是python2.7 出现c2.cv,没有cv这个属性,在命令行import cv 时出错,没有cv这个module,但是可以import cv2,解决方式是下载安装opencv。 两个下载模块的地址: https://pypi.python.org/pypi 介绍cv: http://www.programcreek.com/python/index/4原创 2017-03-28 21:03:30 · 18972 阅读 · 2 评论 -
python + PIL转图片格式
1、用PIL将png转为jpg时出错: raise IOError("cannot write mode %s as JPEG" % im.mode) IOError: cannot write mode P as JPEG from PIL import Image img = Image.open("1.png") 加一句:img = img.convert('RGB')原创 2017-02-21 16:34:23 · 8075 阅读 · 3 评论 -
Python 装饰器decorater
参看:http://www.liaoxuefeng.com/wiki/001374738125095c955c1e6d8bb493182103fac9270762a000/001386819879946007bbf6ad052463ab18034f0254bf355000 功能: ①接受一个函数func作为参数,再返回一个函数wapper 例如: def log(func):转载 2017-02-25 16:20:33 · 1156 阅读 · 0 评论 -
python内置数据类型:list,tuple,dict比较
(一)List,可以变,因此可以append,insert list = [1,2,3,4,5],list中可以有list:[1,2,[1,6],4,5],取list[2][1]=6,相当于二维数组 访问列表,索引从0开始:list[0]=1, list[-1]=5(-1倒数第一个),list[2:3] =[3,4], list[1:] =[2,3,4,5]从第二个开始所有的元素。 更新:l转载 2017-03-02 22:05:03 · 466 阅读 · 0 评论 -
python/ pyqt5 QTreeview 递归获得全目录
getItemPath获得点击处item到根目录的itemname def getItemPath(self): ItemList = [] index = self.treeview.selectionModel().currentIndex() Item = index.data() ParentItem = index.parent().data() ItemList.原创 2017-03-21 17:13:37 · 6678 阅读 · 0 评论 -
pqyt5,Treeview在remove最后一行出错
pqyt5,Treeview在remove最后一行出错 model = self.treeview.model()index = self.treeview.selectionModel().currentIndex() if not index.isValid(): return # #adjust selection so refresh does not trigger Index原创 2017-03-21 17:16:30 · 567 阅读 · 0 评论 -
pyqt5 QMessageBox小结
pyqt5 QMessageBox小结 前面4个都有用到 1、Replay box: reply = QMessageBox.question(self, 'Message',"Are you sure to quit?",QMessageBox.Yes,QMessageBox.No) if reply == QMessageBox.Yes: event.accept()原创 2017-03-22 19:25:51 · 6937 阅读 · 0 评论 -
Python 中文编码问题
前台:通过下拉框获取检索内容 用下拉框ComboBox获取文字,原本是英文,直接 ComboBox.currentText()就可以了,后来把下拉框内容改成了中文,就出错了 'ascii' codec can't encode characters in position 解决方法: import codes scene = (Combo原创 2017-04-08 14:36:25 · 720 阅读 · 0 评论 -
python sqlite3,读取视频信息并存入数据库
要操作关系数据库,首先需要连接到数据库,建立connection。 其次打开游标cursor,通过cursor执行SQL语句。 导入sqlite驱动: import sqlite3 1、refresh sqlite3: def RefreshDB(self, path): #delete the table created before and then create原创 2017-03-23 20:02:51 · 2643 阅读 · 0 评论
分享