import os
import numpy
import cv2 bad_label_file = open("bad_valid.list",'r') names = []
for line in open('data/coco.names','r'):
names.append(line.strip('\n'))
classes = len(names) colors = []
for i in range(80):
#color = [random.uniform(0, 255),random.uniform(0, 255),random.uniform(0, 255)]
color = [(i)*255/classes,(classes-i)*255/classes,(classes+i)*128/classes]
colors.append(color) lines = []
for line in bad_label_file:
lines.append(line) mount = len(lines) oper=0
i=0 #for i in range(mount):
while(i<mount):
i+=oper words = lines[i].split(':')
imagepath = words[0]
#print('reading "{}: No. {}"'.format(path,indexes))
print('{}\\{}'.format(mount,i)) src = cv2.imread(imagepath)
#cv2.imshow("src",src)
h,w = src.shape[:2] labelpath = imagepath.split('-')[0]+'-labels/'+os.path.basename(imagepath).split('.')[0]+'.txt'
try:
labelfile = open(labelpath,'r')
labels = []
for line in labelfile:
#print('get label {}'.format(line))
labels.append(line) for label in labels:
ti,tx,ty,tw,th = map(float,label.split(' ')[:5])
#print('get label {} {} {} {} {}'.format(ti,tx,ty,tw,th))
x0=w*(tx-tw/2)
y0=h*(ty-th/2)
x1=w*(tx+tw/2)
y1=h*(ty+th/2)
w0=w*tw
h0=h*th
ti,x0,y0,x1,y1,w0,h0 = map(int,[ti,x0,y0,x1,y1,w0,h0])
#print('<({},{}),({},{})>,'.format(x0,y0,x1,y1))
cv2.rectangle(src,(x0,y0),(x1,y1),colors[ti],2)
y0+=15
#cv2.putText(src,str(ti)+' '+names[ti],(x0+1,y0+1),cv2.FONT_HERSHEY_COMPLEX,0.5,colors[ti][::-1],1)
#cv2.putText(src,str(ti)+' '+names[ti],(x0-1,y0-1),cv2.FONT_HERSHEY_COMPLEX,0.5,colors[ti][::-1],1)
cv2.putText(src,str(ti)+' '+names[ti],(x0,y0),cv2.FONT_HERSHEY_COMPLEX,0.5,colors[ti],1)
except :
print('guess what? ERROR!(show_bad_valid.py::67)') words = words[1].strip('\n')
probs = words.split(' ')[2:]
#print(words)
#print(probs)
if len(probs) > 0:
for prob in probs:
values = prob.strip('<').strip('>').split(',')
print(values)
ti,tx,ty,tw,th = map(float,values[2:])
x0=w*(tx-tw/2)
y0=h*(ty-th/2)
x1=w*(tx+tw/2)
y1=h*(ty+th/2)
ti,x0,y0,x1,y1 = map(int,[ti,x0,y0,x1,y1])
y1-=10
cv2.rectangle(src,(x0,y0),(x1,y1),colors[ti][::-1],1)
cv2.putText(src,str(ti)+' '+names[ti],(x0,y1),cv2.FONT_HERSHEY_COMPLEX,0.5,colors[ti],1) cv2.imshow("image",src) key = cv2.waitKey(0)
'''
A 65
a 97
D 68
d 100
S 83
s 115
'''
if key == 97:
if i>0:
oper=-1
elif key == 100:
if i<len(lines):
oper=1
elif key == 115:
oper=0
cv2.imwrite('workingspace.jpg',src)
else:
break
bad_label_file.close()

[darknet]查看错误结果 sight of wrong的更多相关文章

  1. 启动mysql错误解决方案,学会查看错误日志:mysql.sock丢失,mysqld_safe启动报错

    本人还是个菜鸟,下面是我的经验之谈,能解决一些问题,有不对的地方,敬请斧正. 我的是CentOS6.3+MySQL5.1.57. 重启了一次服务器后,使用> mysql -u root -p登陆 ...

  2. IE调试网页之三:使用 F12 工具控制台查看错误和状态 (Windows)

    IE调试网页之三:使用 F12 工具控制台查看错误和状态 (Windows)  等 请见博客园的  我的收藏

  3. mysql工具——perror(mysql错误代码,查看错误号释义)

    mysql工具——perror(mysql查看错误代码,查看错误号释义) 关键词:mysql错误代码,mysql错误号,perror

  4. Dos窗口一闪而过,如何查看错误?

    问:Dos窗口一闪而过,如何查看错误? 答:在执行程序最后追加pause或者read(,),即可查看错误信息.

  5. wampserver 运行橙色,80端口没有被占用,查看错误日志方法

    wampserver运行时橙色,经检查80端口并没有被占用,试了很多种方法都无效,去查看错误日志吧 1.以管理员身份打开CMD 注意这里必须是管理员身份的CMD ,powershell不行的 进入wa ...

  6. sae上屏蔽错误显示并查看错误日志

    首先应用上线之前肯定要屏蔽错误显示的, 登录sae,点进去你的应用, 关闭之后进入日志管理当前的当前版本 在http中可以查看各个级别的日志记录了

  7. JMeter采用NON GUI模式时如何记录并查看错误

    在GUI模式下执行JMeter测试时,我们可以通过添加View Results Tree组件来查看JMeter请求的各类详情.那如果在正式测试场景中,当我们采用NON GUI模式时,遇到了断言或其他错 ...

  8. 在linux中怎么查看错误日志

    cat或者tail -f命令 日 志 文 件 说 明 /var/log/message 系统启动后的信息和错误日志,是Red Hat Linux中最常用的日志之一/var/log/secure 与安全 ...

  9. 查看错误日志发现有两个警告(ignored in --skip-name-resolve mode)

    2016-08-02 17:30:26 17374 [Warning] 'user' entry '@losnau-223.com' ignored in --skip-name-resolve mo ...

随机推荐

  1. Android创建列表并为列表添加数据

    在Android开发中经常会用到ListView,也就是列表,而列表的内容需要如何决定呢,很好的方法是使用各种adapter 首先来看看用entries添加列表内容 在布局文件中,创建一个ListVi ...

  2. wrapper induction随笔

    本文是一篇介绍Wrapper Induction的阅读笔记,原文详见<Wrapper induction:Efficiency and expressiveness>. Wrapper I ...

  3. css实现礼券效果

    <template> <div class="demo"> <div class="stamp stamp01"> < ...

  4. python迭代-如何在一个for语句中迭代多个可迭代对象

    如何在一个for语句中迭代多个可迭代对象 问题举例 (1)某班学生期末考试成绩,语文,数学,英语分别存储在3个列表中,同时迭代三个列表,计算每个学生的总分 (2)某年级有4个班,某次考试每班英语成绩分 ...

  5. DDD领域驱动

    DDD领域驱动领域驱动模型.模型驱动代码接触到需求第一步就是考虑领域模型,而不是将其切割成数据和行为,然后数据用数据库实现,行为使用服务实现,最后造成需求的首肢分离.DDD让你首先考虑的是业务语言而不 ...

  6. MongoDB下,启动服务时,出现“服务没有响应控制功能”解决方法

    摘要:https://www.cnblogs.com/luoguixin/p/6291408.html 欢迎转载,若需转载请标明出处:https://www.cnblogs.com/luoguixin ...

  7. java生成条形码工具类

    package com.runtime.extend.utils.CodeCreate;import java.awt.Color;import java.awt.Font;import java.a ...

  8. Error:java: Annotation processing is not supported for module cycles. Please ensure that all modules from cycle [web_dao,web_service] are excluded from annotation processing

    早上学习maven环境搭建时遇到的这个问题 下面这个错误的大概意思是:模块之间的互相依赖 Error:java: Annotation processing is not supported for ...

  9. 【论文速读】Yuliang Liu_2017_Detecting Curve Text in the Wild_New Dataset and New Solution

    Yuliang Liu_2017_Detecting Curve Text in the Wild_New Dataset and New Solution 作者和代码 caffe版代码 关键词 文字 ...

  10. DotNetty网络通信框架学习之源码分析

    DotNetty网络通信框架学习之源码分析 有关DotNetty框架,网上的详细资料不是很多,有不多的几个博友做了简单的介绍,也没有做深入的探究,我也根据源码中提供的demo做一下记录,方便后期查阅. ...