TypeDef.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. enum class JVision_API ImageFormat : int
  51. {
  52. INVALID = 0, // 无效
  53. GRAY8, // 灰度图,色值0~255
  54. RGB888, // 每个像素 24 位,顺序是 0xRRGGBB,没有 Alpha 通道
  55. ARGB32, // 带有 Alpha 通道的 32 位像素格式,顺序是 0xAARRGGBB
  56. RGB32, // 每个像素 32 位,其中包含了 RGB 颜色信息,顺序通常是 0xAARRGGBB(最高字节为 Alpha 通道,但被忽略,因为 Alpha 通道总是视为 0xFF)
  57. YUV422, // YUV4:2:2
  58. };
  59. struct JVision_API ImageInfo
  60. {
  61. ImageInfo();
  62. ImageInfo(int w, int h, int c, ImageFormat f, unsigned char* d);
  63. ImageInfo(unsigned char* d, int w, int h, int c)
  64. : width(w)
  65. , height(h)
  66. , channel(c)
  67. , data(nullptr)
  68. {
  69. int imageSize = w * h * c;
  70. data = new unsigned char[imageSize];
  71. memcpy(data, d, imageSize);
  72. }
  73. ImageInfo(const ImageInfo& other);
  74. ImageInfo(ImageInfo&& other) noexcept;
  75. ImageInfo& operator=(ImageInfo& other);
  76. ImageInfo& operator=(ImageInfo&& other) noexcept;
  77. ~ImageInfo();
  78. int width; // 图像宽度
  79. int height; // 图像高度
  80. int channel; // 图像通道数
  81. ImageFormat format; // 图像格式
  82. unsigned char* data; // 图像数据
  83. };
  84. }
  85. #endif