The paper presents an algorithm for building a map of obstacles and guiding an autonomous mobile platform in an unknown and changing environment. Depth images captured from a stereovision camera are used to detect objects and denote their location on the obstacle map. The depth images acquired from the stereocamera are encumbered with artefacts which poses the main problem in detecting obstacles. We propose a two-step filtering algorithm which is based on morphological operations and Bayesian inference. Experimental results proved the efficiency of the solution in the real environment wherein both static and mobile obstacles are present.