This paper introduces a novel approach to indoor visual localization based on a particle filter, CNN-segmentation and the nearest edge method for particle weight estimation. A main algorithm is used by detecting the edges on the image from camera and then mapping them to a3D model of the room. The main contribution of the paper is to introduce a novel approach that allows to get rid of such problems as noise generated by textured objects, edges created by dynamic objects and groups of unexpected objects which are considered to be excessive and can be removed from localization algorithm. The algorithm described in this paper was verified on a computer model in ROS/Gazebo environment.