1 /* 2 * 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 */ 21 22 #ifndef XCAM_FEATURE_MATCH_H 23 #define XCAM_FEATURE_MATCH_H 24 25 #include <xcam_std.h> 26 #include <video_buffer.h> 27 #include <interface/data_types.h> 28 29 namespace XCam { 30 31 struct CVFMConfig { 32 int sitch_min_width; 33 int min_corners; // number of minimum efficient corners 34 float offset_factor; // last_offset * offset_factor + cur_offset * (1.0f - offset_factor) 35 float delta_mean_offset; // cur_mean_offset - last_mean_offset 36 float recur_offset_error; // cur_offset - mean_offset 37 float max_adjusted_offset; // maximum offset of each adjustment 38 float max_valid_offset_y; // valid maximum offset in vertical direction 39 float max_track_error; // maximum track error 40 CVFMConfigCVFMConfig41 CVFMConfig () 42 : sitch_min_width (56) 43 , min_corners (8) 44 , offset_factor (0.8f) 45 , delta_mean_offset (5.0f) 46 , recur_offset_error (8.0f) 47 , max_adjusted_offset (12.0f) 48 , max_valid_offset_y (8.0f) 49 , max_track_error (24.0f) 50 {} 51 }; 52 53 class FeatureMatch 54 { 55 public: 56 explicit FeatureMatch (); ~FeatureMatch()57 virtual ~FeatureMatch () {}; 58 59 void set_config (CVFMConfig config); 60 CVFMConfig get_config (); 61 62 void set_fm_index (int idx); 63 64 void reset_offsets (); 65 66 virtual void optical_flow_feature_match ( 67 const SmartPtr<VideoBuffer> &left_buf, const SmartPtr<VideoBuffer> &right_buf, 68 Rect &left_crop_rect, Rect &right_crop_rect, int dst_width) = 0; 69 get_current_left_offset_x()70 float get_current_left_offset_x () const { 71 return _x_offset; 72 } 73 74 virtual void set_ocl (bool use_ocl) = 0; 75 virtual bool is_ocl_path () = 0; 76 77 protected: 78 bool get_mean_offset (std::vector<float> &offsets, float sum, int &count, float &mean_offset); 79 80 void adjust_stitch_area (int dst_width, float &x_offset, Rect &stitch0, Rect &stitch1); 81 82 private: 83 XCAM_DEAD_COPY (FeatureMatch); 84 85 protected: 86 float _x_offset; 87 float _mean_offset; 88 int _valid_count; 89 CVFMConfig _config; 90 91 // debug parameters 92 int _fm_idx; 93 uint _frame_num; 94 }; 95 96 } 97 98 #endif // XCAM_FEATURE_MATCH_H 99