A method of generating an occupancy map representing free and occupied space around a vehicle, wherein the occupancy map is divided into a plurality of cells M x,y, the method comprising: capturing two consecutive images by a camera mounted on the vehicle while the vehicle is moving; generating optical flow vectors from the two consecutive images; estimating 3D points in the space around the vehicle from the optical flow vectors; generating rays from the camera to each of the estimated 3D points, wherein the cells M x,y structure the space around the vehicle and intersection points of the rays with the cells M x,y in the space around the vehicle define further 3D points; determining for each of the cells M x,y a function L x, y t for a time step t: L x, y t = L x, y t − 1 + ∑ i log P M x, y | h i, d i 1 − P M x, y | h i, d i, wherein i denotes the 3D points located within the respective cell M x,y and each of the 3D points i is defined by a height h i above ground and a distance d i between the 3D point i and a 3D point on the respective ray where the ray hits the ground or an object, wherein P ( M x,y | h i,d i) is a function of ∑ S P M x, y | S, h i L S | d i ∑ S L S | d i, wherein P ( M x,y | S,h i) is an occupancy probability contribution of a 3D point i dependent on a status S of the 3D point i and the height h i, L ( S | d i) is a likelihood of the status of the 3D point i dependent on the distance d i, and S = {hit, pass, covered}, wherein the status S of a 3D point i is S = hit if the 3D point hits the ground or an object, S = pass if the 3D point is located between the camera and the 3D point on the respective ray where the ray hits the ground or an object, and S = covered if the 3D point is located on the respective ray beyond the 3D point on the respective ray where the ray hits an object; wherein the a-priori probability P(M x,y) is assumed to be 0.5 such that the term log 1 − P M x, y P M x, y vanishes; and determining an occupancy probability P t ( M x,y) from the function L x, y t for each of the cells M x,y by using a predetermined transformation function for transforming a log-odds ratio to probability. capturing two consecutive images by a camera mounted on the vehicle while the vehicle is moving; generating optical flow vectors from the two consecutive images; estimating 3D points in the space around the vehicle from the optical flow vectors; generating rays from the camera to each of the estimated 3D points, wherein the cells M x,y structure the space around the vehicle and intersection points of the rays with the cells M x,y in the space around the vehicle define further 3D points; determining for each of the cells M x,y a function L x, y t for a time step t: L x, y t = L x, y t − 1 + ∑ i log P M x, y | h i, d i 1 − P M x, y | h i, d i, wherein i denotes the 3D points located within the respective cell M x,y and each of the 3D points i is defined by a height h i above ground and a distance d i between the 3D point i and a 3D point on the respective ray where the ray hits the ground or an object, wherein P ( M x,y | h i,d i) is a function of ∑ S P M x, y | S, h i L S | d i ∑ S L S | d i, wherein P ( M x,y | S,h i) is an occupancy probability contribution of a 3D point i dependent on a status S of the 3D point i and the height h i, L ( S | d i) is a likelihood of the status of the 3D point i dependent on the distance d i, and S = {hit, pass, covered}, wherein the status S of a 3D point i is S = hit if the 3D point hits the ground or an object, S = pass if the 3D point is located between the camera and the 3D point on the respective ray where the ray hits the ground or an object, and S = covered if the 3D point is located on the respective ray beyond the 3D point on the respective ray where the ray hits an object; wherein the a-priori probability P(M x,y) is assumed to be 0.5 such that the term log 1 − P M x, y P M x, y vanishes; and determining an occupancy probability P t ( M x,y) from the function L x, y t for each of the cells M x,y by using a predetermined transformation function for transforming a log-odds ratio to probability.