I am using dcm4che3 to decompress a compressed dicom image in Ubuntu 18.04.
while I could get the native library loaded for OpenCV, but still I am getting an UnsatisfiedLinkError while calling Transcoder.transcode(...)
I wonder what I am missing here.
23:03:56.694 [main] DEBUG org.dcm4che3.imageio.codec.Transcoder - Decompressor: org.dcm4che3.opencv.NativeImageReader Mar 06, 2021 11:03:56 PM org.opencv.osgi.OpenCVNativeLoader init INFO: Successfully loaded OpenCV native library. 23:03:56.769 [main] DEBUG ****************: thrown java.lang.UnsatisfiedLinkError(org.opencv.imgcodecs.Imgcodecs.dicomJpgMatRead_0(JII)J) out of org.opencv.imgcodecs.Imgcodecs#dicomJpgMatRead_0[-2] in 219ms
Stacktrace:
Caused by: java.lang.UnsatisfiedLinkError: org.opencv.imgcodecs.Imgcodecs.dicomJpgMatRead_0(JII)J at org.opencv.imgcodecs.Imgcodecs.dicomJpgMatRead_0(Native Method) ~[weasis-opencv-core-3.6.0-rc1.jar:na] at org.opencv.imgcodecs.Imgcodecs.dicomJpgMatRead(Imgcodecs.java:219) ~[weasis-opencv-core-3.6.0-rc1.jar:na] at org.dcm4che3.opencv.NativeImageReader.getNativeImage(NativeImageReader.java:287) ~[dcm4che-imageio-opencv-5.22.1.jar:na] at org.dcm4che3.opencv.NativeImageReader.read(NativeImageReader.java:251) ~[dcm4che-imageio-opencv-5.22.1.jar:na] at org.dcm4che3.imageio.codec.Transcoder.decompressFrame(Transcoder.java:620) ~[dcm4che-imageio-5.22.1.jar:5.22.1] at org.dcm4che3.imageio.codec.Transcoder.decompressPixelData(Transcoder.java:453) ~[dcm4che-imageio-5.22.1.jar:5.22.1] at org.dcm4che3.imageio.codec.Transcoder.processPixelData(Transcoder.java:434) ~[dcm4che-imageio-5.22.1.jar:5.22.1] at org.dcm4che3.imageio.codec.Transcoder.access$300(Transcoder.java:70) ~[dcm4che-imageio-5.22.1.jar:5.22.1] at org.dcm4che3.imageio.codec.Transcoder$1.readValue(Transcoder.java:389) ~[dcm4che-imageio-5.22.1.jar:5.22.1] at org.dcm4che3.io.DicomInputStream.readAttributes(DicomInputStream.java:534) ~[dcm4che-core-5.22.1.jar:5.22.1] at org.dcm4che3.imageio.codec.Transcoder.transcode(Transcoder.java:368) ~[dcm4che-imageio-5.22.1.jar:5.22.1]
I turned to be the case of having the right path set for the envrionment variable LD_LIBRARY_PATH; in my case, /app/open/java/bin had the required .so files.
LD_LIBRARY_PATH=/app/opencv/java/bin
To load the open cv library for junits, I had to provide the path in java.library.path:
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-Djava.library.path=/app/opencv/java/bin</argLine>
</configuration>
</plugin>