config.h 2.68 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
#ifndef NS_API_NSCONFIG_H_
#define NS_API_NSCONFIG_H_
#pragma once

#ifndef NULL
# define NULL 0
#endif

#ifndef TRUE
# define TRUE 1
#endif

#ifndef FALSE
# define FALSE 0
#endif

#undef NS_WIN32
#if defined(WIN32) || defined(_WIN32)
# define NS_WIN32
#endif

#ifdef NS_WIN32
# ifdef BUILDING_WMAI_LIB
#  ifdef __GNUC__
#   define WMAI_EXPORT __attribute__ ((dllexport))
#  else
#   define WMAI_EXPORT __declspec(dllexport)
#  endif
# elif defined(USE_WMAI_LIB)
#  ifdef __GNUC__
#   define WMAI_EXPORT __attribute__ ((dllimport))
#  else
#   define WMAI_EXPORT __declspec(dllimport)
#  endif
# else 
#   define WMAI_EXPORT 
#   define WMAI_LOCAL
# endif
#else
# if __GNUC__ >= 4
#  define WMAI_EXPORT __attribute__ ((visibility ("default")))
#  define WMAI_LOCAL  __attribute__ ((visibility ("hidden")))
# else
#  define WMAI_EXPORT
#  define WMAI_LOCAL
# endif
#endif

#ifdef NS_WIN32
# ifdef __GNUC__
#  define WMAI_API
# else
#  define WMAI_API _cdecl
# endif
#else
# define WMAI_API
#endif

#if defined(_MSC_VER) && _MSC_VER < 1300
# pragma warning(disable : 4250 4786)
#endif

/* 定义全局类型 */
typedef unsigned char uchar;
typedef unsigned long ulong;
typedef unsigned int uint;

/// VC不支持C99的snprintf函数
//#if _MSC_VER
//# define snprintf _snprintf
//# define vsnprintf _vsnprintf
//# define popen _popen
//# define pclose _pclose
//#endif

// linux下使用strcasecmp
#ifndef NS_WIN32
# define stricmp strcasecmp
#endif

// 针对VC6.0编译修改内部宏
#if defined(_MSC_VER) && _MSC_VER < 1300
# define NS_USE_MSVC6 // 使用VC6编译器
# define __FUNCTION__ "" // vc6不支持__FUNCTION__
// Thread.h use TryEnterCriticalSection that 
// requires _WIN32_WINNT >= 0x400(win95)
# ifndef _WIN32_WINNT
#  define _WIN32_WINNT 0x500
# endif
#endif

/**
 * @def SINGLETON(TYPE)
 *
 * 单实例一个类: 隐藏构造函数,禁止拷贝构造函数和重载运算符"="
 */
#ifdef NS_USE_MSVC6
#define SINGLETON(TYPE) TYPE();   \
    TYPE(const TYPE&);            \
    TYPE& operator=(const TYPE&); \
public:                           \
    virtual ~TYPE()
#else
#define SINGLETON(TYPE) TYPE();   \
    TYPE(const TYPE&);            \
    TYPE& operator=(const TYPE&); \
    virtual ~TYPE()
#endif

 /**
  * @def PACKED
  *
  * 取消编译器默认内存对齐方式,只对GCC有效
  */
#if defined(__GNUC__)
# ifndef PACKED
#  define PACKED __attribute__ ((packed))
# endif
#else
# define PACKED
#endif

#endif /* NS_API_NSCONFIG_H_ */

#include <stdio.h>
#include <algorithm>
#include <vector>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>

#include <ncnn/benchmark.h>
#include <ncnn/platform.h>
#include <ncnn/net.h>

  // #undef NCNN_VULKAN

#if NCNN_VULKAN
#include <ncnn/gpu.h>
#endif // NCNN_VULKAN