converted camera code to c