1 // This file is part of OpenCV project.
2 // It is subject to the license terms in the LICENSE file found in the top-level directory
3 // of this distribution and at http://opencv.org/license.html.
4 
5 
6 #ifndef OPENCV_CORE_LLAPI_LLAPI_H
7 #define OPENCV_CORE_LLAPI_LLAPI_H
8 /**
9 @addtogroup core_lowlevel_api
10 
11 API for OpenCV external plugins:
12 - HAL accelerators
13 - VideoIO camera backends / decoders / encoders
14 - Imgcodecs encoders / decoders
15 
16 Plugins are usually built separately or before OpenCV (OpenCV can depend on them - like HAL libraries).
17 
18 Using this approach OpenCV provides some basic low level functionality for external plugins.
19 
20 @note Preview only (no backward compatibility)
21 
22 @{
23 */
24 
25 #ifndef CV_API_CALL
26 //! calling convention (including callbacks)
27 #define CV_API_CALL
28 #endif
29 
30 #ifndef CV_PLUGIN_EXPORTS
31 #if (defined _WIN32 || defined WINCE || defined __CYGWIN__)
32 #  define CV_PLUGIN_EXPORTS __declspec(dllexport)
33 #elif defined __GNUC__ && __GNUC__ >= 4
34 #  define CV_PLUGIN_EXPORTS __attribute__ ((visibility ("default")))
35 #endif
36 #endif
37 
38 typedef enum cvResult
39 {
40     CV_ERROR_FAIL = -1,                          //!< Some error occurred (TODO Require to fill exception information)
41     CV_ERROR_OK = 0                              //!< No error
42 } CvResult;
43 
44 typedef struct OpenCV_API_Header_t
45 {
46     /** @brief valid size of this structure
47      @details `assert(api.header.valid_size >= sizeof(OpenCV_<Name>_API_v<N>));`
48      */
49     size_t valid_size;
50     unsigned min_api_version;                    //!< backward compatible API version
51     unsigned api_version;                        //!< provided API version (features)
52     unsigned opencv_version_major;               //!< compiled OpenCV version
53     unsigned opencv_version_minor;               //!< compiled OpenCV version
54     unsigned opencv_version_patch;               //!< compiled OpenCV version
55     const char* opencv_version_status;           //!< compiled OpenCV version
56     const char* api_description;                 //!< API description (debug purposes only)
57 } OpenCV_API_Header;
58 
59 
60 
61 #if 0
62 
63 typedef int (CV_API_CALL *cv_example_callback1_cb_t)(unsigned const char* cb_result, void* cb_context);
64 
65 struct OpenCV_Example_API_v1
66 {
67     OpenCV_API_Header header;
68 
69     /** @brief Some API call
70 
71     @param param1 description1
72     @param param2 description2
73 
74     @note API-CALL 1, API-Version >=1
75      */
76     CvResult (CV_API_CALL *Request1)(int param1, const char* param2);
77 
78     /** @brief Register callback
79 
80     @param callback function to handle callback
81     @param cb_context context data passed to callback function
82     @param[out] cb_handle callback id (used to unregister callback)
83 
84     @note API-CALL 2, API-Version >=1
85      */
86     CvResult (CV_API_CALL *RegisterCallback)(cv_example_callback1_cb_t callback, void* cb_context, CV_OUT unsigned* cb_handle);
87 
88     /** @brief Unregister callback
89 
90     @param cb_handle callback handle
91 
92     @note API-CALL 3, API-Version >=1
93      */
94     CvResult (CV_API_CALL *UnegisterCallback)(unsigned cb_handle);
95 
96     ...
97 };
98 #endif // 0
99 
100 //! @}
101 
102 #endif // OPENCV_CORE_LLAPI_LLAPI_H
103