我一直在将我的 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/