如何在Android中添加2个org.opencv.core.Point对象? [英] How to add 2 org.opencv.core.Point objects in Android?

查看:187
本文介绍了如何在Android中添加2个org.opencv.core.Point对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是OpenCV和Android的新手。我想将C ++代码转换为java

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.cols, 0), Scalar(0, 255, 0), 4 );

这是它的最后一部分。在这里,我用Core.line替换了一行()

this is the last part of it. Here, I replaced line with Core.line()

现在问题是在上面的代码中添加了这两点

scene_corners[0] + Point2f( img_object.cols, 0)

我用

scene_corners.get(0),new Point(img_object.cols(),0)

由于两者都是 org.opencv.core.Point 类型对象,因此不支持这些类型的操作。任何方式来转换它。请帮我。先感谢您。

Since both are org.opencv.core.Point type objects, these types of operations are not supported. Any way to convert this. Please help me. Thank you in advance.

推荐答案

首先要注意的是Core.line的第二个和第三个参数必须是点。

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.

get方法似乎返回一个Point,但是你需要打印该对象用于确保或仅查看scene_corners的变量定义。使用它来尝试将其打印出来:

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));

如果它是一个Point对象,那么你可以通过获取Point的每个组件将它添加到你的点并将其添加到添加到Point的相应组件中。假设点A和B的分量为0和1.

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)

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

这里,我假设scene_corners.get(0)有x和y属性:

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
);

这篇关于如何在Android中添加2个org.opencv.core.Point对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆