• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * cv_capi_feature_match.h - optical flow feature match
3  *
4  *  Copyright (c) 2016-2017 Intel Corporation
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *   http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  * Author: Wind Yuan <feng.yuan@intel.com>
19  * Author: Yinhang Liu <yinhangx.liu@intel.com>
20  * Author: Zong Wei <wei.zong@intel.com>
21  */
22 
23 #ifndef CV_CAPI_FEATURE_MATCH_H
24 #define CV_CAPI_FEATURE_MATCH_H
25 
26 #include <xcam_std.h>
27 #include <video_buffer.h>
28 #include <interface/feature_match.h>
29 
30 #ifdef ANDROID
31 #include <cv.h>
32 #else
33 #include <opencv2/opencv.hpp>
34 #endif
35 
36 namespace XCam {
37 
38 class CVCapiFeatureMatch
39     : public FeatureMatch
40 {
41 public:
42     explicit CVCapiFeatureMatch ();
43 
44     void optical_flow_feature_match (
45         const SmartPtr<VideoBuffer> &left_buf, const SmartPtr<VideoBuffer> &right_buf,
46         Rect &left_img_crop, Rect &right_img_crop, int dst_width);
47 
set_ocl(bool use_ocl)48     void set_ocl (bool use_ocl) {
49         XCAM_UNUSED (use_ocl);
50     }
is_ocl_path()51     bool is_ocl_path () {
52         return false;
53     }
54 
55 protected:
56     bool get_crop_image (const SmartPtr<VideoBuffer> &buffer, const Rect &crop_rect,
57                          std::vector<char> &crop_image, CvMat &img);
58 
59     void add_detected_data (CvArr* image, std::vector<CvPoint2D32f> &corners);
60     void get_valid_offsets (std::vector<CvPoint2D32f> &corner0, std::vector<CvPoint2D32f> &corner1,
61                             std::vector<char> &status, std::vector<float> &error,
62                             std::vector<float> &offsets, float &sum, int &count,
63                             CvArr* out_image, CvSize &img0_size);
64 
65     void calc_of_match (CvArr* image0, CvArr* image1,
66                         std::vector<CvPoint2D32f> &corner0, std::vector<CvPoint2D32f> &corner1,
67                         std::vector<char> &status, std::vector<float> &error,
68                         int &last_count, float &last_mean_offset, float &out_x_offset);
69 
70     void detect_and_match (CvArr* img_left, CvArr* img_right, Rect &crop_left, Rect &crop_right,
71                            int &valid_count, float &mean_offset, float &x_offset, int dst_width);
72 
73 private:
74     XCAM_DEAD_COPY (CVCapiFeatureMatch);
75 
76     std::vector<char> _left_crop_image;
77     std::vector<char> _right_crop_image;
78 };
79 
80 }
81 
82 #endif // CV_CAPI_FEATURE_MATCH_H
83