macros.hpp 6.2 KB
Newer Older
1 2
#ifndef OPENPOSE_CORE_MACROS_HPP
#define OPENPOSE_CORE_MACROS_HPP
G
Gines 已提交
3

G
gineshidalgo99 已提交
4
#include <chrono> // std::chrono:: functionaligy, e.g., std::chrono::milliseconds
R
Raaj 已提交
5 6
#include <memory> // std::shared_ptr
#include <ostream>
7
#include <string>
G
gineshidalgo99 已提交
8
#include <thread> // std::this_thread
R
Raaj 已提交
9
#include <vector>
G
gineshidalgo99 已提交
10
#include <opencv2/core/core.hpp> // cv::Mat, check OpenCV version
R
Raaj 已提交
11

12 13
// OpenPose name and version
const std::string OPEN_POSE_NAME_STRING = "OpenPose";
G
Gines Hidalgo 已提交
14
const std::string OPEN_POSE_VERSION_STRING = "1.5.1";
15
const std::string OPEN_POSE_NAME_AND_VERSION = OPEN_POSE_NAME_STRING + " " + OPEN_POSE_VERSION_STRING;
16
// #define COMMERCIAL_LICENSE
17

G
Gines 已提交
18 19 20 21 22 23 24 25
#ifndef _WIN32
    #define OP_API
#elif defined OP_EXPORTS
    #define OP_API __declspec(dllexport)
#else
    #define OP_API __declspec(dllimport)
#endif

G
gineshidalgo99 已提交
26
// Disable some Windows Warnings
27 28 29 30 31
#ifdef _WIN32
    #pragma warning ( disable : 4251 ) // XXX needs to have dll-interface to be used by clients of class YYY
    #pragma warning( disable: 4275 ) // non dll-interface structXXX used as base
#endif

G
Gines 已提交
32 33 34 35 36 37
#define UNUSED(unusedVariable) (void)(unusedVariable)

#define DELETE_COPY(className) \
    className(const className&) = delete; \
    className& operator=(const className&) = delete

38
// Instantiate a class with all the basic types
G
Gines 已提交
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
#define COMPILE_TEMPLATE_BASIC_TYPES_CLASS(className) COMPILE_TEMPLATE_BASIC_TYPES(className, class)
#define COMPILE_TEMPLATE_BASIC_TYPES_STRUCT(className) COMPILE_TEMPLATE_BASIC_TYPES(className, struct)
#define COMPILE_TEMPLATE_BASIC_TYPES(className, classType) \
    template classType OP_API className<char>; \
    template classType OP_API className<signed char>; \
    template classType OP_API className<short>; \
    template classType OP_API className<int>; \
    template classType OP_API className<long>; \
    template classType OP_API className<long long>; \
    template classType OP_API className<unsigned char>; \
    template classType OP_API className<unsigned short>; \
    template classType OP_API className<unsigned int>; \
    template classType OP_API className<unsigned long>; \
    template classType OP_API className<unsigned long long>; \
    template classType OP_API className<float>; \
    template classType OP_API className<double>; \
    template classType OP_API className<long double>

57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
// Instantiate a class with float and double specifications
#define COMPILE_TEMPLATE_FLOATING_TYPES_CLASS(className) COMPILE_TEMPLATE_FLOATING_TYPES(className, class)
#define COMPILE_TEMPLATE_FLOATING_TYPES_STRUCT(className) COMPILE_TEMPLATE_FLOATING_TYPES(className, struct)
#define COMPILE_TEMPLATE_FLOATING_TYPES(className, classType) \
  char gInstantiationGuard##className; \
  template classType OP_API className<float>; \
  template classType OP_API className<double>

// Instantiate a class with float and double specifications
#define COMPILE_TEMPLATE_FLOATING_INT_TYPES_CLASS(className) COMPILE_TEMPLATE_FLOATING_INT_TYPES(className, class)
#define COMPILE_TEMPLATE_FLOATING_INT_TYPES_STRUCT(className) COMPILE_TEMPLATE_FLOATING_INT_TYPES(className, struct)
#define COMPILE_TEMPLATE_FLOATING_INT_TYPES(className, classType) \
  char gInstantiationGuard##className; \
  template classType OP_API className<int>; \
  template classType OP_API className<unsigned int>; \
  template classType OP_API className<float>; \
  template classType OP_API className<double>

R
Raaj 已提交
75 76 77 78 79 80 81 82 83 84 85
/**
 * cout operator overload calling toString() function
 * @return std::ostream containing output from toString()
 */
#define OVERLOAD_C_OUT(className) \
    template<typename T> std::ostream &operator<<(std::ostream& ostream, const op::className<T>& obj) \
    { \
        ostream << obj.toString(); \
        return ostream; \
    }

86 87 88 89
// PIMPL does not work if function arguments need the 3rd-party class. Alternative:
// stackoverflow.com/questions/13978775/how-to-avoid-include-dependency-to-external-library?answertab=active#tab-top
struct dim3;

G
gineshidalgo99 已提交
90
// Compabitility for OpenCV 4.0 while preserving 2.4.X and 3.X compatibility
G
gineshidalgo99 已提交
91 92 93 94 95 96 97 98 99 100
// Note:
// - CV_VERSION:         2.4.9.1 | 4.0.0-beta
// - CV_MAJOR_VERSION:         2 | 4
// - CV_MINOR_VERSION:         4 | 0
// - CV_SUBMINOR_VERSION:      9 | 0
// - CV_VERSION_EPOCH:         2 | Not defined
#if (defined(CV_MAJOR_VERSION) && CV_MAJOR_VERSION > 3)
    #define OPEN_CV_IS_4_OR_HIGHER
#endif
#ifdef OPEN_CV_IS_4_OR_HIGHER
G
gineshidalgo99 已提交
101
    #define CV_BGR2GRAY cv::COLOR_BGR2GRAY
102
    #define CV_BGR2RGB cv::COLOR_BGR2RGB
G
gineshidalgo99 已提交
103 104 105 106 107 108 109 110 111 112 113 114 115 116
    #define CV_CALIB_CB_ADAPTIVE_THRESH cv::CALIB_CB_ADAPTIVE_THRESH
    #define CV_CALIB_CB_NORMALIZE_IMAGE cv::CALIB_CB_NORMALIZE_IMAGE
    #define CV_CALIB_CB_FILTER_QUADS cv::CALIB_CB_FILTER_QUADS
    #define CV_CAP_PROP_FPS cv::CAP_PROP_FPS
    #define CV_CAP_PROP_FRAME_COUNT cv::CAP_PROP_FRAME_COUNT
    #define CV_CAP_PROP_FRAME_HEIGHT cv::CAP_PROP_FRAME_HEIGHT
    #define CV_CAP_PROP_FRAME_WIDTH cv::CAP_PROP_FRAME_WIDTH
    #define CV_CAP_PROP_POS_FRAMES cv::CAP_PROP_POS_FRAMES
    #define CV_FOURCC cv::VideoWriter::fourcc
    #define CV_GRAY2BGR cv::COLOR_GRAY2BGR
    #define CV_HAAR_SCALE_IMAGE cv::CASCADE_SCALE_IMAGE
    #define CV_INTER_CUBIC cv::INTER_CUBIC
    #define CV_INTER_LINEAR cv::INTER_LINEAR
    #define CV_L2 cv::NORM_L2
117
    #define CV_RGB2BGR cv::COLOR_RGB2BGR
G
gineshidalgo99 已提交
118 119 120 121 122 123 124 125
    #define CV_TERMCRIT_EPS cv::TermCriteria::Type::EPS
    #define CV_TERMCRIT_ITER cv::TermCriteria::Type::MAX_ITER
    #define CV_WARP_INVERSE_MAP cv::WARP_INVERSE_MAP
    #define CV_WINDOW_FULLSCREEN cv::WINDOW_FULLSCREEN
    #define CV_WINDOW_KEEPRATIO cv::WINDOW_KEEPRATIO
    #define CV_WINDOW_NORMAL cv::WINDOW_NORMAL
    #define CV_WINDOW_OPENGL cv::WINDOW_OPENGL
    #define CV_WND_PROP_FULLSCREEN cv::WND_PROP_FULLSCREEN
G
gineshidalgo99 已提交
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
    // Required for alpha and beta versions, but not for rc version
    #include <opencv2/imgcodecs/imgcodecs.hpp>
    #ifndef CV_IMWRITE_JPEG_QUALITY
        #define CV_IMWRITE_JPEG_QUALITY cv::IMWRITE_JPEG_QUALITY
    #endif
    #ifndef CV_IMWRITE_PNG_COMPRESSION
        #define CV_IMWRITE_PNG_COMPRESSION cv::IMWRITE_PNG_COMPRESSION
    #endif
    #ifndef CV_LOAD_IMAGE_ANYDEPTH
        #define CV_LOAD_IMAGE_ANYDEPTH cv::IMREAD_ANYDEPTH
    #endif
    #ifndef CV_LOAD_IMAGE_COLOR
        #define CV_LOAD_IMAGE_COLOR cv::IMREAD_COLOR
    #endif
    #ifndef CV_LOAD_IMAGE_GRAYSCALE
        #define CV_LOAD_IMAGE_GRAYSCALE cv::IMREAD_GRAYSCALE
    #endif
G
gineshidalgo99 已提交
143 144
#endif

145
#endif // OPENPOSE_CORE_MACROS_HPP