The disclosure extends to methods, systems, and computer program products for detecting whether an illumination source of an endoscope is in use (inside the body of a patient) versus not in use (outside the body of a patient). The disclosure relies on the fact that the working environment is lit solely by the endoscope and its components. Thus, communication between the illumination or light source controller and the imaging device, such as a surgical camera, is required. When the illumination or light source is turned off and the endoscope is outside the body, a sensor will detect ambient light alerting the illumination source controller that it is outside the body, which then keeps the illumination source off or at a low intensity level. Conversely, when the illumination source is turned off and the endoscope is inside the body, the sensor will not detect any light (or will detect only a very low level of light). Based on this logic, if the imaging device, such as a camera, knows that the light is off during a specific period of time the frame(s) from that time period can be analyzed and the level of light gathered in the frame(s) will show the scope location either inside or outside of the body.