Open miaomiaoma0703 opened 3 years ago
Hi, Orientation is just metadata that is used by viewers to rotate the image before the displaying, but the image is encoded as it is. DALI doesn't use metadata to adjust the image after the decoding. If you want to apply the Exif orientation to the actual image I would recommend using imagemagic with -auto-orient option to adjust your image first and then pass it to DALI.
Hi, The fact is that the part of the image decoded with the dali will be rotated (not the same as the one opened with the viewing software), but opencv will not cause the rotation. I suspect it is a bug in the dali library. The dali decoding code as above.
Both viewers and OpenCV apply optional rotation operation based on the Exif metadata - https://github.com/opencv/opencv/blob/master/modules/imgcodecs/src/loadsave.cpp#L912. In the case of DALI, we are not doing such an operation. We will add it to our ToDo list, and we will be more than happy to review and accept any PR introducing such change from the community.
Hi @JanuszL, As you suggested, I will be starting work on this issue. OpenCV has its own parser file here: https://github.com/opencv/opencv/blob/master/modules/imgcodecs/src/exif.hpp I have two questions:
Hi @mohankumarSriram:
image.decoder
that allows the user to decide if apply EXIF metadata to the imagesdali/image
sounds good
The shape of tensor obtained by nvidia.dali reads the image is rotated, because the rotated jpeg file has orientation info, dali considers the rotation head information of the jpeg file, but opencv does not consider it。 code: dali:
opencv:
input = cv2.imread(file_path)
the jpeg file:
the head info: {"size":2534018,"format":"jpeg","width":3000,"height":4000,"colorModel":"ycbcr","orientation":"Right-top"}
obtain by dali and opencv: dali: opencv: