#include-once
; #INDEX# =======================================================================================================================
#region
; Title .........: OpenCV
; AutoIt Version : 3.3.6.1
; Description ...: OpenCV functions that have been translated to AutoIt functions.
; Author(s) .....: Mathias Obetzhauser (m-obi)
; Dll ...........: opencv_core242.dll, opencv_highgui242.dll, opencv_imgproc242.dll, opencv_video242.dll, tbb.dll, tbb_debug.dll
#endregion
; #INDEX# =======================================================================================================================
; #VARIABLES# ===================================================================================================================
#region
Global $__ghOCVDll_1 = 0
Global $__ghOCVDll_2 = 0
Global $__ghOCVDll_3 = 0
Global $__ghOCVDll_4 = 0
Global $__giOCVRef = 0
Global $__ghMouseCallback = 0
Global $NULL = Chr(0)
#endregion
; #VARIABLES# ===================================================================================================================
; #CONSTANTS# ===================================================================================================================
#region
Global Const $CV_LOAD_IMAGE_UNCHANGED = -1
Global Const $CV_LOAD_IMAGE_GRAYSCALE = 0
Global Const $CV_LOAD_IMAGE_COLOR = 1
Global Const $CV_LOAD_IMAGE_ANYDEPTH = 2
Global Const $CV_LOAD_IMAGE_ANYCOLOR = 4
; These 4 flags are used by cvSet/GetWindowProperty
Global Const $CV_WND_PROP_FULLSCREEN = 0 ; to change/get window's fullscreen property
Global Const $CV_WND_PROP_AUTOSIZE = 1 ; to change/get window's autosize property
Global Const $CV_WND_PROP_ASPECTRATIO = 2 ; to change/get window's aspectratio property
Global Const $CV_WND_PROP_OPENGL = 3 ; to change/get window's opengl support
; These 3 flags are used by cvNamedWindow and cvSet/GetWindowProperty
Global Const $CV_WINDOW_NORMAL = 0x00000000 ; the user can resize the window (no constraint) / also use to switch a fullscreen window to a normal size
Global Const $CV_WINDOW_AUTOSIZE = 0x00000001 ; the user cannot resize the window, the size is constrainted by the image displayed
Global Const $CV_WINDOW_OPENGL = 0x00001000 ; window with opengl support
; Those flags are only for Qt
Global Const $CV_GUI_EXPANDED = 0x00000000 ; status bar and tool bar
Global Const $CV_GUI_NORMAL = 0x00000010 ; old fashious way
; These 3 flags are used by cvNamedWindow and cvSet/GetWindowProperty
Global Const $CV_WINDOW_FULLSCREEN = 1 ; change the window to fullscreen
Global Const $CV_WINDOW_FREERATIO = 0x00000100 ; the image expends as much as it can (no ratio constraint)
Global Const $CV_WINDOW_KEEPRATIO = 0x00000000 ; the ration image is respected.
Global Const $CV_IMWRITE_JPEG_QUALITY = 1
Global Const $CV_IMWRITE_PNG_COMPRESSION = 16
Global Const $CV_IMWRITE_PNG_STRATEGY = 17
Global Const $CV_IMWRITE_PNG_STRATEGY_DEFAULT = 0
Global Const $CV_IMWRITE_PNG_STRATEGY_FILTERED = 1
Global Const $CV_IMWRITE_PNG_STRATEGY_HUFFMAN_ONLY = 2
Global Const $CV_IMWRITE_PNG_STRATEGY_RLE = 3
Global Const $CV_IMWRITE_PNG_STRATEGY_FIXED = 4
Global Const $CV_IMWRITE_PXM_BINARY = 32
Global Const $tagIplImage = _
"align 4;" & _
"int nSize;" & _
"int ID;" & _
"int nChannels;" & _
"int alphaChannel;" & _
"int depth;" & _
"char colorModel[4];" & _
"char channelSeq[4];" & _
"int dataOrder;" & _
"int origin;" & _
"int align;" & _
"int width;" & _
"int height;" & _
"ptr _IplROI ;" & _
"ptr _IplImage ;" & _
"ptr imageId;" & _
"ptr _IplTileInfo ;" & _
"int imageSize;" & _
"ptr imageData;" & _
"int widthStep;" & _
"int BorderMode[4];" & _
"int BorderConst[4];" & _
"ptr imageDataOrigin"
Global Const $CV_MAX_DIM = 32
Global Const $CV_MAX_DIM_HEAP = 1024
Global Const $tagCvHistogram = _
"int type;" & _
"ptr bins;" & _
"float thresh[" & $CV_MAX_DIM * 2 & "];" & _ ; For uniform histograms.
"ptr thresh2;" & _ ; For non-uniform histograms.
"ptr mat" ; Embedded matrix header for array histograms.
;*************************************** CvRect *****************************************
Global Const $tagCvRect = _
"int x;" & _
"int y;" & _
"int width;" & _
"int height"
;******************************* CvPoint and variants ***********************************
Global Const $tagCvPoint = _
"int x;" & _
"int y;"
Global Const $tagCvPoint2D32f = _
"float x;" & _
"float y;"
Global Const $tagCvPoint3D32f = _
"float x;" & _
"float y;" & _
"float z;"
Global Const $tagCvPoint2D64f = _
"double x;" & _
"double y;"
Global Const $tagCvPoint3D64f = _
"double x;" & _
"double y;" & _
"double z;"
;******************************** CvSize's & CvBox **************************************
Global Const $tagCvSize = _
"int width;" & _
"int height;"
Global Const $tagCvSize2D32f = _
"float width;" & _
"float height;"
Global Const $tagCvBox2D = _
"CvPoint2D32f center;" & _ ; Center of the box
"CvSize2D32f size;" & _ ; Box width and length
"float angle" ; Angle between the horizontal axis and the first side (i.e. length) in degrees
Global $T_CvPoint3D32f = DllStructCreate($tagCvPoint3D32f)
Global $T_CvSize2D32f = DllStructCreate($tagCvSize2D32f)
Global $pCvPoint3D32f = DllStructGetPtr($T_CvPoint3D32f)
Global $pCvSize2D32f = DllStructGetPtr($T_CvSize2D32f)
Global $T_CvBox2D = DllStructCreate($pCvPoint3D32f & ";" & $pCvSize2D32f & ";float angle")
; Line iterator state
Global Const $tagCvLineIterator = _
"byte* ptr;" & _ ; Pointer to the current point
"int err;" & _ ; Bresenham algorithm state
"int plus_delta;" & _
"int minus_delta;" & _
"int plus_step;" & _
"int minus_step"
Global Const $tagCvMat = _
"int type;" & _
"int step;" & _
"INT_PTR refcount;" & _
"int hdr_refcount;" & _
"ptr data;" & _
"int rows;" & _
"int cols"
;************************************* CvScalar *****************************************
Global Const $tagCvScalar = "double val[4];"
; Connected component structure
Global Const $tagCvConnectedComp = _
"double area;" & _ ; area of the connected component
"CvScalar value;" & _ ; average color of the connected component
"CvRect rect;" & _ ; ROI of the component
"CvSeq* contour" ; optional component boundary (the contour might have child contours corresponding to the holes)
; Constants for color conversion
Global Const $CV_BGR2BGRA = 0
Global Const $CV_RGB2RGBA = $CV_BGR2BGRA
Global Const $CV_BGRA2BGR = 1
Global Const $CV_RGBA2RGB = $CV_BGRA2BGR
Global Const $CV_BGR2RGBA = 2
Global Const $CV_RGB2BGRA = $CV_BGR2RGBA
Global Const $CV_RGBA2BGR = 3
Global Const $CV_BGRA2RGB = $CV_RGBA2BGR
Global Const $CV_BGR2RGB = 4
Global Const $CV_RGB2BGR = $CV_BGR2RGB
Global Const $CV_BGRA2RGBA = 5
Global Const $CV_RGBA2BGRA = $CV_BGRA2RGBA
Global Const $CV_BGR2GRAY = 6
Global Const $CV_RGB2GRAY = 7
Global Const $CV_GRAY2BGR = 8
Global Const $CV_GRAY2RGB = $CV_GRAY2BGR
Global Const $CV_GRAY2BGRA = 9
Global Const $CV_GRAY2RGBA = $CV_GRAY2BGRA
Global Const $CV_BGRA2GRAY = 10
Global Const $CV_RGBA2GRAY = 11
Global Const $CV_BGR2BGR565 = 12
Global Const $CV_RGB2BGR565 = 13
Global Const $CV_BGR5652BGR = 14
Global Const $CV_BGR5652RGB = 15
Global Const $CV_BGRA2BGR565 = 16
Global Const $CV_RGBA2BGR565 = 17
Global Const $CV_BGR5652BGRA = 18
Global Const $CV_BGR5652RGBA = 19
Global Const $CV_GRAY2BGR565 = 20
Global Const $CV_BGR5652GRAY = 21
Global Const $CV_BGR2BGR555 = 22
Global Const $CV_RGB2BGR555 = 23
Global Const $CV_BGR5552BGR = 24
Global Const $CV_BGR5552RGB = 25
Global Const $CV_BGRA2BGR555 = 26
Global Const $CV_RGBA2BGR555 = 27
Global Const $CV_BGR5552BGRA = 28
Global Const $CV_BGR5552RGBA = 29
Global Const $CV_GRAY2BGR555 = 30
Global Const $CV_BGR5552GRAY = 31
Global Const $CV_BGR2XYZ = 32
Global Const $CV_RGB2XYZ = 33
Global Const $CV_XYZ2BGR = 34
Global Const $CV_XYZ2RGB = 35
Global Const $CV_BGR2YCrCb = 36
Global Const $CV_RGB2YCrCb = 37
Global Const $CV_YCrCb2BGR = 38
Global Const $CV_YCrCb2RGB = 39
Global Const $CV_BGR2HSV = 40
Global Const $CV_RGB2HSV = 41
Global Const $CV_BGR2Lab = 44
Global Const $CV_RGB2Lab = 45
Global Const $CV_BayerBG2BGR = 46
Global Const $CV_BayerGB2BGR = 47
Global Const $CV_BayerRG2BGR = 48
Global Const $CV_BayerGR2BGR = 49
Global Const $CV_BayerBG2RGB = $CV_BayerRG2BGR
Global Const $CV_BayerGB2RGB = $CV_BayerGR2BGR
Global Const $CV_BayerRG2RGB = $CV_BayerBG2BGR
Global Const $CV_BayerGR2RGB = $CV_BayerGB2BGR
Global Const $CV_BGR2Luv = 50
Global Const $CV_RGB2Luv = 51
Global Const $CV_BGR2HLS = 52
Global Const $CV_RGB2HLS = 53
Global Const $CV_HSV2BGR = 54
Global Const $CV_HSV2RGB = 55
Global Const $CV_Lab2BGR = 56
Global Const $CV_Lab2RGB = 57
Global Const $CV_Luv2BGR = 58
Global Const $CV_Luv2RGB = 59
Global Const $CV_HLS2BGR = 60
Global Const $CV_HLS2RGB = 61
Global Const $CV_BayerBG2BGR_VNG = 62
Global Const $CV_BayerGB2BGR_VNG = 63
Global Const $CV_BayerRG2BGR_VNG = 64
Global Const $CV_BayerGR2BGR_VNG = 65
Global Const $CV_BAYERBG2RGB_VNG = $CV_BAYERRG2BGR_VNG
Global Const $CV_BAYERGB2RGB_VNG = $CV_BAYERGR2BGR_VNG
Global Const $CV_BAYERRG2RGB_VNG = $CV_BAYERBG2BGR_VNG
Global Const $CV_BAYERGR2RGB_VNG = $CV_BAYERGB2BGR_VNG
Global Const $CV_BGR2HSV_FULL = 66
Global Const $CV_RGB2HSV_FULL = 67
Global Const $CV_BGR2HLS_FULL = 68
Global Const $CV_RGB2HLS_FULL = 69
Global Const $CV_HSV2BGR_FULL = 70
Global Const $CV_HSV2RGB_FULL = 71
Global Const $CV_HLS2BGR_FULL = 72
Global Const $CV_HLS2RGB_FULL = 73
Global Const $CV_LBGR2LAB = 74
Global Const $CV_LRGB2LAB = 75
Global Const $CV_LBGR2LUV = 76
Global Const $CV_LRGB2LUV = 77
Global Const $CV_LAB2LBGR = 78
Global Const $CV_LAB2LRGB = 79
Global Const $CV_LUV2LBGR = 80
Global Const $CV_LUV2LRGB = 81
Global Const $CV_BGR2YUV = 82
Global Const $CV_RGB2YUV = 83
Global Const $CV_YUV2BGR = 84
Global Const $CV_YUV2RGB = 85
Global Const $CV_BAYERBG2GRAY = 86
Global Const $CV_BAYERGB2GRAY = 87
Global Const $CV_BAYERRG2GRAY = 88
Global Const $CV_BAYERGR2GRAY = 89
; YUV 4:2:0 formats family
Global Const $CV_YUV2RGB_NV12 = 90
Global Const $CV_YUV2BGR_NV12 = 91
Global Const $CV_YUV2RGB_NV21 = 92
Global Const $CV_YUV2BGR_NV21 = 93
Global Const $CV_YUV420SP2RGB = $CV_YUV2RGB_NV21
Global Const $CV_YUV420SP2BGR = $CV_YUV2BGR_NV21
Global Const $CV_YUV2RGBA_NV12 = 94
Global Const $CV_YUV2BGRA_NV12 = 95
Global Const $CV_YUV2RGBA_NV21 = 96
Global Const $CV_YUV2BGRA_NV21 = 97
Global Const $CV_YUV420sp2RGBA = $CV_YUV2RGBA_NV21
Global Const $CV_YUV420sp2BGRA = $CV_YUV2BGRA_NV21
Global Const $CV_YUV2RGB_YV12 = 98
Global Const $CV_YUV2BGR_YV12 = 99
Global Const $CV_YUV2RGB_IYUV = 100
Global Const $CV_YUV2BGR_IYUV = 101
Global Const $CV_YUV2RGB_I420 = $CV_YUV2RGB_IYUV
Global Const $CV_YUV2BGR_I420 = $CV_YUV2BGR_IYUV
Global Const $CV_YUV420P2RGB = $CV_YUV2RGB_YV12
Global Const $CV_YUV420P2BGR = $CV_YUV2BGR_YV12
Global Const $CV_YUV2RGBA_YV12 = 102
Global Const $CV_YUV2BGRA_YV12 = 103
Global Const $CV_YUV2RGBA_IYUV = 104
Global Const $CV_YUV2BGRA_IYUV = 105
Global Const $CV_YUV2RGBA_I420 = $CV_YUV2RGBA_IYUV
Global Const $CV_YUV2BGRA_I420 = $CV_YUV2BGRA_IYUV
Global Const $CV_YUV420P2RGBA = $CV_YUV2RGBA_YV12
Global Const $CV_YUV420P2BGRA = $CV_YUV2BGRA_YV12
Global Const $CV_YUV2GRAY_420 = 106
Global Const $CV_YUV2GRAY_NV21 = $CV_YUV2GRAY_420
Global Const $CV_YUV2GRAY_NV12 = $CV_YUV2GRAY_420
Global Const $CV_YUV2GRAY_YV12 = $CV_YUV2GRAY_420
Global Const $CV_YUV2GRAY_IYUV = $CV_YUV2GRAY_420
Global Const $CV_YUV2GRAY_I420 = $CV_YUV2GRAY_420
Global Const $CV_YUV420SP2GRAY = $CV_YUV2GRAY_420
Global Const $CV_YUV420P2GRAY = $CV_YUV2GRAY_420
; YUV 4:2:2 formats family
Global Const $CV_YUV2RGB_UYVY = 107
Global Const $CV_YUV2BGR_UYVY = 108
; Global Const $CV_YUV2RGB_VYUY = 109
; Global Const $CV_YUV2BGR_VYUY = 110
Global Const $CV_YUV2RGB_Y422 = $CV_YUV2RGB_UYVY
Global Const $CV_YUV2BGR_Y422 = $CV_YUV2BGR_UYVY
Global Const $CV_YUV2RGB_UYNV = $CV_YUV2RGB_UYVY
Global Const $CV_YUV2BGR_UYNV = $CV_YUV2BGR_UYVY
Global Const $CV_YUV2RGBA_UYVY = 111
Global Const $CV_YUV2BGRA_UYVY = 112
; Global Const $CV_YUV2RGBA_VYUY = 113
; Global Const $CV_YUV2BGRA_VYUY = 114
Global Const $CV_YUV2RGBA_Y422 = $CV_YUV2RGBA_UYVY
Global Const $CV_YUV2BGRA_Y422 = $CV_YUV2BGRA_UYVY
Global Const $CV_YUV2RGBA_UYNV = $CV_YUV2RGBA_UYVY
Global Const $CV_YUV2BGRA_UYNV = $CV_YUV2BGRA_UYVY
Global Const $CV_YUV2RGB_YUY2 = 115
Global Const $CV_YUV2BGR_YUY2 = 116
Global Const $CV_YUV2RGB_YVYU = 117
Global Const $CV_YUV2BGR_YVYU = 118
Global Const $CV_YUV2RGB_YUYV = $CV_YUV2RGB_YUY2
Global Const $CV_YUV2BGR_YUYV = $CV_YUV2BGR_YUY2
Global Const $CV_YUV2RGB_YUNV = $CV_YUV2RGB_YUY2
Global Const $CV_YUV2BGR_YUNV = $CV_YUV2BGR_YUY2
Global Const $CV_YUV2RGBA_YUY2 = 119
Global Const $CV_YUV2BGRA_YUY2 = 120
Global Const $CV_YUV2RGBA_YVYU = 121
Global Const $CV_YUV2BGRA_YVYU = 122
Global Const $CV_YUV2RGBA_YUYV = $CV_YUV2RGBA_YUY2
Global Const $CV_YUV2BGRA_YUYV = $CV_YUV2BGRA_YUY2
Global Const $CV_YUV2RGBA_YUNV = $CV_YUV2RGBA_YUY2
Global Const $CV_YUV2BGRA_YUNV = $CV_YUV2BGRA_YUY2
Global Const $CV_YUV2GRAY_UYVY = 123
Global Const $CV_YUV2GRAY_YUY2 = 124
; Global Const $CV_YUV2GRAY_VYUY = $CV_YUV2GRAY_UYVY
Global Const $CV_YUV2GRAY_Y422 = $CV_YUV2GRAY_UYVY
Global Const $CV_YUV2GRAY_UYNV = $CV_YUV2GRAY_UYVY
Global Const $CV_YUV2GRAY_YVYU = $CV_YUV2GRAY_YUY2
Global Const $CV_YUV2GRAY_YUYV = $CV_YUV2GRAY_YUY2
Global Const $CV_YUV2GRAY_YUNV = $CV_YUV2GRAY_YUY2
; alpha premultiplication
Global Const $CV_RGBA2MRGBA = 125
Global Const $CV_MRGBA2RGBA = 126
Global Const $CV_COLORCVT_MAX = 127
; Sub-pixel interpolation methods
Global Const $CV_INTER_NN = 0
Global Const $CV_INTER_LINEAR = 1
Global Const $CV_INTER_CUBIC = 2
Global Const $CV_INTER_AREA = 3
Global Const $CV_INTER_LANCZOS4 = 4
Global Const $CV_AA = 16
Global Const $CV_FILLED = -1
Global Const $CV_EVENT_MOUSEMOVE = 0
Global Const $CV_EVENT_LBUTTONDOWN = 1
Global Const $CV_EVENT_RBUTTONDOWN = 2
Global Const $CV_EVENT_MBUTTONDOWN = 3
Global Const $CV_EVENT_LBUTTONUP = 4
Global Const $CV_EVENT_RBUTTONUP = 5
Global Const $CV_EVENT_MBUTTONUP = 6
Global Const $CV_EVENT_LBUTTONDBLCLK = 7
Global Const $CV_EVENT_RBUTTONDBLCLK = 8
Global Const $CV_EVENT_MBUTTONDBLCLK = 9
;****************************************************************************************
; Matrix type (CvMat)
;****************************************************************************************
Global Const $CV_CN_MAX = 512
Global Const $CV_CN_SHIFT = 3
Global Const $CV_DEPTH_MAX = BitShift(1, 0 - $CV_CN_SHIFT)
Global Const $CV_8U = 0
Global Const $CV_8S = 1
Global Const $CV_16U = 2
Global Const $CV_16S = 3
Global Const $CV_32S = 4
Global Const $CV_32F = 5
Global Const $CV_64F = 6
Global Const $CV_USRTYPE1 = 7
Global Const $CV_MAT_DEPTH_MASK = $CV_DEPTH_MAX - 1
Global Const $CV_8UC1 = __MAKETYPE($CV_8U,1)
Global Const $CV_8UC2 = __MAKETYPE($CV_8U,2)
Global Const $CV_8UC3 = __MAKETYPE($CV_8U,3)
Global Const $CV_8UC4 = __MAKETYPE($CV_8U,4)
Global Const $CV_8SC1 = __MAKETYPE($CV_8S,1)
Global Const $CV_8SC2 = __MAKETYPE($CV_8S,2)
Global Const $CV_8SC3 = __MAKETYPE($CV_8S,3)
Global Const $CV_8SC4 = __MAKETYPE($CV_8S,4)
Global Const $CV_16UC1 = __MAKETYPE($CV_16U,1)
Global Const $CV_16UC2 = __MAKETYPE($CV_16U,2)
Global Const $CV_16UC3 = __MAKETYPE($CV_16U,3)
Global Const $CV_16UC4 = __MAKETYPE($CV_16U,4)
Global Const $CV_16SC1 = __MAKETYPE($CV_16S,1)
Global Const $CV_16SC2 = __MAKETYPE($CV_16S,2)
Global Const $CV_16SC3 = __MAKETYPE($CV_16S,3)
Global Const $CV_16SC4 = __MAKETYPE($CV_16S,4)
Global Const $CV_32SC1 = __MAKETYPE($CV_32S,1)
Global Const $CV_32SC2 = __MAKETYPE($CV_32S,2)
Global Const $CV_32SC3 = __MAKETYPE($CV_32S,3)
Global Const $CV_32SC4 = __MAKETYPE($CV_32S,4)
Global Const $CV_32FC1 = __MAKETYPE($CV_32F,1)
Global Const $CV_32FC2 = __MAKETYPE($CV_32F,2)
Global Const $CV_32FC3 = __MAKETYPE($CV_32F,3)
Global Const $CV_32FC4 = __MAKETYPE($CV_32F,4)
Global Const $CV_64FC1 = __MAKETYPE($CV_64F,1)
Global Const $CV_64FC2 = __MAKETYPE($CV_64F,2)
Global Const $CV_64FC3 = __MAKETYPE($CV_64F,3)
Global Const $CV_64FC4 = __MAKETYPE($CV_64F,4)
Global Const $CV_AUTO_STEP = 0x7fffffff
;~ Global Const $CV_WHOLE_ARR = cvSlice( 0, 0x3fffffff )
;~ Global Const $CV_MAT_CN_MASK ((CV_CN_MAX - 1) << CV_CN_SHIFT)
;~ Global Const $CV_MAT_CN(flags) ((((flags) & CV_MAT_CN_MASK) >> CV_CN_SHIFT) + 1)
;~ Global Const $CV_MAT_TYPE_MASK (CV_DEPTH_MAX*CV_CN_MAX - 1)
;~ Global Const $CV_MAT_TYPE(flags) ((flags) & CV_MAT_TYPE_MASK)
;~ Global Const $CV_MAT_CONT_FLAG_SHIFT 14
;~ Global Const $CV_MAT_CONT_FLAG (1 << CV_MAT_CONT_FLAG_SHIFT)
;~ Global Const $CV_IS_MAT_CONT(flags) ((flags) & CV_MAT_CONT_FLAG)
;~ Global Const $CV_IS_CONT_MAT CV_IS_MAT_CONT
;~ Global Const $CV_SUBMAT_FLAG_SHIFT 15
;~ Global Const $CV_SUBMAT_FLAG (1 << CV_SUBMAT_FLAG_SHIFT)
;~ Global Const $CV_IS_SUBMAT(flags) ((flags) & CV_MAT_SUBMAT_FLAG)
Global Const $CV_MAGIC_MASK = 0xFFFF0000
Global Const $CV_MAT_MAGIC_VAL = 0x42420000
Global Const $CV_TYPE_NAME_MAT = "opencv-matrix"
Global Const $CV_TERMCRIT_ITER = 1
Global Const $CV_TERMCRIT_NUMBER = $CV_TERMCRIT_ITER
Global Const $CV_TERMCRIT_EPS = 2
Global Const $CV_PI = 3.1415926535897932384626433832795
Global Const $CV_LOG2 = 0.69314718055994530941723212145818
; Threshold types
Global Const $CV_THRESH_BINARY = 0 ; value = value > threshold ? max_value : 0
Global Const $CV_THRESH_BINARY_INV = 1 ; value = value > threshold ? 0 : max_value
Global Const $CV_THRESH_TRUNC = 2 ; value = value > threshold ? threshold : value
Global Const $CV_THRESH_TOZERO = 3 ; value = value > threshold ? value : 0
Global Const $CV_THRESH_TOZERO_INV = 4 ; value = value > threshold ? 0 : value
Global Const $CV_THRESH_MASK = 7
Global Const $CV_THRESH_OTSU = 8 ; use Otsu algorithm to choose the optimal threshold value;
; combine the flag with one of the above CV_THRESH_* values
; Adaptive threshold methods
Global Const $CV_ADAPTIVE_THRESH_MEAN_C = 0
Global Const $CV_ADAPTIVE_THRESH_GAUSSIAN_C = 1
; FloodFill flags
Global Const $CV_FLOODFILL_FIXED_RANGE = 0x10000
Global Const $CV_FLOODFILL_MASK_ONLY = 0x20000
; Canny edge detector flags
Global Const $CV_CANNY_L2_GRADIENT = 0x80000000
; Variants of a Hough transform
Global Const $CV_HOUGH_STANDARD = 0
Global Const $CV_HOUGH_PROBABILISTIC = 1
Global Const $CV_HOUGH_MULTI_SCALE = 2
Global Const $CV_HOUGH_GRADIENT = 3
Global Const $tagCvMemStorage = _
"int signature;" & _
"ptr bottom;" & _
"ptr top;" & _
"ptr parent;" & _
"int block_size;" & _
"int free_space"
#endregion
; #CONSTANTS# ===================================================================================================================
; #CURRENT# =====================================================================================================================
#region
#endregion
; #CURRENT# =====================================================================================================================
Func _OpenCV_CalcArrBackProject($_tImage, $_tHist)
Local $_tBackProject = DllStructCreate("float;float;float;float;float")
DllCall($__ghOCVDll_3, "none:cdecl", "cvCalcArrBackProject", "ptr", DllStructGetPtr($_tImage), "ptr", DllStructGetPtr($_tBackProject), _
"ptr", DllStructGetPtr($_tHist))
If @error Then Return SetError(@error, 0, 0)
Return $_tBackProject
EndFunc
Func _OpenCV_CalcArrHist($_tImage, $_iAccumulate = 0, $_tMask = $NULL)
Local $_tHist = DllStructCreate($tagCvHistogram)
DllCall($__ghOCVDll_3, "none:cdecl", "cvCalcArrHist", "ptr", DllStructGetPtr($_tImage), "ptr", DllStructGetPtr($_tHist), _
"int", $_iAccumulate, "ptr", DllStructGetPtr($_tMask))
If @error Then Return SetError(@error, 0, 0)
Return $_tHist
EndFunc
Func _OpenCV_CamShift($_tProbImage, $_tWindow, $_tCriteria)
Local $_tComp = DllStructCreate("float;float;float;float;float")
Local $_tRect = DllStructCreate("float;float;float;float;float")
DllCall($__ghOCVDll_4, "none:cdecl", "cvCamShift", "ptr", DllStructGetPtr($_tProbImage), "ptr", DllStructGetPtr($_tWindow), _
"ptr", DllStructGetPtr($_tCriteria), "ptr", DllStructGetPtr($_tComp), "ptr", DllStructGetPtr($_tRect))
If @error Then Return SetError(@error, 0, 0)
Return $_tRect
EndFunc
Func _OpenCV_Threshold(ByRef $_tImage, $_fThreshold, $_fMaxValue, $_iThresholdType)
Local $_tImageDst = _OpenCV_CloneImage($_tImage)
DllCall($__ghOCVDll_3, "double:cdecl", "cvThreshold", "ptr", DllStructGetPtr($_tImage), "ptr", DllStructGetPtr($_tImageDst), "double", $_fThreshold, "double", $_fMaxValue, "int", $_iThresholdType)
If @error Then
Local $_iError = @error
_OpenCV_ReleaseImage($_tImageDst)
Return SetError($_iError, 0, False)
EndIf
_OpenCV_ReleaseImage($_tImage)
$_tImage = _OpenCV_CloneImage($_tImageDst)
_OpenCV_ReleaseImage($_tImageDst)
Return True
EndFunc
Func _OpenCV_Canny(ByRef $_tImage, $_fThreshold1, $_fThreshold2, $_iApertureSize = 3)
Local $_tImageDst = _OpenCV_CloneImage($_tImage)
DllCall($__ghOCVDll_3, "none:cdecl", "cvCanny", "ptr", DllStructGetPtr($_tImage), "ptr", DllStructGetPtr($_tImageDst), "double", $_fThreshold1, "double", $_fThreshold2, "int", $_iApertureSize)
If @error Then
Local $_iError = @error
_OpenCV_ReleaseImage($_tImageDst)
Return SetError($_iError, 0, False)
EndIf
_OpenCV_ReleaseImage($_tImage)
$_tImage = _OpenCV_CloneImage($_tImageDst)
_OpenCV_ReleaseImage($_tImageDst)
Return True
EndFunc
Func _OpenCV_PreCornerDetect(ByRef $_tImage, $_iApertureSize = 3)
Local $_tImageDst = _OpenCV_CreateImage(DllStructGetData($_tImage, "width"), DllStructGetData($_tImage, "height"), 32, 1)
DllCall($__ghOCVDll_3, "none:cdecl", "cvPreCornerDetect", "ptr", DllStructGetPtr($_tImage), "ptr", DllStructGetPtr($_tImageDst), "int", $_iApertureSize)
If @error Then
Local $_iError = @error
_OpenCV_ReleaseImage($_tImageDst)
Return SetError($_iError, 0, False)
EndIf
_OpenCV_ReleaseImage($_tImage)
$_tImage = _OpenCV_CloneImage($_tImageDst)
_OpenCV_ReleaseImage($_tImageDst)
Return True
EndFunc
Func _OpenCV_CornerMinEigenVal(ByRef $_tImage, $_iBlockSize, $_iApertureSize = 3)
Local $_tImageDst = _OpenCV_CreateImage(DllStructGetData($_tImage, "width"), DllStructGetData($_tImage, "height"), 32, 1)
DllCall($__ghOCVDll_3, "none:cdecl", "cvCornerMinEigenVal", "ptr", DllStructGetPtr($_tImage), "ptr", DllStructGetPtr($_tImageDst), "int", $_iBlockSize, "int", $_iApertureSize)
If @error Then
Local $_iError = @error
_OpenCV_ReleaseImage($_tImageDst)
Return SetError($_iError, 0, False)
EndIf
_OpenCV_ReleaseImage($_tImage)
$_tImage = _OpenCV_CloneImage($_tImageDst)
_OpenCV_ReleaseImage($_tImageDst)
Return True
EndFunc
Func _OpenCV_CornerHarris(ByRef $_tImage, $_iBlockSize, $_iApertureSize = 3, $_fK = 0.04)
Local $_tImageDst = _OpenCV_CreateImage(DllStructGetData($_tImage, "width"), DllStructGetData($_tImage, "height"), 32, 1)
DllCall($__ghOCVDll_3, "none:cdecl", "cvCornerHarris", "ptr", DllStructGetPtr($_tImage), "ptr", DllStructGetPtr($_tImageDst), "int", $_iBlockSize, "int", $_iApertureSize, "double", $_fK)
If @error Then
Local $_iError = @error
_OpenCV_ReleaseImage($_tImageDst)
Return SetError($_iError, 0, False)
EndIf
_OpenCV_ReleaseImage($_tImage)
$_tImage = _OpenCV_CloneImage($_tImageDst)
_OpenCV_ReleaseImage($_tImageDst)
Return True
EndFunc
Func _OpenCV_Circle($_tImage, $_iX, $_iY, $_iRadius, $_iColor = 0xFFFFFF, $_iThickness = 1, $_iLineType = 8, $_iShift = 0)
Local $_iR = BitAND(BitShift($_iColor, 16), 0xFF)
Local $_iG = BitAND(BitShift($_iColor, 8), 0xFF)
Local $_iB = BitAND($_iColor, 0xFF)
DllCall($__ghOCVDll_1, "none:cdecl", "cvCircle", "ptr", DllStructGetPtr($_tImage), "int", $_iX, "int", $_iY, "int", $_iRadius, _
"double", $_iB, "double", $_iG, "double", $_iR, "double", 0, "int", $_iThickness, "int", $_iLineType, "int", $_iShift)
If @error Then Return SetError(@error, 0, 0)
Return 1
EndFunc
Func _OpenCV_CloneImage($_tImage)
Local $_aResult = DllCall($__ghOCVDll_1, "int:cdecl", "cvCloneImage", "ptr", DllStructGetPtr($_tImage))
If @error Then Return SetError(@error, 0, 0)
Return DllStructCreate($tagIplImage, Ptr($_aResult[0]))
EndFunc
Func _OpenCV_ConvertScale($_tImageSrc, ByRef $_tImageDst, $_fScale = 1.0, $_fShift = 0.0)
DllCall($__ghOCVDll_1, "none:cdecl", "cvConvertScale", "ptr", DllStructGetPtr($_tImageSrc), "ptr", DllStructGetPtr($_tImageDst), "double", $_fScale, "double", $_fShift)
If @error Then Return SetError(@error, 0, 0)
Return 1
EndFunc
Func _OpenCV_CreateCameraCapture($_iIndex = -1)
Local $_aResult = DllCall($__ghOCVDll_2, "ptr:cdecl", "cvCreateCameraCapture", "int", $_iIndex)
If @error Then Return SetError(1, @error, 0)
If $_aResult[0] = Ptr(0) Then SetError(2, 0, 0)
Return $_aResult[0]
EndFunc
Func _OpenCV_CreateImage($_iWidth, $_iHeight, $_iDepth, $_iChannels)
Local $_aResult = DllCall($__ghOCVDll_1, "int:cdecl", "cvCreateImage", "int", $_iWidth, "int", $_iHeight, "int", $_iDepth, "int", $_iChannels)
If @error Then Return SetError(@error, 0, 0)
Return DllStructCreate($tagIplImage, $_aResult[0])
EndFunc
Func _OpenCV_CreateMat($_iRows, $_iCols, $_iType)
Local $_aResult = DllCall($__ghOCVDll_1, "int:cdecl", "cvCreateMat", "int", $_iRows, "int", $_iCols, "int", $_iType)
If @error Then Return SetError(@error, 0, 0)
Return DllStructCreate($tagCvMat, $_aResult[0])
EndFunc
Func _OpenCV_CreateMemStorage($_iBlockSize)
Local $_aResult = DllCall($__ghOCVDll_1, "int:cdecl", "cvCreateMemStorage", "int", $_iBlockSize)
If @error Then Return SetError(@error, 0, 0)
Return DllStructCreate($tagCvMemStorage, $_aResult[0])
EndFunc
Func _OpenCV_CvtColor1(ByRef $_tImageSrc, $_iCode)
Switch $_iCode
Case $CV_BGR2GRAY, $CV_RGBA2GRAY
Local $_tImageDst = _OpenCV_CreateImage(DllStructGetData($_tImageSrc, "width"), DllStructGetData($_tImageSrc, "height"), DllStructGetData($_tImageSrc, "depth"), 1)
Case $CV_GRAY2RGBA
Local $_tImageDst = _OpenCV_CreateImage(DllStructGetData($_tImageSrc, "width"), DllStructGetData($_tImageSrc, "height"), DllStructGetData($_tImageSrc, "depth"), 4)
EndSwitch
DllCall($__ghOCVDll_3, "none:cdecl", "cvCvtColor", "ptr", DllStructGetPtr($_tImageSrc), "ptr", DllStructGetPtr($_tImageDst), "int", $_iCode)
If @error Then
Local $_iError = @error
_OpenCV_ReleaseImage($_tImageDst)
Return SetError($_iError, 0, False)
EndIf
$_tImageSrc = _OpenCV_CloneImage($_tImageDst)
_OpenCV_ReleaseImage($_tImageDst)
Return True
EndFunc
Func _OpenCV_CvtColor2($_tImageSrc, ByRef $_tImageDst, $_iCode)
DllCall($__ghOCVDll_3, "none:cdecl", "cvCvtColor", "ptr", DllStructGetPtr($_tImageSrc), "ptr", DllStructGetPtr($_tImageDst), "int", $_iCode)
If @error Then Return SetError(@error, 0, False)
Return True
EndFunc
Func _OpenCV_DestroyWindow($_sName)
DllCall($__ghOCVDll_1, "none:cdecl", "cvDestroyWindow", "str", $_sName)
If @error Then Return SetError(@error, 0, False)
Return True
EndFunc
Func _OpenCV_Ellipse($_tImage, $_iX, $_iY, $_iWidth, $_iHeight, $_iAngle, $_iStartAngle, $_iEndAngle, $_iColor = 0xFFFFFF, $_iThickness = 1, $_iLineType = 1, $_iShift = 0)
Local $_iR = BitAND(BitShift($_iColor, 16), 0xFF)
Local $_iG = BitAND(BitShift($_iColor, 8), 0xFF)
Local $_iB = BitAND($_iColor, 0xFF)
DllCall($__ghOCVDll_1, "none:cdecl", "cvEllipse", "ptr", DllStructGetPtr($_tImage), "int", $_iX, "int", $_iY, "int", $_iWidth, "int", $_iHeight, _
"double", $_iAngle, "double", $_iStartAngle, "double", $_iEndAngle, _
"double", $_iB, "double", $_iG, "double", $_iR, "double", 0, "int", $_iThickness, "int", $_iLineType, "int", $_iShift)
If @error Then Return SetError(@error, 0, False)
Return True
EndFunc
Func _OpenCV_GetImageCOI($_tImage)
Local $_aResult = DllCall($__ghOCVDll_1, "int:cdecl", "cvGetImageCOI", "int*", $_tImage)
If @error Then Return SetError(@error, 0, 0)
Return $_aResult[0]
EndFunc
Func _OpenCV_GetImageROI($_tImage)
Local $_tRect = DllStructCreate($tagCvRect)
Local $_aRet[4]
DllCall($__ghOCVDll_1, "none:cdecl", "cvGetImageROI", "ptr", DllStructGetPtr($_tRect), "ptr", DllStructGetPtr($_tImage))
If @error Then Return SetError(@error, 0, 0)
$_aRet[0] = DllStructGetData($_tRect, 1)
$_aRet[1] = DllStructGetData($_tRect, 2)
$_aRet[2] = DllStructGetData($_tRect, 3)
$_aRet[3] = DllStructGetData($_tRect, 4)
Return $_aRet
EndFunc
Func _OpenCV_GetMat($_tImage, $_tHeader, ByRef $_pCoi, $_iAllowND = 0)
Local $_aResult = DllCall($__ghOCVDll_1, "int:cdecl", "cvGetMat", "ptr", DllStructGetPtr($_tImage), _
"ptr", DllStructGetPtr($_tHeader), "ptr", $_pCoi, "int", $_iAllowND)
If @error Then Return SetError(@error, 0, 0)
Return DllStructCreate($tagCvMat, $_aResult[0])
EndFunc
Func _OpenCV_GetSeqElem($_tSeq, $_iIndex)
Local $_aResult = DllCall($__ghOCVDll_1, "ptr:cdecl", "cvGetSeqElem", "ptr", DllStructGetPtr($_tSeq), "int", $_iIndex)
If @error Then Return SetError(@error, 0, 0)
Return $_aResult[0]
EndFunc
Func _OpenCV_GrabFrame(ByRef $_tCapture)
Local $_aResult = DllCall($__ghOCVDll_2, "int:cdecl", "cvGrabFrame", "ptr", $_tCapture)
If @error Then Return SetError(@error, 0, 0)
Return $_aResult[0] > 0
EndFunc
Func _OpenCV_HoughCircles($_tImage, ByRef $_tStorage, $_iMethod = $CV_HOUGH_GRADIENT, $_iDp = 1, $_iMinDist = 10, $_iParam1 = 100, $_iParam2 = 100, $_iMinRadius = 0, $_iMaxRadius = 0)
DllCall($__ghOCVDll_3, "none:cdecl", "cvHoughCircles", "ptr", DllStructGetPtr($_tImage), "ptr", DllStructGetPtr($_tStorage), _
"int", $_iMethod, "double", $_iDp, "double", $_iMinDist, "double", $_iParam1, "double", $_iParam2, _
"int", $_iMinRadius, "int", $_iMaxRadius)
If @error Then Return SetError(@error, 0, 0)
Return True
EndFunc
Func _OpenCV_Laplace($_tImageSrc, ByRef $_tImageDst, $_iApertureSize = 3)
DllCall($__ghOCVDll_3, "none:cdecl", "cvLaplace", "ptr", DllStructGetPtr($_tImageSrc), "ptr", DllStructGetPtr($_tImageDst), "int", $_iApertureSize)
If @error Then Return SetError(@error, 0, 0)
Return 1
EndFunc
Func _OpenCV_Line($_tImage, $_iX1, $_iY1, $_iX2, $_iY2, $_iColor = 0xFFFFFF, $_iThickness = 1, $_iLineType = 8, $_iShift = 0)
Local $_iR = BitAND(BitShift($_iColor, 16), 0xFF)
Local $_iG = BitAND(BitShift($_iColor, 8), 0xFF)
Local $_iB = BitAND($_iColor, 0xFF)
DllCall($__ghOCVDll_1, "none:cdecl", "cvLine", "ptr", DllStructGetPtr($_tImage), "int", $_iX1, "int", $_iY1, "int", $_iX2, "int", $_iY2, _
"double", $_iB, "double", $_iG, "double", $_iR, "double", 0, "int", $_iThickness, "int", $_iLineType, "int", $_iShift)
If @error Then Return SetError(@error, 0, 0)
Return 1
EndFunc
Func _OpenCV_LoadImage($_sPath, $iFlag = $CV_LOAD_IMAGE_COLOR)
Local $_aResult = DllCall($__ghOCVDll_2, "int:cdecl", "cvLoadImage", "str", $_sPath, "int", $iFlag)
If @error Then Return SetError(@error, 0, 0)
Return DllStructCreate($tagIplImage, $_aResult[0])
EndFunc
Func _OpenCV_Merge($_tImageSrc0, $_tImageSrc1, $_tImageSrc2, $_tImageSrc3, ByRef $_tImageDst)
DllCall($__ghOCVDll_3, "none:cdecl", "cvMerge", "ptr", DllStructGetPtr($_tImageSrc0), _
"ptr", DllStructGetPtr($_tImageSrc1), _
"ptr", DllStructGetPtr($_tImageSrc2), _
"ptr", DllStructGetPtr($_tImageSrc3), _
"ptr", DllStructGetPtr($_tImageDst))
If @error Then Return SetError(@error, 0, 0)
Return 1
EndFunc
Func _OpenCV_NamedWindow($_sName, $_iFlag = Default)
If $_iFlag = Default Or $_iFlag = -1 Then $_iFlag = BitOR($CV_WINDOW_AUTOSIZE, $CV_WINDOW_KEEPRATIO, $CV_GUI_EXPANDED)
Local $_aResult = DllCall($__ghOCVDll_2, "int:cdecl", "cvNamedWindow", "str", $_sName, "int", $_iFlag)
If @error Then Return SetError(@error, 0, 0)
Return $_aResult[0]
EndFunc
Func _OpenCV_MoveWindow($_sName, $_iX, $_iY)
DllCall($__ghOCVDll_2, "none:cdecl", "cvMoveWindow", "str", $_sName, "int", $_iX, "int", $_iY)
If @error Then Return SetError(@error, 0, False)
Return True
EndFunc
Func _OpenCV_GetWindowHandle($_sName)
Local $_aResult = DllCall($__ghOCVDll_2, "int:cdecl", "cvGetWindowHandle", "str", $_sName)
If @error Then Return SetError(@error, 0, 0)
Return Ptr($_aResult[0])
EndFunc
Func _OpenCV_Point($_iX, $_iY)
Local $_tPoint = DllStructCreate($tagCvPoint)
DllStructSetData($_tPoint, "x", $_iX)
DllStructSetData($_tPoint, "y", $_iY)
Return $_tPoint
EndFunc
Func _OpenCV_QueryFrame($_tCapture)
Local $_aResult = DllCall($__ghOCVDll_2, "int:cdecl", "cvQueryFrame", "ptr", $_tCapture)
If @error Then Return SetError(@error, 0, 0)
Return DllStructCreate($tagIplImage, $_aResult[0])
EndFunc
Func _OpenCV_Rect($_iX, $_iY, $_iWidth, $_iHeight)
Local $_tRet = DllStructCreate($tagCvRect)
DllStructSetData($_tRet, "x", $_iX)
DllStructSetData($_tRet, "y", $_iY)
DllStructSetData($_tRet, "width", $_iWidth)
DllStructSetData($_tRet, "height", $_iHeight)
Return $_tRet
EndFunc
Func _OpenCV_Rectangle($_tImage, $_iX1, $_iY1, $_iX2, $_iY2, $_iColor = 0xFFFFFF, $_iThickness = 1, $_iLineType = 8, $_iShift = 0)
Local $_iR = BitAND(BitShift($_iColor, 16), 0xFF)
Local $_iG = BitAND(BitShift($_iColor, 8), 0xFF)
Local $_iB = BitAND($_iColor, 0xFF)
DllCall($__ghOCVDll_1, "none:cdecl", "cvRectangle", "ptr", DllStructGetPtr($_tImage), "int", $_iX1, "int", $_iY1, "int", $_iX2, "int", $_iY2, _
"double", $_iB, "double", $_iG, "double", $_iR, "double", 0, "int", $_iThickness, "int", $_iLineType, "int", $_iShift)
If @error Then Return SetError(@error, 0, 0)
Return 1
EndFunc
Func _OpenCV_ReleaseCapture(ByRef $_tCapture)
DllCall($__ghOCVDll_2, "none:cdecl", "cvReleaseCapture", "ptr*", $_tCapture)
If @error Then Return SetError(@error, 0, 0)
$_tCapture = 0
Return 1
EndFunc
Func _OpenCV_ReleaseImage(ByRef $_tImage)
DllCall($__ghOCVDll_1, "none:cdecl", "cvReleaseImage", "ptr*", DllStructGetPtr($_tImage))
If @error Then Return SetError(@error, 0, 0)
$_tImage = 0
Return 1
EndFunc
Func _OpenCV_ReleaseMemStorage(ByRef $_tStorage)
DllCall($__ghOCVDll_1, "none:cdecl", "cvReleaseMemStorage", "ptr*", DllStructGetPtr($_tStorage))
If @error Then Return SetError(@error, 0, 0)
$_tStorage = 0
Return 1
EndFunc
Func _OpenCV_ResetImageROI($_tImage)
DllCall($__ghOCVDll_1, "none:cdecl", "cvResetImageROI", "ptr", DllStructGetPtr($_tImage))
If @error Then Return SetError(@error, 0, False)
Return True
EndFunc
Func _OpenCV_Resize(ByRef $_tImage, $_rPercent = 50.0, $_iInterpolation = $CV_INTER_LINEAR)
Local $_iWidth1 = DllStructGetData($_tImage, "width")
Local $_iChannels = DllStructGetData($_tImage, "nChannels")
Local $_iWidth2 = Int(($_rPercent * $_iWidth1) / 100)
Local $_iPadding = Mod($_iWidth2, 4)
If $_iPadding = 2 Or $_iPadding = 3 Then $_rPercent = ($_iWidth2 + 4 - $_iPadding) * (100 / $_iWidth1)
Local $_tImageResize = _OpenCV_CreateImage(Int(DllStructGetData($_tImage, "width") / (100 / $_rPercent)), Int(DllStructGetData($_tImage, "height") / (100 / $_rPercent)), DllStructGetData($_tImage, "depth"), DllStructGetData($_tImage, "nChannels"))
DllCall($__ghOCVDll_3, "none:cdecl", "cvResize", "ptr", DllStructGetPtr($_tImage), "ptr", DllStructGetPtr($_tImageResize), "int", $_iInterpolation)
If @error Then
Local $_iError = @error
_OpenCV_ReleaseImage($_tImageResize)
Return SetError($_iError, 0, False)
EndIf
_OpenCV_ReleaseImage($_tImage)
$_tImage = _OpenCV_CloneImage($_tImageResize)
_OpenCV_ReleaseImage($_tImageResize)
Return True
EndFunc
Func _OpenCV_ResizeToWidth(ByRef $_tImage, $_iWidth, $_iInterpolation = $CV_INTER_LINEAR)
Local $_rPercent = ($_iWidth * 100) / Int(DllStructGetData($_tImage, "width"))
Local $_iWidth1 = DllStructGetData($_tImage, "width")
Local $_iChannels = DllStructGetData($_tImage, "nChannels")
Local $_iWidth2 = Int(($_rPercent * $_iWidth1) / 100)
Local $_iPadding = Mod($_iWidth2, 4)
If $_iPadding = 2 Or $_iPadding = 3 Then $_rPercent = ($_iWidth2 + 4 - $_iPadding) * (100 / $_iWidth1)
Local $_tImageResize = _OpenCV_CreateImage($_iWidth, Int(DllStructGetData($_tImage, "height") / (100 / $_rPercent)), DllStructGetData($_tImage, "depth"), DllStructGetData($_tImage, "nChannels"))
DllCall($__ghOCVDll_3, "none:cdecl", "cvResize", "ptr", DllStructGetPtr($_tImage), "ptr", DllStructGetPtr($_tImageResize), "int", $_iInterpolation)
If @error Then
Local $_iError = @error
_OpenCV_ReleaseImage($_tImageResize)
Return SetError($_iError, 0, False)
EndIf
_OpenCV_ReleaseImage($_tImage)
$_tImage = _OpenCV_CloneImage($_tImageResize)
_OpenCV_ReleaseImage($_tImageResize)
Return True
EndFunc
Func _OpenCV_RetrieveFrame($_tCapture)
Local $_aResult = DllCall($__ghOCVDll_2, "int:cdecl", "cvRetrieveFrame", "ptr", $_tCapture)
If @error Then Return SetError(@error, 0, 0)
Return DllStructCreate($tagIplImage, $_aResult[0])
EndFunc
Func _OpenCV_SaveImage($_sPath, $_tImage)
Local $_tParams = DllStructCreate("int[2]")
DllStructSetData($_tParams, 1, $CV_IMWRITE_PNG_COMPRESSION)
DllStructSetData($_tParams, 2, 9)
Local $_aResult = DllCall($__ghOCVDll_2, "int:cdecl", "cvSaveImage", "str", $_sPath, "ptr", DllStructGetPtr($_tImage), "ptr", DllStructGetPtr($_tParams))
If @error Then Return SetError(@error, 0, 0)
Return $_aResult[0]
EndFunc
Func _OpenCV_SetImageROI($_tImage, $_iX, $_iY, $_iWidth, $_iHeight)
DllCall($__ghOCVDll_1, "none:cdecl", "cvSetImageROI", "ptr", DllStructGetPtr($_tImage), "int", $_iX, "int", $_iY, "int", $_iWidth, "int", $_iHeight)
If @error Then Return SetError(@error, 0, False)
Return True
EndFunc
Func _OpenCV_SetMouseCallback($_sName, $_sFunc)
$__ghMouseCallback = DllCallbackRegister($_sFunc, "none", "int;int;int;int;ptr")
DllCall($__ghOCVDll_2, "none:cdecl", "cvSetMouseCallback", "str", $_sName, "ptr", DllCallbackGetPtr($__ghMouseCallback), "ptr", 0)
If @error Then Return SetError(@error, 0, 0)
Return 1
EndFunc
Func _OpenCV_ShowImage($_sName, $_tImage)
DllCall($__ghOCVDll_2, "none:cdecl", "cvShowImage", "str", $_sName, "ptr", DllStructGetPtr($_tImage))
If @error Then Return SetError(@error, 0, 0)
Return 1
EndFunc
Func _OpenCV_Shutdown()
If $__ghOCVDll_1 = 0 Then Return SetError(1, 0, False)
If $__ghOCVDll_2 = 0 Then Return SetError(2, 0, False)
If $__ghOCVDll_3 = 0 Then Return SetError(3, 0, False)
If $__ghOCVDll_4 = 0 Then Return SetError(4, 0, False)
If $__ghMouseCallback <> 0 Then DllCallbackFree($__ghMouseCallback)
$__giOCVRef -= 1
If $__giOCVRef = 0 Then
DllClose($__ghOCVDll_1)
DllClose($__ghOCVDll_2)
DllClose($__ghOCVDll_3)
DllClose($__ghOCVDll_4)
$__ghOCVDll_1 = 0
$__ghOCVDll_2 = 0
$__ghOCVDll_3 = 0
$__ghOCVDll_4 = 0
EndIf
Return True
EndFunc ;==>_OpenCV_Shutdown
Func _OpenCV_Sobel($_tImageSrc, ByRef $_tImageDst, $_iXOrder, $_iYOrder, $_iApertureSize = 3)
DllCall($__ghOCVDll_3, "none:cdecl", "cvSobel", "ptr", DllStructGetPtr($_tImageSrc), "ptr", DllStructGetPtr($_tImageDst), "int", $_iXOrder, "int", $_iYOrder, "int", $_iApertureSize)
If @error Then Return SetError(@error, @extended, 0)
Return 1
EndFunc
Func _OpenCV_Startup()
$__giOCVRef += 1
If $__giOCVRef > 1 Then Return True
$__ghOCVDll_1 = DllOpen("opencv_core242.dll")
If $__ghOCVDll_1 = -1 Then Return SetError(1, 0, False)
$__ghOCVDll_2 = DllOpen("opencv_highgui242.dll")
If $__ghOCVDll_2 = -1 Then Return SetError(2, 0, False)
$__ghOCVDll_3 = DllOpen("opencv_imgproc242.dll")
If $__ghOCVDll_3 = -1 Then Return SetError(3, 0, False)
$__ghOCVDll_4 = DllOpen("opencv_video242.dll")
If $__ghOCVDll_4 = -1 Then Return SetError(4, 0, False)
Return True
EndFunc ;==>_OpenCV_Startup
Func _OpenCV_TermCriteria($_iType, $_iMaxIter, $_fEpsilon)
Local $_tRet = DllStructCreate("int;int;double")
DllStructSetData($_tRet, 1, $_iType)
DllStructSetData($_tRet, 2, $_iMaxIter)
DllStructSetData($_tRet, 3, $_fEpsilon)
Return $_tRet
EndFunc
Func _OpenCV_WaitKey($_iDelay)
Local $_aResult = DllCall($__ghOCVDll_2, "int:cdecl", "cvWaitKey", "int", $_iDelay)
If @error Then Return SetError(@error, 0, 0)
Return $_aResult[0]
EndFunc
Func __MAKETYPE($_iDepth, $_iCn)
Return $_iDepth + $CV_MAT_DEPTH_MASK + BitShift(($_iCn - 1), 0 - $CV_CN_SHIFT)
EndFunc