OpenCV Haar Cascade Creation

≯℡__Kan透↙ 提交于 2021-01-07 04:29:28

问题


I want to try create my own .xml file for my graduation project with this reference.

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'

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?


回答1:


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 it:

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())

for it:

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

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

:)




回答2:


Try following this guide. It's more recent.



来源:https://stackoverflow.com/questions/59033016/opencv-haar-cascade-creation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!