Shape detection with limited memory