Skip to content Skip to sidebar Skip to footer

How To Add 2 Org.opencv.core.Point Objects In Android?

I'm new to OpenCV and Android. I'm tring to covert a C++ code to java line( img_matches, scene_corners[0] + Point2f( img_object.cols, 0), scene_corners[1] + Point2f( img_object.col

Solution 1:

The first thing to note is that the second and third parameters to Core.line must be points.

In your replacement, you removed the addition symbol (+). Hmm. I don't think you can do that if you are converting the code line for line.

The get method appears to return a Point, but you'll need to print the object out to make sure or just look at the variable definition for scene_corners. Use this to try printing it out:

System.out.println(scene_corners.get(0));

If it's a Point object, then you can add it to your point by taking each component of the Point and adding it to the corresponding component in the added to Point. Assume Point A and B with components 0 and 1.

P(A) + P(B) = P(A0+B0, A1+B1)

Here, I am assuming that scene_corners.get(0) has x and y properties:

line(
    img_matches,
    new Point(
        img_object.cols() + scene_corners.get(0).x,
        0 + scene_corners.get(0).y),
    new Point(
        img_object.cols() + scene_corners.get(1).x,
        0 + scene_corners.get(1).y),
    Scalar(0, 255, 0),
    4
);

Post a Comment for "How To Add 2 Org.opencv.core.Point Objects In Android?"