fisheye.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. #if !defined( __LIBFISHEYE_H__ )
  2. #define __LIBFISHEYE_H__
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #ifndef MAKEFOURCC
  7. #define MAKEFOURCC(ch0, ch1, ch2, ch3) \
  8. ((DWORD)(BYTE)(ch0) | ((DWORD)(BYTE)(ch1) << 8) | \
  9. ((DWORD)(BYTE)(ch2) << 16) | ((DWORD)(BYTE)(ch3) << 24 ))
  10. #endif //defined(MAKEFOURCC)
  11. #define LIBFISHEYE_VERSION MAKEFOURCC('3', '1', '1', '7')
  12. #ifndef DLLAPI
  13. #ifdef _WIN32
  14. #ifdef _USRDLL
  15. #define DLLAPI __declspec(dllexport) __stdcall
  16. #else
  17. #define DLLAPI __stdcall
  18. #endif //defined(_USRDLL)
  19. #else
  20. #define DLLAPI
  21. #endif //defined(_WIN32)
  22. #endif //defined(DLLAPI)
  23. #include "typedef.h"
  24. typedef enum _FisheyeVPixelFormat
  25. {
  26. FE_PIXELFORMAT_YUV420P, // YUV420 planar
  27. FE_PIXELFORMAT_RGB32 // RGBA interleaved
  28. }FEVPIXELFORMAT;
  29. typedef enum _FisheyeMountType
  30. {
  31. FE_MOUNT_WALL, // Wall
  32. FE_MOUNT_CEILING, // Ceiling
  33. FE_MOUNT_FLOOR // Floor
  34. }FEMOUNTTYPE;
  35. typedef enum _FisheyeDewarpType
  36. {
  37. FE_DEWARP_RECTILINEAR, // Rectilinear
  38. FE_DEWARP_FULLVIEWPANORAMA, // Full-view panorama
  39. FE_DEWARP_DUALVIEWPANORAMA, // Dual-view panorama (which is only available in FE_MOUNT_CEILING and FE_MOUNT_CEILING type)
  40. FE_DEWARP_CLIPVIEWPANORAMA, // Full-HD panorama
  41. FE_DEWARP_AERIALVIEW, // Aerial view
  42. FE_DEWARP_TENSIVEVIEW, // Tensive view
  43. FE_DEWARP_AROUNDVIEW // Around view (Panorama to Rectilinear)
  44. }FEDEWARPTYPE;
  45. typedef enum _FisheyeOptionFlag
  46. {
  47. FE_OPTION_INIMAGEHEADER = (1 << 0), // Input image header
  48. FE_OPTION_INIMAGEBUFFER = (1 << 1), // Input image buffer
  49. FE_OPTION_OUTIMAGEHEADER = (1 << 2), // Output image header
  50. FE_OPTION_OUTIMAGEBUFFER = (1 << 3), // Output image buffer
  51. FE_OPTION_FOVCENTER = (1 << 4), // FOV's center
  52. FE_OPTION_FOVRADIUS = (1 << 5), // FOV's radius
  53. FE_OPTION_MOUNTTYPE = (1 << 6), // Mount type (which is one of the FEMOUNTTYPE)
  54. FE_OPTION_DEWARPTYPE = (1 << 7), // Dewarp type (which is one of the FEDEWARPTYPE)
  55. FE_OPTION_OUTROI = (1 << 8), // Ouput ROI
  56. }FEOPTIONFLAG;
  57. typedef enum _FisheyePTZPositionFlag
  58. {
  59. FE_POSITION_ABSOLUTE, // Absolute position
  60. FE_POSITION_RELATIVE, // Relative position
  61. }FEPTZPOSITIONFLAG;
  62. typedef struct _FisheyePoint
  63. {
  64. int X; // X
  65. int Y; // Y
  66. }FEPOINT;
  67. typedef struct _FisheyeRect
  68. {
  69. int Left; // Left
  70. int Top; // Top
  71. int Right; // Right
  72. int Bottom; // Bottom
  73. }FERECT;
  74. typedef struct _FisheyeVPicture
  75. {
  76. /* Header field */
  77. unsigned int Width; // Width
  78. unsigned int Height; // Height
  79. unsigned int Stride; // Stride
  80. FEVPIXELFORMAT Format; // Pixel format (which is one of the FEVPIXELFORMAT)
  81. /* Buffer field */
  82. BYTE *Buffer; // Buffer
  83. }FEVPICTURE;
  84. typedef struct _FisheyeOption
  85. {
  86. DWORD Flags; // Option flags (which is the combination of one or more flags in FEOPTIONFLAG)
  87. FEVPICTURE InVPicture; // Input picture
  88. FEVPICTURE OutVPicture; // Output picture
  89. FEPOINT FOVCenter; // FOV's center
  90. unsigned int FOVRadius; // FOV's radius
  91. FEMOUNTTYPE MountType; // Mount type
  92. FEDEWARPTYPE DewarpType; // Dewarp type
  93. FERECT OutRoi; // Output ROI
  94. }FEOPTION;
  95. /* Initial the fisheye dewarp module */
  96. SCODE DLLAPI Fisheye_Initial(HANDLE *phObject, DWORD dwVersion);
  97. /* Release the fisheye dewarp module */
  98. SCODE DLLAPI Fisheye_Release(HANDLE *phObject);
  99. /* Dewarp the fisheye frame */
  100. SCODE DLLAPI Fisheye_OneFrame(HANDLE hObject);
  101. /* Change the settings in fisheye dewarp module */
  102. SCODE DLLAPI Fisheye_SetOption(HANDLE hObject, FEOPTION *pOption);
  103. /* Set customized fisheye lens distortion table */
  104. SCODE DLLAPI Fisheye_SetLensDistortionTable(HANDLE hObject, const double* pTable, unsigned int Count, double AngleStep);
  105. /* Set Pan, Tilt and Zoom. (This API uses to replace obsolete options setup.) */
  106. SCODE DLLAPI Fisheye_SetPanTiltZoom(HANDLE hObject, FEPTZPOSITIONFLAG Flag, float Pan, float Tilt, float Zoom);
  107. /* Get Pan, Tilt and Zoom. */
  108. SCODE DLLAPI Fisheye_GetPanTiltZoom(HANDLE hObject, float* pPan, float* pTilt, float* pZoom);
  109. /* Get current pan and tilt boundary*/
  110. SCODE DLLAPI Fisheye_GetCurrentPanBoundary(HANDLE hObject, float* pMinPan, float* pMaxPan);
  111. SCODE DLLAPI Fisheye_GetCurrentTiltBoundary(HANDLE hObject, float* pMinTilt, float* pMaxTilt);
  112. /* The following APIs are some mapping methods between fisheye source image and rectilinear dewarped image */
  113. /* Get Pan/Tilt according to the fisheye source point(x,y) in InVPicture (x : 0 ~ InVPicture.Width, y: 0 ~ InVPicture.Height) */
  114. SCODE DLLAPI Fisheye_InVPicturePointToPanTilt(HANDLE hObject, int X, int Y, float *pPan, float *pTilt);
  115. /* Get the fisheye source point(x,y) according to Pan/Tilt (x : 0 ~ InVPicture.Width, y: 0 ~ InVPicture.Height) */
  116. SCODE DLLAPI Fisheye_PanTiltToInVPicturePoint(HANDLE hObject, float Pan, float Tilt, int* pX, int* pY);
  117. /* Get Pan/Tilt/Zoom according to the fisheye source polygon region(X0,Y0)~(Xn,Yn) in InVPicture (x : 0 ~ InVPicture.Width, y: 0 ~ InVPicture.Height) */
  118. SCODE DLLAPI Fisheye_InVPicturePolygonToPanTiltZoom(HANDLE hObject, unsigned int Count, FEPOINT* pPolygon, float *pPan, float *pTilt, float *pZoom);
  119. /* Get the fisheye source point(x,y) according to OutRoi point(x, y) */
  120. /* (Xo : 0 ~ OutRoi Width, Yo: 0 ~ OutRoi Height) */
  121. /* (Xi : 0 ~ InVPicture.Width, Yi: 0 ~ InVPicture.Height) */
  122. SCODE DLLAPI Fisheye_OutRoiPointToInVPicturePoint(HANDLE hObject, int Xo, int Yo, int* pXi, int* pYi);
  123. #ifdef __cplusplus
  124. }
  125. #endif
  126. #endif // __LIBFISHEYE_H__