Installing IJ-openCV/JavaCV

imagej
installation
opencv
ij-opencv
#1

Dear Everyone,

I am quite new to the world of Imagej. Recently, I have started a project which involves face recognition. For that purpose, I wanted to download and install IJ-OpenCV. I have followed the guide, the manual and the maven option, but I still don’t know how to complete the process.
On one hand, I have installed the Maven tool, but I don’t know how to use it and thus I don’t know how to modify the “pom.xml” file.
On the other hand, I have manually downloaded the files indicated in the “Manual installation” section, but I am stuck a the point of “installing the JavaCV” binaries. I have the binaries downloaded but, what I am supposed to do with that?

I know this seems a rather silly question, but I am learning how to program within the ImageJ tool, so any help will be appreciated.

Kind regards,
SCM

#2

Hello,
If you want to write some Fiji macro/plugin that uses the IJ-OpenCV library I would suggest to just simply activate the IJ-OpenCV update site, it ships JavaCV and Javacpp together.


and then have a look at the example codes in the GitHub repo. There is actually one script about Face recognition.

The API documentation will be helpful too I guess and also have a look at the Fiji Jython wiki page that have a section about OpenCV.

Good luck !

1 Like
#3

Thank you very much. That seems solving my problem and allowing me to use OpenCV functions. However, for the face recognition it also requires to add some kind of xml info somwhere and I do not know where do they refer.
In addition, in order to use OpenCV, I am forced to uninstall the “Align_Template” module as this relies in an older version of OpenCV. Is it possible to update this so that both use the same OpenCV jar?

Upload a XML file on a Fiji update site
#4

Hello,
Sorry for the late answer, for some reason I did not get a notification.

I think it refers to this file on the GitHub repo, which is not shipped with the update site :sweat_smile:
But if you write your own code based on this one you can save this xml file locally and point to it.

Depending on what you do I would take care about the licence by the way. IJ-OpenCV is currently under GPL licence which means that you have to make any code relying on it also available and most likely under GPL too, so maybe not what you want for a commercial application for instance.
This might change to match the initial OpenCV licence see this past pull request

You hit a pain point indeed. 2 different plugins relying on different versions of the same library wont be able to coexist in the same Fiji installation.
We can try to ask @qztseng the author of Align_Template to put the source code on a GitHub repo, so we can collaboratively inspect if updating this plugin is a lot of work or rather straightforward.

In the mean time I would advise to have 2 separate Fiji installations, 1 for each plugin and to share you processing between those 2.

#5

Hello @LThomas,

Thank you very much for your advice. This has more than solved all my questions. Now, let’s see if we are lucky and @qztseng see the petition to make the code available so that it is possible to update the dependencies.

Kind regards,
S

1 Like
#6

This was recently changed. The XML file is distributed with the IJ-OpenCV update site and will be located in Fiji.app/lib.
The classifier can be loaded as following (Jython)

from org.bytedeco.javacpp.opencv_objdetect import CascadeClassifier
import os

XML_path = os.path.join(IJ.getDirectory("imagej"), 'lib', 'haarcascade_frontalface_alt.xml')  
Classifier = CascadeClassifier(XML_path) # now it's very easy to load the classifier file
print Classifier.empty() # False, OK the classifier is loaded
#7

Hello phisanti and Thomas,

Sorry the late response.
The template matching, align slices, PIV, adaptive threshold plugins has been updated to work with the latest version of javacv/opencv as well as the FIJI installation.
The binaries and java sources are uploaded to a github repository as well.


I hope that will still do some helps.

Cheers,

Qingzong

2 Likes
#8

WoW! Thank you very much!

Now, for me will be the first time I install a plugin from Github, do you know what I have to do in order to install the plugin or it is enough with downloading and click on “install plugin”??

Kind regards,
Santi

#9

I think you can still follow the guidelines of the google site but with the files from github.

EDIT : You can simply activate IJ-OpenCV and put the plugin jars in the plugin folder (no the javacv stuff)

1 Like