OpenCv Java CvKNearest usage - java

I am writing a Java application what does feature matching with OpenCV 2.4.10.
The inputs of the program are two images and now the program searches the matching keypoints of the two images with SURF algorythm.
My problem is I cannot filter the good matches. I read that the K-Nearest neighbour algorythm is the solution of my problem and there is an implementation in the OpenCV library. I found some example code with Google but these examples are written in C and the C interface of this feature is different from the Java interface.
Can anyone show me an example for this feature?
How can I use the CvKNearest.train() and the CvKNearest.find_nearest() functions in Java?

i once used open cv 3.0 version and that was for a small application and
i never wanted to implement c methods ,,
bt see the article maybe this could help to call c methods in java
http://cs-people.bu.edu/dgurari/OpenCVwithJava.html

Related

Integrate Python OpenCV with React Native/Android/iOS

I have an app built on React Native whose core functionality is to capture some images, analyse and process the images and return some results. As of now the image analysis was done in the server side using python and opencv. Only the results and the resultant images were returned. Now as per the requirement by the clients, due to privacy concerns, they want the image processing to be done on the mobile app itself. (As the images are medical related and they don't want the images to be sent to the server)
So, my question is, if there is a way I can use my existing python with opencv code and integrate it directly into react-native/android/ios?
Right now what I am doing is using the library react-native-opencv3 , numjs, etc to re-write the algorithm in react-native as I feel comfortable using javascript (I have no experience in swift). However not all opencv, numpy functions are supported by these libraries and it is consuming all the time to re-write the code.
I found about using jython, python-for-android and swift-python-interoperability
Can I use these to directly integrate python opencv code into my current application? If yes, it would be great if someone can help me with some small example or guidelines as I cannot find anything.
Other method that I considered was:
Re-write the algorithm using native code and opencv-android and opencv-ios sdks and create the react-native bridge to call the algorithm. (I am guessing it will take a lot of time as I have to write in 2 different languages. Time that I don't have)

How to use the FaceRecognizer library created in openCV from Java?

I am trying to implement a face recognizer in java. I got this code example and made changes to fit my requirements on how the system should behave. It works but then when I have images of the same person in different light intensities its efficiency drops. I read that there is a library inserted in openCV for faceRecognizer but then its samples are implemented in c++. Is there any way i can use this library to code in java? and also if we can use it then will it increase the efficiency of the code?
Please do provide some help on this. Stuck on it badly...
You can create a C++ dll for java. You should write a wrapper class (in C++) which uses your C++ codes. Function definitions of the wrapper class should use JNI. This link here should be helpful (it was for me). After you implement the wrapper class, export it as a dll.
Just Use java cv so that you can use all c++ function in java.
Download all javacv jar files and try to install javacv to your system
Just look through how to setup javacv in your system.
I think this should do the magic in java
FaceRecognizer model=createFisherFaceRecognizer();
model.train(images,label);
For prediction
Int id=model.predict(img);

Equivalence of cvMatchTemplate() in BoofCV or pure java computer vision library?

I am looking for solutions BoofCV or any pure java computer vision library that doesn't require OpenCV to do template matching of images to detect object within a picture.
For example, finding the position of an image within a bigger picture.
I have had success with cvMatchTemplate() example on OpenCV, but interested in using BoofCV to achieve the same results.
This functionality has recently been added to BoofCV. See example below:
http://boofcv.org/index.php?title=Example_Template_Matching
It seems this functionality is not implemented in BoofCV.

In search for a good Java ODE solver

I'm working on a project to create a GUI for an algorithm in MATLAB using an ODE solver (ode45). So I have to translate the MATLAB code to Java. The problem is the ode45 solver. Java does not seem to have a solver ready to use, and ODE's are not really my speciality. Am I just not looking good, or are there really no ODE solvers for Java implemented?
thanks
If you need a mathematical library for Java, there are several available on the market, either open-source or commercial. These are few ones.
JMSL by Roguewave, entirely written in Java , which we use succesfully at work
NAG, written in C but widely documented so that can be used from Java
Apache commons math, which is open source and contains also a ODE http://commons.apache.org/math/userguide/ode.html
not exactly what you asked but did you consider creating the GUI from matlab instead? it's not that different from basic java swing/awt things unless you're looking for fancy GUI things.
http://www.mathworks.com/help/techdoc/creating_guis/bqz6qcd.html

What can I access in Androids Native libraries? And How?

I am completely new to the NDK.
I have done a couple of the tutorials including the hello from jni one
and another one that calculates the sum of two numbers.
They involved using cygwin and the ndk to create the library so file
and I have a bit of a grasp on how to insert my own libraries into the
libraries layer of Android.
I have now been asked to access the native libraries on Android and
see what I can use them for.
My question is can I do this?
The STABLE-APIS.txt document is a bit vague and mentions the following
as Stable C++ API's in Android 1.5
cstddef
new
utility
stl_pair.h
Does that mean I can access them?
If so then how do I go about it? I dont think that following the
tutorials I have already done would be any help?
Any pointers on how to do this or links to tutorials etc.. would be
greatly appreciated
As others pointed out on the android-ndk group, you probably should just use the SDK. The NDK doesn't give you access to any features beyond those available with the SDK and it reduces the portability of your application. You should only consider it if you have legacy code written C or C++ (that doesn't use exceptions or RTTI). While some operations are much faster in native code, passing data between managed and native code is expensive and thus using the NDK only speeds up certain types of applications.

Categories