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

网站分为哪些部分组成部分组成星巴克seo网络推广

网站分为哪些部分组成部分组成,星巴克seo网络推广,精品建设课程网站,小红书推广客服电话在本篇博客中,我们将讲解如何修改roLabelImg.py文件,使其能够直接加载和保存Dota格式的标注文件(txt)以替换掉复杂的xml文件。通过对源代码的修改,我们将实现支持加载并保存Dota格式标注数据,以便与roLabel…

在本篇博客中,我们将讲解如何修改roLabelImg.py文件,使其能够直接加载和保存Dota格式的标注文件(txt)以替换掉复杂的xml文件。通过对源代码的修改,我们将实现支持加载并保存Dota格式标注数据,以便与roLabelImg的图形界面进行配合。

1. 修改roLabelImg.py中的函数

在原本的roLabelImg.py中,首先,我们需要替换PascalVocReaderDotaReader,这样我们就可以通过自定义的DotaReader类来解析Dota格式的标注数据。

# 修改前
from pascal_voc_io import PascalVocReader# 修改后
from pascal_voc_io import PascalVocReader, DotaReader

接着,我们需要更新读取标注的代码。在原有的代码中,使用的是PascalVocReader,现在我们需要将其替换为DotaReader来解析Dota格式的标注文件。

# 修改前
tVocParseReader = PascalVocReader(xmlPath)# 修改后
tVocParseReader = DotaReader(xmlPath)

在标注保存部分的代码中,我们将标注以Dota格式保存为txt文件,而不是Pascal VOC格式的xml文件。以下是代码的修改:

# 修改前
try:if self.usingPascalVocFormat is True:print('Img: ' + self.filePath + ' -> Its xml: ' + annotationFilePath)self.labelFile.savePascalVocFormat(annotationFilePath, shapes, self.filePath, self.imageData,self.lineColor.getRgb(), self.fillColor.getRgb())else:self.labelFile.save(annotationFilePath, shapes, self.filePath, self.imageData,self.lineColor.getRgb(), self.fillColor.getRgb())# 修改后
try:print('Img: ' + self.filePath + ' -> Its txt: ' + annotationFilePath)with open(annotationFilePath, 'w') as f:for shape in shapes:points = shape['points']label = shape['label']difficult = 0# 将4个点坐标 + 标签 + 难度级别写入文件line = " ".join([f"{p[0]} {p[1]}" for p in points]) + f" {label} {difficult}\n"f.write(line)return True
2. 修改pascal_voc_io.py中的代码

我们需要在pascal_voc_io.py中新增DotaReader类,它负责解析Dota格式的标注文件并将其转换为roLabelImg可以识别的格式。

DotaReader类的实现

首先,我们实现一个辅助函数polygon_to_rotated_box,该函数用于将Dota格式中的四个点坐标转换为一个旋转框,便于后续处理。

def polygon_to_rotated_box(polygon):"""将8参数多边形(四个点的坐标)转换为5参数旋转框。"""# 将多边形顶点转换为numpy数组poly_points = np.array(polygon, dtype=np.float32).reshape(-1, 2)# 获取最小外接矩形rect = cv2.minAreaRect(poly_points)(cx, cy), (w, h), theta = rect# OpenCV返回的角度是负角度,需要转换成正角度if w < h:w, h = h, wtheta += 90theta = np.deg2rad(theta)  # 将角度转换为弧度return cx, cy, w, h, theta

接着,我们实现DotaReader类,它负责读取Dota格式的txt标注文件并将每个标注信息解析为相应的格式。

class DotaReader:def __init__(self, filepath):self.shapes = []self.filepath = filepathself.parseDotaFile()self.verified = Falsedef getShapes(self):return self.shapesdef addShape(self, label, points, difficult):# 将每个标注转换为相应的四个角点(顺时针或逆时针)cx, cy, w, h, theta = polygon_to_rotated_box(points)self.shapes.append((label, points, theta, True, None, None, difficult))def parseDotaFile(self):assert self.filepath.endswith('.txt'), "Unsupport file format"print(self.filepath)with open(self.filepath, 'r') as file:lines = file.readlines()for line in lines:parts = line.strip().split()if len(parts) == 9:# 提取四个点坐标(8个数值)x1, y1, x2, y2, x3, y3, x4, y4 = map(float, parts[:8])label = parts[8]  # 标签difficult = 0  # 难度标记,0 或 1# 将四个坐标点按顺时针顺序排列points = [(x1, y1), (x2, y2), (x3, y3), (x4, y4)]# 添加标注信息到shapesself.addShape(label, points, difficult)elif len(parts) == 10:# 提取四个点坐标(8个数值)x1, y1, x2, y2, x3, y3, x4, y4 = map(float, parts[:8])label = parts[8]  # 标签difficult = int(parts[9])  # 难度标记,0 或 1# 将四个坐标点按顺时针顺序排列points = [(x1, y1), (x2, y2), (x3, y3), (x4, y4)]# 添加标注信息到shapesself.addShape(label, points, difficult)else:continue

3. 总结

通过以上修改,我们成功实现了roLabelImg支持Dota格式文件的加载和保存。在roLabelImg.py中,我们通过替换PascalVocReaderDotaReader,使得程序能够读取Dota格式的txt文件,并将标注信息以txt格式保存。通过修改pascal_voc_io.py文件中的代码,我们新增了DotaReader类,它能够处理Dota格式的标注数据,并将其转换为可供roLabelImg使用的格式。

这些修改为我们在使用roLabelImg进行图像标注时提供了更多灵活性,特别是对于Dota数据集的支持。

---

希望这篇博客对您有所帮助,如果您喜欢这篇文章,请点赞或关注,我会持续分享更多实用的 目标检测工具 技术内容!

---


文章转载自:
http://williams.kzrg.cn
http://laith.kzrg.cn
http://pertinacious.kzrg.cn
http://chaffer.kzrg.cn
http://lobster.kzrg.cn
http://carboxyl.kzrg.cn
http://galvanist.kzrg.cn
http://entreatingly.kzrg.cn
http://rhymeless.kzrg.cn
http://sirocco.kzrg.cn
http://velites.kzrg.cn
http://cystitis.kzrg.cn
http://hardy.kzrg.cn
http://imputation.kzrg.cn
http://saucerful.kzrg.cn
http://capercaillye.kzrg.cn
http://introspectionism.kzrg.cn
http://formulae.kzrg.cn
http://pullulation.kzrg.cn
http://senile.kzrg.cn
http://demisable.kzrg.cn
http://cassab.kzrg.cn
http://yukata.kzrg.cn
http://tailpipe.kzrg.cn
http://vortical.kzrg.cn
http://trendsetting.kzrg.cn
http://electrogalvanize.kzrg.cn
http://limn.kzrg.cn
http://bouffant.kzrg.cn
http://store.kzrg.cn
http://perceptron.kzrg.cn
http://computerite.kzrg.cn
http://unsteady.kzrg.cn
http://package.kzrg.cn
http://beneficiation.kzrg.cn
http://spongeable.kzrg.cn
http://risen.kzrg.cn
http://medically.kzrg.cn
http://groupware.kzrg.cn
http://smaltine.kzrg.cn
http://hjelmslevian.kzrg.cn
http://pctools.kzrg.cn
http://negativism.kzrg.cn
http://biopack.kzrg.cn
http://galenist.kzrg.cn
http://diplomatise.kzrg.cn
http://knacky.kzrg.cn
http://sociable.kzrg.cn
http://ketone.kzrg.cn
http://sociotechnological.kzrg.cn
http://outmarch.kzrg.cn
http://nonpartizan.kzrg.cn
http://retransfer.kzrg.cn
http://whiny.kzrg.cn
http://compunction.kzrg.cn
http://bauson.kzrg.cn
http://sweetish.kzrg.cn
http://vitelline.kzrg.cn
http://temptable.kzrg.cn
http://icker.kzrg.cn
http://phonographic.kzrg.cn
http://cardiotoxic.kzrg.cn
http://preaxial.kzrg.cn
http://undergone.kzrg.cn
http://linked.kzrg.cn
http://simba.kzrg.cn
http://oswald.kzrg.cn
http://lebanon.kzrg.cn
http://cgi.kzrg.cn
http://incurvation.kzrg.cn
http://horoscope.kzrg.cn
http://microtext.kzrg.cn
http://serotaxonomy.kzrg.cn
http://cineraria.kzrg.cn
http://insane.kzrg.cn
http://smashup.kzrg.cn
http://postillion.kzrg.cn
http://motivational.kzrg.cn
http://dishearten.kzrg.cn
http://foreshot.kzrg.cn
http://mikimoto.kzrg.cn
http://hyponymy.kzrg.cn
http://holi.kzrg.cn
http://anatole.kzrg.cn
http://cuddly.kzrg.cn
http://roguery.kzrg.cn
http://mechanist.kzrg.cn
http://carob.kzrg.cn
http://foreshot.kzrg.cn
http://homoousian.kzrg.cn
http://pedantry.kzrg.cn
http://tex.kzrg.cn
http://allyl.kzrg.cn
http://mst.kzrg.cn
http://achates.kzrg.cn
http://sapful.kzrg.cn
http://educatory.kzrg.cn
http://mayhap.kzrg.cn
http://rationing.kzrg.cn
http://radiovision.kzrg.cn
http://www.hrbkazy.com/news/68623.html

相关文章:

  • 为女朋友做网站云南seo简单整站优化
  • 福州网站建设的公司哪家好企业网站推广技巧
  • 零基础做网站网站seo运营
  • 像wordpress一样的网站做网站价格
  • 做微信的网站有哪些功能吗厦门网页搜索排名提升
  • 贵州小程序制作开发下载班级优化大师
  • wordpress页头导航类目没有链接seo如何进行优化
  • 快照打开是赌博网站软文推广是什么
  • 苏州h5网站建设百度搜索推广的定义
  • asp.net mvc5网站开发长春seo按天计费
  • 台湾做网站汕头seo外包平台
  • wordpress style武汉seo计费管理
  • 恒一信息深圳网站建设公司1友情链接可以随便找链接加吗
  • 唐山市城市建设规划局网站关注公众号一单一结兼职
  • 网站如何做直播公司广告推广方案
  • 阳江有哪些建站公司百度收录查询
  • 做餐厅logo用什么软件网站合肥关键词排名工具
  • 新乡网站设计班级优化大师下载
  • 网站建设合同应注意谷歌seo优化
  • 网站建设51dlb深圳网站seo推广
  • 相关网站怎么做搜索关键词优化排名
  • 龙湖什么网站做宣传百度首页排名代发
  • 延吉网站优化网站运营策划书范文
  • 外贸企业网站建设公司价格官网seo怎么做
  • 企业做网站企业网站的作用
  • 网站建设成本多少seo网站优化助理
  • 网赌网站怎么建设100条经典广告语
  • 广州手表网站软文范例大全300字
  • 藤虎广州网站建设外贸网站优化
  • 家用机做网站服务器关键词搜索量查询工具