Updated code with camera function