# Testing a Vision-Based Autonomous Drone Navigation Model in a Forest Environment
## 3 The Proposed Method  
The proposed model for drone navigation based on visual information is shown in Figure 2. Principally, there are four main components in the model: object detection to find the trees that are obstacles and masking to identify the area that can be navigated, and waypoint guiding to navigate the drone.  
The vision sensor or camera located on the drone is used in this study to identify the surrounding objects and sense the information in the environment. In short, the scene is captured as a video sequence, and is processed to extract the contextual features of the visual objects, while our proposed masking method is executed to understand the scene and provide a waypoint for guiding the navigation.  
In an environment with dynamic brightness, flying a drone is a challenging task, especially for scene understanding. In our work, the masking method is applied to perform semantic segmentation to identify a safe route to navigate in the scene.  
The first algorithm, represented in Algorithm 1, focuses on frame processing for drone navigation. It includes steps such as object detection, background adjustment, obstacle detection, spatial relationship analysis, and path determination. These steps collectively contribute to identifying clear paths for drone navigation based on the analysis of video frames. On the other hand, Algorithm 2 presents a different approach to drone navigation, incorporating object detection, semantic segmentation, thresholding for dynamic light conditions, and navigation based on contextual information derived from these processes. This algorithm emphasizes scene understanding through semantic segmentation and the identification of safe routes and bright spots for navigation.  
Figure 2: The complete flow for the proposed method.  
```
1:functionPROCESS_FRAME(frame)
2:objects\(\leftarrow\)DETECT_OBJECT(frame)
3:frame\(\leftarrow\)ADJUST_BACKGROUND(frame)
4:fov_frame\(\leftarrow\)ADD_FOV_REGION(frame)
5:obstacle_boxes\(\leftarrow\)DETECT_OBSTACLES(objects,frame)
6:clear_path\(\leftarrow\) ANALYZE_SPATIAL_RELATIONSHIP(fov_frame,obstacle_boxes)
7:path\(\leftarrow\)DETERMINE_CLEAR_PATH(clear_path)
8:returnpath
9:endfunction
10:functionDETECT_OBJECT(frame)
11:objects\(\leftarrow\)OBJECT_DETECTION_ALGORITHM(frame)\(\triangleright\)Implementation depends on the detection model
12:returnobjects
13:endfunction
14:functionADJUST_BACKGROUND(frame)
15:returnnp_zeros_like(frame)
16:endfunction
17:functionADD_FOV_REGION(frame)
18:fov_frame\(\leftarrow\)frame.copy()
19:fov_frame[FOV_REGION]\(\leftarrow\)[255, 0, 0]\(\triangleright\)Red color
20:returnfov_frame
21:endfunction
22:functionDETECT_OBSTACLES(objects,frame)
23:obstacle_boxes\(\leftarrow\)[obj['bounding_box'] for obj in objects if obj['type'] == 'tree']
24:returnobstacle_boxes
25:endfunction
26:functionanalyze_spatial_RELATIONSHIP(fov_frame,obstacle_boxes)
27:clear_path\(\leftarrow\)spatial_analySIS_ALGORITHM(fov_frame,obstacle_boxes)
28:returnclear_path
29:endfunction
30:functionDETERMINE_CLEAR_PATH(clear_path)
31:drone_path\(\leftarrow\)path_DETERMINATION_ALGORITHM(clear_path)
32:returndrone_path
33:endfunction
```  
**Algorithm 1** Clear Path Determination Algorithm