1 | initial version |
// Draw white colored line on black pixel Image for the given slot
Mat lineFrame=blackImage.clone();
Imgproc.line(lineFrame, start, end, new Scalar(255,255,255), 4);
// Draws white colored detected contour of moving loco on black pixel image
Mat contourFrame=blackImage.clone();
Imgproc.drawContours(contourFrame, array, array.indexOf(matImage), new Scalar(255, 255, 255));
// BitWise_and of line and contour gives the intersection points
Mat result= new Mat();
Core.bitwise_and(lineFrame, contourFrame, result);
// Counts num of non zero pixels (intersection points)
int count=Core.countNonZero(result);
if(count>0){
System.out.println("Intersected "+count);
return true;
}
else{
return false;
}