当前位置: 首页 > news >正文

周口千慧网站建设盘多多百度网盘搜索引擎

周口千慧网站建设,盘多多百度网盘搜索引擎,wordpress做线下交易,建站 报价语义分割的标签(目标处为255,其余处为0) 实例分割的标签(yolo.txt),描述边界的多边形顶点的归一化位置 绘制在原图类似蓝色的边框所示。 废话不多说,直接贴代码; import os import cv2 imp…

语义分割的标签(目标处为255,其余处为0)
在这里插入图片描述
实例分割的标签(yolo.txt),描述边界的多边形顶点的归一化位置
在这里插入图片描述
绘制在原图类似蓝色的边框所示。
在这里插入图片描述

废话不多说,直接贴代码;

import os
import cv2
import numpy as np
import shutildef img2label(imgPath, labelPath, imgbjPath, seletName):# 检查labelPath文件夹是否存在if not os.path.exists(labelPath):os.makedirs(labelPath)if not os.path.exists(imgbjPath):os.makedirs(imgbjPath)imgList = os.listdir(imgPath)for imgName in imgList:# 筛选if imgName.split('_')[0] != seletName and seletName != '':continueprint(imgName)img = cv2.imread(imgPath + imgName, cv2.IMREAD_COLOR)h, w, _ = img.shape# print(h, w)GrayImage=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) #图片灰度化处理ret, binary = cv2.threshold(GrayImage,40,255,cv2.THRESH_BINARY) #图片二值化,灰度值大于40赋值255,反之0# ret, binary = cv2.threshold(binary, 80, 255, cv2.THRESH_BINARY_INV)    # (黑白二值反转)cv2.imwrite(r'denoisedfz.png', binary) #保存图片# 腐蚀# kernel = np.ones((3,3),np.uint8) # binary = cv2.erode(binary,kernel,iterations = 3)thresholdL = h/100 * w/100   #设定阈值thresholdH = h/1 * w/1   #设定阈值#cv2.fingContours寻找图片轮廓信息"""提取二值化后图片中的轮廓信息 ,返回值contours存储的即是图片中的轮廓信息,是一个向量,内每个元素保存了一组由连续的Point点构成的点的集合的向量,每一组Point点集就是一个轮廓,有多少轮廓,向量contours就有多少元素"""contours,hierarch=cv2.findContours(binary,cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_TC89_L1)contoursNorm = []objs= []# print(contours)for i in range(len(contours)):area = cv2.contourArea(contours[i]) #计算轮廓所占面积# print(area)if area > thresholdL and area < thresholdH:obj = ['0']for point in contours[i]:obj.append(str(point[0][0] * 1.0 / w)) # 获取xobj.append(str(point[0][1] * 1.0 / h)) # 获取ycontoursNorm.append(contours[i])objs.append(obj)# print(objs[10])# 查看效果cv2.drawContours(img, contoursNorm, -1,(255,0,0),2)cv2.imwrite(imgbjPath+imgName, img) #保存图片if len(objs) == 0:print('不保存标签,跳过!')continue# 写入txtrealName = imgName.split('-l')[0]f=open(labelPath + realName + '.txt',"w")for obj in objs:f.writelines(' '.join(obj))f.writelines('\n')f.close()# break# oridata 保存着原图像
# maskdata 保存着标签图像
# lab 保存这yolo格式的标签文件
# bj 保存着标记好边界的图像def OrganizeImages(path):imgs = os.listdir(path)for im in imgs:imPath = os.path.join(path, im)if im.split('.')[-1] == 'jpg':# 原图像# 移动到oridatasource_path = imPathdestination_path = 'data\\oridata\\' + imshutil.copy(source_path, destination_path)if im.split('.')[-1] == 'png':# mask label# 移动到maskdatasource_path = imPathdestination_path = 'data\\maskdata\\' + imshutil.copy(source_path, destination_path)if __name__ == '__main__':img2label(imgPath='data\\maskdata\\',  # maskdata 保存着标签图像labelPath='data\\lab\\',     # lab 保存这yolo格式的标签文件imgbjPath = 'data\\bj\\',    # bj 保存着标记好边界的图像seletName='')
http://www.yidumall.com/news/47716.html

相关文章:

  • 免费空间怎么搞网站厦门关键词优化seo
  • 图书馆网站参考咨询建设网站在线制作
  • 广州门户网站网店培训骗局
  • 橱柜网站建设公司天猫seo搜索优化
  • 虚拟机做网站网络工程师
  • 网站策划书的编写腾讯广告代理商加盟
  • 秦皇岛市做网站优化兰州seo公司
  • 做队徽的网站私域流量和裂变营销
  • 番禺做网站的百度竞价排名公式
  • 网站管理人员队伍建设有待加强seo引擎搜索
  • 最好用的crm软件网站优化软件费用
  • 网站建设总计常用的网络营销平台有哪些
  • 银川网站建设实习生湖南专业seo公司
  • 深圳石岩做网站的公司太原网站推广排名
  • 网站开发需求大吗上海网络推广招聘
  • 废旧回收做哪个网站好网络营销的认知
  • 网站搭建实训总结国外网站谷歌seo推广
  • wordpress导出导入数据库seo是什么味
  • 电脑制作网站总么做百度推广的效果
  • 什么软件 做短视频网站上海seo排名
  • 西宁公司网站设计目前主流搜索引擎是哪种
  • dedecms下载站百度收录域名
  • 彩票网站给实体店做代销如何快速网络推广
  • 域名到期如何续费苏州首页排名关键词优化
  • 如何将自己做的网站挂到服务器上百度排名点击软件
  • 网店推广的常用方法有哪些企业网站seo优化公司
  • 自己做网站自己买服务器东莞市网络seo推广企业
  • 营销型网站主页定制郑州做网站公司有哪些
  • 网站建设制作免费咨询开发一个平台需要多少钱
  • 联想公司网站建设现状太原百度快照优化排名