dimatura / pypcd

PCL pcd fileformat i/o in Python
Other
266 stars 196 forks source link

TypeError: startswith first arg must be bytes or a tuple of bytes, not str #28

Closed hynchl closed 4 years ago

hynchl commented 4 years ago

I'm using python3.7.3 and change cStringIO to 'StringIO'. In my code, I used pypcd.PointCloud.from_path(image_path + str(cnt) +".pcd") and error that show 'TypeError: startswith first arg must be bytes or a tuple of bytes, not str' ocurred in if ln.startswith('DATA'):(282, pypcd.py). I guess that this happened because ln is already binary but I don't know how to start to fix it. please, help me...

PiseyYou commented 4 years ago

same error happen in python3.5

deetungsten commented 4 years ago

If you checked through the PR logs, there is a merge request for a forked branch from klintan (https://github.com/klintan/pypcd). Thanks to his/her hardwork, that fork works much better than the current release of pypcd for Python 3. You can install it with pip using pip3 install --upgrade git+https://github.com/klintan/pypcd.git

AlexSeongJu-sr commented 3 years ago

for those who couldn't resolve, refer to this

def point_cloud_from_fileobj(f):
    """ Parse pointcloud coming from file object f
    """
    header = []
    while True:
        ln = f.readline().strip()
        header.append(ln)
        pdb.set_trace()
        if ln.startswith(b'DATA'):
            metadata = parse_header(header)
            dtype = _build_dtype(metadata)
            break

I changed 'DATA' to b'DATA' inside pypcd.py