简体   繁体   English

C ++到Java-OpenCV

[英]C++ to Java - OpenCV

I am trying to "port" an OpenCV C++ program to Java, but the syntax is quite different. 我试图将OpenCV C ++程序“移植”到Java,但是语法却大不相同。

I can't find the Java OpenCV equivalents of: 我找不到Java OpenCV的等效项:

img_bw.at<uchar>(j,i);
boundingRect();
vector.push_back(Point(i,j)); // the Point part

Also, how to reserve space in a Vector? 另外,如何在向量中保留空间?

It is hard to find the Java equivalents for openCV C++ code. 很难找到openCV C ++代码的Java等效项。 You just have to dig through the internet. 您只需要浏览互联网即可。 A lot of it is already on StackOverflow. 其中很多已经在StackOverflow上。

A vector is essentially a Matrix. 向量本质上是一个矩阵。 So Mat is god place to look. 所以Mat是看神的地方。 MatOfPoint should be your vector equivalent, which is just a matrix with points. MatOfPoint应该是您的向量等效项,它只是一个带有点的矩阵。 There are many more MatOf-type objects. 还有更多的MatOf类型的对象。

This code is not semantically equivalent (as I don't know C++), but to give you an idea where to go from here: 这段代码在语义上不是等效的(因为我不了解C ++),但是可以让您知道从这里开始的方向:

mat.get(row, col); // returns pixel info as a double[]
Imgproc.boundingRect(matOfpoint); // returns a Rectangle that wraps the points in this matrix
matOfpoint.push_back(otherMatOfPoint); // pushes points from otherMatOfPoint to the matOfPoint matrix

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM