Modified code for taking pictures without preview