1 /* 2 * cv_context.h - used to init_opencv_ocl once 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: Andrey Parfenov <a1994ndrey (at) gmail.com> 19 * Author: Wind Yuan <feng.yuan (at) intel.com> 20 */ 21 22 #ifndef XCAM_CV_CONTEXT_H 23 #define XCAM_CV_CONTEXT_H 24 25 #include <xcam_std.h> 26 #include <xcam_obj_debug.h> 27 #include <xcam_mutex.h> 28 #include <ocl/cl_context.h> 29 30 #include <opencv2/opencv.hpp> 31 #include <opencv2/core/ocl.hpp> 32 33 namespace XCam { 34 35 class CVContext 36 { 37 public: 38 static SmartPtr<CVContext> instance (); 39 40 SmartPtr<CLContext> get_cl_context () { 41 return _context; 42 } 43 ~CVContext(); 44 bool enable_ocl (bool flag); 45 bool is_ocl_enabled () const; 46 47 private: 48 CVContext (); 49 void init_opencv_ocl (); 50 51 static Mutex _init_mutex; 52 static SmartPtr<CVContext> _instance; 53 54 SmartPtr<CLContext> _context; 55 56 XCAM_DEAD_COPY (CVContext); 57 58 }; 59 60 } 61 62 #endif // XCAM_CV_CONTEXT_H 63