cxerror.h 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. /*M///////////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
  4. //
  5. // By downloading, copying, installing or using the software you agree to this license.
  6. // If you do not agree to this license, do not download, install,
  7. // copy or use the software.
  8. //
  9. //
  10. // Intel License Agreement
  11. // For Open Source Computer Vision Library
  12. //
  13. // Copyright (C) 2000, Intel Corporation, all rights reserved.
  14. // Third party copyrights are property of their respective owners.
  15. //
  16. // Redistribution and use in source and binary forms, with or without modification,
  17. // are permitted provided that the following conditions are met:
  18. //
  19. // * Redistribution's of source code must retain the above copyright notice,
  20. // this list of conditions and the following disclaimer.
  21. //
  22. // * Redistribution's in binary form must reproduce the above copyright notice,
  23. // this list of conditions and the following disclaimer in the documentation
  24. // and/or other materials provided with the distribution.
  25. //
  26. // * The name of Intel Corporation may not be used to endorse or promote products
  27. // derived from this software without specific prior written permission.
  28. //
  29. // This software is provided by the copyright holders and contributors "as is" and
  30. // any express or implied warranties, including, but not limited to, the implied
  31. // warranties of merchantability and fitness for a particular purpose are disclaimed.
  32. // In no event shall the Intel Corporation or contributors be liable for any direct,
  33. // indirect, incidental, special, exemplary, or consequential damages
  34. // (including, but not limited to, procurement of substitute goods or services;
  35. // loss of use, data, or profits; or business interruption) however caused
  36. // and on any theory of liability, whether in contract, strict liability,
  37. // or tort (including negligence or otherwise) arising in any way out of
  38. // the use of this software, even if advised of the possibility of such damage.
  39. //
  40. //M*/
  41. #ifndef _CXCORE_ERROR_H_
  42. #define _CXCORE_ERROR_H_
  43. /************Below is declaration of error handling stuff in PLSuite manner**/
  44. typedef int CVStatus;
  45. /* this part of CVStatus is compatible with IPLStatus
  46. Some of below symbols are not [yet] used in OpenCV
  47. */
  48. #define CV_StsOk 0 /* everithing is ok */
  49. #define CV_StsBackTrace -1 /* pseudo error for back trace */
  50. #define CV_StsError -2 /* unknown /unspecified error */
  51. #define CV_StsInternal -3 /* internal error (bad state) */
  52. #define CV_StsNoMem -4 /* insufficient memory */
  53. #define CV_StsBadArg -5 /* function arg/param is bad */
  54. #define CV_StsBadFunc -6 /* unsupported function */
  55. #define CV_StsNoConv -7 /* iter. didn't converge */
  56. #define CV_StsAutoTrace -8 /* tracing */
  57. #define CV_HeaderIsNull -9 /* image header is NULL */
  58. #define CV_BadImageSize -10 /* image size is invalid */
  59. #define CV_BadOffset -11 /* offset is invalid */
  60. #define CV_BadDataPtr -12 /**/
  61. #define CV_BadStep -13 /**/
  62. #define CV_BadModelOrChSeq -14 /**/
  63. #define CV_BadNumChannels -15 /**/
  64. #define CV_BadNumChannel1U -16 /**/
  65. #define CV_BadDepth -17 /**/
  66. #define CV_BadAlphaChannel -18 /**/
  67. #define CV_BadOrder -19 /**/
  68. #define CV_BadOrigin -20 /**/
  69. #define CV_BadAlign -21 /**/
  70. #define CV_BadCallBack -22 /**/
  71. #define CV_BadTileSize -23 /**/
  72. #define CV_BadCOI -24 /**/
  73. #define CV_BadROISize -25 /**/
  74. #define CV_MaskIsTiled -26 /**/
  75. #define CV_StsNullPtr -27 /* null pointer */
  76. #define CV_StsVecLengthErr -28 /* incorrect vector length */
  77. #define CV_StsFilterStructContentErr -29 /* incorr. filter structure content */
  78. #define CV_StsKernelStructContentErr -30 /* incorr. transform kernel content */
  79. #define CV_StsFilterOffsetErr -31 /* incorrect filter ofset value */
  80. /*extra for CV */
  81. #define CV_StsBadSize -201 /* the input/output structure size is incorrect */
  82. #define CV_StsDivByZero -202 /* division by zero */
  83. #define CV_StsInplaceNotSupported -203 /* in-place operation is not supported */
  84. #define CV_StsObjectNotFound -204 /* request can't be completed */
  85. #define CV_StsUnmatchedFormats -205 /* formats of input/output arrays differ */
  86. #define CV_StsBadFlag -206 /* flag is wrong or not supported */
  87. #define CV_StsBadPoint -207 /* bad CvPoint */
  88. #define CV_StsBadMask -208 /* bad format of mask (neither 8uC1 nor 8sC1)*/
  89. #define CV_StsUnmatchedSizes -209 /* sizes of input/output structures do not match */
  90. #define CV_StsUnsupportedFormat -210 /* the data format/type is not supported by the function*/
  91. #define CV_StsOutOfRange -211 /* some of parameters are out of range */
  92. #define CV_StsParseError -212 /* invalid syntax/structure of the parsed file */
  93. #define CV_StsNotImplemented -213 /* the requested function/feature is not implemented */
  94. #define CV_StsBadMemBlock -214 /* an allocated block has been corrupted */
  95. /********************************* Error handling Macros ********************************/
  96. #define OPENCV_ERROR(status,func,context) \
  97. cvError((status),(func),(context),__FILE__,__LINE__)
  98. #define OPENCV_ERRCHK(func,context) \
  99. {if (cvGetErrStatus() >= 0) \
  100. {OPENCV_ERROR(CV_StsBackTrace,(func),(context));}}
  101. #define OPENCV_ASSERT(expr,func,context) \
  102. {if (! (expr)) \
  103. {OPENCV_ERROR(CV_StsInternal,(func),(context));}}
  104. #define OPENCV_RSTERR() (cvSetErrStatus(CV_StsOk))
  105. #define OPENCV_CALL( Func ) \
  106. { \
  107. Func; \
  108. }
  109. /**************************** OpenCV-style error handling *******************************/
  110. /* CV_FUNCNAME macro defines icvFuncName constant which is used by CV_ERROR macro */
  111. #ifdef CV_NO_FUNC_NAMES
  112. #define CV_FUNCNAME( Name )
  113. #define cvFuncName ""
  114. #else
  115. #define CV_FUNCNAME( Name ) \
  116. static char cvFuncName[] = Name
  117. #endif
  118. /*
  119. CV_ERROR macro unconditionally raises error with passed code and message.
  120. After raising error, control will be transferred to the exit label.
  121. */
  122. #define CV_ERROR( Code, Msg ) \
  123. { \
  124. cvError( (Code), cvFuncName, Msg, __FILE__, __LINE__ ); \
  125. EXIT; \
  126. }
  127. /* Simplified form of CV_ERROR */
  128. #define CV_ERROR_FROM_CODE( code ) \
  129. CV_ERROR( code, "" )
  130. /*
  131. CV_CHECK macro checks error status after CV (or IPL)
  132. function call. If error detected, control will be transferred to the exit
  133. label.
  134. */
  135. #define CV_CHECK() \
  136. { \
  137. if( cvGetErrStatus() < 0 ) \
  138. CV_ERROR( CV_StsBackTrace, "Inner function failed." ); \
  139. }
  140. /*
  141. CV_CALL macro calls CV (or IPL) function, checks error status and
  142. signals a error if the function failed. Useful in "parent node"
  143. error procesing mode
  144. */
  145. #define CV_CALL( Func ) \
  146. { \
  147. Func; \
  148. CV_CHECK(); \
  149. }
  150. /* Runtime assertion macro */
  151. #define CV_ASSERT( Condition ) \
  152. { \
  153. if( !(Condition) ) \
  154. CV_ERROR( CV_StsInternal, "Assertion: " #Condition " failed" ); \
  155. }
  156. #define __BEGIN__ {
  157. #define __END__ goto exit; exit: ; }
  158. #define __CLEANUP__
  159. #define EXIT goto exit
  160. #endif /* _CXCORE_ERROR_H_ */
  161. /* End of file. */