TypeDef.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #ifndef __TYPE_DEF_H__
  2. #define __TYPE_DEF_H__
  3. // *****************************************************************************
  4. // 版权所有(C)2023~2099 上海骄成超声波技术有限公司
  5. // 保留所有权利
  6. // *****************************************************************************
  7. // 作者 : 李祥瑞
  8. // 版本 : 1.0
  9. // 代码创建日期:2024/11/19
  10. // 版本更新日期:2025/01/10
  11. // 功能说明: 定位算法接口使用的基本数据结构
  12. // *****************************************************************************
  13. #if defined(JVISION_LIB_EXPORT)
  14. #define JVision_API __declspec(dllexport)
  15. #else
  16. #define JVision_API __declspec(dllimport)
  17. #endif
  18. #include <string>
  19. #define M_PI (3.14159256)
  20. namespace JVision
  21. {
  22. // 图像数据类型,指向内存中的图像二进制数据
  23. typedef JVision_API unsigned char* ImageDataPtr;
  24. // 返回值类型
  25. typedef JVision_API int ResultCode;
  26. // 参数ID类型
  27. typedef JVision_API int ParamID;
  28. // 参数值类型
  29. typedef JVision_API std::string ParamVal;
  30. /**
  31. * @brief 以像素点表示的坐标
  32. */
  33. struct JVision_API Point
  34. {
  35. double x;//(像素坐标,零点在左上角)
  36. double y;
  37. double angle; // 角度(x正方向为0,逆时针为正)
  38. };
  39. struct JVision_API Point2D
  40. {
  41. double x;//(像素坐标,零点在左上角)
  42. double y;
  43. };
  44. struct JVision_API CircleResult
  45. {
  46. double x;
  47. double y;
  48. double radius;
  49. };
  50. struct JVision_API EllipseResult
  51. {
  52. double x;
  53. double y;
  54. double large_radius; // 长轴一半
  55. double small_radius; // 短轴一半
  56. };
  57. enum class JVision_API ImageFormat : int
  58. {
  59. INVALID = 0, // 无效
  60. GRAY8, // 灰度图,色值0~255
  61. RGB888, // 每个像素 24 位,顺序是 0xRRGGBB,没有 Alpha 通道
  62. ARGB32, // 带有 Alpha 通道的 32 位像素格式,顺序是 0xAARRGGBB
  63. RGB32, // 每个像素 32 位,其中包含了 RGB 颜色信息,顺序通常是 0xAARRGGBB(最高字节为 Alpha 通道,但被忽略,因为 Alpha 通道总是视为 0xFF)
  64. YUV422, // YUV4:2:2
  65. };
  66. struct JVision_API ImageInfo
  67. {
  68. ImageInfo();
  69. ImageInfo(int w, int h, int c, ImageFormat f, unsigned char* d);
  70. ImageInfo(unsigned char* d, int w, int h, int c)
  71. : width(w)
  72. , height(h)
  73. , channel(c)
  74. , data(nullptr)
  75. {
  76. int imageSize = w * h * c;
  77. data = new unsigned char[imageSize];
  78. memcpy(data, d, imageSize);
  79. }
  80. ImageInfo(const ImageInfo& other);
  81. ImageInfo(ImageInfo&& other) noexcept;
  82. ImageInfo& operator=(ImageInfo& other);
  83. ImageInfo& operator=(ImageInfo&& other) noexcept;
  84. ~ImageInfo();
  85. int width; // 图像宽度
  86. int height; // 图像高度
  87. int channel; // 图像通道数
  88. ImageFormat format; // 图像格式
  89. unsigned char* data; // 图像数据
  90. };
  91. }
  92. #endif