Skip to content

imread Fails for CV_8UC4 Mat Saved in JpegXL Format Without IMREAD_UNCHANGED Flag #26767

@sturkmen72

Description

@sturkmen72

System Information

OpenCV version: 4.12.0-dev
Operating System: Windows 11
Compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.37.32822/bin/Hostx64/x64/cl.exe (ver 19.37.32822.0)

Detailed description

When a cv::Mat of type CV_8UC4 is saved in JpegXL format, the imread function fails to load the image unless the IMREAD_UNCHANGED flag is used.

Steps to reproduce

int main(int argc, char** argv)
{
    Mat img(240, 320, CV_8UC4);
    randu(img, Scalar(0, 0, 0, 255), Scalar(255, 255, 255, 255));

    string fname = "test.jxl";
    imwrite(fname, img);
    Mat test_img = imread(fname, IMREAD_UNCHANGED);
    Mat test_img2 = imread(fname);
    return 0;
}
[ERROR:0@0.072] global loadsave.cpp:507 cv::imread_ imread_('test.jxl'): can't read data: OpenCV(4.12.0-dev) C:\projects\opencv\modules\imgcodecs\src\loadsave.cpp:501: error: (-2:Unspecified error) in function 'bool __cdecl cv::imread_(const class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &,int,const class cv::_OutputArray &)'
> Internal imread issue:
>     'original_ptr == real_mat.data' must be 'true'

Issue submission checklist

  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
  • I updated to the latest OpenCV version and the issue is still there
  • There is reproducer code and related data files (videos, images, onnx, etc)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions