将 objective-c 代码转换为 java 会产生编译错误

Converting objective-c code to java gives compile error

这是objective c++

中编写的部分可编译代码
cv::Mat blurred(image);
medianBlur(image, blurred, 9);

cv::Mat gray0(blurred.size(), CV_8U), gray;
cv::vector<cv::vector<cv::Point> > contours;

for (int c = 0; c < 3; c++)
{
    int ch[] = {c, 0};
    mixChannels(&blurred, 1, &gray0, 1, ch, 1);

    const int threshold_level = 2;
    for (int l = 0; l < threshold_level; l++)
    {
        if (l == 0)
        {
            Canny(gray0, gray, 50, 150, 3); 
            dilate(gray, gray, cv::Mat(), cv::Point(-1,-1));
        }
        else
        {
            gray = gray0 >= (l+1) * 255 / threshold_level;

//这是 AppCode 中的编译问题,但代码编译正常并且可以工作... } ....

这就是我在 java 中编写的方式,但我在最后一行停了下来,我不理解并且无法在 java 中编写以正确编译,即使在 AppCode 编辑器中作为 obecectiv- c代码它被突出显示为错误但编译没有问题。所以我认为 AppCode 解析器也有理解它的问题,但无论如何代码工作,我已经看到 AppCode 解析器的其他问题所以我不在乎,我使用静态导入,但我需要理解的只是最后一行,代码继续进一步并且相当复杂...

    Mat blurred = new Mat();
    Imgproc.medianBlur(image, blurred, 9);  
    Mat gray0 = new Mat(blurred.size(), CvType.CV_8U);
    Mat gray = new Mat();
    Vector<Vector<Point>> contours = new Vector<>();

    for (int c = 0; c < 3; c++) {
        int ch[] = {c, 0};
        Core.mixChannels(list(blurred), list(gray0), new MatOfInt(ch));
        int threshold_level = 2;
        for (int l = 0; l < threshold_level; l++) {
            if (l == 0) {
                Canny(gray0, gray, 50, 150, 3, false);
                dilate(gray, gray, new Mat(), new Point(-1, -1), 1);
            } else {
                gray = gray0 >= (l + 1) * 255 / threshold_level;  //here is compile problem and I don't understand line at all...
            }
        }
    }

正如我在上面所建议的那样,cv::Mat 似乎有一些隐藏了某些功能的重载运算符。 This doc 表示至少有一些运算符被重载了。

这是这条魔法线 java 中的最终解决方案:

 Core.compare(gray0, new Mat(gray0.size(), gray0.type(), new Scalar((l + 1) * 255 / threshold_level)), gray, Core.CMP_GE);