Home | History | Annotate | Download | only in ocl
      1 /*
      2  * cv_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 (at) intel.com>
     19  * Author: Yinhang Liu <yinhangx.liu (at) intel.com>
     20  */
     21 
     22 #ifndef XCAM_CV_FEATURE_MATCH_H
     23 #define XCAM_CV_FEATURE_MATCH_H
     24 
     25 #include <xcam_std.h>
     26 #include <video_buffer.h>
     27 #include <ocl/cv_base_class.h>
     28 #include <interface/feature_match.h>
     29 #include <interface/data_types.h>
     30 
     31 #include <ocl/cl_context.h>
     32 #include <ocl/cl_device.h>
     33 #include <ocl/cl_memory.h>
     34 
     35 namespace XCam {
     36 
     37 class CVFeatureMatch
     38     : public CVBaseClass
     39     , public FeatureMatch
     40 {
     41 public:
     42     explicit CVFeatureMatch ();
     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 
     48     void set_ocl (bool use_ocl) {
     49         CVBaseClass::set_ocl (use_ocl);
     50     }
     51     bool is_ocl_path () {
     52         return CVBaseClass::is_ocl_path ();
     53     }
     54 
     55 protected:
     56     bool get_crop_image (const SmartPtr<VideoBuffer> &buffer, const Rect &crop_rect, cv::UMat &img);
     57 
     58     void add_detected_data (cv::InputArray image, cv::Ptr<cv::Feature2D> detector, std::vector<cv::Point2f> &corners);
     59     void get_valid_offsets (std::vector<cv::Point2f> &corner0, std::vector<cv::Point2f> &corner1,
     60                             std::vector<uchar> &status, std::vector<float> &error,
     61                             std::vector<float> &offsets, float &sum, int &count,
     62                             cv::InputOutputArray debug_img, cv::Size &img0_size);
     63 
     64     void calc_of_match (cv::InputArray image0, cv::InputArray image1,
     65                         std::vector<cv::Point2f> &corner0, std::vector<cv::Point2f> &corner1,
     66                         std::vector<uchar> &status, std::vector<float> &error,
     67                         int &last_count, float &last_mean_offset, float &out_x_offset);
     68 
     69     void detect_and_match (cv::InputArray img_left, cv::InputArray img_right, Rect &crop_left, Rect &crop_right,
     70                            int &valid_count, float &mean_offset, float &x_offset, int dst_width);
     71 
     72 private:
     73     XCAM_DEAD_COPY (CVFeatureMatch);
     74 
     75 };
     76 
     77 }
     78 
     79 #endif // XCAM_CV_FEATURE_MATCH_H
     80