【问题标题】:Android OpenCV - Applying math operators on matricesAndroid OpenCV - 在矩阵上应用数学运算符
【发布时间】:2016-03-21 10:29:53
【问题描述】:

我正在将一些 cpp 代码翻译成 android。在 cpp 中,有一些重载方法可以在 opencv 矩阵之间进行数学运算符。它在android中不起作用。

cpp代码:

int thresh = 30, N = 11;
Mat gray0(image.size(), CV_8U), gray;

for (int l = 0; l < N; l++) {

        if (l == 0)
        {
            // apply Canny. Take the upper threshold from slider
            // and set the lower to 0 (which forces edges merging)
            Canny(gray0, gray, 0, thresh, 5);
            // dilate canny output to remove potential
            // holes between edge segments
            dilate(gray, gray, Mat(), Point(-1, -1));
        }
        else
        {
            // apply threshold if l!=0:
            gray = gray0 >= (l + 1) * 255 / N;
        }
}

我被困在else 部分。

需要在 android 中编写该代码。 任何帮助将不胜感激。

【问题讨论】:

  • cv::threshold(gray0, gray, (l+1)*255/N, 255, THRESH_BINARY); 给出相同的结果。 reference

标签: android c++ opencv matrix operators


【解决方案1】:

在 opencv 库中找到它。运算符位于Core.compare

回答:Core.compare(gray0, new Scalar((l+1) * 255/N), gray, Core.CMP_GE);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-05-28
    • 1970-01-01
    • 1970-01-01
    • 2020-04-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-05
    相关资源
    最近更新 更多