Search code examples
pythonnumpyhdf5point-clouds

convert point cloud .npy file to .h5 in python


I asked similar question before (how to convert .pts or .npy file into .ply or .h5 file?).

But I have more advanced question.

h5format

as shown in above picture, this .h5 file has (N,N,3) shape.

and I have point cloud data as (N,3) shape .npy file format.

The way I convert .npy to .h5 as former question's answer(above link)

The result .h5 shows (N,3) shape.(as below picture)

converted_1

Could you refer to me example codes or help me for converting file format?

Sorry for my poor English skills.


Solution

  • Sorry, I got the solution from many other example codes.

    for i in range(0, len(filenames)):
        if filenames[i] == "":
            continue        
        npydata = np.load("./data/npy/" + filenames[i] + ".npy")
    
        print(npydata.shape)
    
        for j in range(0, 2048):
            a_data[i, j] = [npydata[j][0], npydata[j][1], npydata[j][2]]
    
    data = f.create_dataset("data", data = a_data)
    f.close()
    

    The above code solved my problem.