Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: image I/O backend for JPEG and PNG types #1004

Merged
merged 12 commits into from
Jan 26, 2022

Conversation

s-trinh
Copy link
Contributor

@s-trinh s-trinh commented Jan 24, 2022

see also #947


Some performance numbers on Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz CPU and Ubuntu 20.04:

  • libjpeg-turbo is actually used, I would also recommend to install libjpeg-turbo instead of classical libjpeg
  • current Simd code contains only optimized code for image writing, see: JPEG/PNG I/O performance ermig1979/Simd#183 (comment)
  • libpng seems to not perform very well, but we are not comparing file size

Figure_1
Figure_2
Figure_3
Figure_4
Figure_5
Figure_6
Figure_7
Figure_8

Copy link
Contributor Author

@s-trinh s-trinh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some self-review comments.

modules/io/include/visp3/io/vpImageIo.h Show resolved Hide resolved
modules/io/include/visp3/io/vpImageIo.h Outdated Show resolved Hide resolved
modules/io/test/perfImageLoadSave.cpp Outdated Show resolved Hide resolved
*/

void vpImageIo::writePFM(const vpImage<float> &I, const std::string &filename)
void vpImageIo::readJPEG(vpImage<unsigned char> &I, const std::string &filename, int backend)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be updated to not throw an exception if the backend is not available but instead print an error and use either stb or simd as they are always available depending on the performance numbers.

Same for PNG.

@fspindle
Copy link
Contributor

@s-trinh I found an issue in readPNG() with simdlib backend on color images

int main()
{
  vpImage<vpRGBa> I;
  vpImageIo::read(I, "/home/fspindle/visp-ws/visp-images/warp/cv_warp_affine_rot_45_color_NN.png", vpImageIo::IO_SIMDLIB_BACKEND);
  vpImageIo::write(I, "I.ppm");
  return 0;
}

I

If I modify

void readSimdlib(vpImage<vpRGBa> &I, const std::string &filename)
{
  size_t stride = 0, width = 0, height = 0;
  SimdPixelFormatType format = SimdPixelFormatRgba32;
  uint8_t* data = SimdImageLoadFromFile(filename.c_str(), &stride, &width, &height, &format);
  std::cout << "width: " << width << " height: " << height << " stride: " << stride << std::endl;
  ...

it prints

width: 558 height: 560 stride: 2240

For me stride = 558*4 = 2232.

It needs to be investigated before merging

…a from Simd to ViSP type to properly take care of memory padding (introduced in the Simd lib to deal with memory alignment for vec instructions).
@fspindle
Copy link
Contributor

@s-trinh Thanks. I will merge this PR even if there remain some potential issues.

There is the testColorConversion.cpp test that seems to segfault sometimes (not always from what I understand) on mingw workflow. I suspect something wrong in BGRToGrey() when image size is 64x4. We can come back later to fix it if confirmed.

The sanitizers show also some issues when -fsanitize=thread is used.

@fspindle fspindle merged commit 4f1a80b into lagadic:master Jan 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants