More work refactoring means I think I can say that the Mat multiplication code I have is causing the issue (or the code that generates the input Wiener filter - which I still cannot visualise). I am banging my head against a wall though I feel, as no amount of switching Mat creation methods or chaining together (or not) intermediate objects seems to be helping me get closer to resolving.
I have since done a build of opencv 4.5.1 in order to see if the sample "example_tutorial_out_of_focus_deblur_filter " code works, but it is giving me either a core dump with a png file, or an “ERROR : Image cannot be loaded…!!” with jpg files.
i.e.
./example_tutorial_out_of_focus_deblur_filter -image=./eve.jpg
2018-07-12
DeBlur_v8
You will learn how to recover an out-of-focus image by Wiener filter
ERROR : Image cannot be loaded…!!
or
./example_tutorial_out_of_focus_deblur_filter -image=./lena.png
2018-07-12
DeBlur_v8
You will learn how to recover an out-of-focus image by Wiener filter
Segmentation fault (core dumped)
valgrind on the lena.png call shows the following:
==52144== Use of uninitialised value of size 8
==52144== at 0x77E6126: jpeg_CreateCompress (in /usr/lib/libjpeg.so.8.2.2)
==52144== by 0x486D859: cv::JpegEncoder::write(cv::Mat const&, std::vector<int, std::allocator > const&) (in /home/name/git/opencv_4.5.0_pre/build/lib/libopencv_imgcode
cs.so.4.5.1)
==52144== by 0x486310F: cv::imwrite(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, cv::_InputArray const&, std::vector<int, std::allo
cator > const&) (in /home/name/git/opencv_4.5.0_pre/build/lib/libopencv_imgcodecs.so.4.5.1)
==52144== by 0x10AA72: main (in /home/name/git/opencv_4.5.0_pre/build/bin/example_tutorial_out_of_focus_deblur_filter)
==52144==
==52144== Invalid write of size 4
==52144== at 0x77E6126: jpeg_CreateCompress (in /usr/lib/libjpeg.so.8.2.2)
==52144== by 0x486D859: cv::JpegEncoder::write(cv::Mat const&, std::vector<int, std::allocator > const&) (in /home/name/git/opencv_4.5.0_pre/build/lib/libopencv_imgcode
cs.so.4.5.1)
==52144== by 0x486310F: cv::imwrite(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, cv::_InputArray const&, std::vector<int, std::allo
cator > const&) (in /home/name/git/opencv_4.5.0_pre/build/lib/libopencv_imgcodecs.so.4.5.1)
==52144== by 0x10AA72: main (in /home/name/git/opencv_4.5.0_pre/build/bin/example_tutorial_out_of_focus_deblur_filter)
==52144== Address 0x679 is not stack’d, malloc’d or (recently) free’d
==52144==
==52144==
==52144== Process terminating with default action of signal 11 (SIGSEGV): dumping core
==52144== Access not within mapped region at address 0x679
==52144== at 0x77E6126: jpeg_CreateCompress (in /usr/lib/libjpeg.so.8.2.2)
==52144== by 0x486D859: cv::JpegEncoder::write(cv::Mat const&, std::vector<int, std::allocator > const&) (in /home/name/git/opencv_4.5.0_pre/build/lib/libopencv_imgcode
cs.so.4.5.1)
==52144== by 0x486310F: cv::imwrite(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, cv::_InputArray const&, std::vector<int, std::allo
cator > const&) (in /home/name/git/opencv_4.5.0_pre/build/lib/libopencv_imgcodecs.so.4.5.1)
==52144== by 0x10AA72: main (in /home/name/git/opencv_4.5.0_pre/build/bin/example_tutorial_out_of_focus_deblur_filter)
The image files are:
file ./eve.jpg
./eve.jpg: JPEG image data, JFIF standard 1.01, resolution (DPI), density 300x300, segment length 16, Exif Standard: [TIFF image data, little-endian, direntries=13, manufacturer
=Nokia, model=N70-1, orientation=upper-left, xresolution=182, yresolution=190, resolutionunit=2, software=darktable 3.2.1, datetime=2020:12:30 11:57:42], baseline, precision 8,
1024x768, components 3
and
file ./lena.png
./lena.png: PNG image data, 512 x 512, 8-bit/color RGB, non-interlaced
NB: I suspect the cause of the problem (from the valgrind output) here is that during the build I had errors with various .so, for example:
/usr/lib/x86_64-linux-gnu/libjpeg.so
and other libs for png, webp, tiff etc.
I created symlinks to the relevant libs in /usr/lib in order to get the build to complete.
But why when running with lena.png is libjpeg.so being used? Why is the jpg file not loading? (I created both files with Darktable, converting from colour versions).
I am running Manjaro 20.1
Linux host 5.8.18-1-MANJARO #1 SMP PREEMPT Sun Nov 1 14:10:04 UTC 2020 x86_64 GNU/Linux