Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

well, the java wrappers are indeed somewhat clumsy here (compared to c++),

but you could either work around it with 1-pixel Mat's like:

Mat left = img.submat( yleft, yleft+1, xleft, xleft+1);
Mat right = img.submat( yright , yright +1, xright , xright +1);
doublle dist = Core.norm(left, right);

or just compute it manually:

double dx = right_pt[0] - pti[0];
double dy = right_pt[1] - pti[1];
double dist = Math.sqrt(dx*dx + dy*dy);

well, the java wrappers are indeed somewhat clumsy here (compared to c++),

but you could either work around it with 1-pixel Mat's like:

Mat left = img.submat( yleft, yleft+1, xleft, xleft+1);
Mat right = img.submat( yright , yright +1, xright , xright +1);
doublle double dist = Core.norm(left, right);

or just compute it manually:

double dx db = right_pt[0] - pti[0];
double dy dg = right_pt[1] - pti[1];
double dr = right_pt[2] - pti[2];
double dist = Math.sqrt(dx*dx Math.sqrt(db*db + dy*dy);
dg*dg + dr*dr);

well, the java wrappers are indeed somewhat clumsy here (compared to c++),

but you could either work around it with 1-pixel Mat's like:

Mat left  = img.submat( yleft, img.submat(yleft,  yleft+1,  xleft,  xleft+1);
Mat right = img.submat( yright , yright +1, xright , xright +1);
img.submat(yright, yright+1, xright, xright+1);
double dist = Core.norm(left, right);

or just compute it manually:

double db = right_pt[0] - pti[0];
double dg = right_pt[1] - pti[1];
double dr = right_pt[2] - pti[2];
double dist = Math.sqrt(db*db + dg*dg + dr*dr);