Computer Science
Computer Science-2021.gz:143336
Computer Science
099d059990300565771903f53517fccb499a69a8
Consistent Depth of Moving Objects in Video

We present a method to estimate depth of a dynamic scene, containing arbitrary moving objects, from an ordinary video captured with a moving camera. We seek a geometrically and temporally consistent solution to this underconstrained problem: the depth predictions of corresponding points across frames should induce plausible, smooth motion in 3D. We formulate this objective in a new test-time training framework where a depth-prediction CNN is trained in tandem with an auxiliary scene-flow prediction MLP over the entire input video. By recursively unrolling the scene-flow prediction MLP over varying time steps, we compute both short-range scene flow to impose local smooth motion priors directly in 3D, and long-range scene flow to impose multi-view consistency constraints with wide baselines. We demonstrate accurate and temporally coherent results on a variety of challenging videos containing diverse moving objects (pets, people, cars), as well as camera motion. Our depth maps give rise to a number of depth-and-motion aware video editing effects such as object and lighting insertion.


Reprojected video x-t slice
Our method estimates geometrically and temporally consistent depth from a general video containing fast-moving objects and camera motion. The input video (a) contains a continuous camera dolly motion following the moving person and puppy. This is a difficult case for depth estimation due to the correlated motion between camera and subject. The video is shown reprojected into the camera at frame using our predicted depth (b), with disparity maps of the re-projection shown below (c). On the right: − slices for the horizontal line marked in red on frame in (a). The slice of the original video (top) shows both camera and objects' motion (slanted lines in the background, twisted lines in the foreground). The slice of the re-projected frames (middle) shows the camera fixed relative to the background (vertical lines), and foreground objects moving relative to the camera (twisted lines).
We present a method to estimate depth of a dynamic scene, containing arbitrary moving objects, from an ordinary video captured with a moving camera. We seek a geometrically and temporally consistent solution to this underconstrained problem: the depth predictions of corresponding points across frames should induce plausible, smooth motion in 3D. We formulate this objective in a new test-time training framework where a depth-prediction CNN is trained in tandem with an auxiliary scene-flow prediction MLP over the entire input video. By recursively unrolling the scene-flow prediction MLP over varying time steps, we compute both short-range scene flow to impose local smooth motion priors directly in 3D, and long-range scene flow to impose multi-view consistency constraints with wide baselines. We demonstrate accurate and temporally coherent results on a variety of challenging videos containing diverse moving objects (pets, people, cars), as well as camera motion. Our depth maps give rise to a number of depth-and-motion aware video editing effects such as object and lighting insertion.

INTRODUCTION
Estimating the geometry of moving objects from ordinary videoswhere both the camera and objects in the scene are moving-is an open, underconstrained problem. For any video of a moving object, there is a space of solutions that satisfy the visual evidence: the object could be far away and moving fast, or close and moving slowly. Thus, prior knowledge about objects' motion or shape is necessary to estimate geometry of moving objects in video. Learning geometric priors directly from data has proven to be a promising approach that facilitates geometry estimation in unconstrained setups such as predicting depth from a single RGB image (RGB-to-depth), or from a video where both the camera and the people in the scene are moving. In such cases, epipolar geometry constraints break and triangulation-based methods are not applicable, so the solution is determined by learned geometric priors. Such geometric priors are typically learned from a large dataset containing visual data (images/videos), and their corresponding depth maps, which are used as supervision during training. While powerful, a purely data-driven approach has two main weaknesses in the case of arbitrary moving objects in a monocular video: (i) scarcity of training data-video datasets of dynamic scenes with ground truth depth are still limited and only available for specific class of objects (e.g., moving people [Li et al. 2019[Li et al. , 2020a), (ii) temporal consistency-feed-forward models for videos consider a fixed, short-range window of inputs (often one or two frames), resulting in inconsistent geometry and flickering depth over time.
Instead of relying entirely on data, we take a hybrid approach and initialize a solution from geometric priors learned from a large dataset, then optimize the solution to satisfy space-time geometric constraints. This approach is inspired by the recent work of [Luo et al. 2020], which finetunes a monocular depth prediction model for a video by assuming a static scene and requiring depth estimates for corresponding pixels to be consistent across frames. Our method generalizes this approach to videos of dynamic scenes by explicitly modeling scene flow, i.e., the 3D motion of objects in the scene.
We seek a geometrically and temporally consistent solution: the depth and scene flow at corresponding points should to be consistent over frames, and the scene flow should change smoothly in time. Our key contribution is a formulation of this ill-posed problem via the optimization of two networks: a depth-prediction CNN that takes an RGB frame as input and outputs a dense depth map; and an auxiliary scene-flow-prediction multi-layer perceptron (MLP) that takes a 3D point as input and outputs its 3D velocity vector. The depth network is first initialized using a data-driven prior (pretrained weights), and then finetuned in tandem with the scene-flow network for a given input video, using a smooth-motion prior and multi-view consistency losses. As in [Luo et al. 2020], we compute camera poses and optical flow between pairs of frames in a pre-processing step and use them as input.
Our scene-flow MLP plays two important roles: (1) it provides an explicit, 3D representation of scene flow that aggregates information over space and time through the shared weights of the network, and produces plausible flow in cases where an analytic solution derived from depth and optical flow is unstable (e.g., nearly parallel rays between two points, as shown in Section 5.1.). (2) it provides a mechanism to form scene flow estimates over varying time steps. As demonstrated by stereo and MVS methods, wide baseline correspondences are required to accurately estimate depth, but smooth-motion priors must be evaluated locally. The scene-flow MLP, which maps a 3D point at time to its velocity vector (3D offset between and + 1), can be evaluated recursively by unrolling. This allows us to compute long-range scene flow to apply multi-view consistency losses between distant frames, and short-range scene flow to apply a smooth motion prior.
We demonstrate detailed, accurate, and temporally-consistent depth maps produced from ordinary videos with multiple, nonrigid, rapidly-moving objects (Fig. 1). We evaluate and ablate our method quantitatively and show 40-45% reduction in 1 relative error vs. single-view depth prediction, and show various depth and motion aware editing effects in videos made possible by our depth and scene flow estimates.

RELATED WORK
Learning-based depth prediction. Deep learning based methods for predicting depth under different setups have demonstrated a dramatic improvement in recent years. Numerous methods have been proposed to predict depth from a single RGB image. Such methods typically use a feed-forward CNN-based model and can be divided into two main categories: supervised methods that regress to ground-truth depth maps given a large dataset of images and their corresponding depth maps Eigen et al. 2014;Fu et al. 2018;Li and Snavely 2018;Ranftl et al. 2020;Wang et al. 2019;Xian et al. 2018], and self-supervised methods [Casser et al. 2019a;Godard et al. 2017Godard et al. , 2019Yin and Shi 2018;Zhou et al. 2017] that learn depth prediction by optimizing for photometric consistency, either using stereo images or monocular video. To handle moving objects in training videos, self-supervised methods predict an optical flow field as an additional task (e.g. Yin and Shi 2018]), or learn to mask out moving objects (e.g. [Godard et al. 2019]).
Once trained, single-frame methods are agnostic to moving objects, and can be applied to any video in a frame-by-frame fashion. However, because depth is predicted independently per-frame, such an approach results in temporally inconsistent estimates. The loss of epipolar constraints also means single-view prediction lags in accuracy over multi-view stereo (MVS) methods Seitz et al. 2006] for stationary regions.
Geometry estimation of dynamic scenes. Methods for estimating geometry of a dynamic scene roughly fall into two major categories. The first category of works aim to solve this problem by considering either a multi-camera setup where epipolar geometry constrains can be applied, or using RGBD data (e.g., [Bansal et al. 2020;Basha et al. 2012Basha et al. , 2013Dou et al. 2016;Innmann et al. 2016;Newcombe et al. 2015;Richardt et al. 2016;Wedel et al. 2011]). The second category of works aim to tackle this problem using monocular videos, which is a more challenging and ill-posed task. To deal with such challenges, some approaches aim to reconstruct the geometry of a dynamic scene by limiting in the type of scenes and objects' motion [Park et al. 2010b;Ranftl et al. 2016;Russell et al. 2014;Simon et al. 2017].
Other methods combine data-driven priors with multi-view stereo methods [Li et al. 2019;Rematas et al. 2018;Yoon et al. 2020]. For example, [Li et al. 2019] uses parallax between two RGB frames to estimate depth in static parts of the image, then inpaints the depth of dynamic regions using a depth-prediction network.
In contrast, our method optimizes a pre-trained depth prediction network over the entire video at test-time to produce consistent estimations. The fusion method of [Yoon et al. 2020] uses the entire video to compute MVS estimates that are combined with a singleview CNN prediction using a learned module. Our method does not require MVS depth as input, only camera poses, and does not require training a fusion module. In addition, some methods [Klingner et al. 2020;Patil et al. 2020] use semantic information to guide depth prediction and identify moving objects during training. Those methods usually focuses on specific scenarios such as autonomous driving.
Our method does not require semantic information and aims to solve for consistent depth maps for general videos.
Test-time training for depth estimation. Recently, test-time training methods for depth estimation [Casser et al. 2019b;Chen et al. 2019;Luo et al. 2020] have appeared, which use deep neural networks as optimizers: given an objective function defined over the test data, the variables of optimization are the weights of a deep network that predicts the unknowns, rather than the unknowns themselves. By finetuning a pre-trained network on a single video, these methods both apply data-driven depth priors and aggregate information across the entire video. The method of [Casser et al. 2019b] segments the video and proposes separate motion models for each segment, whereas our scene-flow MLP learns a global motion model. Compared to GLNet [Chen et al. 2019], we explicitly model 3D motion, rather than deriving it from optical flow and depth. We show that this explicit model of motion is important for stability and long-range correspondence. Most closely related to our work is [Luo et al. 2020], which shares our goal of accurate, temporally-consistent depth from video. While their method tolerates small amounts of object motion, it fundamentally assumes a stationary scene, whereas our method is designed to handle large object motion.
Reconstruction from smooth motion priors and non-rigid SfM. Prior to the rise of data-driven methods, reconstruction of dynamic scenes was explored using Nonrigid Structure-from-Motion [Torresani et al. 2008].
Multi-view stereo methods typically treat dynamic objects as outliers and produce either empty or spurious estimates in moving regions. NSfM methods produce estimates for moving regions by solving a reduced dimension approximation of the problem, or by applying additional losses such as smooth-motion priors (see [Jensen et al. 2020] for a recent survey).
The effectiveness of an explicit smooth-motion prior depends heavily on accurate tracking, a notoriously difficult problem in itself. NSfM methods use sparse feature tracks (e.g. [Vo et al. 2016]) or build an explicit geometric model and fit it to 2D observations (e.g. [Torresani et al. 2008]). However, feature tracking can only track sparse points, while explicit geometric models fail to capture real-world sequences with complex motions. Instead, we train an MLP to predict a dense scene flow field at all points in 3D, and apply a smooth-motion prior directly to the outputs of the MLP. A similar method of predicting scene flow was used by [Niemeyer et al. 2019] to align body scans, however they did not take advantage of the unrolling capability of the MLP.
Concurrent Work. Concurrent to our work, several methods have been proposed to tackle reconstruction of dynamic scenes captured by a moving camera. Dynamic NeRF methods aim at generalizing the original Neural Radiance Field framework [Mildenhall et al. 2020] to dynamic scenes by modeling and estimating the scene motion either using a locally-rigid deformation [Park et al. 2020], or a scene flow field [Li et al. 2020b]. Their training loss is primarily a reconstruction loss over the RGB video frames. These methods have demonstrated impressive results for synthesizing novel views of a dynamic scene, but they are currently limited to short (2 seconds) videos [Li et al. 2020b], or small motions [Park et al. 2020]. In contrast to NeRFbased methods, our main goal is to estimate general purpose depth maps for long videos with arbitrary camera and object motion.
Robust CVD ] also aims to produce depth maps from monocular video, in addition to estimating camera poses. Their method also applies a pre-trained depth prediction model but does not model the 3D motion in the scene, instead assuming that the depth error in dynamic regions can be removed using a spatially and temporally smooth scaling of the initial depth. In contrast, our method finetunes the weights of the depth prediction network while estimating a dense scene-flow field for each frame, and so can resolve initial depth errors that cannot be resolved by smooth scaling. Figure 2 illustrates the pipeline of our method. Our system takes a calibrated video as input where both the objects in the scene and the camera are naturally moving, and predicts per-frame depth maps. This is done via an optimization framework where two networks are trained, at test time, on the input video: (i) a single-frame CNN depth prediction model that takes an RGB image as input and outputs a depth map. (ii) a scene flow MLP prediction model that takes a 4D point ( , , , ) as input and outputs its 3D displacement to the next time step + 1. Both the depth and the scene flow networks are trained jointly where the depth network is initialized with a pre-trained monocular depth prediction model (e.g., [Li et al. 2020a] or [Ranftl et al. 2020]), and then finetuned over the input video; this initialization equips our model with depth priors learned from external source of data [Luo et al. 2020]. The scene flow module allows us to explicitly model the 3D motion of arbitrary dynamic objects in the scene, and is trained from scratch.

METHOD 3.1 Overview
In a pre-processing step, we compute camera poses of all the frames and optical flow fields between pairs of frames { , } using off-the-shelf techniques (Section 3.2). The computed camera poses and optical flow fields are used to apply two types of re-projection losses: a flow consistency loss, i.e., we require that the 2D displacement field between two frames resulting by projecting the predicted depth and scene flow onto 2D would match the pre-computed 2D optical flow field between the frames; we further apply a depth consistency loss which encourages coherency between the depth and scene flow estimates across different frames. Finally, we impose a local linear motion prior on the predicted scene flow to reduce the inherent ambiguity between depth and motion. We next describe each of these losses in detail.

Pre-processing
We use a similar pre-processing strategy by presented by [Luo et al. 2020 Fig. 2. Pipeline. Our system takes as input an ordinary video with freelymoving camera and scene objects and predicts a depth map for each frame of the video. We assume known camera poses and compute optical flow between frames in a per-processing step. Our system consists of two networks: A depth prediction CNN , which takes (RGB frame) as input and outputs a depth map ; we initialize this network with a pre-trained monocular depth model (e.g., [Li et al. 2020a]); and a scene flow MLP , which takes a space-time point, ( , , , ), as input and outputs its scene flow vector, i.e., 3D displacement vector w.r.t. + 1. The depth and scene flow networks are trained jointly in a self-supervised manner under two losses: L 2D measures the difference between the induced flow and the input optical flow, while L disp measures the difference between the induced depth at time and the predicted depth at time . We further apply a constant velocity prior on the scene flow vectors (see Section 3.3).
backwards optical flow + → are computed between subsequent frames ( = 1) and between a subset of wide-baseline frame pairs ( ∈ [2, 4, 6, 8]) using RAFT [Teed and Deng 2020]. We then generate initial depth maps init using a single-frame depth prediction network [Li et al. 2020a;Ranftl et al. 2020]. Since such predictions are scale-invariant, we align the scale of to roughly match the the scale of initial depth estimates. Specifically, the scale is calculated by: = mean(median( init / sfm )), and applied for all camera translations .
For each pair of optical flow fields → + and + → we find occluded regions (as well as regions of inaccurate flow) using forwardbackward consistency to generate an occlusion mask → + for masking the loss computation. All flows with inconsistency larger than 1 pixel are considered to be occluded or unreliable. Formally: where denotes pixel locations in frame .

Test-time Learning of Depth and Scene Flow
Given the input video, along with the pre-computed optical-flow fields and camera poses (see Section 3.2), we turn to the task of Similarly, the corresponding pixel of in frame , denoted by → , is backprojected to ( → ) (green point). We require consistency between ( → ) and ( ) after displacement by our predicted scene flow → , denoted by → ( ) as follows: (i) L 2D penalizes the 2D distance between the projection of → ( ) onto frame , and → . (ii) L disp penalizes the difference in disparity between → ( ) and ( → ). See details in Section. 3.3.
fine-tuning a pre-trained, single-frame, depth-prediction network, that takes an RGB frame as input and produces a depth map , and training from scratch an auxiliary scene-flow-prediction network that takes a 3D point in world coordinate system , and predicts its 3D world-space scene flow → +1 .
The networks' parameters and are the only variables of the optimization and are trained in conjunction: the inputs to the scene flow network are updated at each optimization step, based on the current depth estimate; and the scene flow losses are backpropagated to update our depth model at each step.
Theoretically, the scene flow module is redundant-it can be analytically computed given 2D dense correspondences between frames (optical flow) and depth estimates for each frame. However, such estimation can often be noisy and unstable especially when the camera rays at corresponding points are nearly parallel. Implicitly representing the scene flow using our MLP network acts as an auxiliary variable that is encouraged to match the analytically computed scene flow through the training losses. This design choice is crucial for making the optimization stable as demonstrated in Section. 5.1.
Our objective loss for optimizing and consists of three terms: arg min L 2D encourages the depth and scene flow between two frames to match the pre-computed optical flow when projected onto 2D. L disp encourages the predicted depth and scene flow w.r.t. frame , → to be consistent with , the predicted depth of frame . L prior is a smoothness prior imposed on the predicted scene flow.
The hyper-parameters and control the relative weighting of the different terms. We next describe each of the loss terms in detail.

Training Losses
Given a pair of frames { , }, we define the following losses on the predicted depth maps { , }, and the predicted scene flow between the frames → . An visual illustration of these losses and our notation is presented in Fig. 3. We unproject each pixel ∈ into a 3D point ( ) in world coordinates, using the predicted depth map and camera poses: where˜is the 2D homogenous augmentation of , is the camera intrinsics matrix, is the 3x3 camera rotation matrix, and is the camera translation vector.
We can now compute the scene flow of ( ) w.r.t. time + 1 by feeding it into our MLP scene flow network. That is, To compute the scene flow w.r.t. frame where − > 1, we can simply unroll the scene flow MLP − times: Finally, the 3D position of ( ) at time is given by: Consistency in 2D. We define a 2D consistency loss L 2D → ( ) that measures the pixel distance between the corresponding pixel of in frame , and the projection of → ( ) onto camera .
Formally, let → ( ) be the pre-computed optical flow vector of pixel ∈ w.r.t. frame . The corresponding pixel of is given by: The loss term L 2D is given by: where ∥·∥ 1 denotes the 1 norm, → denotes the occlusion mask of frame w.r.t frame , and M ( ) denotes the projection of a world-space point onto the ℎ camera: where is the projection operator

Consistency in 3D.
Similarly to [Luo et al. 2020], we define the disparity consistency loss L disp , which measures the consistency between the inverse depth value of → ( ) under camera , and the inverse of : where | · | denotes taking the depth component of a 3D point, i.e. = |[ , , ]| .
Smooth 3D motion. To regularize the motion in 3D, we impose a constant velocity prior L prior : where is the pixel location in frame .
Optional motion masks. If motion segmentation is available for the video sequence, we can further constrain the motion in 3D by penalizing velocities in static regions. Formally, given a mask of static regions at frame , denoted as , we introduce a static prior L static : The total loss when using static/dynamic masks is given by: Otherwise, the loss is given by Eq. 2. We do not use any motion segmentation throughout our experiments unless explicitly noted; for real videos, only the ablation study (Fig. 8) includes a motion mask.
Training schedule. As discussed in Section 3.1, we initialize the depth network with a pre-trained monocular depth model. However, the scene flow network has to be trained from scratch. Naively initializing with random weights produces small initial scene flow values that are inconsistent with the initial depth estimate and pre-computed optical flow. Training both depth and scene flow networks from this initialization results in large changes in the depth prediction network in order to satisfy the consistency losses. We overcome this issue via a "warm-up" phase in which only is trained using L total with = 0 while the pre-trained depth network is kept fixed. In practice, we found converged after 5 epochs, and set the warm-up phase to 5 epochs in all our experiments, after which both networks are finetuned jointly using L total .
Note that even if the predicted scene flow matches the analytic scene flow perfectly after warm-up, there is still a training signal from the smooth-motion prior applied to the scene flow after the warm up phase. The scene flow MLP will deviate from its warmedup state during training in order to find a solution that induces locally linear motion while satisfying the optical flow loss terms.

IMPLEMENTATION DETAILS
Network architectures. In our experiments , we use either the single-frame MannequinChallenge model [Li et al. 2019] or the Mi-DaS v2 model [Ranftl et al. 2020] for the depth prediction network . The scene flow network is a MLP with positional encoding [Mildenhall et al. 2020] for the input. Specifically, the positional encoding ( ) for input is defined as: where we use = 16 for all the experiments, and the encoding is applied to both 3D locations and time. The MLP is comprised of 4 hidden layers, each with 256 units.
Hyperparameters. Throughout our experiments, we set = 0.1, = 1 for the total loss defined in Eq. 2. When motion segmentations are present, we set = 100 in Eq. 13. We use a learning rate of 10 −5 for the depth network when initialized with the Man-nequinChallenge model [Li et al. 2019], and a learning rate of 10 −6 when initialized with the MiDaS v2 model [Ranftl et al. 2020]. The sceneflow network is optimized with a learning rate of 0.001. Both networks are optimized using the Adam optimizer with 1 = 0.9 and 2 = 0.999. Batch size is set to 1.
Training Time. The networks are trained for 20 epochs for all experiments, so the training time of our method depends linearly on the number of frames. For a 60-frame video, the training time is about 75 minutes on a single NVIDIA P100 GPU. The training time of our method is about 2× longer than CVD [Luo et al. 2020], due to the extra scene flow network.

RESULTS
Our experiments demonstrate the quality of predicted depth and the importance of the scene flow network on two synthetic datasets and real-world videos. We first justify the design choice of the scene flow MLP against analytically deriving scene flow (Sec. 5.1). We then evaluate our method on the synthetic Sintel [Butler et al. 2012] dataset and show quantitative improvement over competing methods (Sec. 5.2). To demonstrate the real-world capabilities of the method, we show qualitative examples on videos with significant camera and object motion (Sec. 5.3). Finally, we show multiple video editing results based on our consistent depth estimates (Sec. 5.4).

MLP scene flow vs. Analytic scene flow
We examine the importance of representing scene flow implicitly via our MLP model vs. analytically computing scene flow (using the depth estimates, camera poses and optical flow fields). To do so, we generated a simple synthetic scene where a cube is moving along a straight line in 3D, towards the camera at a constant velocity, while the camera is moving along a sine curve that simulates handheld camera wobble (see Figure 4a, and full video in the SM). Using ground truth optical flow fields and camera poses, we then train: (1) Our full framework, including both depth and scene flow networks, using Eq. 2.
(2) Only depth network only (no MLP scene flow). At each iteration of training, we compute scene flow given the current depth estimates: where ( ) and +1 ( → +1 ( )) are computed by unprojecting pixel ∈ , and its corresponding pixel → +1 ( ) ∈ +1 to 3D, using the depth estimates { , +1 } as defined in Eq. 3. We then plug the computed scene flow into Eq. 2 by replacing all → +1 and ( , ) withˆ→ +1 . Note that by construction, L 2D and L disp are perfectly satisfied (the scene flow is derived from two depth maps and flow). Thus, the only loss that drives the optimization is L prior . Intuitively, this baseline simply optimizes the depth network such that the derived scene flow is locally smooth.
As can be seen in Figure 4, the baseline w/o scene flow MLP does not converge to the correct solution, even when ground truth optical flow and camera poses are used to derive scene flow.
We hypothesize the failure is due to the L prior term being illposed for analytic scene flow. When the motion of the camera and the object are nearly aligned, even momentarily, → +1 ( ) ≈ . In this case analytic scene flow is ill-posed (see Appendix A.1) and the gradient of L prior is numerically unstable, leading to poor convergence.
In contrast, our scene flow network avoids this issue by acting as a slack variable that aggregates information across the entire video. When L prior is defined in terms of the output of (Eq. 11), the scene flow at ( ) potentially depends on all the rays in the scene. Each frame of the video has ≈ 2 17 pixels, whereas has only ≈ 2 18 parameters, so weights must be shared between rays.
In the presence of badly conditioned ray pairs these shared weights act as a regularizer, allowing our method to nearly perfectly reconstruct the ground truth cube (Fig. 4d).

Quantitative Evaluation
We quantitatively evaluate, ablate and compare our method on a subset of the Sintel dataset [Butler et al. 2012], as follows.
Dataset. We test the depth prediction accuracy of our method using the 23 sequences of the Sintel dataset. We use the motion masks provided by [Taniai et al. 2017] as and for separately evaluating performance in static and dynamic regions. Input optical flow is computed using RAFT [Teed and Deng 2020], not the groundtruth flow from the dataset.
Baselines. We compare our method with three baselines: the single-frame MannequinChallenge model(MC) [Li et al. 2019], singleframe MiDaS v2 [Ranftl et al. 2020] and CVD. For CVD with MC initialization, we use the original implementation provided by the authors. We found training the original implementation of CVD numerically unstable (training loss being NaN for some sequences) Table 1. Depth accuracy on Sintel. We evaluate error for the entire depth map (Full), and separately for the dynamic and static regions. We evaluate the initial depth maps produced by MC (top) and MiDaS (bottom), along with the depth prediction results of CVD and our method using each of the depth initializations. Additionally, we evaluate our performance when the smooth motion prior is omitted from our objective (w/o L prior ), and when static/dynamic segmentation masks are incorporated (Eq. 13). Our full method consistently improves upon the initial depth estimations, in both static and moving regions. Since CVD assumes a static scene, it fails to recover large moving regions. Given the motion masks, our performance further improves in static and dynamic regions, and is on par with CVD in static regions. Additionally, we observe a significant degradation in our performance when L prior is omitted, demonstrating its importance in reducing the ambiguity between depth and 3D motion. CVD † denotes our implementation of CVD under MiDaS initialization, as the original code fails to train on some of the sequences (see Sec. 5 for more details.)

Method
Full  when initialized with MiDaS due to the near-zero disparity values MiDaS produces in background areas. We therefore implemented a modified version of CVD that clips near-zero disparity to a small, non-zero value using our frame work: removing the scene flow MLP and replace our losses with the ones proposed by the original paper.

(a) Sample Frames (b) Initialization (c) CVD (d) Ours w/o motion reg. (e) Ours full (f) Ours w/ motion mask (g) Ground truth depth
Ablation. We compare our method when: the smooth motion prior is omitted from our objective ("w/o motion prior"), and w/o and w/ dynamic/static motion segmentation masks (Eq. 2 and Eq. 13, respectively.) Metrics. We use three metrics to evaluate the quality of the depth maps: 1 relative, log RMSE, and RMSE [Butler et al. 2012]. To examine temporal consistency, we do not match the scale of each individual frame against the ground truth during evaluation. Instead, we apply a single calibrated scale for the entire sequence during the preprocessing stage, as described in Sec. 3.2. We also evaluate separately on moving and static regions using the ground truth motion mask. We follow the common practice of excluding depth values that exceed 80m during evaluation, as distant, high-magnitude outliers otherwise confuse the results. (e) Our predicted depth maps (no motion segmentation masks were used). (f) Corresponding − slice for each of the methods (the sampled horizontal line is marked in red in (a)): MiDas produces inconsistent depth over time, apparent by the zigzagging patterns in the slice. CVD outputs temporally consistent depth estimates in the static regions, but fails in the dynamic regions (darker regions in the slice). Note that the last row depicts small, in-place motion (person is waving), in which case most of the person region is reconstructed by MVS. In all example, our method is able to produce temporally consistent depth estimates in both static and dynamic regions. As can be shown in Table 1, our method, when initialized with the corresponding single-frame depth prediction model, consistently improves upon the initialization in both moving and static regions by an average of 40-45% in 1 relative error. Our method outperforms CVD in moving regions by a large margin due to our explicit handling of motion, while CVD still performs well in static regions. When motion masks are incorporated into our framework, we achieve similar performance to CVD in static regions. Finally, removing the motion prior L prior for our objective leads to 150-175% increase in 1 relative error, which demonstrates the importance of this regularization. Figure 5 shows several qualitative results. Note that our method (e) using MiDaS v2 [Ranftl et al. 2020] as initialization improves depth in both moving and static regions compare to the initial depth estimates (b) even when motion segmentation masks are not used. Using the motion masks further improves our results (e,f). CVD improves the static regions but fails to produce correct depth for moving objects, tending to erase them to the background value (c).

Real Videos -Qualitative Results
We test our method on real world videos containing a variety of moving objects (people, pets, cars) performing complex motions such as running or dancing. Representative results are shown in Fig. 6, and the full set of videos is provided in the SM. All of our results on real videos are produced with MiDaS [Ranftl et al. 2020] initialization. In addition to depth maps, we also present depthslices (Fig. 6f) for qualitative comparison of temporal consistency of our results compared to the initial depth (MiDas) and CVD.
While the per-frame depth maps produced by MiDaS (Fig. 6c) are generally sharp and accurate in terms of overall depth ordering, our method shows improved temporal consistency as shown by the reduced zigzagging patterns and color variation in the -slices.
The full-video method CVD produces good temporal consistency and can reconstruct some small motions (e.g. waving hand, Fig. 6 Input bottom). However, CVD tends to push large moving regions to infinity ( Fig. 6d) due to the violation of epipolar constraints, while our method works well for the moving regions as well as the static regions. Note that no input segmentation of moving vs. static regions is used for these results. The CVD results shown in Fig. 6 is produced by the original implementation by the authors, using the MannequinChallenge model as initialization. CVD with MiDaS initialization fail to train on some of the sequences due to reasons described in Sec. 5.2 The output of the scene flow MLP is visualized in Fig. 7 by projecting to image space. The scene flow of our method (d) is almost zero on static regions, while scene flows derived from the initial depth estimates (c) assign significant motion to stationary objects, in some cases of similar magnitude as moving objects (ground and wall in first row, hedge and sky in second row). This spurious motion stems from the lack of temporal coherence in the initial depth maps. Note that our method produces accurate, non-zero scene flow even when optical flow is close to zero (head of left person in second row, center person in bottom row).
When an accurate motion mask is available for a real video, our method can incorporate it to improve results in static parts of the scene (Fig. 8, top). Using an inaccurate motion mask can harm results, however (Fig. 8, bottom): the truck is incorrectly marked as stationary, and is spuriously pulled towards the camera as a result. We do not use motion masks for any results other than Fig 8.

Applications
We explore several applications of our depth maps, including inserting virtual objects into a video, inserting a new light source that travels the scene, or segmenting the video via tracking of simple proxy geometries in 3D. In all these applications, the geometrical and temporal consistency of the depth maps play a critical role in producing realistic effects in which depth ordering of moving objects is preserved and the result is consistent over time.
Object and Light Insertion. Fig. 9 shows the results of inserting synthetic objects and lights into real-world videos. The 3D scene is created by unprojecting our depth maps per-frame using the per-frame input camera, without further 3D processing. To slightly improve the sharpness of depth edges, we identify edges between moving and static regions using the depth map and projected scene flow, then separately apply morphological erosion followed by dilation to the moving and static regions in order to replace values along depth edges with depth values from interior regions. Lights and objects were placed manually using NUKE [Ltd 2018].
Temporal coherence is critical for creating effective insertion results: while the human eye is often not sensitive to small inaccuracies in shadow or lighting placement, it is extremely sensitive to the jitter or flashing that can occur when the depth predictions near an inserted object are unstable. The depth maps produced by our method are stable enough to avoid distracting artifacts compared with single-frame depth prediction, even with large moving objects (see supplementary video for comparison).
3D Segmentation. The stability of our depth maps allows for effective manual segmentation of videos using 3D information. The user may place simple proxy geometry around the objects in 3D, then color the points by the proxy geometry they fall inside (Fig. 10). The proxies may be animated to track moving objects such as the dog and walking person (Fig. 10, left). Loose proxy geometry usually suffices to separate the objects in 3D: for the "puppy" sequence, each segment was represented by either a box (dog, person) or a plane (ground, wall, background). The position of the bounding boxes was manually adjusted over time. Only 8 keyframes for the 121 frame sequence were required. This 3D setup can be achieved in a few minutes using a 3D video editing package such as NUKE [Ltd 2018].
Unlike data-drive segmentation models such as Mask R-CNN [He et al. 2017], this approach allows the user to segment objects that Input 3D Proxy Geometry Segmentation Fig. 10. Image segmentation using 3D proxy geometry. An input image (left) may be segmented by using simple proxy geometry in 3D (center). Points that lie within boxes (dog, person) or behind planes (ground, wall, background) are colored by the respective proxies' color to produce the segmentation (right). Black indicates areas outside of a proxy or inside multiple proxies. The green and blue boxes track the dog and person using manual keyframes. Because of the temporal coherence of the depth maps, keyframes were needed on only 8 of 121 frames for this sequence.
may not correspond to a specific label in the segmentation training set (e.g., the red wall in Fig. 10, right). To obtain this result using learned, image-based segmentation, a dataset of ground-truth segmentations with labels corresponding to geometric features would typically be required.

DISCUSSION AND LIMITATIONS
Our method generates high-quality, temporally consistent depth maps for arbitrary moving objects in video, suitable for effects such as object insertion, relighting, and 3D segmentation. There are two main areas for improvement, however: failures due to inaccuracy of optical flow, and accuracy of occlusion boundaries. Our performance is affected by the accuracy of the optical flow estimates. While state-of-the art optical flow methods are getting better and better, they still have errors in some cases. Our method Input Optical Flow Flow Consistency Our Result Fig. 11. Effect of optical flow failure. Even when evaluated with wide baselines, RAFT optical flow [Teed and Deng 2020] may be inaccurate. Where our mask → + marks flow as inaccurate, our depth estimates are robust to flow errors (top: note head of person is dark in consistency map). If, however, flow is self-consistent but wrong, our method produces incorrect results (bottom, note heads are marked consistent).
can handle optical flow errors to some extent as long as the erroneous regions can be identified using a left-right consistency check and removed from our objective (as described in Sec. 3.3). We observed that in some cases, severe errors such as removal of heads and limbs can still be left-right consistent (with less than a pixel error). In such cases, the optical flow errors translate into errors in our depth prediction (Fig. 11). This problem can be potentially alleviated by developing more intelligent confidence measurements, or by exploring the use of photometric reconstruction losses.
The occlusion boundaries produced by our method may be inaccurate by a few pixels, and so are not yet suitable for demanding effects such as novel view synthesis. Blurring of depth boundaries is a common side effect of CNN depth prediction, and semi-transparent effects such as hair are not solvable using a single depth map. Edgeaware filtering of depth maps [Barron and Poole 2016] may improve sharpness, but may reduce temporal consistency. In future work, we hope to integrate a matting or layering approach (e.g. [Lu et al. 2020]) to better handle difficult depth boundaries.