{'fraction_non_alphanumeric': 0.03514499044973086, 'fraction_numerical': 0.013821844070151067, 'mean_word_length': 4.7776886035313, 'pattern_counts': {'":': 0, '<': 1, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Occlusion-Aware Depth Estimation with Adaptive Normal Constraints

We present a new learning-based method for multi-frame depth estimation from a color video, which is a fundamental problem in scene understanding, robot navigation or handheld 3D reconstruction. While recent learning-based methods estimate depth at high accuracy, 3D point clouds exported from their depth maps often fail to preserve important geometric feature (e.g., corners, edges, planes) of man-made scenes. Widely-used pixel-wise depth errors do not specifically penalize inconsistency on these features. These inaccuracies are particularly severe when subsequent depth reconstructions are accumulated in an attempt to scan a full environment with man-made objects with this kind of features. Our depth estimation algorithm therefore introduces a Combined Normal Map (CNM) constraint, which is designed to better preserve high-curvature features and global planar regions. In order to further improve the depth estimation accuracy, we introduce a new occlusion-aware strategy that aggregates initial depth predictions from multiple adjacent views into one final depth map and one occlusion probability map for the current reference view. Our method outperforms the state-of-the-art in terms of depth estimation accuracy, and preserves essential geometric features of man-made indoor scenes much better than other algorithms.


Introduction
Dense multi-view stereo is one of the fundamental problems in computer vision with decades of research, e.g. [31,14,4,40,13,43]. Algorithms vastly differ in their assumptions on input (pairs of images, multi-view images etc.) or employed scene representations (depth maps, point clouds, meshes, patches, volumetric scalar fields etc.) [11].
In this paper, we focus on the specific problem of multi-view depth estimation from a color video from a single moving RGB camera [11]. Algorithms to solve this problem have many important applications in computer vision, graphics and robotics. They empower robots to avoid collisions and plan paths using arXiv:2004.00845v4 [cs.CV] 12 Jul 2021 only one onboard color camera [3]. Such algorithms thus enable on-board depth estimation from mobile phones to properly combine virtual and real scenes in augmented reality in an occlusion-aware way. Purely color-based solutions bear many advantages over RGB-D based approaches [47] since color cameras are ubiquitous, cheap, consume little energy, and work nearly in all scene conditions. Depth estimation from a video sequence is a challenging problem. Traditional methods [14,4,40,13,43] achieve impressive results but struggle on important scene aspects: texture-less regions, thin structures, shape edges and features, and non-Lambertian surfaces. Recently there are some attempts to employ learning techniques to this problem [20,16,36,41,18]. These methods train an end-to-end network typically with a pixel-wise depth loss function. They lead to significant accuracy improvement in depth estimation compared to non-learning-based approaches. However, most of these works fail to preserve prominent features of 3D shapes, such as corners, sharp edges and planes, because they use only depth for supervision and their loss functions are therefore not built to preserve these structures. This problem is particularly detrimental when reconstructing indoor scenes with man-made objects or regular shapes, as shown in Fig. 4. Another problem is the performance degradation caused by the depth ambiguity in the occluded region, which has been ignored by most of the existing works.
We present a new method for depth estimation with a single moving color camera that is designed to preserve important local features (edges, corners, high curvature features) and planar regions. It takes one video frame as reference image and uses some other frames as source images to estimate depth in the reference frame. Pairing the reference image with each source image, we first build an initial 3D cost volume from each pair via plane-sweeping warping. Subsequent cost aggregation for each initial cost volume yields an initial depth maps for each image pair (e.g. the reference image and a source image). Then we employ a new occlusion-aware strategy to combine these initial depth maps into one final reference-view depth map, along with an occlusion probability map.
Our first main contribution is a new structure preserving constraint enforced during training. It is inspired by learning-based monocular depth estimation methods using normal constraints for structure preservation. GeoNet [29] enforces a surface normal constraint, but their results have artifacts due to noise in the ground truth depth. Yin et al. [42] propose a global geometric constraint, called virtual normal. However, they cannot preserve intrinsic geometric features of real surfaces and local high-curvature features. We therefore propose a new Combined Normal Map (CNM) constraint, attached to local features for both local high-curvature regions and global planar regions. For training our network, we use a differentiable least squares module to compute normals directly from the estimated depth and use the CNM as ground truth in addition to the standard depth loss. Experiments in Section 5.2 show that the use of this novel CNM constraint significantly improves the depth estimation accuracy and outperforms those approaches that use only local or global constraints.
Our second contribution is a new neural network that combines depth maps predicted with individual source images into one final reference-view depth map, together with an occlusion probability map. It uses a novel occlusion-aware loss function which assigns higher weights to the non-occluded regions. Importantly, this network is trained without any occlusion ground truth.
We experimentally show that our method significantly outperforms the stateof-the-art multi-view stereo from monocular video, both quantitatively and qualitatively. Furthermore, we show that our depth estimation algorithm, when integrated into a fusion-based handheld 3D scene scanning approach, enables interactive scanning of man-made scenes and objects in much higher shape quality (See Fig. 6).

Related Work
Multi-view stereo. MVS algorithms [14,4,40,13,43] are able to reconstruct 3D models from images under the assumptions of known materials, viewpoints, and lighting conditions. The MVS methods vary significantly according to different scene representations, but the typical workflow is to use hand-crafted photoconsistency metrics to build a cost volume and do the cost aggregation and estimate the 3D geometry from the aggregated cost volume. These methods tend to fail for thin objects, non-diffuse surfaces, or the objects with insufficient features. Learning-based depth estimation. Recently some learning-based methods achieve compelling results in depth estimation. They can be categorized into four groups: i) single-view depth estimation [9,25,22,10]; ii) two-view stereo depth estimation [44,26,34,5,20]; iii) multi-view stereo depth estimation [16,41,18]; iv) depth estimation from a video sequence [36,23]. Single-view depth estimation is an ill-posed problem due to inherent depth ambiguity. On the other hand, two-view and multi-view depth estimation [11] is also challenging due to the difficulties in dense correspondence matching and depth prediction in featureless or specular regions. Some two-view [44,26,5,20] and multi-view [16,36,41,18] depth estimation algorithms have produced promising results in accuracy and speed by integrating cost volume generation, cost volume aggregation, disparity optimization and disparity refinement in an end-to-end network.
Depth estimation from video frames is becoming popular with the high demand in emerging areas, such as AR/VR, robot navigation, autonomous driving and view-dependent realistic rendering. Wang et al. [36] design a real-time multi-view depth estimation network. Liu et al. [23] propose a Bayesian filtering framework to use frame coherence to improve depth estimation. Since these methods enforce depth constraint only, they often fail to preserve important geometric feature (e.g., corners, edges, planes) of man-made scenes. Surface normal constraint. Depth-normal consistency has been explored before for the depth estimation task [8,46,29,42]. Eigen et al. [8] propose a neural network with three decoders to separately predict depth, surface normal and segmentation. Zhang et al. [46] enforce the surface normal constraint for depth completion. Qi et al. [29] incorporate geometric relations between depth and surface normal by introducing the depth-to-normal and normal-to-depth networks. The performance of these methods suffers from the noise in surface normal stemming from ground truth depth. Yin et al. [42] propose a global geometric constraint, called virtual normal, which is defined as the normal of a virtual surface plane formed by three randomly sampled non-collinear points with a large distance. The virtual normal is unable to faithfully capture the geometric features of real surfaces and the local high-curvature features. Kusupati et al. [21] use the sobel operator to calculate the spatial gradient of depth and enforce the consistency of the spatial gradient and the normal in the pixel coordinate space. However the gradient calculated by the sobel operator is very sensitive to local noise, and causes obvious artifacts in the surface normal calculated from estimated depth (See Fig. 5 for the visual result). Occlusion handling for depth estimation. Non-learning methods [19,7,39,37,27,1] use post-processing, such as left-right consistency check [7], to handle the occlusion issue. There are some learning-based methods for handling occlusion as well. Ilg et al. [17] and Wang et al. [35] predict occlusions by training a neural network on a synthetic dataset in a supervised manner. Qiu et al. [30] directly learn an intermediate occlusion mask for a single image; it has no epipolar geometry guarantee and just drives network to learn experienced patterns. We propose an occlusion-aware strategy to jointly refine depth prediction and estimate an occlusion probability map for multi-view depth estimation without any ground truth occlusion labels.

Method
In this section we describe the proposed network, as outlined in Fig. 1. Our pipeline takes the frames in a local time window in the video as input. Note that in our setting the video frame rate is 30 fps and we sample video frames with the interval of 10.
For the sake of simplicity in exposition, we suppose that the time window size is 3. We take the middle frame as the reference image I ref , and the two adjacent images as the two source images {I 1 s , I 2 s } which are supposed to have sufficient overlap with the reference image. Our goal is to compute an accurate depth map from the view of the reference image.
We first outline our method. With a differentiable homography warping operation [41], all the source images are first warped into a stack of different frontoparallel planes of the reference camera to form an initial 3D cost volume (see Section 3.1). Next, cost aggregation is applied to the initial cost volume to rectify any incorrect cost values and then an initial depth map is extracted from the aggregated cost volume. Besides pixel-wise depth supervision over the initial depth map, we also enforce a novel local and global geometric constraint, namely Combined Normal Map (CNM), for training the network to produce superior results (see Section 3.2). We then further improve the accuracy of depth estimation by applying a new occlusion-aware strategy to aggregate the depth predictions from different adjacent views into one depth map for the reference  view, with an occlusion probability map (see Section 3.3). The details of each step will be elaborated in the subsequent sections.

Differentiable Homography Warping
Consider the reference image I ref and one of its source images, denoted I i s . We warp I i s into fronto-parallel virtual planes of I ref to form an initial cost volume. Similar to [16,41], we first uniformly sample D depth planes at depth d n in a range [d min , d max ], n = 1, 2, . . . , D. The mapping from the the warped I i s to the n th virtual plane of I ref at depth d n is determined by a planar homography transformation H n , following the classical plane-sweeping stereo [12].
where u is the homogeneous coordinate of a pixel in reference image, u n is projected coordinate of u in source image I i s with virtual plane d n . K denotes the intrinsic parameters of the camera, {R s,i , t s,i } are the rotation and the translation of the source image I i s relative to the reference image I ref . Next, we measure the visual consistency of the warped I i s and I ref at depth d n and build a cost volume C i with the size of W × H × D, where W, H, D are the image width, image height and the number of depth planes, respectively. Unlike previous works [41,23] that use extracted feature maps of an image pair for warping and building a 4D cost volume, here we use the image pair directly to avoid the memory-heavy and time-consuming 3D convolution operation on a 4D cost volume.

DepthNet for Initial Depth Prediction
Similar to recent learning-based stereo [20] and MVS [41,18] methods, after getting cost volumes we first use the neural network DepthNet to do cost aggregation for each C i , which rectifies the incorrect values by aggregating the neighbouring pixel values. Note that we feed C i stacked with I s together into the DepthNet in order to make use of more detailed context information as [36] does. We denote the aggregated cost volume as V i . Next, we retrieve the initial depth map D i ref from the aggregated cost volume V i using a 2D convolution layer. Note that two initial depth maps, We train the network with depth supervision. With only depth supervision, the point cloud converted from the estimated depth does not preserve regular features, such as sharp edges and planar regions. We therefore propose to also enforce the normal constraint for further improvement. Note that, instead of just using local surface normal [29] or just a global virtual normal [42], we use the so called Combine Normal Map (CNM) that combines the local surface normal and the global planar structural feature in an adaptive manner.
Pixel-wise Depth Loss We use a standard pixel-wise depth map loss as follows, where Q is the set of all pixels that are valid in ground truth depth,D(q) is the ground truth depth value of pixel q, and D i (q) is the initial estimated depth value of pixel q. Combined Normal Map In order to preserve both local and global structures of scenes, we introduce the Combined Normal Map (CNM) as ground truth for the supervision with the normal constraint. To obtain this normal map, we first use PlaneCNN [24] to extract planar regions, such as walls, tables, and floors. Then we apply the local surface normals to non-planar regions, and use the mean of the surface normals in a planar region as the assigned to the region. The visual comparison of the local normal map and the CNM can be seen in Fig. 2.
The key insight here is to use local surface normal to capture rich local geometric features in the high-curvature regions and to employ the average normal to filter out noise in the surface normals for the planar regions to preserve global structures. In this way, the CNM significantly improves the depth prediction and the recovery of good 3D structures of the scene, compared to using only local or global normal supervision (see the ablation study in Section 5.4).
Combined Normal Loss We define the loss on the CNM as follows: Local normal map Combined normal map Plane segmentation where Q is the set of valid ground truth pixels,N (q) is the combined normal of pixel q, and N i (q) is the surface tangent normal of the 3D point corresponding to the pixel q, both normalized to unit vectors.
To obtain an accurate depth map and preserve geometric features, we combine the Pixel-wise Depth Loss and the Combined Normal Loss together to supervise the network output. The overall loss is: where λ is a trade-off parameter, which is set to 1 in all experiments.

Occlusion-aware RefineNet
The next step is to combine the initial depth maps s or I 2 s . In contrast to treating all pixels equally, when calculating the loss we assign the lower weights to the occluded region and the higher weights to the non-occluded region, which shifts the focus of the network to the non-occluded regions, since the depth prediction in the non-occluded regions is more reliable. Furthermore, the occlusion probability map predicted by the network can be used to filter out unreliable depth samples, as shown in Fig. 3, which is useful when the depth maps are fused for 3D reconstruction (see more details in Section 5.4).
Here we describe more technical details of this step. We design the RefineNet to predict the final depth map and the occlusion probability map from the average cost volumeV of the two cost volumes {V i } i=1,2 and two initial depth maps The RefineNet has one encoder and two decoders. The first decoder estimates the occlusion probabilities based on the occlusion information encoded in the average cost volumeV and the initial depth maps. Intuitively, for a pixel in the non-occluded region, it has the strongest response (peak) at n th layer with depth d n of the average cost volumeV , and different values on the initial depth maps at this pixel. The other decoder predicts the refined depth map with the depth constraint and the CNM constraint, as described in Section 3.2 To train the RefineNet, we design a novel occlusion-aware loss function as follows, where Here D r (q) denotes the refined estimated depth at pixel q, N r (q) denotes the surface normal of the 3D point corresponding to q,D(q) is the ground truth depth of q,N (q) is the combined normal of q, and P (q) denotes the occlusion probability value of q (P (q) is high when q is occluded). The weight α is set to 0.2 and β is set to 1 in all experiments.

Datasets and Implementation Details
Dataset We train our network with the ScanNet dataset [6], and evaluate our method on the 7scenes dataset [32] and the SUN3D dataset [38]. ScanNet consists of 1600 different indoor scenes, which are divided into 1000 for training and 600 for testing. ScanNet provides RGB images, ground truth depth maps and camera poses. We generate the CNM as described in Section 3.  [36] and neuralrgbd [23]. Our estimated depth maps preserve shape regularity better than by mvdepthnet and neuralrgbd, for example, in the regions of sofa, cabinet and wall. The result by mvdepthnet (colum 2) shows strong discontinuity of depth value at the lower end of the red wall, which is incorrect. We also show the visualization of normal maps computed from these depth maps to further show the superior quality of our depth estimation in terms of shape regularity. Note that the red region of GT depth (black region of GT normal) is invalid due to scanning failure of the Kinect sensor. More comparisons can be found in the supplementary materials and run for 6 epochs for each stage. We implemented our model in Pytorch [28]. Training the network with two GeForce RTX 2080 Ti GPUs, which takes two days for all stages.

Experiments
To evaluate our method, we compare our method with state-of-the-arts in three aspects: accuracy of depth estimation, geometric consistency, and video-based 3D reconstruction with TSDF fusion.

Evaluation Metrics
For depth accuracy, we compute the widely-used statistical metrics defined in [9]: i) accuracy under threshold (σ < 1.25 i where i ∈ {1, 2, 3}); ii) scale-invariant error (scale.inv); iii) absolute relative error (abs.rel); iv) square relative error (sq.rel); iv) root mean square error (rmse); v) rmse in log space (rmse log). We evaluate the surface normal accuracy with the following metrics used in the prior works [8,29]: i) the mean of angle error (mean); ii) the median of the angle error (median); iii) rmse; iv) the percentage of pixels with angle error below threshold t where t ∈ [11.25 • , 22.5 • , 30 • ]. Table 1. Comparison of depth estimation over 7-Scenes dataset [32] with the metrics defined in [9].

Comparisons
Depth prediction We compare our method with several other depth estimation methods. We categorize them according to their input formats: i) one single image: DORN [10], GeoNet [29] and VNL [42]; ii) two images from monocular camera: DeMoN [34]; iii) multiple unordered images: MVSNet [41], DPSNet [18], kusupati et al. [21]; iv) a video sequence: mvdepthnet [36] and neuralrgbd [23]. The models provided by these methods were trained on different datasets and are evaluated on a separate dataset, 7Scenes dataset [32]. For the multi-view depth estimation methods, neuralrgbd [23] and kusupati et al. [21] are trained on ScanNet, MVSNet [41] is trained on DTU dataset [2], mvdepthnet [36] and DP-SNet [18] are trained on mixed datasets (SUN3D [38], TUM RGB-D [33], MVS datasets [34], SceneNN [15] and synthetic dataset Scenes11 [34]). For fair comparison, we further retrained MVSNet [41], mvdepthnet [36] and DPSNet [18] on ScanNet. Table 1 shows that our method outperforms other methods in terms of all evaluation metrics. Visual comparison In Fig. 4, compared to mvdepthnet [36] and neuralrgbd [23], our estimated depth map has less noise, sharper boundaries and spatially consistent depth values, which can be also seen in the surface normal visualization. Furthermore, the 3D point cloud exported from the estimated depth preserves global planar features and local features in the high-curvature regions. More comparison examples are included in the supplementary materials. Surface normal accuracy To evaluate the accuracy of normal calculated from estimated depth, we choose two single-view depth estimation methods: GeoNet [29] and Yin et al. [42], and one multi-view depth estimation method: Kusupati et al. [21]. GeoNet [29] incorporates surface normal constraint to depth estimation, while Yin et al. [42] propose a global normal constraint, namely Virtual Normal, which is defined by three randomly sampled non-collinear points. Table 2. Evaluation of the calculated surface normal from estimated depth on 7scenes [32] and SUN3D [38]."Ours with VNL" denotes our model retrained using virtual normal loss [42].  Kusupati et al. [21] use the sobel operator to calculate depth gradient and enforce the consistency of the depth gradient and the normal in the pixel coordinate space. To demonstrate that the improved performance of our method indeed benefits from the new CNM constraint (rather than entirely due to our multi-view input), we also retrained our network by replacing the Combined Normal Loss with the Virtual Normal loss (denoted as "Ours with VNL" in Table 2) on ScanNet dataset. As shown in Table 2 and Fig. 5, our method outperforms GeoNet [29], Yin et al. [42] and Kusupati et al. [21] both quantitatively and qualitatively. Compared with our model retrained using VNL, our model with the CNM constraint works much better, which preserves local and global features.

Video Reconstruction
With the high-fidelity depth map and the occlusion probability map obtained by our method, high-quality reconstruction of video even in texture-less environments can be achieved by applying TSDF fusion method [45]. We compare our method with mvdepthnet [36] and neuralrgbd [23]. Note that these three methods are all trained on the ScanNet dataset. As shown in Fig. 6, even for white walls, feature-less sofa and table, our reconstructed result is much better than the other two methods in the aspects of local and global structural recovery, and completion. Also, the color of our reconstruction is closest to the color of Table 3. Evaluation of the usefulness of CNM and the occlusion-aware refinement module. The first four rows show the results without any constraint, with only local normal constraint, with only global normal constraint, and with the CNM constraint respectively. The last two rows show the results without/with the occlusion-aware loss.  the ground truth. This confirms that the individual depth maps have less noise and high-consistency so the colors would not be mixed up in the fusion process.

Ablation studies
Compared with prior works, we explicitly drive the depth estimation network to adaptively learn local surface directions and global planar structures. Taking multiple views as inputs, our refinement module jointly refines depth and predicts occlusion probability. In this section, we evaluate the usefulness of each component.
Combined normal map As shown in Table 3, enforced by our CNM constraint (local + global), our model achieves better performance in terms of estimated depth and calculated normal from estimated depth, compared to that without geometric constraint, only with local normal constraint, and only with global  normal constraint (the plane normal constraint). Fig. 7 also shows that with CNM, the calculated normal is more consistent in planar regions and the point cloud converted from estimated depth keeps better shape. The number of source views for refinement Our refinement module can allow any arbitrary even number of source views as input, and generate a refined depth map and an occlusion probability map. In Table 3, with refinement module, the performance of our model has been significantly improved. As shown in Table 4, the quality of refined depth will be improved gradually with the increase of source views. A forward pass with 2/4/6 source views all takes nearly 0.02s on a GeForce RTX 2080 Ti GPU. Furthermore, we evaluate how the performance is affected by the choice of the reference view. We find that the performance of our model will degrade significantly if we use the last frame as the reference view rather than the middle frame in the local time window. This is because the middle frame shares more overlapping areas than the last frame with the other frames in the time window.
The usefulness of occlusion probability map Unlike left-right check as a post-processing operation, our RefineNet jointly refines depth and generates an occlusion probability map. As shown in Table. 3, our model with the occlusionaware refinement achieves better results than that with a naive refinement (w/o GT w/o occlusion map w/ occlusion map target Fig. 8. Effect of occlusion probability map for video reconstruction. The occlusion probability map provides weighting parameters into TSDF fusion system for fusing estimated depth maps, and enables reconstructed model to keep sharp boundaries. occlusion map) and without any refinement. The naive refinement treats every pixel equally regardless whether it is on the occluded region or non-occluded region. In contrast, our occlusion-aware refinement penalizes occluded pixels less and pays more attention to the non-occluded region. In Fig. 3, the point cloud converted from estimated depth becomes cleaner and has sharp boundaries by applying the occlusion probability map to the multi-view depth integration process. Moreover unlike binary mask, our occlusion map can be easily used in TSDF fusion system [45] as weights. In Fig. 8, the fused mesh using estimated depth and the occlusion probability map has less artifact than that without occlusion map.

Conclusion and Limitations
In this paper, we propose a new method for estimating depth from a video sequence. There are two main contributions. We propose a novel normal-based constraint CNM, which is designed to preserve local and global geometric features for depth estimation, and a new occlusion-aware strategy to aggregate multiple depth predictions into one single depth map. Experiments demonstrate that our method outperforms than the state-of-the-art in terms of the accuracy of depth prediction and the recovery of geometric features. Furthermore, the highfidelity depth prediction and the occlusion detection make the highly-detailed reconstruction with only a commercial RGB camera possible. Now we discuss the limitations of our work and possible future directions. First, the performance of our method relies on the quality of the CNM, which is based on the segmentation of global planar regions. It has been observed that existing plane segmentation methods are not robust for all the scenes. One possible solution is to jointly learn the segmentation labels and the depth prediction. Second, for the task of video-based 3D reconstruction, our work can be extended by designing an end-to-end network to directly generate 3D reconstruction from video, rather than having to invoke the explicit step of using TSDF fusion to integrate the estimated depth maps.