CNN-Based Patch Matching for Optical Flow with Thresholded Hinge Embedding Loss

Christian Bailer, Kiran Varanasi, Didier Stricker

Abstract

Learning-based approaches have not yet achieved their full potential in optical flow estimation, where their performance still trails heuristic approaches. In this paper, we present a CNN-based patch matching approach for optical flow estimation. An important contribution of our approach is a novel thresholded loss for Siamese networks. We demonstrate that our loss performs clearly better than existing losses and allows for speeding up training by a factor of 2. Furthermore, we present a novel way for calculating CNN-based features for different image scales, which performs better than existing methods. We also discuss new ways of evaluating the robustness of trained features for patch matching. An interesting discovery is that low-pass filtering of feature maps can increase the robustness of features created by CNNs. We proved the competitive performance of our approach by obtaining state-of-the-art results on the KITTI 2012, KITTI 2015, and MPI-Sintel datasets.

Introduction

Optical flow—the task of estimating the motion of pixels between two consecutive image frames—has traditionally been dominated by heuristic, "engineered" approaches like PatchMatch or Flow Fields. While Convolutional Neural Networks (CNNs) have shown promise in matching image patches, they often struggle to outperform these classical methods in dense, multi-scale scenarios.

The authors identify three primary challenges in current CNN-based approaches:

  1. The "Unnecessary Push": Standard loss functions (like hinge loss) try to force the distance between matching patches to zero. This is often counterproductive as patches rarely look identical due to noise, illumination changes, or motion blur, leading to overfitting.
  2. Convolutional Bias: CNNs naturally learn that neighboring patches are similar, but in patch matching, distinguishing between nearby candidates is crucial to avoid false positives.
  3. Computational Efficiency: Dense matching requires comparing every pixel in one image to many candidates, making many high-performing CNN architectures too slow for practical use.

Proposed Methodology

Thresholded Hinge Embedding Loss

The core innovation is the Thresholded Hinge Embedding Loss ($l_t$). Unlike standard hinge loss, this version introduces a threshold $t$. If the $L_2$ distance between two matching patches is already below $t$, the loss becomes zero. This prevents the network from trying to "perfectly" match noisy data, allowing it to focus on harder cases.

Figure 6: Distribution of L2 distances for positive and negative samples using the proposed thresholded loss (Lt) versus standard generalized hinge loss (Lg).

This mechanism not only improves robustness but also speeds up training. Because the thresholded loss results in zero gradients for many "easy" samples, backpropagation can be skipped for those samples, doubling training speed in the authors' tests.

Multi-scale Feature Recalculation

Instead of the standard approach of blurring a high-resolution feature map to create lower scales, the authors recalculate CNN features on downsampled versions of the image. They found that a CNN trained specifically on lower resolutions performs much more robustly for large-displacement matching.

Figure 2: Comparison between the original approach of feature scaling and the proposed modification involving feature recalculation on downsampled images.

Feature Map Smoothing

A surprising discovery was that applying a simple 2x low-pass filter (blurring) to the final CNN feature maps significantly increases matching robustness. This creates a form of "matching invariance" that helps remove high-frequency noise which often leads to false positives in the matching process.

Evaluation and Results

The approach was evaluated on three major optical flow benchmarks: KITTI 2012, KITTI 2015, and MPI-Sintel.

  • State-of-the-Art Performance: The method ranked #1 among general optical flow methods on all three leaderboards at the time of publication.
  • Accuracy: On KITTI 2012, it achieved an Outlier Error (EPE > 3px) of 4.89%, outperforming the previous best CNN-based approach (PatchBatch at 5.29%).
  • Efficiency: The training process is roughly 2x faster than standard hinge loss. The final pipeline takes about 23 seconds per image pair, making it competitive with other top-tier methods.

Discussion and Conclusion

The primary insight of this work is that relaxing constraints—specifically not aiming for perfect zero distance in matches—makes features more robust to real-world image variations. By allowing a small margin of error ($t$), the network avoids "destructive" training on noisy samples.

While the method achieves state-of-the-art results, it still faces challenges in occluded areas, currently relying on external interpolation methods like EpicFlow. Future work could explore dynamic thresholding or integrating more modern architectural components like dilated convolutions to further enhance performance.

Summary updated

BibTeX
@inproceedings{bailer2017cnn,
  author = {Christian Bailer and Kiran Varanasi and Didier Stricker},
  title = {{CNN-Based Patch Matching for Optical Flow with Thresholded Hinge Embedding Loss}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2017},
  url = {https://openreview.net/forum?id=SyN3D1MO-H},
}
Figure