Would this be how to use the detectRectangles function in java. We looked at the ellipseDetect and I am thinking that hey do the same thing just based on different descriptors.
Code:
private static final BlockingFunction imaqDetectRectanglesFn =
NativeLibrary.getDefaultInstance().getBlockingFunction("imaqDetectRectangles");
static { imaqDetectRectanglesFn.setTaskExecutor(NIVision.taskExecutor); }
private static Pointer numberOfRectanglesDetected = new Pointer(4);
public static RectangleMatch[] detectRectangles(MonoImage image, RectangleDescriptor rectangleDescriptor,
CurveOptions curveOptions, ShapeDetectionOptions shapeDetectionOptions,
RegionOfInterest roi) throws NIVisionException {
int curveOptionsPointer = 0;
if (curveOptions != null)
curveOptionsPointer = curveOptions.getPointer().address().toUWord().toPrimitive();
int shapeDetectionOptionsPointer = 0;
if (shapeDetectionOptions != null)
shapeDetectionOptionsPointer = shapeDetectionOptions.getPointer().address().toUWord().toPrimitive();
int roiPointer = 0;
if (roi != null)
roiPointer = roi.getPointer().address().toUWord().toPrimitive();
int returnedAddress =
imaqDetectRectanglesFn.call6(
image.image.address().toUWord().toPrimitive(),
rectangleDescriptor.getPointer().address().toUWord().toPrimitive(),
curveOptionsPointer, shapeDetectionOptionsPointer,
roiPointer,
numberOfRectanglesDetected.address().toUWord().toPrimitive());
try {
NIVision.assertCleanStatus(returnedAddress);
} catch (NIVisionException ex) {
if (!ex.getMessage().equals("No error."))
throw ex;
}
RectanglesMatch[] matches = RectanglesMatch.getMatchesFromMemory(returnedAddress, numberOfRectanglesDetected.getInt(0));
NIVision.dispose(new Pointer(returnedAddress,0));
return matches;
}