java - opencv c++ 到 java 距离变换

标签 java opencv

我一直在将我的 c++ 2.4.9 中的 opencv 代码转换为 java,但我一直无法使该代码正常工作。

C++代码

Mat Gradient;
Mat edge = MeanShift >= 225, dist;
cvtColor(edge, edge, CV_BGR2GRAY); 
distanceTransform(edge, dist, CV_DIST_L2, CV_DIST_MASK_5);
dist *= 65655;
pow(dist, 2, dist);
dist.convertTo(Gradient, CV_8U, 1, 0.1);
threshold(Gradient, Gradient, 2, 255, CV_THRESH_BINARY);

imshow("Gradient before", Gradient);

我真的很困惑如何得到 Mat edge = MeanShift >= 225, dist;在 Java 中...

有办法吗?

最佳答案

在 C++ 中,这将在 Mat 对象上调用运算符>=,然后在生成的 Mat edge 上调用逗号运算符。

基本上这段代码是:

Mat edge = MeanShift.operator>=(225);
edge.operator,(dist);

因此,正确的查找位置应该首先是 C++ 运算符,然后是 Java 中的比较函数。

让后者我想我可以在这里找到:

[ http://docs.opencv.org/java/org/opencv/core/Core.html#compare(org.opencv.core.Mat , org.opencv.core.Scalar, org.opencv.core.Mat, int)][1]

[1]:在Core.html中比较

关于java - opencv c++ 到 java 距离变换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30551561/

相关文章:

Java - 修剪换行符后的字符串

python - 'HOG feature'列表中的每个值指示什么?

在 OpenCV 中创建 XML 文件

python - 人脸识别模型无法正确预测训练图像

java - 如何使用 jsoup 读入网页非链接文本?

java - Hibernate通过无状态 session 保存延迟获取的实体

python - 在 RaspberryPi 中安装 OpenCV 以与 Python 一起使用的正确方法

android - 如何让 OpenCV 库支持 Android 2.3.4 和 4.1?

java - android - 插页式广告仅在模拟器上弹出

java - static Final的继承-->不可见