nroduit / Weasis

Weasis is a DICOM viewer available as a desktop application or as a web-based application.
https://nroduit.github.io
Other
835 stars 295 forks source link

Unable to load OpenCV native library on Windows #431

Closed SleLaugh closed 1 year ago

SleLaugh commented 1 year ago

Describe the bug. What happened?

I found a bug.

In some environments, weasis versions later than 4.0.3 cannot load dicom.

I tried the following versions: 4.0.1, 4.0.2, 4.0.3, 4.1.0, 4.1.1, 4.1.2. These versions are installed after downloading the windows installation package, rather than compiling through code.

When I opened the dicom or dragged the dicom onto the weasis form, the first three versions loaded the dicom correctly, but the last three failed to load the dicom properly.

So I looked at their logs.

I found that versions that load dicom correctly, after starting weasis, will always have a sentence at the end of the log "[FelixStartLevel] org.opencv.osgi: Successfully loaded OpenCV native library ", and the version that failed to load dicom does not output this sentence in the log. So I wonder if it is because OpenCV is not loaded correctly that the dicom cannot be loaded.

Note: I tested the above six versions in three environments, one of which was my own machine (windows10) and the other two were VMware virtual machines (windows server 2012R2).

In one of the virtual machines and my local environment, the above 6 versions can load OpenCV and load dicom correctly, and when I check their logs, they all output the log of OpenCV loading success;

Another virtual machine, the first three versions are normal output OpenCV loading success log, and can also open the dicom , while the latter three versions do not output OpenCV loading success log, and can not load the dicom .

I've had this problem with windows7.

At that time it was like this: there were two computers with windows7, but one of them could not load dicom properly, and the other could load dicom normally. The weasis version at the time was a bit higher than the 4.0.3 environment and was compiled from code in March 2023.

I didn't care at the time, but now I think OpenCV didn't load successfully.

I'm a java novice, sorry if I'm wrong.

My English is not very good, if you are not clear, please reply me, I will try my best to express more clearly.

What version of Weasis are you running?

4.1.2

On which system the problem occurs?

Windows

Relevant log output

This is the startup log for weasis4.0.3 .

28.06.2023 10:20:25.071 *INFO* [main] org.weasis.launcher.ConfigData: Starting Weasis...

28.06.2023 10:20:25.149 *INFO* [main] org.weasis.launcher.ConfigData: Initialization of the launch configuration...
28.06.2023 10:20:25.180 *INFO* [main] org.weasis.launcher.ConfigData: Properties: {weasis.user=Administrator, weasis.name=Weasis, weasis.version=4.0.3, weasis.config.hash=-1663154439, weasis.path=C:\Users\Administrator\.weasis, weasis.launch.type=NATIVE, weasis.codebase.url=file:/E:/4.0.3/app, weasis.pref.local.session=true, weasis.codebase.local=E:\4.0.3\app, felix.extended.config.properties=file:/E:/4.0.3/app/conf/ext-config.properties, felix.config.properties=file:/E:/4.0.3/app/conf/config.properties, weasis.source.id=D704AB3D, weasis.profile=default, http.agent=Weasis/4.0.3 (Windows Server 2012 R2; 6.3; amd64; pf:default; rv:4.0.3) Java/19.0.1}
28.06.2023 10:20:25.211 *INFO* [main] org.weasis.launcher.Singleton: Local port of the Singleton server: 49,315
28.06.2023 10:20:25.243 *INFO* [main] org.weasis.launcher.WeasisLauncher: Config of locale.lang.code = zh_CN
28.06.2023 10:20:25.243 *INFO* [main] org.weasis.launcher.WeasisLauncher: Config of locale.format.code = zh_CN
28.06.2023 10:20:25.243 *INFO* [main] org.weasis.launcher.WeasisLauncher: Config of org.apache.sling.commons.log.level = INFO
28.06.2023 10:20:25.243 *INFO* [main] org.weasis.launcher.WeasisLauncher: Config of org.apache.sling.commons.log.file.activate = false
28.06.2023 10:20:25.243 *INFO* [main] org.weasis.launcher.WeasisLauncher: Config of org.apache.sling.commons.log.file.number = 5
28.06.2023 10:20:25.243 *INFO* [main] org.weasis.launcher.WeasisLauncher: Config of org.apache.sling.commons.log.file.size = 10MB
28.06.2023 10:20:25.243 *INFO* [main] org.weasis.launcher.WeasisLauncher: Config of org.apache.sling.commons.log.stack.limit = 3
28.06.2023 10:20:25.243 *INFO* [main] org.weasis.launcher.WeasisLauncher: Config of org.apache.sling.commons.log.pattern = {0,date,dd.MM.yyyy HH:mm:ss.SSS} *{4}* [{2}] {3}: {5}
28.06.2023 10:20:25.367 *INFO* [main] org.weasis.launcher.WeasisLauncher: Config of flatlaf.uiScale = -1
28.06.2023 10:20:25.758 *INFO* [main] org.weasis.launcher.WeasisLauncher: Config of weasis.show.disclaimer = true
28.06.2023 10:20:25.758 *INFO* [main] org.weasis.launcher.WeasisLauncher: Config of weasis.show.release = true
28.06.2023 10:20:25.758 *INFO* [main] org.weasis.launcher.WeasisLauncher: 
***** Configuration *****
  Last running version = 4.0.3
  Current version = 4.0.3
  Application name = Weasis
  Application Source ID = D704AB3D
  Application Profile = default
  Application local codebase = E:\4.0.3\app
  Application codebase URL = file:/E:/4.0.3/app
  Application configuration file = file:/E:/4.0.3/app/conf/config.properties
  Application extension configuration file = file:/E:/4.0.3/app/conf/ext-config.properties
  User = Administrator
  User home directory = C:\Users\Administrator\.weasis
  Resources path = E:\4.0.3\app\resources
  Preferences directory = C:\Users\Administrator\.weasis\preferences\Administrator\default
  Look and Feel = com.formdev.flatlaf.FlatIntelliJLaf
  Languages path = file:/E:/4.0.3/app/bundle-i18n/
  Languages available = en,ar,bg_BG,bs_BA,cs,de,el,es,fa,fr,hr_HR,hu_HU,it,ja,ko,ms_MY,pl_PL,pt,pt_BR,ro,ru_RU,si,sk_SK,sr_RS,sv,tr,uk,vi,vi_VN,zh_CN,zh-Hans,zh_TW
  OSGI native specs = windows-x86-64
  HTTP user agent = Weasis/4.0.3 (Windows Server 2012 R2; 6.3; amd64; pf:default; rv:4.0.3) Java/19.0.1
  Operating system = Windows Server 2012 R2 6.3 amd64
  Java vendor = Eclipse Adoptium
  Java version = 19.0.1
  Java Path = E:\4.0.3\runtime
  Java max memory (less survivor space) = 1.0 GiB
***** End of Configuration *****
28.06.2023 10:20:25.758 *INFO* [main] org.weasis.launcher.WeasisLauncher: 
Starting OSGI Bundles...

         | | /| / /__ ___ ____ (_)__
         | |/ |/ / -_) _ `(_-</ (_-<
         |__/|__/\__/\_,_/___/_/___/

28.06.2023 10:20:28.622 *INFO* [FelixStartLevel] org.opencv.osgi: Successfully loaded OpenCV native library.

28.06.2023 10:20:48.594 *INFO* [Dicom Model-pool-2-thread-1] org.opencv.osgi: Successfully loaded OpenCV native library.

This is the startup log for weasis4.1.0

28.06.2023 10:23:41.720 *INFO* [main] org.weasis.launcher.ConfigData: Starting Weasis...
28.06.2023 10:23:41.798 *INFO* [main] org.weasis.launcher.ConfigData: Initialization of the launch configuration...
28.06.2023 10:23:41.846 *INFO* [main] org.weasis.launcher.ConfigData: Properties: {weasis.user=Administrator, weasis.name=Weasis, weasis.version=4.1.0, weasis.config.hash=-364138625, weasis.path=C:\Users\Administrator\.weasis, weasis.launch.type=NATIVE, weasis.codebase.url=file:/E:/4.1.0/app, weasis.pref.local.session=true, weasis.codebase.local=E:\4.1.0\app, felix.extended.config.properties=file:/E:/4.1.0/app/conf/ext-config.properties, felix.config.properties=file:/E:/4.1.0/app/conf/config.properties, weasis.source.id=A1CD84BF, weasis.profile=default, http.agent=Weasis/4.1.0 (Windows Server 2012 R2; 6.3; amd64; pf:default; rv:4.1.0) Java/20.0.1}
28.06.2023 10:23:41.861 *INFO* [main] org.weasis.launcher.Singleton: Local port of the Singleton server: 49,327
28.06.2023 10:23:41.908 *INFO* [main] org.weasis.launcher.WeasisLauncher: Config of locale.lang.code = zh_CN
28.06.2023 10:23:41.908 *INFO* [main] org.weasis.launcher.WeasisLauncher: Config of locale.format.code = zh_CN
28.06.2023 10:23:41.908 *INFO* [main] org.weasis.launcher.WeasisLauncher: Config of org.apache.sling.commons.log.level = INFO
28.06.2023 10:23:41.908 *INFO* [main] org.weasis.launcher.WeasisLauncher: Config of org.apache.sling.commons.log.file.activate = false
28.06.2023 10:23:41.908 *INFO* [main] org.weasis.launcher.WeasisLauncher: Config of org.apache.sling.commons.log.file.number = 5
28.06.2023 10:23:41.908 *INFO* [main] org.weasis.launcher.WeasisLauncher: Config of org.apache.sling.commons.log.file.size = 10MB
28.06.2023 10:23:41.908 *INFO* [main] org.weasis.launcher.WeasisLauncher: Config of org.apache.sling.commons.log.stack.limit = 3
28.06.2023 10:23:41.908 *INFO* [main] org.weasis.launcher.WeasisLauncher: Config of org.apache.sling.commons.log.pattern = {0,date,dd.MM.yyyy HH:mm:ss.SSS} *{4}* [{2}] {3}: {5}
28.06.2023 10:23:42.033 *INFO* [main] org.weasis.launcher.WeasisLauncher: Config of flatlaf.uiScale = -1
28.06.2023 10:23:42.502 *INFO* [main] org.weasis.launcher.WeasisLauncher: Config of weasis.show.disclaimer = true
28.06.2023 10:23:42.502 *INFO* [main] org.weasis.launcher.WeasisLauncher: Config of weasis.show.release = true
28.06.2023 10:23:42.548 *INFO* [main] org.weasis.launcher.WeasisLauncher: 
***** Configuration *****
  Last running version = null
  Current version = 4.1.0
  Application name = Weasis
  Application Source ID = A1CD84BF
  Application Profile = default
  Application local codebase = E:\4.1.0\app
  Application codebase URL = file:/E:/4.1.0/app
  Application configuration file = file:/E:/4.1.0/app/conf/config.properties
  Application extension configuration file = file:/E:/4.1.0/app/conf/ext-config.properties
  User = Administrator
  User home directory = C:\Users\Administrator\.weasis
  Resources path = E:\4.1.0\app\resources
  Preferences directory = C:\Users\Administrator\.weasis\preferences\Administrator\default
  Look and Feel = com.formdev.flatlaf.FlatIntelliJLaf
  Languages path = file:/E:/4.1.0/app/bundle-i18n/
  Languages available = 
  OSGI native specs = windows-x86-64
  HTTP user agent = Weasis/4.1.0 (Windows Server 2012 R2; 6.3; amd64; pf:default; rv:4.1.0) Java/20.0.1
  Operating system = Windows Server 2012 R2 6.3 amd64
  Java vendor = Eclipse Adoptium
  Java version = 20.0.1
  Java Path = E:\4.1.0\runtime
  Java max memory (less survivor space) = 1.0 GiB
***** End of Configuration *****
28.06.2023 10:23:42.564 *INFO* [main] org.weasis.launcher.WeasisLauncher: 
Starting OSGI Bundles...

         | | /| / /__ ___ ____ (_)__
         | |/ |/ / -_) _ `(_-</ (_-<
         |__/|__/\__/\_,_/___/_/___/

Additional contextual elements

No response

SleLaugh commented 1 year ago

By the way, in the version that can load dicom properly, the log output "[Dicom Model-pool-2-thread-1] org.opencv.osgi: Successfully loaded OpenCV native library."

In the version that cannot load the dicom properly, no matter how I open the dicom operation, there will be no log statement output

nroduit commented 1 year ago

I can't reproduce the problem on Windows 2012 R2. If OpenCV fails to load, you should see this in the log output. Please provide logs (default.log) when you open DICOM file because the logs above don't give any clue about the issue.

arunjoshtech commented 1 year ago

I have faced this issues for for different radiologist and end up with older versions. today I have connected with surface pro windows 11 pc and latest version was not loading images and installed 3.8 version works fine. it is really major issue. Kindly do the needful.

SleLaugh commented 1 year ago

I can't reproduce the problem on Windows 2012 R2. If OpenCV fails to load, you should see this in the log output. Please provide logs (default.log) when you open DICOM file because the logs above don't give any clue about the issue.

Of course, I'd be happy to offer it to you. 4.0.3 boot-0.0.log 4.0.3 default.log 4.1.2 boot-0.0.log 4.1.2 default.log

default

SleLaugh commented 1 year ago

我无法在 Windows 2012 R2 上重现该问题。如果 OpenCV 加载失败,您应该在日志输出中看到这一点。当您打开 DICOM 文件时,请提供日志 (default.log),因为上面的日志没有提供有关该问题的任何线索。

当然,我很乐意将其提供给您。 4.0.3 boot-0.0.log 4.0.3 default.log 4.1.2 boot-0.0.log 4.1.2 default.log

默认

At the same time, although 4.1.2 does not load DICOM, the load icon in the lower left corner will flash

nroduit commented 1 year ago

It's really amazing because there are no errors and some plugins don't seem to be launched. I've never seen this before.

Could provide the output of the OSGI console that will give the status of all the plugins, start Weasis and type in a prompt:

SleLaugh commented 1 year ago

It's really amazing because there are no errors and some plugins don't seem to be launched. I've never seen this before.

Could provide the output of the OSGI console that will give the status of all the plugins, start Weasis and type in a prompt:

  • telnet localhost 17179
  • lb This is the output of the OSGI console. 4.0.3 4 0 3 4.1.2 4 1 2

And I tweaked my test procedure and found some new clues.

After I opened weasis for the first time and set default.log, I deleted the log opened this time.

I then restarted weasis and opened DICOM.

Here is the new log. 4.0.3 boot-0.0.log 4.0.3 default.log 4.1.2 boot-0.0.log 4.1.2 default.log

After comparison, I found that in the version (4.1.2) where the image cannot be opened, the two sentences "INFO [FelixStartLevel] org.weasis.core.internal.cv.NativeOpenCVCodec: Native OpenCV is activated","INFO [FelixStartLevel] org.weasis.core.internal.Activator: Register Image Codec Plug-in: OpenCV imgcodecs"are missing in default.log. They are available in default.log in 4.0.3. Missing

I hope this clue will help you.

nroduit commented 1 year ago

It is like the weasis-core-img-4.6.1-jdk11.jar.xz package is corrupted because it is Active in the OSGI console "Image Processing (OpenCV) 4.6.1" but we do not see the initialisation in the logs.

Could you try to delete cache folder in your user ".weasis/cache-id" (replace id by the one in boot.log Application Source ID = B130CF7D) and the restart. Or delete the whole .weasis folder.

SleLaugh commented 1 year ago

It is like the weasis-core-img-4.6.1-jdk11.jar.xz package is corrupted because it is Active in the OSGI console "Image Processing (OpenCV) 4.6.1" but we do not see the initialisation in the logs.

Could you try to delete cache folder in your user ".weasis/cache-id" (replace id by the one in boot.log Application Source ID = B130CF7D) and the restart. Or delete the whole .weasis folder.

Sorry, I'm a little confused. You mean that the ".weasis" cache folder generated by the previous test version is deleted before each version test?

If this is the case, then before this, every test I have done has been to delete the previous ".weasis" folder and then test. This means that there are no cached folders for each test, as they are all reloaded in this round of tests.

If not, please provide more detailed test procedures.

nroduit commented 1 year ago

If you delete .weasis folder it will clean all the preferences and some cache for osgi. So it will be the same state when you run Weasis for the very first time on a Windows session. In general when package is corrupted in the osgi cache, weasis will automatically clean at next start but in your case there is no apparent error. So that's why I asking to delete manually.

SleLaugh commented 1 year ago

My steps are as follows:

  1. Delete the "C/.weasis" folder

  2. Open weasis4.1.2

  3. Set default.log

  4. Open the image and observe defalut.log. No exception log is displayed

  5. Close weasis4.1.2 and delete the "cache-B130CF7D" folder

  6. Open weasis

  7. Open the image and look at defalut.log. Some exception logs are observed, but they don't seem to have much to do with openCV

I repeated steps 4-7 many times

I hope these things work

boot-0.0.log default.log

nroduit commented 1 year ago

Okay, the package doesn't seem to be corrupted. I've modified the library to log all the errors, not just RuntimeError. Follow this instructions:

  1. Download this file weasis-core.zip

  2. Unzip the file

  3. Replace this weasis-core-img-4.6.1-jdk11.jar.xz with one installed in program folder.

  4. Delete again .weasis folder, restart Weasis and check logs

SleLaugh commented 1 year ago

There are indeed abnormal log outputs.

When opening weasis, boot.log has abnormal information output: "SEVERE [FelixStartLevel] org.opencv.osgi: Cannot load OpenCV native library: C:\Users\Administrator.weasis\cache-B130CF7D\bundle37\version0.0\bundle.jar-lib\0\opencv_java.dll: Can’t find dependent libraries".

Then, I performed the open DICOM operation, and it will load the DICOM, although what is loaded is error information. errorImg

At the same time, there is also abnormal information output, please see the log file for details. boot-0.0.log default.log

Before replacing the weasis-core you provided, there was no content loaded when performing the open DICOM operation. noLoad

But please note that under the same environment, when opening versions below weasis4.0.3 (including 4.0.3), the DICOM can be opened normally.

I’m glad we’ve made some progress.

arunjoshtech commented 1 year ago

Dear sir, I used to install older version like 3.8.1 then if we upgrade to 4.1 it used to work. some thing need to fix and resolve.

nroduit commented 1 year ago

Now the problem is clear: opencv_java.dll is missing some dependencies.

First, I'll propose modifying the initialization in the opencv project because this error is not caught.

According to the documentation, the latest build requires: If the import fails on Windows, make sure you have Visual C++ redistributable 2015 installed. If you are using older Windows version than Windows 10 and latest system updates are not installed, Universal C Runtime might be also required.

For systems prior to Windows 10 they are already end of life, it should no longer be used. For Windows 2012 R2, there are 3 months left before EOL.

SleLaugh commented 1 year ago

Now the problem is clear: opencv_java.dll is missing some dependencies.

First, I'll propose modifying the initialization in the opencv project because this error is not caught.

I'm glad you found the problem According to the documentation, the latest build requires: If the import fails on Windows, make sure you have Visual C++ redistributable 2015 installed. If you are using older Windows version than Windows 10 and latest system updates are not installed, Universal C Runtime might be also required.

After I tried to install Visual C++ redistributable 2015, it worked fine. I hope you can solve this problem in the next version. But what explains why version 4.0.3 works?

For systems prior to Windows 10 they are already end of life, it should no longer be used. For Windows 2012 R2, there are 3 months left before EOL.

For some hospitals, they will still choose to use windows 7,, which is inevitable, but in most cases it will still be windows 10.

nroduit commented 1 year ago

Unfortunately, there's no clear information on these developments, and I can't see any obvious change in the construction of the binaries.

I'll have a look, but I don't think I'll be able to change that, as it's in OpenCV and seems to be part of the library's evolution. As it's already a lot of effort to get Weasis supported on many systems and architectures, it's obvious that end-of-life systems can't be supported.

However, I'll update the requirement in the download comment.

SleLaugh commented 1 year ago

No matter what the outcome, thank you for your dedication and support.

nroduit commented 1 year ago

Weasis 4.2.0 will use a new release of opencv without a Visual C++ redistributable 2015 dependency.