OpenCV Haar 级联创建 [英] OpenCV Haar Cascade Creation

查看:70
本文介绍了OpenCV Haar 级联创建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想尝试使用这个 参考为我的毕业项目创建我自己的 .xml 文件.

但是我有一个问题,第 6 阶段不起作用.它给出了如下错误:

But I have a problem which stage 6 doesn't work.It gives error such as:

Traceback (most recent call last):
  File "./tools/mergevec.py", line 170, in <module>
    merge_vec_files(vec_directory, output_filename)
  File "./tools/mergevec.py", line 120, in merge_vec_files
    val = struct.unpack('<iihh', content[:12])
TypeError: a bytes-like object is required, not 'str'

我找到了一个解决方案,它说找到 0 个大小的矢量文件并删除它们.但是,我不知道哪些矢量文件的大小为 0 以及如何检测它们.你能帮忙解决这个问题吗?

I have found a solution which says find 0 size vector files and delete them. But, I don't know which vector files are 0 size and how I can detect them. Can you help about this please?

推荐答案

当我改变它时,我能够解决我的问题:

I was able to solve my problem when i changed it:

for f in files:
            with open(f, 'rb') as vecfile:
                content = ''.join(str(line) for line in vecfile.readlines())
                data = content[12:]
                outputfile.write(data)
except Exception as e:
    exception_response(e)

为了它:

for f in files:
            with open(f, 'rb') as vecfile:
                content = b''.join((line) for line in vecfile.readlines())
                outputfile.write(bytearray(content[12:]))
except Exception as e:
    exception_response(e)

就像我改变它之前一样:

and like before i changed it:

content = ''.join(str(line) for line in vecfile.readlines())

为了它:

content = b''.join((line) for line in vecfile.readlines())

因为它正在等待一些 str,现在它能够接收我们需要的二进制档案.

because it was waiting for some str, and now it is able to receive the binary archives that we're in need.

:)

这篇关于OpenCV Haar 级联创建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆