code: private void configureContourDetector(T gray) {
  		// determine the maximum possible size of a square based on image size
  		int maxContourSize = Math.min(gray.width,gray.height)*4;
  		BinaryContourFinder contourFinder = squareDetector.getDetector().getContourFinder();
  		contourFinder.setMaxContour(maxContourSize);
  		contourFinder.setSaveInnerContour(false);
  	}
docs: Configures the contour detector based on the image size. Setting a maximum contour and turning off recording
  of inner contours and improve speed and reduce the memory foot print significantly.