Android OpenCV - 在矩阵上应用数学运算符

Android OpenCV - Applying math operators on matrices

本文关键字:应用数学 运算符 OpenCV Android      更新时间:2023-10-16

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

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部分。

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

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

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