confused with goodFeaturesToTrack

462 views
Skip to first unread message

Stéphane TALLARD

unread,
Nov 27, 2014, 3:05:13 PM11/27/14
to javacpp...@googlegroups.com
Hello guys,

I'm trying to use the goodFeaturesToTrack method :

@Namespace("cv") public static native void goodFeaturesToTrack( @ByVal Mat image, @ByVal Mat corners, int maxCorners, double qualityLevel, double minDistance


corners being the output of the method, I don't know how to extract from corners parameter the information I need (Points) . Could you give some help on the good method to achieve this ?

Moreover, I've googled around and found some code examples that didn't compile with the bytedeco java opencv libraries.

Those examples of codes use objets like MatOfPoint that belong to a .jar found in the opencv 2.4.9. superpack ( found here : http://garr.dl.sourceforge.net/project/opencvlibrary/opencv-win/2.4.9/opencv-2.4.9.exe )

That jar can be found on maven central (see http://grepcode.com/file/repo1.maven.org/maven2/nu.pattern/opencv/2.4.9-4/org/opencv/core/MatOfPoint.java#MatOfPoint) .

Unfortunatly, that .jar contains types already defined in the bytedeco distribution like Mat, althought in different packages.

Could you give some information on that jar : Is it safe to add that jar in my maven dependencies ? what is the point in having two open java bindings in the same project ?

Thank you for your help ,
Stéphane

Stéphane TALLARD

unread,
Nov 28, 2014, 9:21:35 AM11/28/14
to javacpp...@googlegroups.com
By the way getFloatBuffer made the trick .

Following code made my day :

 public Mat process(Mat inputImage) {

    Mat corners = new Mat(inputImage.size(), inputImage.type());

    Mat mask = new Mat(inputImage.size(), CV_8U);

    goodFeaturesToTrack(src, corners, goodFeaturesTotrack.getCornerCount(), goodFeaturesTotrack.getQualityLevel(), goodFeaturesTotrack.getMindistance(), mask, goodFeaturesTotrack.getAperture(), goodFeaturesTotrack.isUseHarris(), goodFeaturesTotrack.getK());

    if (!corners.empty()) {
        FloatBuffer array = corners.getFloatBuffer();

        int nbLoop = array.limit() / 2;
        for (int i = 0; i < nbLoop; i++) {
        float x = array.get();
        float y = array.get();
        myCircle(inputImage, new Point((int) x, (int) y));

        }
    }

    return inputImage;

    }

Anyone for my last question ?

Cheers,
Stéphane

Samuel Audet

unread,
Nov 28, 2014, 8:39:20 PM11/28/14
to javacpp...@googlegroups.com
On 11/28/2014 11:21 PM, Stéphane TALLARD wrote:
> By the way getFloatBuffer made the trick .

Yes, that's the way for now :)

> Could you give some information on that jar : Is it safe to add that jar in my maven dependencies ? what is the point in having two open java bindings in the same project ?

There's nothing unsafe about it, but the Java build of OpenCV creates a
separate library file from the C++ modules, which the JavaCPP Presets
use, so we end up with much duplicated functionality...

The OpenCV guys maintain some more stuff for Android than there is in
the JavaCPP Presets, but that's about it. JavaCPP has a more complete
interface otherwise. The thing is, the Java bindings in OpenCV make use
of Python, and the Python guys wouldn't be happy with a generator
written in Java, and that's why they aren't interested in JavaCPP. It's
all very political. :)

Samuel

Stéphane TALLARD

unread,
Nov 30, 2014, 10:50:01 AM11/30/14
to javacpp...@googlegroups.com
Ok,  thank you Samuel

Stéphane



--
You received this message because you are subscribed to a topic in the Google Groups "javacpp" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/javacpp-project/OiBUyP95Sl0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to javacpp-project+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages