The very first type of camera was called camera Obscura or a pinhole camera. It is difficult to tell who exactly invented this type of the camera. But one of the most popular story is about Mozi, a Chinese philosopher.
When Mozi, observed a beam of light falling on a wall of a darkened room through a pinhole made on the opposite side of the object, he saw an inverted replica of that object. On proper research, Mozi concluded that since light travels in a straight line, this phenomenon takes place in nature. It was the building rock for modern cameras and photography.