Caffe2 - C++ API
A deep learning, cross platform ML framework
optical_flow.h
1 
17 #ifndef CAFFE2_VIDEO_OPTICAL_FLOW_H_
18 #define CAFFE2_VIDEO_OPTICAL_FLOW_H_
19 
20 #include <opencv2/core.hpp>
21 #include <opencv2/highgui.hpp>
22 #include <opencv2/opencv.hpp>
23 #include <opencv2/video.hpp>
24 
25 #include <caffe2/core/logging.h>
26 
27 namespace caffe2 {
28 
29 // Four different types of optical flow algorithms supported;
30 // BroxOpticalFlow doesn't have a CPU version;
31 // DensePyrLKOpticalFlow only has sparse CPU version;
32 enum FLowAlgType {
33  FarnebackOpticalFlow = 0,
34  DensePyrLKOpticalFlow = 1,
35  BroxOpticalFlow = 2,
36  OpticalFlowDual_TVL1 = 3,
37 };
38 
39 // Define different types of optical flow data type
40 // 0: original two channel optical flow
41 // 1: three channel optical flow with magnitude as the third channel
42 // 2: two channel optical flow + one channel gray
43 // 3: two channel optical flow + three channel rgb
44 enum FlowDataType {
45  Flow2C = 0,
46  Flow3C = 1,
47  FlowWithGray = 2,
48  FlowWithRGB = 3,
49 };
50 
51 void OpticalFlowExtractor(
52  const cv::Mat& prev_gray,
53  const cv::Mat& curr_gray,
54  const int optical_flow_alg_type,
55  cv::Mat& flow);
56 
57 void MergeOpticalFlow(cv::Mat& prev_flow, const cv::Mat& curr_flow);
58 
59 void MultiFrameOpticalFlowExtractor(
60  const std::vector<cv::Mat>& grays,
61  const int optical_flow_alg_type,
62  cv::Mat& flow);
63 
64 } // namespace caffe2
65 
66 #endif // CAFFE2_VIDEO_OPTICAL_FLOW_H_
Copyright (c) 2016-present, Facebook, Inc.