I'm looking for a way to access x
and y
from Point
class in java bindings. Below is the code I'm working with:
Mat gray = new Mat();
Imgproc.cvtColor(img, gray, Highgui.CV_LOAD_IMAGE_GRAYSCALE);
int erosion_size = 5;
Mat element = Imgproc.getStructuringElement(
Imgproc.MORPH_CROSS, new Size(2 * erosion_size + 1, 2 * erosion_size + 1), new Point(erosion_size, erosion_size)
);
Imgproc.erode(img, gray, element);
List<Point> points = new ArrayList<Point>();
for (int i = 0; i < gray.rows(); i++) {
for (int j = 0; j < gray.cols(); j++) {
points.add(new Point(i,j));
}
}
now that I've got a list of Point
s I would like to call x
and y
on them as it is done in the c++ code below:
std::vector<cv::Point> points;
cv::Mat_<uchar>::iterator it = gray.begin<uchar>();
cv::Mat_<uchar>::iterator end = gray.end<uchar>();
int left, right, top, bottom;
for (int i = 0; i < points.size(); i++)
{
if (i == 0) // initialize corner values
{
left = right = points[i].x;
top = bottom = points[i].y;
}
}
I looked at the API documentation and don't see any way to access the X and Y from the Point class.
Is there a workaround?