The article proposes a new approach to the use of computer vision when controlling a robot in a dynamic environment. While moving along an unchanged path to the target point, a robot can encounter any new object (static or moving). We describe a visual analysis to determine the detection distance of moving objects to prevent collisions with the robot in a timely manner. An obstacle detection algorithm in the robot zone was developed based on data from an RGB-D video camera using computer vision methods. Based on ROS in a Gazebo virtual environment with a Turtlebot robot kit and an open source library (opencv), we adopted software implementation of the developed approaches which confirmed their applicability to the detection of objects in the mobile robot environment.