Updated camera code to avoid taking too many redundant pictures