isl-org / Open3D

Open3D: A Modern Library for 3D Data Processing
http://www.open3d.org
Other
11.46k stars 2.31k forks source link

PPM/PGM file support #43

Closed syncle closed 7 years ago

syncle commented 7 years ago

Looks like the current image IO can handle jpg and png image format. However, some of RGBD dataset (such as NYU dataset) is captured with ppm/pgm format. Do we need to extend OpenCV support for these formats as well?

syncle commented 7 years ago

Looks like libjpeg supports ppm (see line 142 External/libjpeg/jconfig.h)

qianyizh commented 7 years ago

Very good. Yes, we need to support these file formats. However, we have two viable solutions.

  1. If ppm is natively supported by libjpeg, then the solution is simple, just copy FileJPG.h/cpp to FilePPM.h/cpp and edit the interface.

  2. If option 1 is too complicated, we don't need to introduce new libraries for parsing image. py3d supports creating an Image from a numpy array. E.g.

    print("Convet a numpy image to Image and show it with DrawGeomtries().")
    y = mpimg.imread("../TestData/lena_color.jpg")
    print(y.shape)
    yy = Image(y)
    print(yy)
    DrawGeometries([yy])

    So for the NYU data, we don't even need to write a parser for ppm. Just in our python tutorial, we read the image using this method. This is actually the benefit of using Python. Open3D need not to support everything. We just write 3D algorithms in C++, and Python can take care of the auxiliary functionalities.

syncle commented 7 years ago

I agree. I also thought the same thing, and I was working on option 2. Actually it turns out that even mathploblib.image is not friendly toward NYU pgm depth format, and I had to write a python function for this. You will check this issue from new commit.

qianyizh commented 7 years ago

Addressed in #42