Weasis icon indicating copy to clipboard operation
Weasis copied to clipboard

Enhance openCV to support optiicalFlow - Video.calcOpticalFlowPyrLK (Lucas-Kanade)method

Open DD-72 opened this issue 1 year ago • 7 comments

Is your feature request related to a problem? (optional)

No response

Description of the new feature/enhancement

Currently openCV provided in Weasis is not supporting all features provided by original openCV. It seems you guys trimmed some features of openCV and developed some third party libraries. We have a requirement in our application to use Video.calcOpticalFlowPyrLK (Lucas-Kanade)method but this is not available in Weaisis's openCV. It would be helpful if you include optical flow related features in openCV. Please let me know if you need any more details

Proposed technical implementation details (optional)

No response

Describe alternatives you've considered (optional)

No response

Additional context (optional)

No response

DD-72 avatar Sep 06 '24 10:09 DD-72

In fact, we only integrate 3 modules:

  • core
  • imgproc
  • imgcodecs: witch contains specific implementations

Unfortunately, we don't want to add any other opencv modules to the basic version, for reasons of binary volume and system compatibility. You'll have to look into adding these in additional custom plugins.

For example, we have a video plugin with ffmeg (80 MB) that will be distributed as an additional plugin.

nroduit avatar Sep 06 '24 17:09 nroduit

@nroduit Thank you very much for responding. Could you please provide more insights on custom plugins. I tried following to add openCV but Weasis is failing to start up.

  1. Created new plugin by following steps provided in https://weasis.org/en/basics/customize/build-plugins/index.html#build-plug-ins-from-maven-archetype

  2. Tried with different Java openCV libraries like JavaCV, openpnp. Added JavaCV dependences in pom.xml of plugin created in above step. <dependency> <groupId>org.openpnp</groupId> <artifactId>opencv</artifactId> <version>3.4.2-0</version> </dependency>

  3. Its compiled successfully and able to import Video.calcOpticalFlowPyrLK but Weasis is failing to start.

  4. Error log - org/weasis/core/weasis-core/4.2.0-SNAPSHOT/weasis-core-4.2.0-SNAPSHOT.jar (org.osgi.framework.BundleException: Unable to resolve weasis-core [31](R 31.0): missing requirement [weasis-core [31](R 31.0)] osgi.wiring.package; (osgi.wiring.package=org.dcm4che3.img.stream) [caused by: Unable to resolve weasis-dicom-codec [3](R 3.0): missing requirement [weasis-dicom-codec [3](R 3.0)] osgi.wiring.package; (&(osgi.wiring.package=org.opencv.core)(version>=3.4.0)(!(version>=4.0.0)))] Unresolved requirements: [[weasis-core [31](R 31.0)] osgi.wiring.package; (**osgi.wiring.package=org.dcm4che3.img.stream**)])

  5. To fix above issue, updated Exported-Package and Import-Package section in pom.xml of weasis-core with packages got in above errors (org.dcm4che3.img.stream) but facing same kind issue with different packages.

DD-72 avatar Sep 09 '24 11:09 DD-72

According to the errors, I imagine you've modified the core module and created impossible dependencies. The core module cannot have dicom-codec as a dependency (this will produce cyclic dependencies), see the OSGI module hierarchy.

nroduit avatar Sep 09 '24 15:09 nroduit

@nroduit We followed the same module hierarchy and Its all working fine without newly created plugin. We are facing issue only when adding newly created plugin dependency in weasis-core. Please find attached pom.xml for both weasis-core and custom-plugin. Attached complete error logs also. custom_plugin_error_log.txt weasis-core-pom.txt custom_plugin_pom.txt

DD-72 avatar Sep 10 '24 15:09 DD-72

You can't attach plugins that use DICOM functionality to weasis-core. This will create cyclic dependencies. You need to create a new launch context (see example) and add your plugins. Plugin documentation remains valid as long as properties files are replaced by json files.

nroduit avatar Sep 18 '24 08:09 nroduit

  1. Removed all DICOM dependencies from new plugin
  2. Added this new plugin in Weasis/weasis-launcher/conf/config.properties and Weasis/weasis-launcher/conf/base.json
  3. Added this new plugin as a dependency in weasis-core module But getting below error. Not sure why Dicom-Explorer, dicom-viewer2d are failing when new plugin was added in weasis-core.

ERROR: Bundle weasis-dicom-explorer [23] Error starting file:C:/Users/DD/.m2/repository/org/weasis/dicom/weasis-dicom-explorer/4.2.0-SNAPSHOT/weasis-dicom-explorer-4.2.0-SNAPSHOT.jar (org.osgi.framework.BundleException: Activator start error in bundle weasis-dicom-explorer [23].) java.lang.NoClassDefFoundError: org/osgi/framework/BundleActivator

ERROR: Bundle weasis-dicom-viewer2d [26] Error starting file:C:/Users/DD/.m2/repository/org/weasis/dicom/weasis-dicom-viewer2d/4.2.0-SNAPSHOT/weasis-dicom-viewer2d-4.2.0-SNAPSHOT.jar (org.osgi.framework.BundleException: Activator start error in bundle weasis-dicom-viewer2d [26].) java.lang.NoClassDefFoundError: org/weasis/core/ui/editor/image/ImageViewerPlugin

Caused by: java.lang.ClassNotFoundException: org.osgi.framework.BundleActivator not found by weasis-dicom-explorer [23]

Could you please check and let me know if I missed anything.

DD-72 avatar Sep 24 '24 14:09 DD-72

Is number 23 in below exception anyway related to felix.auto.install.23 in config.properties?. This is related to Weasis openCV. Adding another openCV causing this issue?

ERROR: Bundle weasis-dicom-explorer **[23]** Error starting file:C:/Users/DD/.m2/repository/org/weasis/dicom/weasis-dicom-explorer/4.2.0-SNAPSHOT/weasis-dicom-explorer-4.2.0-SNAPSHOT.jar (org.osgi.framework.BundleException: Activator start error in bundle weasis-dicom-explorer **[23]**.) java.lang.NoClassDefFoundError: org/osgi/framework/BundleActivator

felix.auto.install**.23**= \ file:${maven.localRepository}/org/weasis/opencv/w**easis-opencv-core**-${native.library.spec}/${weasis.opencv.native.version}/weasis-opencv-core-${native.library.spec}-${weasis.opencv.native.version}.jar

DD-72 avatar Sep 24 '24 14:09 DD-72

We're closing this issue due to inactivity over the past several months. If the problem persists or if you have any further information to provide, please feel free to reopen this issue or create a new one. We appreciate your contributions and feedback!

nroduit avatar Jun 19 '25 05:06 nroduit