Accessor Functions Requiring DISTTRANSFORM
#python self.subscription.subscribe(playmotion.SERVICE_DISTTRANSFORM)
syntax
float VisionInput::getDistanceFromEdge(int x, int y)
float VisionInput::getDistanceFromEdge(CvPoint point)
brief
Returns a floating point distance between the input point and the nearest black/white pixel boundary in the segmentation image. This as an image space operation, meaning that the input point shold be a pair (x,y) of coordinates with origin at the upper lefthand corner. The point should not lie outside the boundary of the segmentation image. The return value is also in image space -- the Euclidean distance from the input point to the nearest pixel across the image. Negative values mean that the point is inside a white region.
details
Typically, the distance transform takes an image as input and returns an image of the same dimension as output where the output pixel is the distance from that pixel location to the nearest zero pixel. Obviously if the input pixel is zero, the distance is zero, and hence black pixels are fixed points of this operation.
PlayMotion's distance transform operation is a modification of the one described above, providing distances both from black pixels to white ones and vice versa. To do this, we compute the distance transform of both the segmentation image and its inverse. The former result is multiplied by -1 to give negative values and the two images are combined by simple signed addition. Of course one of the operands in each pixel addition is zero, so this is a trivial combination. The resulting image is the one that is queried when getDistanceFromEdge() calls are made.
code snippet:
related links:
