openCV library for Renesas RZ/A
Dependents: RZ_A2M_Mbed_samples
include/opencv2/core/core_c.h@0:0e0631af0305, 2021-01-29 (annotated)
- Committer:
- RyoheiHagimoto
- Date:
- Fri Jan 29 04:53:38 2021 +0000
- Revision:
- 0:0e0631af0305
copied from https://github.com/d-kato/opencv-lib.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| RyoheiHagimoto | 0:0e0631af0305 | 1 | /*M/////////////////////////////////////////////////////////////////////////////////////// |
| RyoheiHagimoto | 0:0e0631af0305 | 2 | // |
| RyoheiHagimoto | 0:0e0631af0305 | 3 | // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. |
| RyoheiHagimoto | 0:0e0631af0305 | 4 | // |
| RyoheiHagimoto | 0:0e0631af0305 | 5 | // By downloading, copying, installing or using the software you agree to this license. |
| RyoheiHagimoto | 0:0e0631af0305 | 6 | // If you do not agree to this license, do not download, install, |
| RyoheiHagimoto | 0:0e0631af0305 | 7 | // copy or use the software. |
| RyoheiHagimoto | 0:0e0631af0305 | 8 | // |
| RyoheiHagimoto | 0:0e0631af0305 | 9 | // |
| RyoheiHagimoto | 0:0e0631af0305 | 10 | // License Agreement |
| RyoheiHagimoto | 0:0e0631af0305 | 11 | // For Open Source Computer Vision Library |
| RyoheiHagimoto | 0:0e0631af0305 | 12 | // |
| RyoheiHagimoto | 0:0e0631af0305 | 13 | // Copyright (C) 2000-2008, Intel Corporation, all rights reserved. |
| RyoheiHagimoto | 0:0e0631af0305 | 14 | // Copyright (C) 2009, Willow Garage Inc., all rights reserved. |
| RyoheiHagimoto | 0:0e0631af0305 | 15 | // Copyright (C) 2013, OpenCV Foundation, all rights reserved. |
| RyoheiHagimoto | 0:0e0631af0305 | 16 | // Third party copyrights are property of their respective owners. |
| RyoheiHagimoto | 0:0e0631af0305 | 17 | // |
| RyoheiHagimoto | 0:0e0631af0305 | 18 | // Redistribution and use in source and binary forms, with or without modification, |
| RyoheiHagimoto | 0:0e0631af0305 | 19 | // are permitted provided that the following conditions are met: |
| RyoheiHagimoto | 0:0e0631af0305 | 20 | // |
| RyoheiHagimoto | 0:0e0631af0305 | 21 | // * Redistribution's of source code must retain the above copyright notice, |
| RyoheiHagimoto | 0:0e0631af0305 | 22 | // this list of conditions and the following disclaimer. |
| RyoheiHagimoto | 0:0e0631af0305 | 23 | // |
| RyoheiHagimoto | 0:0e0631af0305 | 24 | // * Redistribution's in binary form must reproduce the above copyright notice, |
| RyoheiHagimoto | 0:0e0631af0305 | 25 | // this list of conditions and the following disclaimer in the documentation |
| RyoheiHagimoto | 0:0e0631af0305 | 26 | // and/or other materials provided with the distribution. |
| RyoheiHagimoto | 0:0e0631af0305 | 27 | // |
| RyoheiHagimoto | 0:0e0631af0305 | 28 | // * The name of the copyright holders may not be used to endorse or promote products |
| RyoheiHagimoto | 0:0e0631af0305 | 29 | // derived from this software without specific prior written permission. |
| RyoheiHagimoto | 0:0e0631af0305 | 30 | // |
| RyoheiHagimoto | 0:0e0631af0305 | 31 | // This software is provided by the copyright holders and contributors "as is" and |
| RyoheiHagimoto | 0:0e0631af0305 | 32 | // any express or implied warranties, including, but not limited to, the implied |
| RyoheiHagimoto | 0:0e0631af0305 | 33 | // warranties of merchantability and fitness for a particular purpose are disclaimed. |
| RyoheiHagimoto | 0:0e0631af0305 | 34 | // In no event shall the Intel Corporation or contributors be liable for any direct, |
| RyoheiHagimoto | 0:0e0631af0305 | 35 | // indirect, incidental, special, exemplary, or consequential damages |
| RyoheiHagimoto | 0:0e0631af0305 | 36 | // (including, but not limited to, procurement of substitute goods or services; |
| RyoheiHagimoto | 0:0e0631af0305 | 37 | // loss of use, data, or profits; or business interruption) however caused |
| RyoheiHagimoto | 0:0e0631af0305 | 38 | // and on any theory of liability, whether in contract, strict liability, |
| RyoheiHagimoto | 0:0e0631af0305 | 39 | // or tort (including negligence or otherwise) arising in any way out of |
| RyoheiHagimoto | 0:0e0631af0305 | 40 | // the use of this software, even if advised of the possibility of such damage. |
| RyoheiHagimoto | 0:0e0631af0305 | 41 | // |
| RyoheiHagimoto | 0:0e0631af0305 | 42 | //M*/ |
| RyoheiHagimoto | 0:0e0631af0305 | 43 | |
| RyoheiHagimoto | 0:0e0631af0305 | 44 | |
| RyoheiHagimoto | 0:0e0631af0305 | 45 | #ifndef OPENCV_CORE_C_H |
| RyoheiHagimoto | 0:0e0631af0305 | 46 | #define OPENCV_CORE_C_H |
| RyoheiHagimoto | 0:0e0631af0305 | 47 | |
| RyoheiHagimoto | 0:0e0631af0305 | 48 | #include "opencv2/core/types_c.h" |
| RyoheiHagimoto | 0:0e0631af0305 | 49 | |
| RyoheiHagimoto | 0:0e0631af0305 | 50 | #ifdef __cplusplus |
| RyoheiHagimoto | 0:0e0631af0305 | 51 | # ifdef _MSC_VER |
| RyoheiHagimoto | 0:0e0631af0305 | 52 | /* disable warning C4190: 'function' has C-linkage specified, but returns UDT 'typename' |
| RyoheiHagimoto | 0:0e0631af0305 | 53 | which is incompatible with C |
| RyoheiHagimoto | 0:0e0631af0305 | 54 | |
| RyoheiHagimoto | 0:0e0631af0305 | 55 | It is OK to disable it because we only extend few plain structures with |
| RyoheiHagimoto | 0:0e0631af0305 | 56 | C++ construrtors for simpler interoperability with C++ API of the library |
| RyoheiHagimoto | 0:0e0631af0305 | 57 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 58 | # pragma warning(disable:4190) |
| RyoheiHagimoto | 0:0e0631af0305 | 59 | # elif defined __clang__ && __clang_major__ >= 3 |
| RyoheiHagimoto | 0:0e0631af0305 | 60 | # pragma GCC diagnostic ignored "-Wreturn-type-c-linkage" |
| RyoheiHagimoto | 0:0e0631af0305 | 61 | # endif |
| RyoheiHagimoto | 0:0e0631af0305 | 62 | #endif |
| RyoheiHagimoto | 0:0e0631af0305 | 63 | |
| RyoheiHagimoto | 0:0e0631af0305 | 64 | #ifdef __cplusplus |
| RyoheiHagimoto | 0:0e0631af0305 | 65 | extern "C" { |
| RyoheiHagimoto | 0:0e0631af0305 | 66 | #endif |
| RyoheiHagimoto | 0:0e0631af0305 | 67 | |
| RyoheiHagimoto | 0:0e0631af0305 | 68 | /** @addtogroup core_c |
| RyoheiHagimoto | 0:0e0631af0305 | 69 | @{ |
| RyoheiHagimoto | 0:0e0631af0305 | 70 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 71 | |
| RyoheiHagimoto | 0:0e0631af0305 | 72 | /****************************************************************************************\ |
| RyoheiHagimoto | 0:0e0631af0305 | 73 | * Array allocation, deallocation, initialization and access to elements * |
| RyoheiHagimoto | 0:0e0631af0305 | 74 | \****************************************************************************************/ |
| RyoheiHagimoto | 0:0e0631af0305 | 75 | |
| RyoheiHagimoto | 0:0e0631af0305 | 76 | /** `malloc` wrapper. |
| RyoheiHagimoto | 0:0e0631af0305 | 77 | If there is no enough memory, the function |
| RyoheiHagimoto | 0:0e0631af0305 | 78 | (as well as other OpenCV functions that call cvAlloc) |
| RyoheiHagimoto | 0:0e0631af0305 | 79 | raises an error. */ |
| RyoheiHagimoto | 0:0e0631af0305 | 80 | CVAPI(void*) cvAlloc( size_t size ); |
| RyoheiHagimoto | 0:0e0631af0305 | 81 | |
| RyoheiHagimoto | 0:0e0631af0305 | 82 | /** `free` wrapper. |
| RyoheiHagimoto | 0:0e0631af0305 | 83 | Here and further all the memory releasing functions |
| RyoheiHagimoto | 0:0e0631af0305 | 84 | (that all call cvFree) take double pointer in order to |
| RyoheiHagimoto | 0:0e0631af0305 | 85 | to clear pointer to the data after releasing it. |
| RyoheiHagimoto | 0:0e0631af0305 | 86 | Passing pointer to NULL pointer is Ok: nothing happens in this case |
| RyoheiHagimoto | 0:0e0631af0305 | 87 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 88 | CVAPI(void) cvFree_( void* ptr ); |
| RyoheiHagimoto | 0:0e0631af0305 | 89 | #define cvFree(ptr) (cvFree_(*(ptr)), *(ptr)=0) |
| RyoheiHagimoto | 0:0e0631af0305 | 90 | |
| RyoheiHagimoto | 0:0e0631af0305 | 91 | /** @brief Creates an image header but does not allocate the image data. |
| RyoheiHagimoto | 0:0e0631af0305 | 92 | |
| RyoheiHagimoto | 0:0e0631af0305 | 93 | @param size Image width and height |
| RyoheiHagimoto | 0:0e0631af0305 | 94 | @param depth Image depth (see cvCreateImage ) |
| RyoheiHagimoto | 0:0e0631af0305 | 95 | @param channels Number of channels (see cvCreateImage ) |
| RyoheiHagimoto | 0:0e0631af0305 | 96 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 97 | CVAPI(IplImage*) cvCreateImageHeader( CvSize size, int depth, int channels ); |
| RyoheiHagimoto | 0:0e0631af0305 | 98 | |
| RyoheiHagimoto | 0:0e0631af0305 | 99 | /** @brief Initializes an image header that was previously allocated. |
| RyoheiHagimoto | 0:0e0631af0305 | 100 | |
| RyoheiHagimoto | 0:0e0631af0305 | 101 | The returned IplImage\* points to the initialized header. |
| RyoheiHagimoto | 0:0e0631af0305 | 102 | @param image Image header to initialize |
| RyoheiHagimoto | 0:0e0631af0305 | 103 | @param size Image width and height |
| RyoheiHagimoto | 0:0e0631af0305 | 104 | @param depth Image depth (see cvCreateImage ) |
| RyoheiHagimoto | 0:0e0631af0305 | 105 | @param channels Number of channels (see cvCreateImage ) |
| RyoheiHagimoto | 0:0e0631af0305 | 106 | @param origin Top-left IPL_ORIGIN_TL or bottom-left IPL_ORIGIN_BL |
| RyoheiHagimoto | 0:0e0631af0305 | 107 | @param align Alignment for image rows, typically 4 or 8 bytes |
| RyoheiHagimoto | 0:0e0631af0305 | 108 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 109 | CVAPI(IplImage*) cvInitImageHeader( IplImage* image, CvSize size, int depth, |
| RyoheiHagimoto | 0:0e0631af0305 | 110 | int channels, int origin CV_DEFAULT(0), |
| RyoheiHagimoto | 0:0e0631af0305 | 111 | int align CV_DEFAULT(4)); |
| RyoheiHagimoto | 0:0e0631af0305 | 112 | |
| RyoheiHagimoto | 0:0e0631af0305 | 113 | /** @brief Creates an image header and allocates the image data. |
| RyoheiHagimoto | 0:0e0631af0305 | 114 | |
| RyoheiHagimoto | 0:0e0631af0305 | 115 | This function call is equivalent to the following code: |
| RyoheiHagimoto | 0:0e0631af0305 | 116 | @code |
| RyoheiHagimoto | 0:0e0631af0305 | 117 | header = cvCreateImageHeader(size, depth, channels); |
| RyoheiHagimoto | 0:0e0631af0305 | 118 | cvCreateData(header); |
| RyoheiHagimoto | 0:0e0631af0305 | 119 | @endcode |
| RyoheiHagimoto | 0:0e0631af0305 | 120 | @param size Image width and height |
| RyoheiHagimoto | 0:0e0631af0305 | 121 | @param depth Bit depth of image elements. See IplImage for valid depths. |
| RyoheiHagimoto | 0:0e0631af0305 | 122 | @param channels Number of channels per pixel. See IplImage for details. This function only creates |
| RyoheiHagimoto | 0:0e0631af0305 | 123 | images with interleaved channels. |
| RyoheiHagimoto | 0:0e0631af0305 | 124 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 125 | CVAPI(IplImage*) cvCreateImage( CvSize size, int depth, int channels ); |
| RyoheiHagimoto | 0:0e0631af0305 | 126 | |
| RyoheiHagimoto | 0:0e0631af0305 | 127 | /** @brief Deallocates an image header. |
| RyoheiHagimoto | 0:0e0631af0305 | 128 | |
| RyoheiHagimoto | 0:0e0631af0305 | 129 | This call is an analogue of : |
| RyoheiHagimoto | 0:0e0631af0305 | 130 | @code |
| RyoheiHagimoto | 0:0e0631af0305 | 131 | if(image ) |
| RyoheiHagimoto | 0:0e0631af0305 | 132 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 133 | iplDeallocate(*image, IPL_IMAGE_HEADER | IPL_IMAGE_ROI); |
| RyoheiHagimoto | 0:0e0631af0305 | 134 | *image = 0; |
| RyoheiHagimoto | 0:0e0631af0305 | 135 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 136 | @endcode |
| RyoheiHagimoto | 0:0e0631af0305 | 137 | but it does not use IPL functions by default (see the CV_TURN_ON_IPL_COMPATIBILITY macro). |
| RyoheiHagimoto | 0:0e0631af0305 | 138 | @param image Double pointer to the image header |
| RyoheiHagimoto | 0:0e0631af0305 | 139 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 140 | CVAPI(void) cvReleaseImageHeader( IplImage** image ); |
| RyoheiHagimoto | 0:0e0631af0305 | 141 | |
| RyoheiHagimoto | 0:0e0631af0305 | 142 | /** @brief Deallocates the image header and the image data. |
| RyoheiHagimoto | 0:0e0631af0305 | 143 | |
| RyoheiHagimoto | 0:0e0631af0305 | 144 | This call is a shortened form of : |
| RyoheiHagimoto | 0:0e0631af0305 | 145 | @code |
| RyoheiHagimoto | 0:0e0631af0305 | 146 | if(*image ) |
| RyoheiHagimoto | 0:0e0631af0305 | 147 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 148 | cvReleaseData(*image); |
| RyoheiHagimoto | 0:0e0631af0305 | 149 | cvReleaseImageHeader(image); |
| RyoheiHagimoto | 0:0e0631af0305 | 150 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 151 | @endcode |
| RyoheiHagimoto | 0:0e0631af0305 | 152 | @param image Double pointer to the image header |
| RyoheiHagimoto | 0:0e0631af0305 | 153 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 154 | CVAPI(void) cvReleaseImage( IplImage** image ); |
| RyoheiHagimoto | 0:0e0631af0305 | 155 | |
| RyoheiHagimoto | 0:0e0631af0305 | 156 | /** Creates a copy of IPL image (widthStep may differ) */ |
| RyoheiHagimoto | 0:0e0631af0305 | 157 | CVAPI(IplImage*) cvCloneImage( const IplImage* image ); |
| RyoheiHagimoto | 0:0e0631af0305 | 158 | |
| RyoheiHagimoto | 0:0e0631af0305 | 159 | /** @brief Sets the channel of interest in an IplImage. |
| RyoheiHagimoto | 0:0e0631af0305 | 160 | |
| RyoheiHagimoto | 0:0e0631af0305 | 161 | If the ROI is set to NULL and the coi is *not* 0, the ROI is allocated. Most OpenCV functions do |
| RyoheiHagimoto | 0:0e0631af0305 | 162 | *not* support the COI setting, so to process an individual image/matrix channel one may copy (via |
| RyoheiHagimoto | 0:0e0631af0305 | 163 | cvCopy or cvSplit) the channel to a separate image/matrix, process it and then copy the result |
| RyoheiHagimoto | 0:0e0631af0305 | 164 | back (via cvCopy or cvMerge) if needed. |
| RyoheiHagimoto | 0:0e0631af0305 | 165 | @param image A pointer to the image header |
| RyoheiHagimoto | 0:0e0631af0305 | 166 | @param coi The channel of interest. 0 - all channels are selected, 1 - first channel is selected, |
| RyoheiHagimoto | 0:0e0631af0305 | 167 | etc. Note that the channel indices become 1-based. |
| RyoheiHagimoto | 0:0e0631af0305 | 168 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 169 | CVAPI(void) cvSetImageCOI( IplImage* image, int coi ); |
| RyoheiHagimoto | 0:0e0631af0305 | 170 | |
| RyoheiHagimoto | 0:0e0631af0305 | 171 | /** @brief Returns the index of the channel of interest. |
| RyoheiHagimoto | 0:0e0631af0305 | 172 | |
| RyoheiHagimoto | 0:0e0631af0305 | 173 | Returns the channel of interest of in an IplImage. Returned values correspond to the coi in |
| RyoheiHagimoto | 0:0e0631af0305 | 174 | cvSetImageCOI. |
| RyoheiHagimoto | 0:0e0631af0305 | 175 | @param image A pointer to the image header |
| RyoheiHagimoto | 0:0e0631af0305 | 176 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 177 | CVAPI(int) cvGetImageCOI( const IplImage* image ); |
| RyoheiHagimoto | 0:0e0631af0305 | 178 | |
| RyoheiHagimoto | 0:0e0631af0305 | 179 | /** @brief Sets an image Region Of Interest (ROI) for a given rectangle. |
| RyoheiHagimoto | 0:0e0631af0305 | 180 | |
| RyoheiHagimoto | 0:0e0631af0305 | 181 | If the original image ROI was NULL and the rect is not the whole image, the ROI structure is |
| RyoheiHagimoto | 0:0e0631af0305 | 182 | allocated. |
| RyoheiHagimoto | 0:0e0631af0305 | 183 | |
| RyoheiHagimoto | 0:0e0631af0305 | 184 | Most OpenCV functions support the use of ROI and treat the image rectangle as a separate image. For |
| RyoheiHagimoto | 0:0e0631af0305 | 185 | example, all of the pixel coordinates are counted from the top-left (or bottom-left) corner of the |
| RyoheiHagimoto | 0:0e0631af0305 | 186 | ROI, not the original image. |
| RyoheiHagimoto | 0:0e0631af0305 | 187 | @param image A pointer to the image header |
| RyoheiHagimoto | 0:0e0631af0305 | 188 | @param rect The ROI rectangle |
| RyoheiHagimoto | 0:0e0631af0305 | 189 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 190 | CVAPI(void) cvSetImageROI( IplImage* image, CvRect rect ); |
| RyoheiHagimoto | 0:0e0631af0305 | 191 | |
| RyoheiHagimoto | 0:0e0631af0305 | 192 | /** @brief Resets the image ROI to include the entire image and releases the ROI structure. |
| RyoheiHagimoto | 0:0e0631af0305 | 193 | |
| RyoheiHagimoto | 0:0e0631af0305 | 194 | This produces a similar result to the following, but in addition it releases the ROI structure. : |
| RyoheiHagimoto | 0:0e0631af0305 | 195 | @code |
| RyoheiHagimoto | 0:0e0631af0305 | 196 | cvSetImageROI(image, cvRect(0, 0, image->width, image->height )); |
| RyoheiHagimoto | 0:0e0631af0305 | 197 | cvSetImageCOI(image, 0); |
| RyoheiHagimoto | 0:0e0631af0305 | 198 | @endcode |
| RyoheiHagimoto | 0:0e0631af0305 | 199 | @param image A pointer to the image header |
| RyoheiHagimoto | 0:0e0631af0305 | 200 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 201 | CVAPI(void) cvResetImageROI( IplImage* image ); |
| RyoheiHagimoto | 0:0e0631af0305 | 202 | |
| RyoheiHagimoto | 0:0e0631af0305 | 203 | /** @brief Returns the image ROI. |
| RyoheiHagimoto | 0:0e0631af0305 | 204 | |
| RyoheiHagimoto | 0:0e0631af0305 | 205 | If there is no ROI set, cvRect(0,0,image-\>width,image-\>height) is returned. |
| RyoheiHagimoto | 0:0e0631af0305 | 206 | @param image A pointer to the image header |
| RyoheiHagimoto | 0:0e0631af0305 | 207 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 208 | CVAPI(CvRect) cvGetImageROI( const IplImage* image ); |
| RyoheiHagimoto | 0:0e0631af0305 | 209 | |
| RyoheiHagimoto | 0:0e0631af0305 | 210 | /** @brief Creates a matrix header but does not allocate the matrix data. |
| RyoheiHagimoto | 0:0e0631af0305 | 211 | |
| RyoheiHagimoto | 0:0e0631af0305 | 212 | The function allocates a new matrix header and returns a pointer to it. The matrix data can then be |
| RyoheiHagimoto | 0:0e0631af0305 | 213 | allocated using cvCreateData or set explicitly to user-allocated data via cvSetData. |
| RyoheiHagimoto | 0:0e0631af0305 | 214 | @param rows Number of rows in the matrix |
| RyoheiHagimoto | 0:0e0631af0305 | 215 | @param cols Number of columns in the matrix |
| RyoheiHagimoto | 0:0e0631af0305 | 216 | @param type Type of the matrix elements, see cvCreateMat |
| RyoheiHagimoto | 0:0e0631af0305 | 217 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 218 | CVAPI(CvMat*) cvCreateMatHeader( int rows, int cols, int type ); |
| RyoheiHagimoto | 0:0e0631af0305 | 219 | |
| RyoheiHagimoto | 0:0e0631af0305 | 220 | #define CV_AUTOSTEP 0x7fffffff |
| RyoheiHagimoto | 0:0e0631af0305 | 221 | |
| RyoheiHagimoto | 0:0e0631af0305 | 222 | /** @brief Initializes a pre-allocated matrix header. |
| RyoheiHagimoto | 0:0e0631af0305 | 223 | |
| RyoheiHagimoto | 0:0e0631af0305 | 224 | This function is often used to process raw data with OpenCV matrix functions. For example, the |
| RyoheiHagimoto | 0:0e0631af0305 | 225 | following code computes the matrix product of two matrices, stored as ordinary arrays: |
| RyoheiHagimoto | 0:0e0631af0305 | 226 | @code |
| RyoheiHagimoto | 0:0e0631af0305 | 227 | double a[] = { 1, 2, 3, 4, |
| RyoheiHagimoto | 0:0e0631af0305 | 228 | 5, 6, 7, 8, |
| RyoheiHagimoto | 0:0e0631af0305 | 229 | 9, 10, 11, 12 }; |
| RyoheiHagimoto | 0:0e0631af0305 | 230 | |
| RyoheiHagimoto | 0:0e0631af0305 | 231 | double b[] = { 1, 5, 9, |
| RyoheiHagimoto | 0:0e0631af0305 | 232 | 2, 6, 10, |
| RyoheiHagimoto | 0:0e0631af0305 | 233 | 3, 7, 11, |
| RyoheiHagimoto | 0:0e0631af0305 | 234 | 4, 8, 12 }; |
| RyoheiHagimoto | 0:0e0631af0305 | 235 | |
| RyoheiHagimoto | 0:0e0631af0305 | 236 | double c[9]; |
| RyoheiHagimoto | 0:0e0631af0305 | 237 | CvMat Ma, Mb, Mc ; |
| RyoheiHagimoto | 0:0e0631af0305 | 238 | |
| RyoheiHagimoto | 0:0e0631af0305 | 239 | cvInitMatHeader(&Ma, 3, 4, CV_64FC1, a); |
| RyoheiHagimoto | 0:0e0631af0305 | 240 | cvInitMatHeader(&Mb, 4, 3, CV_64FC1, b); |
| RyoheiHagimoto | 0:0e0631af0305 | 241 | cvInitMatHeader(&Mc, 3, 3, CV_64FC1, c); |
| RyoheiHagimoto | 0:0e0631af0305 | 242 | |
| RyoheiHagimoto | 0:0e0631af0305 | 243 | cvMatMulAdd(&Ma, &Mb, 0, &Mc); |
| RyoheiHagimoto | 0:0e0631af0305 | 244 | // the c array now contains the product of a (3x4) and b (4x3) |
| RyoheiHagimoto | 0:0e0631af0305 | 245 | @endcode |
| RyoheiHagimoto | 0:0e0631af0305 | 246 | @param mat A pointer to the matrix header to be initialized |
| RyoheiHagimoto | 0:0e0631af0305 | 247 | @param rows Number of rows in the matrix |
| RyoheiHagimoto | 0:0e0631af0305 | 248 | @param cols Number of columns in the matrix |
| RyoheiHagimoto | 0:0e0631af0305 | 249 | @param type Type of the matrix elements, see cvCreateMat . |
| RyoheiHagimoto | 0:0e0631af0305 | 250 | @param data Optional: data pointer assigned to the matrix header |
| RyoheiHagimoto | 0:0e0631af0305 | 251 | @param step Optional: full row width in bytes of the assigned data. By default, the minimal |
| RyoheiHagimoto | 0:0e0631af0305 | 252 | possible step is used which assumes there are no gaps between subsequent rows of the matrix. |
| RyoheiHagimoto | 0:0e0631af0305 | 253 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 254 | CVAPI(CvMat*) cvInitMatHeader( CvMat* mat, int rows, int cols, |
| RyoheiHagimoto | 0:0e0631af0305 | 255 | int type, void* data CV_DEFAULT(NULL), |
| RyoheiHagimoto | 0:0e0631af0305 | 256 | int step CV_DEFAULT(CV_AUTOSTEP) ); |
| RyoheiHagimoto | 0:0e0631af0305 | 257 | |
| RyoheiHagimoto | 0:0e0631af0305 | 258 | /** @brief Creates a matrix header and allocates the matrix data. |
| RyoheiHagimoto | 0:0e0631af0305 | 259 | |
| RyoheiHagimoto | 0:0e0631af0305 | 260 | The function call is equivalent to the following code: |
| RyoheiHagimoto | 0:0e0631af0305 | 261 | @code |
| RyoheiHagimoto | 0:0e0631af0305 | 262 | CvMat* mat = cvCreateMatHeader(rows, cols, type); |
| RyoheiHagimoto | 0:0e0631af0305 | 263 | cvCreateData(mat); |
| RyoheiHagimoto | 0:0e0631af0305 | 264 | @endcode |
| RyoheiHagimoto | 0:0e0631af0305 | 265 | @param rows Number of rows in the matrix |
| RyoheiHagimoto | 0:0e0631af0305 | 266 | @param cols Number of columns in the matrix |
| RyoheiHagimoto | 0:0e0631af0305 | 267 | @param type The type of the matrix elements in the form |
| RyoheiHagimoto | 0:0e0631af0305 | 268 | CV_\<bit depth\>\<S|U|F\>C\<number of channels\> , where S=signed, U=unsigned, F=float. For |
| RyoheiHagimoto | 0:0e0631af0305 | 269 | example, CV _ 8UC1 means the elements are 8-bit unsigned and the there is 1 channel, and CV _ |
| RyoheiHagimoto | 0:0e0631af0305 | 270 | 32SC2 means the elements are 32-bit signed and there are 2 channels. |
| RyoheiHagimoto | 0:0e0631af0305 | 271 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 272 | CVAPI(CvMat*) cvCreateMat( int rows, int cols, int type ); |
| RyoheiHagimoto | 0:0e0631af0305 | 273 | |
| RyoheiHagimoto | 0:0e0631af0305 | 274 | /** @brief Deallocates a matrix. |
| RyoheiHagimoto | 0:0e0631af0305 | 275 | |
| RyoheiHagimoto | 0:0e0631af0305 | 276 | The function decrements the matrix data reference counter and deallocates matrix header. If the data |
| RyoheiHagimoto | 0:0e0631af0305 | 277 | reference counter is 0, it also deallocates the data. : |
| RyoheiHagimoto | 0:0e0631af0305 | 278 | @code |
| RyoheiHagimoto | 0:0e0631af0305 | 279 | if(*mat ) |
| RyoheiHagimoto | 0:0e0631af0305 | 280 | cvDecRefData(*mat); |
| RyoheiHagimoto | 0:0e0631af0305 | 281 | cvFree((void**)mat); |
| RyoheiHagimoto | 0:0e0631af0305 | 282 | @endcode |
| RyoheiHagimoto | 0:0e0631af0305 | 283 | @param mat Double pointer to the matrix |
| RyoheiHagimoto | 0:0e0631af0305 | 284 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 285 | CVAPI(void) cvReleaseMat( CvMat** mat ); |
| RyoheiHagimoto | 0:0e0631af0305 | 286 | |
| RyoheiHagimoto | 0:0e0631af0305 | 287 | /** @brief Decrements an array data reference counter. |
| RyoheiHagimoto | 0:0e0631af0305 | 288 | |
| RyoheiHagimoto | 0:0e0631af0305 | 289 | The function decrements the data reference counter in a CvMat or CvMatND if the reference counter |
| RyoheiHagimoto | 0:0e0631af0305 | 290 | |
| RyoheiHagimoto | 0:0e0631af0305 | 291 | pointer is not NULL. If the counter reaches zero, the data is deallocated. In the current |
| RyoheiHagimoto | 0:0e0631af0305 | 292 | implementation the reference counter is not NULL only if the data was allocated using the |
| RyoheiHagimoto | 0:0e0631af0305 | 293 | cvCreateData function. The counter will be NULL in other cases such as: external data was assigned |
| RyoheiHagimoto | 0:0e0631af0305 | 294 | to the header using cvSetData, header is part of a larger matrix or image, or the header was |
| RyoheiHagimoto | 0:0e0631af0305 | 295 | converted from an image or n-dimensional matrix header. |
| RyoheiHagimoto | 0:0e0631af0305 | 296 | @param arr Pointer to an array header |
| RyoheiHagimoto | 0:0e0631af0305 | 297 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 298 | CV_INLINE void cvDecRefData( CvArr* arr ) |
| RyoheiHagimoto | 0:0e0631af0305 | 299 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 300 | if( CV_IS_MAT( arr )) |
| RyoheiHagimoto | 0:0e0631af0305 | 301 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 302 | CvMat* mat = (CvMat*)arr; |
| RyoheiHagimoto | 0:0e0631af0305 | 303 | mat->data.ptr = NULL; |
| RyoheiHagimoto | 0:0e0631af0305 | 304 | if( mat->refcount != NULL && --*mat->refcount == 0 ) |
| RyoheiHagimoto | 0:0e0631af0305 | 305 | cvFree( &mat->refcount ); |
| RyoheiHagimoto | 0:0e0631af0305 | 306 | mat->refcount = NULL; |
| RyoheiHagimoto | 0:0e0631af0305 | 307 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 308 | else if( CV_IS_MATND( arr )) |
| RyoheiHagimoto | 0:0e0631af0305 | 309 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 310 | CvMatND* mat = (CvMatND*)arr; |
| RyoheiHagimoto | 0:0e0631af0305 | 311 | mat->data.ptr = NULL; |
| RyoheiHagimoto | 0:0e0631af0305 | 312 | if( mat->refcount != NULL && --*mat->refcount == 0 ) |
| RyoheiHagimoto | 0:0e0631af0305 | 313 | cvFree( &mat->refcount ); |
| RyoheiHagimoto | 0:0e0631af0305 | 314 | mat->refcount = NULL; |
| RyoheiHagimoto | 0:0e0631af0305 | 315 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 316 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 317 | |
| RyoheiHagimoto | 0:0e0631af0305 | 318 | /** @brief Increments array data reference counter. |
| RyoheiHagimoto | 0:0e0631af0305 | 319 | |
| RyoheiHagimoto | 0:0e0631af0305 | 320 | The function increments CvMat or CvMatND data reference counter and returns the new counter value if |
| RyoheiHagimoto | 0:0e0631af0305 | 321 | the reference counter pointer is not NULL, otherwise it returns zero. |
| RyoheiHagimoto | 0:0e0631af0305 | 322 | @param arr Array header |
| RyoheiHagimoto | 0:0e0631af0305 | 323 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 324 | CV_INLINE int cvIncRefData( CvArr* arr ) |
| RyoheiHagimoto | 0:0e0631af0305 | 325 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 326 | int refcount = 0; |
| RyoheiHagimoto | 0:0e0631af0305 | 327 | if( CV_IS_MAT( arr )) |
| RyoheiHagimoto | 0:0e0631af0305 | 328 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 329 | CvMat* mat = (CvMat*)arr; |
| RyoheiHagimoto | 0:0e0631af0305 | 330 | if( mat->refcount != NULL ) |
| RyoheiHagimoto | 0:0e0631af0305 | 331 | refcount = ++*mat->refcount; |
| RyoheiHagimoto | 0:0e0631af0305 | 332 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 333 | else if( CV_IS_MATND( arr )) |
| RyoheiHagimoto | 0:0e0631af0305 | 334 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 335 | CvMatND* mat = (CvMatND*)arr; |
| RyoheiHagimoto | 0:0e0631af0305 | 336 | if( mat->refcount != NULL ) |
| RyoheiHagimoto | 0:0e0631af0305 | 337 | refcount = ++*mat->refcount; |
| RyoheiHagimoto | 0:0e0631af0305 | 338 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 339 | return refcount; |
| RyoheiHagimoto | 0:0e0631af0305 | 340 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 341 | |
| RyoheiHagimoto | 0:0e0631af0305 | 342 | |
| RyoheiHagimoto | 0:0e0631af0305 | 343 | /** Creates an exact copy of the input matrix (except, may be, step value) */ |
| RyoheiHagimoto | 0:0e0631af0305 | 344 | CVAPI(CvMat*) cvCloneMat( const CvMat* mat ); |
| RyoheiHagimoto | 0:0e0631af0305 | 345 | |
| RyoheiHagimoto | 0:0e0631af0305 | 346 | |
| RyoheiHagimoto | 0:0e0631af0305 | 347 | /** @brief Returns matrix header corresponding to the rectangular sub-array of input image or matrix. |
| RyoheiHagimoto | 0:0e0631af0305 | 348 | |
| RyoheiHagimoto | 0:0e0631af0305 | 349 | The function returns header, corresponding to a specified rectangle of the input array. In other |
| RyoheiHagimoto | 0:0e0631af0305 | 350 | |
| RyoheiHagimoto | 0:0e0631af0305 | 351 | words, it allows the user to treat a rectangular part of input array as a stand-alone array. ROI is |
| RyoheiHagimoto | 0:0e0631af0305 | 352 | taken into account by the function so the sub-array of ROI is actually extracted. |
| RyoheiHagimoto | 0:0e0631af0305 | 353 | @param arr Input array |
| RyoheiHagimoto | 0:0e0631af0305 | 354 | @param submat Pointer to the resultant sub-array header |
| RyoheiHagimoto | 0:0e0631af0305 | 355 | @param rect Zero-based coordinates of the rectangle of interest |
| RyoheiHagimoto | 0:0e0631af0305 | 356 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 357 | CVAPI(CvMat*) cvGetSubRect( const CvArr* arr, CvMat* submat, CvRect rect ); |
| RyoheiHagimoto | 0:0e0631af0305 | 358 | #define cvGetSubArr cvGetSubRect |
| RyoheiHagimoto | 0:0e0631af0305 | 359 | |
| RyoheiHagimoto | 0:0e0631af0305 | 360 | /** @brief Returns array row or row span. |
| RyoheiHagimoto | 0:0e0631af0305 | 361 | |
| RyoheiHagimoto | 0:0e0631af0305 | 362 | The functions return the header, corresponding to a specified row/row span of the input array. |
| RyoheiHagimoto | 0:0e0631af0305 | 363 | cvGetRow(arr, submat, row) is a shortcut for cvGetRows(arr, submat, row, row+1). |
| RyoheiHagimoto | 0:0e0631af0305 | 364 | @param arr Input array |
| RyoheiHagimoto | 0:0e0631af0305 | 365 | @param submat Pointer to the resulting sub-array header |
| RyoheiHagimoto | 0:0e0631af0305 | 366 | @param start_row Zero-based index of the starting row (inclusive) of the span |
| RyoheiHagimoto | 0:0e0631af0305 | 367 | @param end_row Zero-based index of the ending row (exclusive) of the span |
| RyoheiHagimoto | 0:0e0631af0305 | 368 | @param delta_row Index step in the row span. That is, the function extracts every delta_row -th |
| RyoheiHagimoto | 0:0e0631af0305 | 369 | row from start_row and up to (but not including) end_row . |
| RyoheiHagimoto | 0:0e0631af0305 | 370 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 371 | CVAPI(CvMat*) cvGetRows( const CvArr* arr, CvMat* submat, |
| RyoheiHagimoto | 0:0e0631af0305 | 372 | int start_row, int end_row, |
| RyoheiHagimoto | 0:0e0631af0305 | 373 | int delta_row CV_DEFAULT(1)); |
| RyoheiHagimoto | 0:0e0631af0305 | 374 | |
| RyoheiHagimoto | 0:0e0631af0305 | 375 | /** @overload |
| RyoheiHagimoto | 0:0e0631af0305 | 376 | @param arr Input array |
| RyoheiHagimoto | 0:0e0631af0305 | 377 | @param submat Pointer to the resulting sub-array header |
| RyoheiHagimoto | 0:0e0631af0305 | 378 | @param row Zero-based index of the selected row |
| RyoheiHagimoto | 0:0e0631af0305 | 379 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 380 | CV_INLINE CvMat* cvGetRow( const CvArr* arr, CvMat* submat, int row ) |
| RyoheiHagimoto | 0:0e0631af0305 | 381 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 382 | return cvGetRows( arr, submat, row, row + 1, 1 ); |
| RyoheiHagimoto | 0:0e0631af0305 | 383 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 384 | |
| RyoheiHagimoto | 0:0e0631af0305 | 385 | |
| RyoheiHagimoto | 0:0e0631af0305 | 386 | /** @brief Returns one of more array columns. |
| RyoheiHagimoto | 0:0e0631af0305 | 387 | |
| RyoheiHagimoto | 0:0e0631af0305 | 388 | The functions return the header, corresponding to a specified column span of the input array. That |
| RyoheiHagimoto | 0:0e0631af0305 | 389 | |
| RyoheiHagimoto | 0:0e0631af0305 | 390 | is, no data is copied. Therefore, any modifications of the submatrix will affect the original array. |
| RyoheiHagimoto | 0:0e0631af0305 | 391 | If you need to copy the columns, use cvCloneMat. cvGetCol(arr, submat, col) is a shortcut for |
| RyoheiHagimoto | 0:0e0631af0305 | 392 | cvGetCols(arr, submat, col, col+1). |
| RyoheiHagimoto | 0:0e0631af0305 | 393 | @param arr Input array |
| RyoheiHagimoto | 0:0e0631af0305 | 394 | @param submat Pointer to the resulting sub-array header |
| RyoheiHagimoto | 0:0e0631af0305 | 395 | @param start_col Zero-based index of the starting column (inclusive) of the span |
| RyoheiHagimoto | 0:0e0631af0305 | 396 | @param end_col Zero-based index of the ending column (exclusive) of the span |
| RyoheiHagimoto | 0:0e0631af0305 | 397 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 398 | CVAPI(CvMat*) cvGetCols( const CvArr* arr, CvMat* submat, |
| RyoheiHagimoto | 0:0e0631af0305 | 399 | int start_col, int end_col ); |
| RyoheiHagimoto | 0:0e0631af0305 | 400 | |
| RyoheiHagimoto | 0:0e0631af0305 | 401 | /** @overload |
| RyoheiHagimoto | 0:0e0631af0305 | 402 | @param arr Input array |
| RyoheiHagimoto | 0:0e0631af0305 | 403 | @param submat Pointer to the resulting sub-array header |
| RyoheiHagimoto | 0:0e0631af0305 | 404 | @param col Zero-based index of the selected column |
| RyoheiHagimoto | 0:0e0631af0305 | 405 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 406 | CV_INLINE CvMat* cvGetCol( const CvArr* arr, CvMat* submat, int col ) |
| RyoheiHagimoto | 0:0e0631af0305 | 407 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 408 | return cvGetCols( arr, submat, col, col + 1 ); |
| RyoheiHagimoto | 0:0e0631af0305 | 409 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 410 | |
| RyoheiHagimoto | 0:0e0631af0305 | 411 | /** @brief Returns one of array diagonals. |
| RyoheiHagimoto | 0:0e0631af0305 | 412 | |
| RyoheiHagimoto | 0:0e0631af0305 | 413 | The function returns the header, corresponding to a specified diagonal of the input array. |
| RyoheiHagimoto | 0:0e0631af0305 | 414 | @param arr Input array |
| RyoheiHagimoto | 0:0e0631af0305 | 415 | @param submat Pointer to the resulting sub-array header |
| RyoheiHagimoto | 0:0e0631af0305 | 416 | @param diag Index of the array diagonal. Zero value corresponds to the main diagonal, -1 |
| RyoheiHagimoto | 0:0e0631af0305 | 417 | corresponds to the diagonal above the main, 1 corresponds to the diagonal below the main, and so |
| RyoheiHagimoto | 0:0e0631af0305 | 418 | forth. |
| RyoheiHagimoto | 0:0e0631af0305 | 419 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 420 | CVAPI(CvMat*) cvGetDiag( const CvArr* arr, CvMat* submat, |
| RyoheiHagimoto | 0:0e0631af0305 | 421 | int diag CV_DEFAULT(0)); |
| RyoheiHagimoto | 0:0e0631af0305 | 422 | |
| RyoheiHagimoto | 0:0e0631af0305 | 423 | /** low-level scalar <-> raw data conversion functions */ |
| RyoheiHagimoto | 0:0e0631af0305 | 424 | CVAPI(void) cvScalarToRawData( const CvScalar* scalar, void* data, int type, |
| RyoheiHagimoto | 0:0e0631af0305 | 425 | int extend_to_12 CV_DEFAULT(0) ); |
| RyoheiHagimoto | 0:0e0631af0305 | 426 | |
| RyoheiHagimoto | 0:0e0631af0305 | 427 | CVAPI(void) cvRawDataToScalar( const void* data, int type, CvScalar* scalar ); |
| RyoheiHagimoto | 0:0e0631af0305 | 428 | |
| RyoheiHagimoto | 0:0e0631af0305 | 429 | /** @brief Creates a new matrix header but does not allocate the matrix data. |
| RyoheiHagimoto | 0:0e0631af0305 | 430 | |
| RyoheiHagimoto | 0:0e0631af0305 | 431 | The function allocates a header for a multi-dimensional dense array. The array data can further be |
| RyoheiHagimoto | 0:0e0631af0305 | 432 | allocated using cvCreateData or set explicitly to user-allocated data via cvSetData. |
| RyoheiHagimoto | 0:0e0631af0305 | 433 | @param dims Number of array dimensions |
| RyoheiHagimoto | 0:0e0631af0305 | 434 | @param sizes Array of dimension sizes |
| RyoheiHagimoto | 0:0e0631af0305 | 435 | @param type Type of array elements, see cvCreateMat |
| RyoheiHagimoto | 0:0e0631af0305 | 436 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 437 | CVAPI(CvMatND*) cvCreateMatNDHeader( int dims, const int* sizes, int type ); |
| RyoheiHagimoto | 0:0e0631af0305 | 438 | |
| RyoheiHagimoto | 0:0e0631af0305 | 439 | /** @brief Creates the header and allocates the data for a multi-dimensional dense array. |
| RyoheiHagimoto | 0:0e0631af0305 | 440 | |
| RyoheiHagimoto | 0:0e0631af0305 | 441 | This function call is equivalent to the following code: |
| RyoheiHagimoto | 0:0e0631af0305 | 442 | @code |
| RyoheiHagimoto | 0:0e0631af0305 | 443 | CvMatND* mat = cvCreateMatNDHeader(dims, sizes, type); |
| RyoheiHagimoto | 0:0e0631af0305 | 444 | cvCreateData(mat); |
| RyoheiHagimoto | 0:0e0631af0305 | 445 | @endcode |
| RyoheiHagimoto | 0:0e0631af0305 | 446 | @param dims Number of array dimensions. This must not exceed CV_MAX_DIM (32 by default, but can be |
| RyoheiHagimoto | 0:0e0631af0305 | 447 | changed at build time). |
| RyoheiHagimoto | 0:0e0631af0305 | 448 | @param sizes Array of dimension sizes. |
| RyoheiHagimoto | 0:0e0631af0305 | 449 | @param type Type of array elements, see cvCreateMat . |
| RyoheiHagimoto | 0:0e0631af0305 | 450 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 451 | CVAPI(CvMatND*) cvCreateMatND( int dims, const int* sizes, int type ); |
| RyoheiHagimoto | 0:0e0631af0305 | 452 | |
| RyoheiHagimoto | 0:0e0631af0305 | 453 | /** @brief Initializes a pre-allocated multi-dimensional array header. |
| RyoheiHagimoto | 0:0e0631af0305 | 454 | |
| RyoheiHagimoto | 0:0e0631af0305 | 455 | @param mat A pointer to the array header to be initialized |
| RyoheiHagimoto | 0:0e0631af0305 | 456 | @param dims The number of array dimensions |
| RyoheiHagimoto | 0:0e0631af0305 | 457 | @param sizes An array of dimension sizes |
| RyoheiHagimoto | 0:0e0631af0305 | 458 | @param type Type of array elements, see cvCreateMat |
| RyoheiHagimoto | 0:0e0631af0305 | 459 | @param data Optional data pointer assigned to the matrix header |
| RyoheiHagimoto | 0:0e0631af0305 | 460 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 461 | CVAPI(CvMatND*) cvInitMatNDHeader( CvMatND* mat, int dims, const int* sizes, |
| RyoheiHagimoto | 0:0e0631af0305 | 462 | int type, void* data CV_DEFAULT(NULL) ); |
| RyoheiHagimoto | 0:0e0631af0305 | 463 | |
| RyoheiHagimoto | 0:0e0631af0305 | 464 | /** @brief Deallocates a multi-dimensional array. |
| RyoheiHagimoto | 0:0e0631af0305 | 465 | |
| RyoheiHagimoto | 0:0e0631af0305 | 466 | The function decrements the array data reference counter and releases the array header. If the |
| RyoheiHagimoto | 0:0e0631af0305 | 467 | reference counter reaches 0, it also deallocates the data. : |
| RyoheiHagimoto | 0:0e0631af0305 | 468 | @code |
| RyoheiHagimoto | 0:0e0631af0305 | 469 | if(*mat ) |
| RyoheiHagimoto | 0:0e0631af0305 | 470 | cvDecRefData(*mat); |
| RyoheiHagimoto | 0:0e0631af0305 | 471 | cvFree((void**)mat); |
| RyoheiHagimoto | 0:0e0631af0305 | 472 | @endcode |
| RyoheiHagimoto | 0:0e0631af0305 | 473 | @param mat Double pointer to the array |
| RyoheiHagimoto | 0:0e0631af0305 | 474 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 475 | CV_INLINE void cvReleaseMatND( CvMatND** mat ) |
| RyoheiHagimoto | 0:0e0631af0305 | 476 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 477 | cvReleaseMat( (CvMat**)mat ); |
| RyoheiHagimoto | 0:0e0631af0305 | 478 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 479 | |
| RyoheiHagimoto | 0:0e0631af0305 | 480 | /** Creates a copy of CvMatND (except, may be, steps) */ |
| RyoheiHagimoto | 0:0e0631af0305 | 481 | CVAPI(CvMatND*) cvCloneMatND( const CvMatND* mat ); |
| RyoheiHagimoto | 0:0e0631af0305 | 482 | |
| RyoheiHagimoto | 0:0e0631af0305 | 483 | /** @brief Creates sparse array. |
| RyoheiHagimoto | 0:0e0631af0305 | 484 | |
| RyoheiHagimoto | 0:0e0631af0305 | 485 | The function allocates a multi-dimensional sparse array. Initially the array contain no elements, |
| RyoheiHagimoto | 0:0e0631af0305 | 486 | that is PtrND and other related functions will return 0 for every index. |
| RyoheiHagimoto | 0:0e0631af0305 | 487 | @param dims Number of array dimensions. In contrast to the dense matrix, the number of dimensions is |
| RyoheiHagimoto | 0:0e0631af0305 | 488 | practically unlimited (up to \f$2^{16}\f$ ). |
| RyoheiHagimoto | 0:0e0631af0305 | 489 | @param sizes Array of dimension sizes |
| RyoheiHagimoto | 0:0e0631af0305 | 490 | @param type Type of array elements. The same as for CvMat |
| RyoheiHagimoto | 0:0e0631af0305 | 491 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 492 | CVAPI(CvSparseMat*) cvCreateSparseMat( int dims, const int* sizes, int type ); |
| RyoheiHagimoto | 0:0e0631af0305 | 493 | |
| RyoheiHagimoto | 0:0e0631af0305 | 494 | /** @brief Deallocates sparse array. |
| RyoheiHagimoto | 0:0e0631af0305 | 495 | |
| RyoheiHagimoto | 0:0e0631af0305 | 496 | The function releases the sparse array and clears the array pointer upon exit. |
| RyoheiHagimoto | 0:0e0631af0305 | 497 | @param mat Double pointer to the array |
| RyoheiHagimoto | 0:0e0631af0305 | 498 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 499 | CVAPI(void) cvReleaseSparseMat( CvSparseMat** mat ); |
| RyoheiHagimoto | 0:0e0631af0305 | 500 | |
| RyoheiHagimoto | 0:0e0631af0305 | 501 | /** Creates a copy of CvSparseMat (except, may be, zero items) */ |
| RyoheiHagimoto | 0:0e0631af0305 | 502 | CVAPI(CvSparseMat*) cvCloneSparseMat( const CvSparseMat* mat ); |
| RyoheiHagimoto | 0:0e0631af0305 | 503 | |
| RyoheiHagimoto | 0:0e0631af0305 | 504 | /** @brief Initializes sparse array elements iterator. |
| RyoheiHagimoto | 0:0e0631af0305 | 505 | |
| RyoheiHagimoto | 0:0e0631af0305 | 506 | The function initializes iterator of sparse array elements and returns pointer to the first element, |
| RyoheiHagimoto | 0:0e0631af0305 | 507 | or NULL if the array is empty. |
| RyoheiHagimoto | 0:0e0631af0305 | 508 | @param mat Input array |
| RyoheiHagimoto | 0:0e0631af0305 | 509 | @param mat_iterator Initialized iterator |
| RyoheiHagimoto | 0:0e0631af0305 | 510 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 511 | CVAPI(CvSparseNode*) cvInitSparseMatIterator( const CvSparseMat* mat, |
| RyoheiHagimoto | 0:0e0631af0305 | 512 | CvSparseMatIterator* mat_iterator ); |
| RyoheiHagimoto | 0:0e0631af0305 | 513 | |
| RyoheiHagimoto | 0:0e0631af0305 | 514 | /** @brief Returns the next sparse matrix element |
| RyoheiHagimoto | 0:0e0631af0305 | 515 | |
| RyoheiHagimoto | 0:0e0631af0305 | 516 | The function moves iterator to the next sparse matrix element and returns pointer to it. In the |
| RyoheiHagimoto | 0:0e0631af0305 | 517 | current version there is no any particular order of the elements, because they are stored in the |
| RyoheiHagimoto | 0:0e0631af0305 | 518 | hash table. The sample below demonstrates how to iterate through the sparse matrix: |
| RyoheiHagimoto | 0:0e0631af0305 | 519 | @code |
| RyoheiHagimoto | 0:0e0631af0305 | 520 | // print all the non-zero sparse matrix elements and compute their sum |
| RyoheiHagimoto | 0:0e0631af0305 | 521 | double sum = 0; |
| RyoheiHagimoto | 0:0e0631af0305 | 522 | int i, dims = cvGetDims(sparsemat); |
| RyoheiHagimoto | 0:0e0631af0305 | 523 | CvSparseMatIterator it; |
| RyoheiHagimoto | 0:0e0631af0305 | 524 | CvSparseNode* node = cvInitSparseMatIterator(sparsemat, &it); |
| RyoheiHagimoto | 0:0e0631af0305 | 525 | |
| RyoheiHagimoto | 0:0e0631af0305 | 526 | for(; node != 0; node = cvGetNextSparseNode(&it)) |
| RyoheiHagimoto | 0:0e0631af0305 | 527 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 528 | int* idx = CV_NODE_IDX(array, node); |
| RyoheiHagimoto | 0:0e0631af0305 | 529 | float val = *(float*)CV_NODE_VAL(array, node); |
| RyoheiHagimoto | 0:0e0631af0305 | 530 | printf("M"); |
| RyoheiHagimoto | 0:0e0631af0305 | 531 | for(i = 0; i < dims; i++ ) |
| RyoheiHagimoto | 0:0e0631af0305 | 532 | printf("[%d]", idx[i]); |
| RyoheiHagimoto | 0:0e0631af0305 | 533 | printf("=%g\n", val); |
| RyoheiHagimoto | 0:0e0631af0305 | 534 | |
| RyoheiHagimoto | 0:0e0631af0305 | 535 | sum += val; |
| RyoheiHagimoto | 0:0e0631af0305 | 536 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 537 | |
| RyoheiHagimoto | 0:0e0631af0305 | 538 | printf("nTotal sum = %g\n", sum); |
| RyoheiHagimoto | 0:0e0631af0305 | 539 | @endcode |
| RyoheiHagimoto | 0:0e0631af0305 | 540 | @param mat_iterator Sparse array iterator |
| RyoheiHagimoto | 0:0e0631af0305 | 541 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 542 | CV_INLINE CvSparseNode* cvGetNextSparseNode( CvSparseMatIterator* mat_iterator ) |
| RyoheiHagimoto | 0:0e0631af0305 | 543 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 544 | if( mat_iterator->node->next ) |
| RyoheiHagimoto | 0:0e0631af0305 | 545 | return mat_iterator->node = mat_iterator->node->next; |
| RyoheiHagimoto | 0:0e0631af0305 | 546 | else |
| RyoheiHagimoto | 0:0e0631af0305 | 547 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 548 | int idx; |
| RyoheiHagimoto | 0:0e0631af0305 | 549 | for( idx = ++mat_iterator->curidx; idx < mat_iterator->mat->hashsize; idx++ ) |
| RyoheiHagimoto | 0:0e0631af0305 | 550 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 551 | CvSparseNode* node = (CvSparseNode*)mat_iterator->mat->hashtable[idx]; |
| RyoheiHagimoto | 0:0e0631af0305 | 552 | if( node ) |
| RyoheiHagimoto | 0:0e0631af0305 | 553 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 554 | mat_iterator->curidx = idx; |
| RyoheiHagimoto | 0:0e0631af0305 | 555 | return mat_iterator->node = node; |
| RyoheiHagimoto | 0:0e0631af0305 | 556 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 557 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 558 | return NULL; |
| RyoheiHagimoto | 0:0e0631af0305 | 559 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 560 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 561 | |
| RyoheiHagimoto | 0:0e0631af0305 | 562 | |
| RyoheiHagimoto | 0:0e0631af0305 | 563 | #define CV_MAX_ARR 10 |
| RyoheiHagimoto | 0:0e0631af0305 | 564 | |
| RyoheiHagimoto | 0:0e0631af0305 | 565 | /** matrix iterator: used for n-ary operations on dense arrays */ |
| RyoheiHagimoto | 0:0e0631af0305 | 566 | typedef struct CvNArrayIterator |
| RyoheiHagimoto | 0:0e0631af0305 | 567 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 568 | int count; /**< number of arrays */ |
| RyoheiHagimoto | 0:0e0631af0305 | 569 | int dims; /**< number of dimensions to iterate */ |
| RyoheiHagimoto | 0:0e0631af0305 | 570 | CvSize size; /**< maximal common linear size: { width = size, height = 1 } */ |
| RyoheiHagimoto | 0:0e0631af0305 | 571 | uchar* ptr[CV_MAX_ARR]; /**< pointers to the array slices */ |
| RyoheiHagimoto | 0:0e0631af0305 | 572 | int stack[CV_MAX_DIM]; /**< for internal use */ |
| RyoheiHagimoto | 0:0e0631af0305 | 573 | CvMatND* hdr[CV_MAX_ARR]; /**< pointers to the headers of the |
| RyoheiHagimoto | 0:0e0631af0305 | 574 | matrices that are processed */ |
| RyoheiHagimoto | 0:0e0631af0305 | 575 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 576 | CvNArrayIterator; |
| RyoheiHagimoto | 0:0e0631af0305 | 577 | |
| RyoheiHagimoto | 0:0e0631af0305 | 578 | #define CV_NO_DEPTH_CHECK 1 |
| RyoheiHagimoto | 0:0e0631af0305 | 579 | #define CV_NO_CN_CHECK 2 |
| RyoheiHagimoto | 0:0e0631af0305 | 580 | #define CV_NO_SIZE_CHECK 4 |
| RyoheiHagimoto | 0:0e0631af0305 | 581 | |
| RyoheiHagimoto | 0:0e0631af0305 | 582 | /** initializes iterator that traverses through several arrays simulteneously |
| RyoheiHagimoto | 0:0e0631af0305 | 583 | (the function together with cvNextArraySlice is used for |
| RyoheiHagimoto | 0:0e0631af0305 | 584 | N-ari element-wise operations) */ |
| RyoheiHagimoto | 0:0e0631af0305 | 585 | CVAPI(int) cvInitNArrayIterator( int count, CvArr** arrs, |
| RyoheiHagimoto | 0:0e0631af0305 | 586 | const CvArr* mask, CvMatND* stubs, |
| RyoheiHagimoto | 0:0e0631af0305 | 587 | CvNArrayIterator* array_iterator, |
| RyoheiHagimoto | 0:0e0631af0305 | 588 | int flags CV_DEFAULT(0) ); |
| RyoheiHagimoto | 0:0e0631af0305 | 589 | |
| RyoheiHagimoto | 0:0e0631af0305 | 590 | /** returns zero value if iteration is finished, non-zero (slice length) otherwise */ |
| RyoheiHagimoto | 0:0e0631af0305 | 591 | CVAPI(int) cvNextNArraySlice( CvNArrayIterator* array_iterator ); |
| RyoheiHagimoto | 0:0e0631af0305 | 592 | |
| RyoheiHagimoto | 0:0e0631af0305 | 593 | |
| RyoheiHagimoto | 0:0e0631af0305 | 594 | /** @brief Returns type of array elements. |
| RyoheiHagimoto | 0:0e0631af0305 | 595 | |
| RyoheiHagimoto | 0:0e0631af0305 | 596 | The function returns type of the array elements. In the case of IplImage the type is converted to |
| RyoheiHagimoto | 0:0e0631af0305 | 597 | CvMat-like representation. For example, if the image has been created as: |
| RyoheiHagimoto | 0:0e0631af0305 | 598 | @code |
| RyoheiHagimoto | 0:0e0631af0305 | 599 | IplImage* img = cvCreateImage(cvSize(640, 480), IPL_DEPTH_8U, 3); |
| RyoheiHagimoto | 0:0e0631af0305 | 600 | @endcode |
| RyoheiHagimoto | 0:0e0631af0305 | 601 | The code cvGetElemType(img) will return CV_8UC3. |
| RyoheiHagimoto | 0:0e0631af0305 | 602 | @param arr Input array |
| RyoheiHagimoto | 0:0e0631af0305 | 603 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 604 | CVAPI(int) cvGetElemType( const CvArr* arr ); |
| RyoheiHagimoto | 0:0e0631af0305 | 605 | |
| RyoheiHagimoto | 0:0e0631af0305 | 606 | /** @brief Return number of array dimensions |
| RyoheiHagimoto | 0:0e0631af0305 | 607 | |
| RyoheiHagimoto | 0:0e0631af0305 | 608 | The function returns the array dimensionality and the array of dimension sizes. In the case of |
| RyoheiHagimoto | 0:0e0631af0305 | 609 | IplImage or CvMat it always returns 2 regardless of number of image/matrix rows. For example, the |
| RyoheiHagimoto | 0:0e0631af0305 | 610 | following code calculates total number of array elements: |
| RyoheiHagimoto | 0:0e0631af0305 | 611 | @code |
| RyoheiHagimoto | 0:0e0631af0305 | 612 | int sizes[CV_MAX_DIM]; |
| RyoheiHagimoto | 0:0e0631af0305 | 613 | int i, total = 1; |
| RyoheiHagimoto | 0:0e0631af0305 | 614 | int dims = cvGetDims(arr, size); |
| RyoheiHagimoto | 0:0e0631af0305 | 615 | for(i = 0; i < dims; i++ ) |
| RyoheiHagimoto | 0:0e0631af0305 | 616 | total *= sizes[i]; |
| RyoheiHagimoto | 0:0e0631af0305 | 617 | @endcode |
| RyoheiHagimoto | 0:0e0631af0305 | 618 | @param arr Input array |
| RyoheiHagimoto | 0:0e0631af0305 | 619 | @param sizes Optional output vector of the array dimension sizes. For 2d arrays the number of rows |
| RyoheiHagimoto | 0:0e0631af0305 | 620 | (height) goes first, number of columns (width) next. |
| RyoheiHagimoto | 0:0e0631af0305 | 621 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 622 | CVAPI(int) cvGetDims( const CvArr* arr, int* sizes CV_DEFAULT(NULL) ); |
| RyoheiHagimoto | 0:0e0631af0305 | 623 | |
| RyoheiHagimoto | 0:0e0631af0305 | 624 | |
| RyoheiHagimoto | 0:0e0631af0305 | 625 | /** @brief Returns array size along the specified dimension. |
| RyoheiHagimoto | 0:0e0631af0305 | 626 | |
| RyoheiHagimoto | 0:0e0631af0305 | 627 | @param arr Input array |
| RyoheiHagimoto | 0:0e0631af0305 | 628 | @param index Zero-based dimension index (for matrices 0 means number of rows, 1 means number of |
| RyoheiHagimoto | 0:0e0631af0305 | 629 | columns; for images 0 means height, 1 means width) |
| RyoheiHagimoto | 0:0e0631af0305 | 630 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 631 | CVAPI(int) cvGetDimSize( const CvArr* arr, int index ); |
| RyoheiHagimoto | 0:0e0631af0305 | 632 | |
| RyoheiHagimoto | 0:0e0631af0305 | 633 | |
| RyoheiHagimoto | 0:0e0631af0305 | 634 | /** @brief Return pointer to a particular array element. |
| RyoheiHagimoto | 0:0e0631af0305 | 635 | |
| RyoheiHagimoto | 0:0e0631af0305 | 636 | The functions return a pointer to a specific array element. Number of array dimension should match |
| RyoheiHagimoto | 0:0e0631af0305 | 637 | to the number of indices passed to the function except for cvPtr1D function that can be used for |
| RyoheiHagimoto | 0:0e0631af0305 | 638 | sequential access to 1D, 2D or nD dense arrays. |
| RyoheiHagimoto | 0:0e0631af0305 | 639 | |
| RyoheiHagimoto | 0:0e0631af0305 | 640 | The functions can be used for sparse arrays as well - if the requested node does not exist they |
| RyoheiHagimoto | 0:0e0631af0305 | 641 | create it and set it to zero. |
| RyoheiHagimoto | 0:0e0631af0305 | 642 | |
| RyoheiHagimoto | 0:0e0631af0305 | 643 | All these as well as other functions accessing array elements ( cvGetND , cvGetRealND , cvSet |
| RyoheiHagimoto | 0:0e0631af0305 | 644 | , cvSetND , cvSetRealND ) raise an error in case if the element index is out of range. |
| RyoheiHagimoto | 0:0e0631af0305 | 645 | @param arr Input array |
| RyoheiHagimoto | 0:0e0631af0305 | 646 | @param idx0 The first zero-based component of the element index |
| RyoheiHagimoto | 0:0e0631af0305 | 647 | @param type Optional output parameter: type of matrix elements |
| RyoheiHagimoto | 0:0e0631af0305 | 648 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 649 | CVAPI(uchar*) cvPtr1D( const CvArr* arr, int idx0, int* type CV_DEFAULT(NULL)); |
| RyoheiHagimoto | 0:0e0631af0305 | 650 | /** @overload */ |
| RyoheiHagimoto | 0:0e0631af0305 | 651 | CVAPI(uchar*) cvPtr2D( const CvArr* arr, int idx0, int idx1, int* type CV_DEFAULT(NULL) ); |
| RyoheiHagimoto | 0:0e0631af0305 | 652 | /** @overload */ |
| RyoheiHagimoto | 0:0e0631af0305 | 653 | CVAPI(uchar*) cvPtr3D( const CvArr* arr, int idx0, int idx1, int idx2, |
| RyoheiHagimoto | 0:0e0631af0305 | 654 | int* type CV_DEFAULT(NULL)); |
| RyoheiHagimoto | 0:0e0631af0305 | 655 | /** @overload |
| RyoheiHagimoto | 0:0e0631af0305 | 656 | @param arr Input array |
| RyoheiHagimoto | 0:0e0631af0305 | 657 | @param idx Array of the element indices |
| RyoheiHagimoto | 0:0e0631af0305 | 658 | @param type Optional output parameter: type of matrix elements |
| RyoheiHagimoto | 0:0e0631af0305 | 659 | @param create_node Optional input parameter for sparse matrices. Non-zero value of the parameter |
| RyoheiHagimoto | 0:0e0631af0305 | 660 | means that the requested element is created if it does not exist already. |
| RyoheiHagimoto | 0:0e0631af0305 | 661 | @param precalc_hashval Optional input parameter for sparse matrices. If the pointer is not NULL, |
| RyoheiHagimoto | 0:0e0631af0305 | 662 | the function does not recalculate the node hash value, but takes it from the specified location. |
| RyoheiHagimoto | 0:0e0631af0305 | 663 | It is useful for speeding up pair-wise operations (TODO: provide an example) |
| RyoheiHagimoto | 0:0e0631af0305 | 664 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 665 | CVAPI(uchar*) cvPtrND( const CvArr* arr, const int* idx, int* type CV_DEFAULT(NULL), |
| RyoheiHagimoto | 0:0e0631af0305 | 666 | int create_node CV_DEFAULT(1), |
| RyoheiHagimoto | 0:0e0631af0305 | 667 | unsigned* precalc_hashval CV_DEFAULT(NULL)); |
| RyoheiHagimoto | 0:0e0631af0305 | 668 | |
| RyoheiHagimoto | 0:0e0631af0305 | 669 | /** @brief Return a specific array element. |
| RyoheiHagimoto | 0:0e0631af0305 | 670 | |
| RyoheiHagimoto | 0:0e0631af0305 | 671 | The functions return a specific array element. In the case of a sparse array the functions return 0 |
| RyoheiHagimoto | 0:0e0631af0305 | 672 | if the requested node does not exist (no new node is created by the functions). |
| RyoheiHagimoto | 0:0e0631af0305 | 673 | @param arr Input array |
| RyoheiHagimoto | 0:0e0631af0305 | 674 | @param idx0 The first zero-based component of the element index |
| RyoheiHagimoto | 0:0e0631af0305 | 675 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 676 | CVAPI(CvScalar) cvGet1D( const CvArr* arr, int idx0 ); |
| RyoheiHagimoto | 0:0e0631af0305 | 677 | /** @overload */ |
| RyoheiHagimoto | 0:0e0631af0305 | 678 | CVAPI(CvScalar) cvGet2D( const CvArr* arr, int idx0, int idx1 ); |
| RyoheiHagimoto | 0:0e0631af0305 | 679 | /** @overload */ |
| RyoheiHagimoto | 0:0e0631af0305 | 680 | CVAPI(CvScalar) cvGet3D( const CvArr* arr, int idx0, int idx1, int idx2 ); |
| RyoheiHagimoto | 0:0e0631af0305 | 681 | /** @overload |
| RyoheiHagimoto | 0:0e0631af0305 | 682 | @param arr Input array |
| RyoheiHagimoto | 0:0e0631af0305 | 683 | @param idx Array of the element indices |
| RyoheiHagimoto | 0:0e0631af0305 | 684 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 685 | CVAPI(CvScalar) cvGetND( const CvArr* arr, const int* idx ); |
| RyoheiHagimoto | 0:0e0631af0305 | 686 | |
| RyoheiHagimoto | 0:0e0631af0305 | 687 | /** @brief Return a specific element of single-channel 1D, 2D, 3D or nD array. |
| RyoheiHagimoto | 0:0e0631af0305 | 688 | |
| RyoheiHagimoto | 0:0e0631af0305 | 689 | Returns a specific element of a single-channel array. If the array has multiple channels, a runtime |
| RyoheiHagimoto | 0:0e0631af0305 | 690 | error is raised. Note that Get?D functions can be used safely for both single-channel and |
| RyoheiHagimoto | 0:0e0631af0305 | 691 | multiple-channel arrays though they are a bit slower. |
| RyoheiHagimoto | 0:0e0631af0305 | 692 | |
| RyoheiHagimoto | 0:0e0631af0305 | 693 | In the case of a sparse array the functions return 0 if the requested node does not exist (no new |
| RyoheiHagimoto | 0:0e0631af0305 | 694 | node is created by the functions). |
| RyoheiHagimoto | 0:0e0631af0305 | 695 | @param arr Input array. Must have a single channel. |
| RyoheiHagimoto | 0:0e0631af0305 | 696 | @param idx0 The first zero-based component of the element index |
| RyoheiHagimoto | 0:0e0631af0305 | 697 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 698 | CVAPI(double) cvGetReal1D( const CvArr* arr, int idx0 ); |
| RyoheiHagimoto | 0:0e0631af0305 | 699 | /** @overload */ |
| RyoheiHagimoto | 0:0e0631af0305 | 700 | CVAPI(double) cvGetReal2D( const CvArr* arr, int idx0, int idx1 ); |
| RyoheiHagimoto | 0:0e0631af0305 | 701 | /** @overload */ |
| RyoheiHagimoto | 0:0e0631af0305 | 702 | CVAPI(double) cvGetReal3D( const CvArr* arr, int idx0, int idx1, int idx2 ); |
| RyoheiHagimoto | 0:0e0631af0305 | 703 | /** @overload |
| RyoheiHagimoto | 0:0e0631af0305 | 704 | @param arr Input array. Must have a single channel. |
| RyoheiHagimoto | 0:0e0631af0305 | 705 | @param idx Array of the element indices |
| RyoheiHagimoto | 0:0e0631af0305 | 706 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 707 | CVAPI(double) cvGetRealND( const CvArr* arr, const int* idx ); |
| RyoheiHagimoto | 0:0e0631af0305 | 708 | |
| RyoheiHagimoto | 0:0e0631af0305 | 709 | /** @brief Change the particular array element. |
| RyoheiHagimoto | 0:0e0631af0305 | 710 | |
| RyoheiHagimoto | 0:0e0631af0305 | 711 | The functions assign the new value to a particular array element. In the case of a sparse array the |
| RyoheiHagimoto | 0:0e0631af0305 | 712 | functions create the node if it does not exist yet. |
| RyoheiHagimoto | 0:0e0631af0305 | 713 | @param arr Input array |
| RyoheiHagimoto | 0:0e0631af0305 | 714 | @param idx0 The first zero-based component of the element index |
| RyoheiHagimoto | 0:0e0631af0305 | 715 | @param value The assigned value |
| RyoheiHagimoto | 0:0e0631af0305 | 716 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 717 | CVAPI(void) cvSet1D( CvArr* arr, int idx0, CvScalar value ); |
| RyoheiHagimoto | 0:0e0631af0305 | 718 | /** @overload */ |
| RyoheiHagimoto | 0:0e0631af0305 | 719 | CVAPI(void) cvSet2D( CvArr* arr, int idx0, int idx1, CvScalar value ); |
| RyoheiHagimoto | 0:0e0631af0305 | 720 | /** @overload */ |
| RyoheiHagimoto | 0:0e0631af0305 | 721 | CVAPI(void) cvSet3D( CvArr* arr, int idx0, int idx1, int idx2, CvScalar value ); |
| RyoheiHagimoto | 0:0e0631af0305 | 722 | /** @overload |
| RyoheiHagimoto | 0:0e0631af0305 | 723 | @param arr Input array |
| RyoheiHagimoto | 0:0e0631af0305 | 724 | @param idx Array of the element indices |
| RyoheiHagimoto | 0:0e0631af0305 | 725 | @param value The assigned value |
| RyoheiHagimoto | 0:0e0631af0305 | 726 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 727 | CVAPI(void) cvSetND( CvArr* arr, const int* idx, CvScalar value ); |
| RyoheiHagimoto | 0:0e0631af0305 | 728 | |
| RyoheiHagimoto | 0:0e0631af0305 | 729 | /** @brief Change a specific array element. |
| RyoheiHagimoto | 0:0e0631af0305 | 730 | |
| RyoheiHagimoto | 0:0e0631af0305 | 731 | The functions assign a new value to a specific element of a single-channel array. If the array has |
| RyoheiHagimoto | 0:0e0631af0305 | 732 | multiple channels, a runtime error is raised. Note that the Set\*D function can be used safely for |
| RyoheiHagimoto | 0:0e0631af0305 | 733 | both single-channel and multiple-channel arrays, though they are a bit slower. |
| RyoheiHagimoto | 0:0e0631af0305 | 734 | |
| RyoheiHagimoto | 0:0e0631af0305 | 735 | In the case of a sparse array the functions create the node if it does not yet exist. |
| RyoheiHagimoto | 0:0e0631af0305 | 736 | @param arr Input array |
| RyoheiHagimoto | 0:0e0631af0305 | 737 | @param idx0 The first zero-based component of the element index |
| RyoheiHagimoto | 0:0e0631af0305 | 738 | @param value The assigned value |
| RyoheiHagimoto | 0:0e0631af0305 | 739 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 740 | CVAPI(void) cvSetReal1D( CvArr* arr, int idx0, double value ); |
| RyoheiHagimoto | 0:0e0631af0305 | 741 | /** @overload */ |
| RyoheiHagimoto | 0:0e0631af0305 | 742 | CVAPI(void) cvSetReal2D( CvArr* arr, int idx0, int idx1, double value ); |
| RyoheiHagimoto | 0:0e0631af0305 | 743 | /** @overload */ |
| RyoheiHagimoto | 0:0e0631af0305 | 744 | CVAPI(void) cvSetReal3D( CvArr* arr, int idx0, |
| RyoheiHagimoto | 0:0e0631af0305 | 745 | int idx1, int idx2, double value ); |
| RyoheiHagimoto | 0:0e0631af0305 | 746 | /** @overload |
| RyoheiHagimoto | 0:0e0631af0305 | 747 | @param arr Input array |
| RyoheiHagimoto | 0:0e0631af0305 | 748 | @param idx Array of the element indices |
| RyoheiHagimoto | 0:0e0631af0305 | 749 | @param value The assigned value |
| RyoheiHagimoto | 0:0e0631af0305 | 750 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 751 | CVAPI(void) cvSetRealND( CvArr* arr, const int* idx, double value ); |
| RyoheiHagimoto | 0:0e0631af0305 | 752 | |
| RyoheiHagimoto | 0:0e0631af0305 | 753 | /** clears element of ND dense array, |
| RyoheiHagimoto | 0:0e0631af0305 | 754 | in case of sparse arrays it deletes the specified node */ |
| RyoheiHagimoto | 0:0e0631af0305 | 755 | CVAPI(void) cvClearND( CvArr* arr, const int* idx ); |
| RyoheiHagimoto | 0:0e0631af0305 | 756 | |
| RyoheiHagimoto | 0:0e0631af0305 | 757 | /** @brief Returns matrix header for arbitrary array. |
| RyoheiHagimoto | 0:0e0631af0305 | 758 | |
| RyoheiHagimoto | 0:0e0631af0305 | 759 | The function returns a matrix header for the input array that can be a matrix - CvMat, an image - |
| RyoheiHagimoto | 0:0e0631af0305 | 760 | IplImage, or a multi-dimensional dense array - CvMatND (the third option is allowed only if |
| RyoheiHagimoto | 0:0e0631af0305 | 761 | allowND != 0) . In the case of matrix the function simply returns the input pointer. In the case of |
| RyoheiHagimoto | 0:0e0631af0305 | 762 | IplImage\* or CvMatND it initializes the header structure with parameters of the current image ROI |
| RyoheiHagimoto | 0:0e0631af0305 | 763 | and returns &header. Because COI is not supported by CvMat, it is returned separately. |
| RyoheiHagimoto | 0:0e0631af0305 | 764 | |
| RyoheiHagimoto | 0:0e0631af0305 | 765 | The function provides an easy way to handle both types of arrays - IplImage and CvMat using the same |
| RyoheiHagimoto | 0:0e0631af0305 | 766 | code. Input array must have non-zero data pointer, otherwise the function will report an error. |
| RyoheiHagimoto | 0:0e0631af0305 | 767 | |
| RyoheiHagimoto | 0:0e0631af0305 | 768 | @note If the input array is IplImage with planar data layout and COI set, the function returns the |
| RyoheiHagimoto | 0:0e0631af0305 | 769 | pointer to the selected plane and COI == 0. This feature allows user to process IplImage structures |
| RyoheiHagimoto | 0:0e0631af0305 | 770 | with planar data layout, even though OpenCV does not support such images. |
| RyoheiHagimoto | 0:0e0631af0305 | 771 | @param arr Input array |
| RyoheiHagimoto | 0:0e0631af0305 | 772 | @param header Pointer to CvMat structure used as a temporary buffer |
| RyoheiHagimoto | 0:0e0631af0305 | 773 | @param coi Optional output parameter for storing COI |
| RyoheiHagimoto | 0:0e0631af0305 | 774 | @param allowND If non-zero, the function accepts multi-dimensional dense arrays (CvMatND\*) and |
| RyoheiHagimoto | 0:0e0631af0305 | 775 | returns 2D matrix (if CvMatND has two dimensions) or 1D matrix (when CvMatND has 1 dimension or |
| RyoheiHagimoto | 0:0e0631af0305 | 776 | more than 2 dimensions). The CvMatND array must be continuous. |
| RyoheiHagimoto | 0:0e0631af0305 | 777 | @sa cvGetImage, cvarrToMat. |
| RyoheiHagimoto | 0:0e0631af0305 | 778 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 779 | CVAPI(CvMat*) cvGetMat( const CvArr* arr, CvMat* header, |
| RyoheiHagimoto | 0:0e0631af0305 | 780 | int* coi CV_DEFAULT(NULL), |
| RyoheiHagimoto | 0:0e0631af0305 | 781 | int allowND CV_DEFAULT(0)); |
| RyoheiHagimoto | 0:0e0631af0305 | 782 | |
| RyoheiHagimoto | 0:0e0631af0305 | 783 | /** @brief Returns image header for arbitrary array. |
| RyoheiHagimoto | 0:0e0631af0305 | 784 | |
| RyoheiHagimoto | 0:0e0631af0305 | 785 | The function returns the image header for the input array that can be a matrix (CvMat) or image |
| RyoheiHagimoto | 0:0e0631af0305 | 786 | (IplImage). In the case of an image the function simply returns the input pointer. In the case of |
| RyoheiHagimoto | 0:0e0631af0305 | 787 | CvMat it initializes an image_header structure with the parameters of the input matrix. Note that |
| RyoheiHagimoto | 0:0e0631af0305 | 788 | if we transform IplImage to CvMat using cvGetMat and then transform CvMat back to IplImage using |
| RyoheiHagimoto | 0:0e0631af0305 | 789 | this function, we will get different headers if the ROI is set in the original image. |
| RyoheiHagimoto | 0:0e0631af0305 | 790 | @param arr Input array |
| RyoheiHagimoto | 0:0e0631af0305 | 791 | @param image_header Pointer to IplImage structure used as a temporary buffer |
| RyoheiHagimoto | 0:0e0631af0305 | 792 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 793 | CVAPI(IplImage*) cvGetImage( const CvArr* arr, IplImage* image_header ); |
| RyoheiHagimoto | 0:0e0631af0305 | 794 | |
| RyoheiHagimoto | 0:0e0631af0305 | 795 | |
| RyoheiHagimoto | 0:0e0631af0305 | 796 | /** @brief Changes the shape of a multi-dimensional array without copying the data. |
| RyoheiHagimoto | 0:0e0631af0305 | 797 | |
| RyoheiHagimoto | 0:0e0631af0305 | 798 | The function is an advanced version of cvReshape that can work with multi-dimensional arrays as |
| RyoheiHagimoto | 0:0e0631af0305 | 799 | well (though it can work with ordinary images and matrices) and change the number of dimensions. |
| RyoheiHagimoto | 0:0e0631af0305 | 800 | |
| RyoheiHagimoto | 0:0e0631af0305 | 801 | Below are the two samples from the cvReshape description rewritten using cvReshapeMatND: |
| RyoheiHagimoto | 0:0e0631af0305 | 802 | @code |
| RyoheiHagimoto | 0:0e0631af0305 | 803 | IplImage* color_img = cvCreateImage(cvSize(320,240), IPL_DEPTH_8U, 3); |
| RyoheiHagimoto | 0:0e0631af0305 | 804 | IplImage gray_img_hdr, *gray_img; |
| RyoheiHagimoto | 0:0e0631af0305 | 805 | gray_img = (IplImage*)cvReshapeMatND(color_img, sizeof(gray_img_hdr), &gray_img_hdr, 1, 0, 0); |
| RyoheiHagimoto | 0:0e0631af0305 | 806 | ... |
| RyoheiHagimoto | 0:0e0631af0305 | 807 | int size[] = { 2, 2, 2 }; |
| RyoheiHagimoto | 0:0e0631af0305 | 808 | CvMatND* mat = cvCreateMatND(3, size, CV_32F); |
| RyoheiHagimoto | 0:0e0631af0305 | 809 | CvMat row_header, *row; |
| RyoheiHagimoto | 0:0e0631af0305 | 810 | row = (CvMat*)cvReshapeMatND(mat, sizeof(row_header), &row_header, 0, 1, 0); |
| RyoheiHagimoto | 0:0e0631af0305 | 811 | @endcode |
| RyoheiHagimoto | 0:0e0631af0305 | 812 | In C, the header file for this function includes a convenient macro cvReshapeND that does away with |
| RyoheiHagimoto | 0:0e0631af0305 | 813 | the sizeof_header parameter. So, the lines containing the call to cvReshapeMatND in the examples |
| RyoheiHagimoto | 0:0e0631af0305 | 814 | may be replaced as follow: |
| RyoheiHagimoto | 0:0e0631af0305 | 815 | @code |
| RyoheiHagimoto | 0:0e0631af0305 | 816 | gray_img = (IplImage*)cvReshapeND(color_img, &gray_img_hdr, 1, 0, 0); |
| RyoheiHagimoto | 0:0e0631af0305 | 817 | ... |
| RyoheiHagimoto | 0:0e0631af0305 | 818 | row = (CvMat*)cvReshapeND(mat, &row_header, 0, 1, 0); |
| RyoheiHagimoto | 0:0e0631af0305 | 819 | @endcode |
| RyoheiHagimoto | 0:0e0631af0305 | 820 | @param arr Input array |
| RyoheiHagimoto | 0:0e0631af0305 | 821 | @param sizeof_header Size of output header to distinguish between IplImage, CvMat and CvMatND |
| RyoheiHagimoto | 0:0e0631af0305 | 822 | output headers |
| RyoheiHagimoto | 0:0e0631af0305 | 823 | @param header Output header to be filled |
| RyoheiHagimoto | 0:0e0631af0305 | 824 | @param new_cn New number of channels. new_cn = 0 means that the number of channels remains |
| RyoheiHagimoto | 0:0e0631af0305 | 825 | unchanged. |
| RyoheiHagimoto | 0:0e0631af0305 | 826 | @param new_dims New number of dimensions. new_dims = 0 means that the number of dimensions |
| RyoheiHagimoto | 0:0e0631af0305 | 827 | remains the same. |
| RyoheiHagimoto | 0:0e0631af0305 | 828 | @param new_sizes Array of new dimension sizes. Only new_dims-1 values are used, because the |
| RyoheiHagimoto | 0:0e0631af0305 | 829 | total number of elements must remain the same. Thus, if new_dims = 1, new_sizes array is not |
| RyoheiHagimoto | 0:0e0631af0305 | 830 | used. |
| RyoheiHagimoto | 0:0e0631af0305 | 831 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 832 | CVAPI(CvArr*) cvReshapeMatND( const CvArr* arr, |
| RyoheiHagimoto | 0:0e0631af0305 | 833 | int sizeof_header, CvArr* header, |
| RyoheiHagimoto | 0:0e0631af0305 | 834 | int new_cn, int new_dims, int* new_sizes ); |
| RyoheiHagimoto | 0:0e0631af0305 | 835 | |
| RyoheiHagimoto | 0:0e0631af0305 | 836 | #define cvReshapeND( arr, header, new_cn, new_dims, new_sizes ) \ |
| RyoheiHagimoto | 0:0e0631af0305 | 837 | cvReshapeMatND( (arr), sizeof(*(header)), (header), \ |
| RyoheiHagimoto | 0:0e0631af0305 | 838 | (new_cn), (new_dims), (new_sizes)) |
| RyoheiHagimoto | 0:0e0631af0305 | 839 | |
| RyoheiHagimoto | 0:0e0631af0305 | 840 | /** @brief Changes shape of matrix/image without copying data. |
| RyoheiHagimoto | 0:0e0631af0305 | 841 | |
| RyoheiHagimoto | 0:0e0631af0305 | 842 | The function initializes the CvMat header so that it points to the same data as the original array |
| RyoheiHagimoto | 0:0e0631af0305 | 843 | but has a different shape - different number of channels, different number of rows, or both. |
| RyoheiHagimoto | 0:0e0631af0305 | 844 | |
| RyoheiHagimoto | 0:0e0631af0305 | 845 | The following example code creates one image buffer and two image headers, the first is for a |
| RyoheiHagimoto | 0:0e0631af0305 | 846 | 320x240x3 image and the second is for a 960x240x1 image: |
| RyoheiHagimoto | 0:0e0631af0305 | 847 | @code |
| RyoheiHagimoto | 0:0e0631af0305 | 848 | IplImage* color_img = cvCreateImage(cvSize(320,240), IPL_DEPTH_8U, 3); |
| RyoheiHagimoto | 0:0e0631af0305 | 849 | CvMat gray_mat_hdr; |
| RyoheiHagimoto | 0:0e0631af0305 | 850 | IplImage gray_img_hdr, *gray_img; |
| RyoheiHagimoto | 0:0e0631af0305 | 851 | cvReshape(color_img, &gray_mat_hdr, 1); |
| RyoheiHagimoto | 0:0e0631af0305 | 852 | gray_img = cvGetImage(&gray_mat_hdr, &gray_img_hdr); |
| RyoheiHagimoto | 0:0e0631af0305 | 853 | @endcode |
| RyoheiHagimoto | 0:0e0631af0305 | 854 | And the next example converts a 3x3 matrix to a single 1x9 vector: |
| RyoheiHagimoto | 0:0e0631af0305 | 855 | @code |
| RyoheiHagimoto | 0:0e0631af0305 | 856 | CvMat* mat = cvCreateMat(3, 3, CV_32F); |
| RyoheiHagimoto | 0:0e0631af0305 | 857 | CvMat row_header, *row; |
| RyoheiHagimoto | 0:0e0631af0305 | 858 | row = cvReshape(mat, &row_header, 0, 1); |
| RyoheiHagimoto | 0:0e0631af0305 | 859 | @endcode |
| RyoheiHagimoto | 0:0e0631af0305 | 860 | @param arr Input array |
| RyoheiHagimoto | 0:0e0631af0305 | 861 | @param header Output header to be filled |
| RyoheiHagimoto | 0:0e0631af0305 | 862 | @param new_cn New number of channels. 'new_cn = 0' means that the number of channels remains |
| RyoheiHagimoto | 0:0e0631af0305 | 863 | unchanged. |
| RyoheiHagimoto | 0:0e0631af0305 | 864 | @param new_rows New number of rows. 'new_rows = 0' means that the number of rows remains |
| RyoheiHagimoto | 0:0e0631af0305 | 865 | unchanged unless it needs to be changed according to new_cn value. |
| RyoheiHagimoto | 0:0e0631af0305 | 866 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 867 | CVAPI(CvMat*) cvReshape( const CvArr* arr, CvMat* header, |
| RyoheiHagimoto | 0:0e0631af0305 | 868 | int new_cn, int new_rows CV_DEFAULT(0) ); |
| RyoheiHagimoto | 0:0e0631af0305 | 869 | |
| RyoheiHagimoto | 0:0e0631af0305 | 870 | /** Repeats source 2d array several times in both horizontal and |
| RyoheiHagimoto | 0:0e0631af0305 | 871 | vertical direction to fill destination array */ |
| RyoheiHagimoto | 0:0e0631af0305 | 872 | CVAPI(void) cvRepeat( const CvArr* src, CvArr* dst ); |
| RyoheiHagimoto | 0:0e0631af0305 | 873 | |
| RyoheiHagimoto | 0:0e0631af0305 | 874 | /** @brief Allocates array data |
| RyoheiHagimoto | 0:0e0631af0305 | 875 | |
| RyoheiHagimoto | 0:0e0631af0305 | 876 | The function allocates image, matrix or multi-dimensional dense array data. Note that in the case of |
| RyoheiHagimoto | 0:0e0631af0305 | 877 | matrix types OpenCV allocation functions are used. In the case of IplImage they are used unless |
| RyoheiHagimoto | 0:0e0631af0305 | 878 | CV_TURN_ON_IPL_COMPATIBILITY() has been called before. In the latter case IPL functions are used |
| RyoheiHagimoto | 0:0e0631af0305 | 879 | to allocate the data. |
| RyoheiHagimoto | 0:0e0631af0305 | 880 | @param arr Array header |
| RyoheiHagimoto | 0:0e0631af0305 | 881 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 882 | CVAPI(void) cvCreateData( CvArr* arr ); |
| RyoheiHagimoto | 0:0e0631af0305 | 883 | |
| RyoheiHagimoto | 0:0e0631af0305 | 884 | /** @brief Releases array data. |
| RyoheiHagimoto | 0:0e0631af0305 | 885 | |
| RyoheiHagimoto | 0:0e0631af0305 | 886 | The function releases the array data. In the case of CvMat or CvMatND it simply calls |
| RyoheiHagimoto | 0:0e0631af0305 | 887 | cvDecRefData(), that is the function can not deallocate external data. See also the note to |
| RyoheiHagimoto | 0:0e0631af0305 | 888 | cvCreateData . |
| RyoheiHagimoto | 0:0e0631af0305 | 889 | @param arr Array header |
| RyoheiHagimoto | 0:0e0631af0305 | 890 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 891 | CVAPI(void) cvReleaseData( CvArr* arr ); |
| RyoheiHagimoto | 0:0e0631af0305 | 892 | |
| RyoheiHagimoto | 0:0e0631af0305 | 893 | /** @brief Assigns user data to the array header. |
| RyoheiHagimoto | 0:0e0631af0305 | 894 | |
| RyoheiHagimoto | 0:0e0631af0305 | 895 | The function assigns user data to the array header. Header should be initialized before using |
| RyoheiHagimoto | 0:0e0631af0305 | 896 | cvCreateMatHeader, cvCreateImageHeader, cvCreateMatNDHeader, cvInitMatHeader, |
| RyoheiHagimoto | 0:0e0631af0305 | 897 | cvInitImageHeader or cvInitMatNDHeader. |
| RyoheiHagimoto | 0:0e0631af0305 | 898 | @param arr Array header |
| RyoheiHagimoto | 0:0e0631af0305 | 899 | @param data User data |
| RyoheiHagimoto | 0:0e0631af0305 | 900 | @param step Full row length in bytes |
| RyoheiHagimoto | 0:0e0631af0305 | 901 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 902 | CVAPI(void) cvSetData( CvArr* arr, void* data, int step ); |
| RyoheiHagimoto | 0:0e0631af0305 | 903 | |
| RyoheiHagimoto | 0:0e0631af0305 | 904 | /** @brief Retrieves low-level information about the array. |
| RyoheiHagimoto | 0:0e0631af0305 | 905 | |
| RyoheiHagimoto | 0:0e0631af0305 | 906 | The function fills output variables with low-level information about the array data. All output |
| RyoheiHagimoto | 0:0e0631af0305 | 907 | |
| RyoheiHagimoto | 0:0e0631af0305 | 908 | parameters are optional, so some of the pointers may be set to NULL. If the array is IplImage with |
| RyoheiHagimoto | 0:0e0631af0305 | 909 | ROI set, the parameters of ROI are returned. |
| RyoheiHagimoto | 0:0e0631af0305 | 910 | |
| RyoheiHagimoto | 0:0e0631af0305 | 911 | The following example shows how to get access to array elements. It computes absolute values of the |
| RyoheiHagimoto | 0:0e0631af0305 | 912 | array elements : |
| RyoheiHagimoto | 0:0e0631af0305 | 913 | @code |
| RyoheiHagimoto | 0:0e0631af0305 | 914 | float* data; |
| RyoheiHagimoto | 0:0e0631af0305 | 915 | int step; |
| RyoheiHagimoto | 0:0e0631af0305 | 916 | CvSize size; |
| RyoheiHagimoto | 0:0e0631af0305 | 917 | |
| RyoheiHagimoto | 0:0e0631af0305 | 918 | cvGetRawData(array, (uchar**)&data, &step, &size); |
| RyoheiHagimoto | 0:0e0631af0305 | 919 | step /= sizeof(data[0]); |
| RyoheiHagimoto | 0:0e0631af0305 | 920 | |
| RyoheiHagimoto | 0:0e0631af0305 | 921 | for(int y = 0; y < size.height; y++, data += step ) |
| RyoheiHagimoto | 0:0e0631af0305 | 922 | for(int x = 0; x < size.width; x++ ) |
| RyoheiHagimoto | 0:0e0631af0305 | 923 | data[x] = (float)fabs(data[x]); |
| RyoheiHagimoto | 0:0e0631af0305 | 924 | @endcode |
| RyoheiHagimoto | 0:0e0631af0305 | 925 | @param arr Array header |
| RyoheiHagimoto | 0:0e0631af0305 | 926 | @param data Output pointer to the whole image origin or ROI origin if ROI is set |
| RyoheiHagimoto | 0:0e0631af0305 | 927 | @param step Output full row length in bytes |
| RyoheiHagimoto | 0:0e0631af0305 | 928 | @param roi_size Output ROI size |
| RyoheiHagimoto | 0:0e0631af0305 | 929 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 930 | CVAPI(void) cvGetRawData( const CvArr* arr, uchar** data, |
| RyoheiHagimoto | 0:0e0631af0305 | 931 | int* step CV_DEFAULT(NULL), |
| RyoheiHagimoto | 0:0e0631af0305 | 932 | CvSize* roi_size CV_DEFAULT(NULL)); |
| RyoheiHagimoto | 0:0e0631af0305 | 933 | |
| RyoheiHagimoto | 0:0e0631af0305 | 934 | /** @brief Returns size of matrix or image ROI. |
| RyoheiHagimoto | 0:0e0631af0305 | 935 | |
| RyoheiHagimoto | 0:0e0631af0305 | 936 | The function returns number of rows (CvSize::height) and number of columns (CvSize::width) of the |
| RyoheiHagimoto | 0:0e0631af0305 | 937 | input matrix or image. In the case of image the size of ROI is returned. |
| RyoheiHagimoto | 0:0e0631af0305 | 938 | @param arr array header |
| RyoheiHagimoto | 0:0e0631af0305 | 939 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 940 | CVAPI(CvSize) cvGetSize( const CvArr* arr ); |
| RyoheiHagimoto | 0:0e0631af0305 | 941 | |
| RyoheiHagimoto | 0:0e0631af0305 | 942 | /** @brief Copies one array to another. |
| RyoheiHagimoto | 0:0e0631af0305 | 943 | |
| RyoheiHagimoto | 0:0e0631af0305 | 944 | The function copies selected elements from an input array to an output array: |
| RyoheiHagimoto | 0:0e0631af0305 | 945 | |
| RyoheiHagimoto | 0:0e0631af0305 | 946 | \f[\texttt{dst} (I)= \texttt{src} (I) \quad \text{if} \quad \texttt{mask} (I) \ne 0.\f] |
| RyoheiHagimoto | 0:0e0631af0305 | 947 | |
| RyoheiHagimoto | 0:0e0631af0305 | 948 | If any of the passed arrays is of IplImage type, then its ROI and COI fields are used. Both arrays |
| RyoheiHagimoto | 0:0e0631af0305 | 949 | must have the same type, the same number of dimensions, and the same size. The function can also |
| RyoheiHagimoto | 0:0e0631af0305 | 950 | copy sparse arrays (mask is not supported in this case). |
| RyoheiHagimoto | 0:0e0631af0305 | 951 | @param src The source array |
| RyoheiHagimoto | 0:0e0631af0305 | 952 | @param dst The destination array |
| RyoheiHagimoto | 0:0e0631af0305 | 953 | @param mask Operation mask, 8-bit single channel array; specifies elements of the destination array |
| RyoheiHagimoto | 0:0e0631af0305 | 954 | to be changed |
| RyoheiHagimoto | 0:0e0631af0305 | 955 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 956 | CVAPI(void) cvCopy( const CvArr* src, CvArr* dst, |
| RyoheiHagimoto | 0:0e0631af0305 | 957 | const CvArr* mask CV_DEFAULT(NULL) ); |
| RyoheiHagimoto | 0:0e0631af0305 | 958 | |
| RyoheiHagimoto | 0:0e0631af0305 | 959 | /** @brief Sets every element of an array to a given value. |
| RyoheiHagimoto | 0:0e0631af0305 | 960 | |
| RyoheiHagimoto | 0:0e0631af0305 | 961 | The function copies the scalar value to every selected element of the destination array: |
| RyoheiHagimoto | 0:0e0631af0305 | 962 | \f[\texttt{arr} (I)= \texttt{value} \quad \text{if} \quad \texttt{mask} (I) \ne 0\f] |
| RyoheiHagimoto | 0:0e0631af0305 | 963 | If array arr is of IplImage type, then is ROI used, but COI must not be set. |
| RyoheiHagimoto | 0:0e0631af0305 | 964 | @param arr The destination array |
| RyoheiHagimoto | 0:0e0631af0305 | 965 | @param value Fill value |
| RyoheiHagimoto | 0:0e0631af0305 | 966 | @param mask Operation mask, 8-bit single channel array; specifies elements of the destination |
| RyoheiHagimoto | 0:0e0631af0305 | 967 | array to be changed |
| RyoheiHagimoto | 0:0e0631af0305 | 968 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 969 | CVAPI(void) cvSet( CvArr* arr, CvScalar value, |
| RyoheiHagimoto | 0:0e0631af0305 | 970 | const CvArr* mask CV_DEFAULT(NULL) ); |
| RyoheiHagimoto | 0:0e0631af0305 | 971 | |
| RyoheiHagimoto | 0:0e0631af0305 | 972 | /** @brief Clears the array. |
| RyoheiHagimoto | 0:0e0631af0305 | 973 | |
| RyoheiHagimoto | 0:0e0631af0305 | 974 | The function clears the array. In the case of dense arrays (CvMat, CvMatND or IplImage), |
| RyoheiHagimoto | 0:0e0631af0305 | 975 | cvZero(array) is equivalent to cvSet(array,cvScalarAll(0),0). In the case of sparse arrays all the |
| RyoheiHagimoto | 0:0e0631af0305 | 976 | elements are removed. |
| RyoheiHagimoto | 0:0e0631af0305 | 977 | @param arr Array to be cleared |
| RyoheiHagimoto | 0:0e0631af0305 | 978 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 979 | CVAPI(void) cvSetZero( CvArr* arr ); |
| RyoheiHagimoto | 0:0e0631af0305 | 980 | #define cvZero cvSetZero |
| RyoheiHagimoto | 0:0e0631af0305 | 981 | |
| RyoheiHagimoto | 0:0e0631af0305 | 982 | |
| RyoheiHagimoto | 0:0e0631af0305 | 983 | /** Splits a multi-channel array into the set of single-channel arrays or |
| RyoheiHagimoto | 0:0e0631af0305 | 984 | extracts particular [color] plane */ |
| RyoheiHagimoto | 0:0e0631af0305 | 985 | CVAPI(void) cvSplit( const CvArr* src, CvArr* dst0, CvArr* dst1, |
| RyoheiHagimoto | 0:0e0631af0305 | 986 | CvArr* dst2, CvArr* dst3 ); |
| RyoheiHagimoto | 0:0e0631af0305 | 987 | |
| RyoheiHagimoto | 0:0e0631af0305 | 988 | /** Merges a set of single-channel arrays into the single multi-channel array |
| RyoheiHagimoto | 0:0e0631af0305 | 989 | or inserts one particular [color] plane to the array */ |
| RyoheiHagimoto | 0:0e0631af0305 | 990 | CVAPI(void) cvMerge( const CvArr* src0, const CvArr* src1, |
| RyoheiHagimoto | 0:0e0631af0305 | 991 | const CvArr* src2, const CvArr* src3, |
| RyoheiHagimoto | 0:0e0631af0305 | 992 | CvArr* dst ); |
| RyoheiHagimoto | 0:0e0631af0305 | 993 | |
| RyoheiHagimoto | 0:0e0631af0305 | 994 | /** Copies several channels from input arrays to |
| RyoheiHagimoto | 0:0e0631af0305 | 995 | certain channels of output arrays */ |
| RyoheiHagimoto | 0:0e0631af0305 | 996 | CVAPI(void) cvMixChannels( const CvArr** src, int src_count, |
| RyoheiHagimoto | 0:0e0631af0305 | 997 | CvArr** dst, int dst_count, |
| RyoheiHagimoto | 0:0e0631af0305 | 998 | const int* from_to, int pair_count ); |
| RyoheiHagimoto | 0:0e0631af0305 | 999 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1000 | /** @brief Converts one array to another with optional linear transformation. |
| RyoheiHagimoto | 0:0e0631af0305 | 1001 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1002 | The function has several different purposes, and thus has several different names. It copies one |
| RyoheiHagimoto | 0:0e0631af0305 | 1003 | array to another with optional scaling, which is performed first, and/or optional type conversion, |
| RyoheiHagimoto | 0:0e0631af0305 | 1004 | performed after: |
| RyoheiHagimoto | 0:0e0631af0305 | 1005 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1006 | \f[\texttt{dst} (I) = \texttt{scale} \texttt{src} (I) + ( \texttt{shift} _0, \texttt{shift} _1,...)\f] |
| RyoheiHagimoto | 0:0e0631af0305 | 1007 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1008 | All the channels of multi-channel arrays are processed independently. |
| RyoheiHagimoto | 0:0e0631af0305 | 1009 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1010 | The type of conversion is done with rounding and saturation, that is if the result of scaling + |
| RyoheiHagimoto | 0:0e0631af0305 | 1011 | conversion can not be represented exactly by a value of the destination array element type, it is |
| RyoheiHagimoto | 0:0e0631af0305 | 1012 | set to the nearest representable value on the real axis. |
| RyoheiHagimoto | 0:0e0631af0305 | 1013 | @param src Source array |
| RyoheiHagimoto | 0:0e0631af0305 | 1014 | @param dst Destination array |
| RyoheiHagimoto | 0:0e0631af0305 | 1015 | @param scale Scale factor |
| RyoheiHagimoto | 0:0e0631af0305 | 1016 | @param shift Value added to the scaled source array elements |
| RyoheiHagimoto | 0:0e0631af0305 | 1017 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1018 | CVAPI(void) cvConvertScale( const CvArr* src, CvArr* dst, |
| RyoheiHagimoto | 0:0e0631af0305 | 1019 | double scale CV_DEFAULT(1), |
| RyoheiHagimoto | 0:0e0631af0305 | 1020 | double shift CV_DEFAULT(0) ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1021 | #define cvCvtScale cvConvertScale |
| RyoheiHagimoto | 0:0e0631af0305 | 1022 | #define cvScale cvConvertScale |
| RyoheiHagimoto | 0:0e0631af0305 | 1023 | #define cvConvert( src, dst ) cvConvertScale( (src), (dst), 1, 0 ) |
| RyoheiHagimoto | 0:0e0631af0305 | 1024 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1025 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1026 | /** Performs linear transformation on every source array element, |
| RyoheiHagimoto | 0:0e0631af0305 | 1027 | stores absolute value of the result: |
| RyoheiHagimoto | 0:0e0631af0305 | 1028 | dst(x,y,c) = abs(scale*src(x,y,c)+shift). |
| RyoheiHagimoto | 0:0e0631af0305 | 1029 | destination array must have 8u type. |
| RyoheiHagimoto | 0:0e0631af0305 | 1030 | In other cases one may use cvConvertScale + cvAbsDiffS */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1031 | CVAPI(void) cvConvertScaleAbs( const CvArr* src, CvArr* dst, |
| RyoheiHagimoto | 0:0e0631af0305 | 1032 | double scale CV_DEFAULT(1), |
| RyoheiHagimoto | 0:0e0631af0305 | 1033 | double shift CV_DEFAULT(0) ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1034 | #define cvCvtScaleAbs cvConvertScaleAbs |
| RyoheiHagimoto | 0:0e0631af0305 | 1035 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1036 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1037 | /** checks termination criteria validity and |
| RyoheiHagimoto | 0:0e0631af0305 | 1038 | sets eps to default_eps (if it is not set), |
| RyoheiHagimoto | 0:0e0631af0305 | 1039 | max_iter to default_max_iters (if it is not set) |
| RyoheiHagimoto | 0:0e0631af0305 | 1040 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1041 | CVAPI(CvTermCriteria) cvCheckTermCriteria( CvTermCriteria criteria, |
| RyoheiHagimoto | 0:0e0631af0305 | 1042 | double default_eps, |
| RyoheiHagimoto | 0:0e0631af0305 | 1043 | int default_max_iters ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1044 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1045 | /****************************************************************************************\ |
| RyoheiHagimoto | 0:0e0631af0305 | 1046 | * Arithmetic, logic and comparison operations * |
| RyoheiHagimoto | 0:0e0631af0305 | 1047 | \****************************************************************************************/ |
| RyoheiHagimoto | 0:0e0631af0305 | 1048 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1049 | /** dst(mask) = src1(mask) + src2(mask) */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1050 | CVAPI(void) cvAdd( const CvArr* src1, const CvArr* src2, CvArr* dst, |
| RyoheiHagimoto | 0:0e0631af0305 | 1051 | const CvArr* mask CV_DEFAULT(NULL)); |
| RyoheiHagimoto | 0:0e0631af0305 | 1052 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1053 | /** dst(mask) = src(mask) + value */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1054 | CVAPI(void) cvAddS( const CvArr* src, CvScalar value, CvArr* dst, |
| RyoheiHagimoto | 0:0e0631af0305 | 1055 | const CvArr* mask CV_DEFAULT(NULL)); |
| RyoheiHagimoto | 0:0e0631af0305 | 1056 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1057 | /** dst(mask) = src1(mask) - src2(mask) */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1058 | CVAPI(void) cvSub( const CvArr* src1, const CvArr* src2, CvArr* dst, |
| RyoheiHagimoto | 0:0e0631af0305 | 1059 | const CvArr* mask CV_DEFAULT(NULL)); |
| RyoheiHagimoto | 0:0e0631af0305 | 1060 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1061 | /** dst(mask) = src(mask) - value = src(mask) + (-value) */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1062 | CV_INLINE void cvSubS( const CvArr* src, CvScalar value, CvArr* dst, |
| RyoheiHagimoto | 0:0e0631af0305 | 1063 | const CvArr* mask CV_DEFAULT(NULL)) |
| RyoheiHagimoto | 0:0e0631af0305 | 1064 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 1065 | cvAddS( src, cvScalar( -value.val[0], -value.val[1], -value.val[2], -value.val[3]), |
| RyoheiHagimoto | 0:0e0631af0305 | 1066 | dst, mask ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1067 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 1068 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1069 | /** dst(mask) = value - src(mask) */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1070 | CVAPI(void) cvSubRS( const CvArr* src, CvScalar value, CvArr* dst, |
| RyoheiHagimoto | 0:0e0631af0305 | 1071 | const CvArr* mask CV_DEFAULT(NULL)); |
| RyoheiHagimoto | 0:0e0631af0305 | 1072 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1073 | /** dst(idx) = src1(idx) * src2(idx) * scale |
| RyoheiHagimoto | 0:0e0631af0305 | 1074 | (scaled element-wise multiplication of 2 arrays) */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1075 | CVAPI(void) cvMul( const CvArr* src1, const CvArr* src2, |
| RyoheiHagimoto | 0:0e0631af0305 | 1076 | CvArr* dst, double scale CV_DEFAULT(1) ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1077 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1078 | /** element-wise division/inversion with scaling: |
| RyoheiHagimoto | 0:0e0631af0305 | 1079 | dst(idx) = src1(idx) * scale / src2(idx) |
| RyoheiHagimoto | 0:0e0631af0305 | 1080 | or dst(idx) = scale / src2(idx) if src1 == 0 */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1081 | CVAPI(void) cvDiv( const CvArr* src1, const CvArr* src2, |
| RyoheiHagimoto | 0:0e0631af0305 | 1082 | CvArr* dst, double scale CV_DEFAULT(1)); |
| RyoheiHagimoto | 0:0e0631af0305 | 1083 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1084 | /** dst = src1 * scale + src2 */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1085 | CVAPI(void) cvScaleAdd( const CvArr* src1, CvScalar scale, |
| RyoheiHagimoto | 0:0e0631af0305 | 1086 | const CvArr* src2, CvArr* dst ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1087 | #define cvAXPY( A, real_scalar, B, C ) cvScaleAdd(A, cvRealScalar(real_scalar), B, C) |
| RyoheiHagimoto | 0:0e0631af0305 | 1088 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1089 | /** dst = src1 * alpha + src2 * beta + gamma */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1090 | CVAPI(void) cvAddWeighted( const CvArr* src1, double alpha, |
| RyoheiHagimoto | 0:0e0631af0305 | 1091 | const CvArr* src2, double beta, |
| RyoheiHagimoto | 0:0e0631af0305 | 1092 | double gamma, CvArr* dst ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1093 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1094 | /** @brief Calculates the dot product of two arrays in Euclidean metrics. |
| RyoheiHagimoto | 0:0e0631af0305 | 1095 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1096 | The function calculates and returns the Euclidean dot product of two arrays. |
| RyoheiHagimoto | 0:0e0631af0305 | 1097 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1098 | \f[src1 \bullet src2 = \sum _I ( \texttt{src1} (I) \texttt{src2} (I))\f] |
| RyoheiHagimoto | 0:0e0631af0305 | 1099 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1100 | In the case of multiple channel arrays, the results for all channels are accumulated. In particular, |
| RyoheiHagimoto | 0:0e0631af0305 | 1101 | cvDotProduct(a,a) where a is a complex vector, will return \f$||\texttt{a}||^2\f$. The function can |
| RyoheiHagimoto | 0:0e0631af0305 | 1102 | process multi-dimensional arrays, row by row, layer by layer, and so on. |
| RyoheiHagimoto | 0:0e0631af0305 | 1103 | @param src1 The first source array |
| RyoheiHagimoto | 0:0e0631af0305 | 1104 | @param src2 The second source array |
| RyoheiHagimoto | 0:0e0631af0305 | 1105 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1106 | CVAPI(double) cvDotProduct( const CvArr* src1, const CvArr* src2 ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1107 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1108 | /** dst(idx) = src1(idx) & src2(idx) */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1109 | CVAPI(void) cvAnd( const CvArr* src1, const CvArr* src2, |
| RyoheiHagimoto | 0:0e0631af0305 | 1110 | CvArr* dst, const CvArr* mask CV_DEFAULT(NULL)); |
| RyoheiHagimoto | 0:0e0631af0305 | 1111 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1112 | /** dst(idx) = src(idx) & value */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1113 | CVAPI(void) cvAndS( const CvArr* src, CvScalar value, |
| RyoheiHagimoto | 0:0e0631af0305 | 1114 | CvArr* dst, const CvArr* mask CV_DEFAULT(NULL)); |
| RyoheiHagimoto | 0:0e0631af0305 | 1115 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1116 | /** dst(idx) = src1(idx) | src2(idx) */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1117 | CVAPI(void) cvOr( const CvArr* src1, const CvArr* src2, |
| RyoheiHagimoto | 0:0e0631af0305 | 1118 | CvArr* dst, const CvArr* mask CV_DEFAULT(NULL)); |
| RyoheiHagimoto | 0:0e0631af0305 | 1119 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1120 | /** dst(idx) = src(idx) | value */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1121 | CVAPI(void) cvOrS( const CvArr* src, CvScalar value, |
| RyoheiHagimoto | 0:0e0631af0305 | 1122 | CvArr* dst, const CvArr* mask CV_DEFAULT(NULL)); |
| RyoheiHagimoto | 0:0e0631af0305 | 1123 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1124 | /** dst(idx) = src1(idx) ^ src2(idx) */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1125 | CVAPI(void) cvXor( const CvArr* src1, const CvArr* src2, |
| RyoheiHagimoto | 0:0e0631af0305 | 1126 | CvArr* dst, const CvArr* mask CV_DEFAULT(NULL)); |
| RyoheiHagimoto | 0:0e0631af0305 | 1127 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1128 | /** dst(idx) = src(idx) ^ value */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1129 | CVAPI(void) cvXorS( const CvArr* src, CvScalar value, |
| RyoheiHagimoto | 0:0e0631af0305 | 1130 | CvArr* dst, const CvArr* mask CV_DEFAULT(NULL)); |
| RyoheiHagimoto | 0:0e0631af0305 | 1131 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1132 | /** dst(idx) = ~src(idx) */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1133 | CVAPI(void) cvNot( const CvArr* src, CvArr* dst ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1134 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1135 | /** dst(idx) = lower(idx) <= src(idx) < upper(idx) */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1136 | CVAPI(void) cvInRange( const CvArr* src, const CvArr* lower, |
| RyoheiHagimoto | 0:0e0631af0305 | 1137 | const CvArr* upper, CvArr* dst ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1138 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1139 | /** dst(idx) = lower <= src(idx) < upper */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1140 | CVAPI(void) cvInRangeS( const CvArr* src, CvScalar lower, |
| RyoheiHagimoto | 0:0e0631af0305 | 1141 | CvScalar upper, CvArr* dst ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1142 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1143 | #define CV_CMP_EQ 0 |
| RyoheiHagimoto | 0:0e0631af0305 | 1144 | #define CV_CMP_GT 1 |
| RyoheiHagimoto | 0:0e0631af0305 | 1145 | #define CV_CMP_GE 2 |
| RyoheiHagimoto | 0:0e0631af0305 | 1146 | #define CV_CMP_LT 3 |
| RyoheiHagimoto | 0:0e0631af0305 | 1147 | #define CV_CMP_LE 4 |
| RyoheiHagimoto | 0:0e0631af0305 | 1148 | #define CV_CMP_NE 5 |
| RyoheiHagimoto | 0:0e0631af0305 | 1149 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1150 | /** The comparison operation support single-channel arrays only. |
| RyoheiHagimoto | 0:0e0631af0305 | 1151 | Destination image should be 8uC1 or 8sC1 */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1152 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1153 | /** dst(idx) = src1(idx) _cmp_op_ src2(idx) */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1154 | CVAPI(void) cvCmp( const CvArr* src1, const CvArr* src2, CvArr* dst, int cmp_op ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1155 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1156 | /** dst(idx) = src1(idx) _cmp_op_ value */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1157 | CVAPI(void) cvCmpS( const CvArr* src, double value, CvArr* dst, int cmp_op ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1158 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1159 | /** dst(idx) = min(src1(idx),src2(idx)) */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1160 | CVAPI(void) cvMin( const CvArr* src1, const CvArr* src2, CvArr* dst ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1161 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1162 | /** dst(idx) = max(src1(idx),src2(idx)) */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1163 | CVAPI(void) cvMax( const CvArr* src1, const CvArr* src2, CvArr* dst ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1164 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1165 | /** dst(idx) = min(src(idx),value) */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1166 | CVAPI(void) cvMinS( const CvArr* src, double value, CvArr* dst ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1167 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1168 | /** dst(idx) = max(src(idx),value) */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1169 | CVAPI(void) cvMaxS( const CvArr* src, double value, CvArr* dst ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1170 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1171 | /** dst(x,y,c) = abs(src1(x,y,c) - src2(x,y,c)) */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1172 | CVAPI(void) cvAbsDiff( const CvArr* src1, const CvArr* src2, CvArr* dst ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1173 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1174 | /** dst(x,y,c) = abs(src(x,y,c) - value(c)) */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1175 | CVAPI(void) cvAbsDiffS( const CvArr* src, CvArr* dst, CvScalar value ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1176 | #define cvAbs( src, dst ) cvAbsDiffS( (src), (dst), cvScalarAll(0)) |
| RyoheiHagimoto | 0:0e0631af0305 | 1177 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1178 | /****************************************************************************************\ |
| RyoheiHagimoto | 0:0e0631af0305 | 1179 | * Math operations * |
| RyoheiHagimoto | 0:0e0631af0305 | 1180 | \****************************************************************************************/ |
| RyoheiHagimoto | 0:0e0631af0305 | 1181 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1182 | /** Does cartesian->polar coordinates conversion. |
| RyoheiHagimoto | 0:0e0631af0305 | 1183 | Either of output components (magnitude or angle) is optional */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1184 | CVAPI(void) cvCartToPolar( const CvArr* x, const CvArr* y, |
| RyoheiHagimoto | 0:0e0631af0305 | 1185 | CvArr* magnitude, CvArr* angle CV_DEFAULT(NULL), |
| RyoheiHagimoto | 0:0e0631af0305 | 1186 | int angle_in_degrees CV_DEFAULT(0)); |
| RyoheiHagimoto | 0:0e0631af0305 | 1187 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1188 | /** Does polar->cartesian coordinates conversion. |
| RyoheiHagimoto | 0:0e0631af0305 | 1189 | Either of output components (magnitude or angle) is optional. |
| RyoheiHagimoto | 0:0e0631af0305 | 1190 | If magnitude is missing it is assumed to be all 1's */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1191 | CVAPI(void) cvPolarToCart( const CvArr* magnitude, const CvArr* angle, |
| RyoheiHagimoto | 0:0e0631af0305 | 1192 | CvArr* x, CvArr* y, |
| RyoheiHagimoto | 0:0e0631af0305 | 1193 | int angle_in_degrees CV_DEFAULT(0)); |
| RyoheiHagimoto | 0:0e0631af0305 | 1194 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1195 | /** Does powering: dst(idx) = src(idx)^power */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1196 | CVAPI(void) cvPow( const CvArr* src, CvArr* dst, double power ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1197 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1198 | /** Does exponention: dst(idx) = exp(src(idx)). |
| RyoheiHagimoto | 0:0e0631af0305 | 1199 | Overflow is not handled yet. Underflow is handled. |
| RyoheiHagimoto | 0:0e0631af0305 | 1200 | Maximal relative error is ~7e-6 for single-precision input */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1201 | CVAPI(void) cvExp( const CvArr* src, CvArr* dst ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1202 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1203 | /** Calculates natural logarithms: dst(idx) = log(abs(src(idx))). |
| RyoheiHagimoto | 0:0e0631af0305 | 1204 | Logarithm of 0 gives large negative number(~-700) |
| RyoheiHagimoto | 0:0e0631af0305 | 1205 | Maximal relative error is ~3e-7 for single-precision output |
| RyoheiHagimoto | 0:0e0631af0305 | 1206 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1207 | CVAPI(void) cvLog( const CvArr* src, CvArr* dst ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1208 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1209 | /** Fast arctangent calculation */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1210 | CVAPI(float) cvFastArctan( float y, float x ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1211 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1212 | /** Fast cubic root calculation */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1213 | CVAPI(float) cvCbrt( float value ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1214 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1215 | #define CV_CHECK_RANGE 1 |
| RyoheiHagimoto | 0:0e0631af0305 | 1216 | #define CV_CHECK_QUIET 2 |
| RyoheiHagimoto | 0:0e0631af0305 | 1217 | /** Checks array values for NaNs, Infs or simply for too large numbers |
| RyoheiHagimoto | 0:0e0631af0305 | 1218 | (if CV_CHECK_RANGE is set). If CV_CHECK_QUIET is set, |
| RyoheiHagimoto | 0:0e0631af0305 | 1219 | no runtime errors is raised (function returns zero value in case of "bad" values). |
| RyoheiHagimoto | 0:0e0631af0305 | 1220 | Otherwise cvError is called */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1221 | CVAPI(int) cvCheckArr( const CvArr* arr, int flags CV_DEFAULT(0), |
| RyoheiHagimoto | 0:0e0631af0305 | 1222 | double min_val CV_DEFAULT(0), double max_val CV_DEFAULT(0)); |
| RyoheiHagimoto | 0:0e0631af0305 | 1223 | #define cvCheckArray cvCheckArr |
| RyoheiHagimoto | 0:0e0631af0305 | 1224 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1225 | #define CV_RAND_UNI 0 |
| RyoheiHagimoto | 0:0e0631af0305 | 1226 | #define CV_RAND_NORMAL 1 |
| RyoheiHagimoto | 0:0e0631af0305 | 1227 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1228 | /** @brief Fills an array with random numbers and updates the RNG state. |
| RyoheiHagimoto | 0:0e0631af0305 | 1229 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1230 | The function fills the destination array with uniformly or normally distributed random numbers. |
| RyoheiHagimoto | 0:0e0631af0305 | 1231 | @param rng CvRNG state initialized by cvRNG |
| RyoheiHagimoto | 0:0e0631af0305 | 1232 | @param arr The destination array |
| RyoheiHagimoto | 0:0e0631af0305 | 1233 | @param dist_type Distribution type |
| RyoheiHagimoto | 0:0e0631af0305 | 1234 | > - **CV_RAND_UNI** uniform distribution |
| RyoheiHagimoto | 0:0e0631af0305 | 1235 | > - **CV_RAND_NORMAL** normal or Gaussian distribution |
| RyoheiHagimoto | 0:0e0631af0305 | 1236 | @param param1 The first parameter of the distribution. In the case of a uniform distribution it is |
| RyoheiHagimoto | 0:0e0631af0305 | 1237 | the inclusive lower boundary of the random numbers range. In the case of a normal distribution it |
| RyoheiHagimoto | 0:0e0631af0305 | 1238 | is the mean value of the random numbers. |
| RyoheiHagimoto | 0:0e0631af0305 | 1239 | @param param2 The second parameter of the distribution. In the case of a uniform distribution it |
| RyoheiHagimoto | 0:0e0631af0305 | 1240 | is the exclusive upper boundary of the random numbers range. In the case of a normal distribution |
| RyoheiHagimoto | 0:0e0631af0305 | 1241 | it is the standard deviation of the random numbers. |
| RyoheiHagimoto | 0:0e0631af0305 | 1242 | @sa randu, randn, RNG::fill. |
| RyoheiHagimoto | 0:0e0631af0305 | 1243 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1244 | CVAPI(void) cvRandArr( CvRNG* rng, CvArr* arr, int dist_type, |
| RyoheiHagimoto | 0:0e0631af0305 | 1245 | CvScalar param1, CvScalar param2 ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1246 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1247 | CVAPI(void) cvRandShuffle( CvArr* mat, CvRNG* rng, |
| RyoheiHagimoto | 0:0e0631af0305 | 1248 | double iter_factor CV_DEFAULT(1.)); |
| RyoheiHagimoto | 0:0e0631af0305 | 1249 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1250 | #define CV_SORT_EVERY_ROW 0 |
| RyoheiHagimoto | 0:0e0631af0305 | 1251 | #define CV_SORT_EVERY_COLUMN 1 |
| RyoheiHagimoto | 0:0e0631af0305 | 1252 | #define CV_SORT_ASCENDING 0 |
| RyoheiHagimoto | 0:0e0631af0305 | 1253 | #define CV_SORT_DESCENDING 16 |
| RyoheiHagimoto | 0:0e0631af0305 | 1254 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1255 | CVAPI(void) cvSort( const CvArr* src, CvArr* dst CV_DEFAULT(NULL), |
| RyoheiHagimoto | 0:0e0631af0305 | 1256 | CvArr* idxmat CV_DEFAULT(NULL), |
| RyoheiHagimoto | 0:0e0631af0305 | 1257 | int flags CV_DEFAULT(0)); |
| RyoheiHagimoto | 0:0e0631af0305 | 1258 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1259 | /** Finds real roots of a cubic equation */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1260 | CVAPI(int) cvSolveCubic( const CvMat* coeffs, CvMat* roots ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1261 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1262 | /** Finds all real and complex roots of a polynomial equation */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1263 | CVAPI(void) cvSolvePoly(const CvMat* coeffs, CvMat *roots2, |
| RyoheiHagimoto | 0:0e0631af0305 | 1264 | int maxiter CV_DEFAULT(20), int fig CV_DEFAULT(100)); |
| RyoheiHagimoto | 0:0e0631af0305 | 1265 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1266 | /****************************************************************************************\ |
| RyoheiHagimoto | 0:0e0631af0305 | 1267 | * Matrix operations * |
| RyoheiHagimoto | 0:0e0631af0305 | 1268 | \****************************************************************************************/ |
| RyoheiHagimoto | 0:0e0631af0305 | 1269 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1270 | /** @brief Calculates the cross product of two 3D vectors. |
| RyoheiHagimoto | 0:0e0631af0305 | 1271 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1272 | The function calculates the cross product of two 3D vectors: |
| RyoheiHagimoto | 0:0e0631af0305 | 1273 | \f[\texttt{dst} = \texttt{src1} \times \texttt{src2}\f] |
| RyoheiHagimoto | 0:0e0631af0305 | 1274 | or: |
| RyoheiHagimoto | 0:0e0631af0305 | 1275 | \f[\begin{array}{l} \texttt{dst} _1 = \texttt{src1} _2 \texttt{src2} _3 - \texttt{src1} _3 \texttt{src2} _2 \\ \texttt{dst} _2 = \texttt{src1} _3 \texttt{src2} _1 - \texttt{src1} _1 \texttt{src2} _3 \\ \texttt{dst} _3 = \texttt{src1} _1 \texttt{src2} _2 - \texttt{src1} _2 \texttt{src2} _1 \end{array}\f] |
| RyoheiHagimoto | 0:0e0631af0305 | 1276 | @param src1 The first source vector |
| RyoheiHagimoto | 0:0e0631af0305 | 1277 | @param src2 The second source vector |
| RyoheiHagimoto | 0:0e0631af0305 | 1278 | @param dst The destination vector |
| RyoheiHagimoto | 0:0e0631af0305 | 1279 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1280 | CVAPI(void) cvCrossProduct( const CvArr* src1, const CvArr* src2, CvArr* dst ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1281 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1282 | /** Matrix transform: dst = A*B + C, C is optional */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1283 | #define cvMatMulAdd( src1, src2, src3, dst ) cvGEMM( (src1), (src2), 1., (src3), 1., (dst), 0 ) |
| RyoheiHagimoto | 0:0e0631af0305 | 1284 | #define cvMatMul( src1, src2, dst ) cvMatMulAdd( (src1), (src2), NULL, (dst)) |
| RyoheiHagimoto | 0:0e0631af0305 | 1285 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1286 | #define CV_GEMM_A_T 1 |
| RyoheiHagimoto | 0:0e0631af0305 | 1287 | #define CV_GEMM_B_T 2 |
| RyoheiHagimoto | 0:0e0631af0305 | 1288 | #define CV_GEMM_C_T 4 |
| RyoheiHagimoto | 0:0e0631af0305 | 1289 | /** Extended matrix transform: |
| RyoheiHagimoto | 0:0e0631af0305 | 1290 | dst = alpha*op(A)*op(B) + beta*op(C), where op(X) is X or X^T */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1291 | CVAPI(void) cvGEMM( const CvArr* src1, const CvArr* src2, double alpha, |
| RyoheiHagimoto | 0:0e0631af0305 | 1292 | const CvArr* src3, double beta, CvArr* dst, |
| RyoheiHagimoto | 0:0e0631af0305 | 1293 | int tABC CV_DEFAULT(0)); |
| RyoheiHagimoto | 0:0e0631af0305 | 1294 | #define cvMatMulAddEx cvGEMM |
| RyoheiHagimoto | 0:0e0631af0305 | 1295 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1296 | /** Transforms each element of source array and stores |
| RyoheiHagimoto | 0:0e0631af0305 | 1297 | resultant vectors in destination array */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1298 | CVAPI(void) cvTransform( const CvArr* src, CvArr* dst, |
| RyoheiHagimoto | 0:0e0631af0305 | 1299 | const CvMat* transmat, |
| RyoheiHagimoto | 0:0e0631af0305 | 1300 | const CvMat* shiftvec CV_DEFAULT(NULL)); |
| RyoheiHagimoto | 0:0e0631af0305 | 1301 | #define cvMatMulAddS cvTransform |
| RyoheiHagimoto | 0:0e0631af0305 | 1302 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1303 | /** Does perspective transform on every element of input array */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1304 | CVAPI(void) cvPerspectiveTransform( const CvArr* src, CvArr* dst, |
| RyoheiHagimoto | 0:0e0631af0305 | 1305 | const CvMat* mat ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1306 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1307 | /** Calculates (A-delta)*(A-delta)^T (order=0) or (A-delta)^T*(A-delta) (order=1) */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1308 | CVAPI(void) cvMulTransposed( const CvArr* src, CvArr* dst, int order, |
| RyoheiHagimoto | 0:0e0631af0305 | 1309 | const CvArr* delta CV_DEFAULT(NULL), |
| RyoheiHagimoto | 0:0e0631af0305 | 1310 | double scale CV_DEFAULT(1.) ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1311 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1312 | /** Tranposes matrix. Square matrices can be transposed in-place */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1313 | CVAPI(void) cvTranspose( const CvArr* src, CvArr* dst ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1314 | #define cvT cvTranspose |
| RyoheiHagimoto | 0:0e0631af0305 | 1315 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1316 | /** Completes the symmetric matrix from the lower (LtoR=0) or from the upper (LtoR!=0) part */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1317 | CVAPI(void) cvCompleteSymm( CvMat* matrix, int LtoR CV_DEFAULT(0) ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1318 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1319 | /** Mirror array data around horizontal (flip=0), |
| RyoheiHagimoto | 0:0e0631af0305 | 1320 | vertical (flip=1) or both(flip=-1) axises: |
| RyoheiHagimoto | 0:0e0631af0305 | 1321 | cvFlip(src) flips images vertically and sequences horizontally (inplace) */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1322 | CVAPI(void) cvFlip( const CvArr* src, CvArr* dst CV_DEFAULT(NULL), |
| RyoheiHagimoto | 0:0e0631af0305 | 1323 | int flip_mode CV_DEFAULT(0)); |
| RyoheiHagimoto | 0:0e0631af0305 | 1324 | #define cvMirror cvFlip |
| RyoheiHagimoto | 0:0e0631af0305 | 1325 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1326 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1327 | #define CV_SVD_MODIFY_A 1 |
| RyoheiHagimoto | 0:0e0631af0305 | 1328 | #define CV_SVD_U_T 2 |
| RyoheiHagimoto | 0:0e0631af0305 | 1329 | #define CV_SVD_V_T 4 |
| RyoheiHagimoto | 0:0e0631af0305 | 1330 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1331 | /** Performs Singular Value Decomposition of a matrix */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1332 | CVAPI(void) cvSVD( CvArr* A, CvArr* W, CvArr* U CV_DEFAULT(NULL), |
| RyoheiHagimoto | 0:0e0631af0305 | 1333 | CvArr* V CV_DEFAULT(NULL), int flags CV_DEFAULT(0)); |
| RyoheiHagimoto | 0:0e0631af0305 | 1334 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1335 | /** Performs Singular Value Back Substitution (solves A*X = B): |
| RyoheiHagimoto | 0:0e0631af0305 | 1336 | flags must be the same as in cvSVD */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1337 | CVAPI(void) cvSVBkSb( const CvArr* W, const CvArr* U, |
| RyoheiHagimoto | 0:0e0631af0305 | 1338 | const CvArr* V, const CvArr* B, |
| RyoheiHagimoto | 0:0e0631af0305 | 1339 | CvArr* X, int flags ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1340 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1341 | #define CV_LU 0 |
| RyoheiHagimoto | 0:0e0631af0305 | 1342 | #define CV_SVD 1 |
| RyoheiHagimoto | 0:0e0631af0305 | 1343 | #define CV_SVD_SYM 2 |
| RyoheiHagimoto | 0:0e0631af0305 | 1344 | #define CV_CHOLESKY 3 |
| RyoheiHagimoto | 0:0e0631af0305 | 1345 | #define CV_QR 4 |
| RyoheiHagimoto | 0:0e0631af0305 | 1346 | #define CV_NORMAL 16 |
| RyoheiHagimoto | 0:0e0631af0305 | 1347 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1348 | /** Inverts matrix */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1349 | CVAPI(double) cvInvert( const CvArr* src, CvArr* dst, |
| RyoheiHagimoto | 0:0e0631af0305 | 1350 | int method CV_DEFAULT(CV_LU)); |
| RyoheiHagimoto | 0:0e0631af0305 | 1351 | #define cvInv cvInvert |
| RyoheiHagimoto | 0:0e0631af0305 | 1352 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1353 | /** Solves linear system (src1)*(dst) = (src2) |
| RyoheiHagimoto | 0:0e0631af0305 | 1354 | (returns 0 if src1 is a singular and CV_LU method is used) */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1355 | CVAPI(int) cvSolve( const CvArr* src1, const CvArr* src2, CvArr* dst, |
| RyoheiHagimoto | 0:0e0631af0305 | 1356 | int method CV_DEFAULT(CV_LU)); |
| RyoheiHagimoto | 0:0e0631af0305 | 1357 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1358 | /** Calculates determinant of input matrix */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1359 | CVAPI(double) cvDet( const CvArr* mat ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1360 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1361 | /** Calculates trace of the matrix (sum of elements on the main diagonal) */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1362 | CVAPI(CvScalar) cvTrace( const CvArr* mat ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1363 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1364 | /** Finds eigen values and vectors of a symmetric matrix */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1365 | CVAPI(void) cvEigenVV( CvArr* mat, CvArr* evects, CvArr* evals, |
| RyoheiHagimoto | 0:0e0631af0305 | 1366 | double eps CV_DEFAULT(0), |
| RyoheiHagimoto | 0:0e0631af0305 | 1367 | int lowindex CV_DEFAULT(-1), |
| RyoheiHagimoto | 0:0e0631af0305 | 1368 | int highindex CV_DEFAULT(-1)); |
| RyoheiHagimoto | 0:0e0631af0305 | 1369 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1370 | ///* Finds selected eigen values and vectors of a symmetric matrix */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1371 | //CVAPI(void) cvSelectedEigenVV( CvArr* mat, CvArr* evects, CvArr* evals, |
| RyoheiHagimoto | 0:0e0631af0305 | 1372 | // int lowindex, int highindex ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1373 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1374 | /** Makes an identity matrix (mat_ij = i == j) */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1375 | CVAPI(void) cvSetIdentity( CvArr* mat, CvScalar value CV_DEFAULT(cvRealScalar(1)) ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1376 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1377 | /** Fills matrix with given range of numbers */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1378 | CVAPI(CvArr*) cvRange( CvArr* mat, double start, double end ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1379 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1380 | /** @anchor core_c_CovarFlags |
| RyoheiHagimoto | 0:0e0631af0305 | 1381 | @name Flags for cvCalcCovarMatrix |
| RyoheiHagimoto | 0:0e0631af0305 | 1382 | @see cvCalcCovarMatrix |
| RyoheiHagimoto | 0:0e0631af0305 | 1383 | @{ |
| RyoheiHagimoto | 0:0e0631af0305 | 1384 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1385 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1386 | /** flag for cvCalcCovarMatrix, transpose([v1-avg, v2-avg,...]) * [v1-avg,v2-avg,...] */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1387 | #define CV_COVAR_SCRAMBLED 0 |
| RyoheiHagimoto | 0:0e0631af0305 | 1388 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1389 | /** flag for cvCalcCovarMatrix, [v1-avg, v2-avg,...] * transpose([v1-avg,v2-avg,...]) */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1390 | #define CV_COVAR_NORMAL 1 |
| RyoheiHagimoto | 0:0e0631af0305 | 1391 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1392 | /** flag for cvCalcCovarMatrix, do not calc average (i.e. mean vector) - use the input vector instead |
| RyoheiHagimoto | 0:0e0631af0305 | 1393 | (useful for calculating covariance matrix by parts) */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1394 | #define CV_COVAR_USE_AVG 2 |
| RyoheiHagimoto | 0:0e0631af0305 | 1395 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1396 | /** flag for cvCalcCovarMatrix, scale the covariance matrix coefficients by number of the vectors */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1397 | #define CV_COVAR_SCALE 4 |
| RyoheiHagimoto | 0:0e0631af0305 | 1398 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1399 | /** flag for cvCalcCovarMatrix, all the input vectors are stored in a single matrix, as its rows */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1400 | #define CV_COVAR_ROWS 8 |
| RyoheiHagimoto | 0:0e0631af0305 | 1401 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1402 | /** flag for cvCalcCovarMatrix, all the input vectors are stored in a single matrix, as its columns */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1403 | #define CV_COVAR_COLS 16 |
| RyoheiHagimoto | 0:0e0631af0305 | 1404 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1405 | /** @} */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1406 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1407 | /** Calculates covariation matrix for a set of vectors |
| RyoheiHagimoto | 0:0e0631af0305 | 1408 | @see @ref core_c_CovarFlags "flags" |
| RyoheiHagimoto | 0:0e0631af0305 | 1409 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1410 | CVAPI(void) cvCalcCovarMatrix( const CvArr** vects, int count, |
| RyoheiHagimoto | 0:0e0631af0305 | 1411 | CvArr* cov_mat, CvArr* avg, int flags ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1412 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1413 | #define CV_PCA_DATA_AS_ROW 0 |
| RyoheiHagimoto | 0:0e0631af0305 | 1414 | #define CV_PCA_DATA_AS_COL 1 |
| RyoheiHagimoto | 0:0e0631af0305 | 1415 | #define CV_PCA_USE_AVG 2 |
| RyoheiHagimoto | 0:0e0631af0305 | 1416 | CVAPI(void) cvCalcPCA( const CvArr* data, CvArr* mean, |
| RyoheiHagimoto | 0:0e0631af0305 | 1417 | CvArr* eigenvals, CvArr* eigenvects, int flags ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1418 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1419 | CVAPI(void) cvProjectPCA( const CvArr* data, const CvArr* mean, |
| RyoheiHagimoto | 0:0e0631af0305 | 1420 | const CvArr* eigenvects, CvArr* result ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1421 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1422 | CVAPI(void) cvBackProjectPCA( const CvArr* proj, const CvArr* mean, |
| RyoheiHagimoto | 0:0e0631af0305 | 1423 | const CvArr* eigenvects, CvArr* result ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1424 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1425 | /** Calculates Mahalanobis(weighted) distance */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1426 | CVAPI(double) cvMahalanobis( const CvArr* vec1, const CvArr* vec2, const CvArr* mat ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1427 | #define cvMahalonobis cvMahalanobis |
| RyoheiHagimoto | 0:0e0631af0305 | 1428 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1429 | /****************************************************************************************\ |
| RyoheiHagimoto | 0:0e0631af0305 | 1430 | * Array Statistics * |
| RyoheiHagimoto | 0:0e0631af0305 | 1431 | \****************************************************************************************/ |
| RyoheiHagimoto | 0:0e0631af0305 | 1432 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1433 | /** Finds sum of array elements */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1434 | CVAPI(CvScalar) cvSum( const CvArr* arr ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1435 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1436 | /** Calculates number of non-zero pixels */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1437 | CVAPI(int) cvCountNonZero( const CvArr* arr ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1438 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1439 | /** Calculates mean value of array elements */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1440 | CVAPI(CvScalar) cvAvg( const CvArr* arr, const CvArr* mask CV_DEFAULT(NULL) ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1441 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1442 | /** Calculates mean and standard deviation of pixel values */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1443 | CVAPI(void) cvAvgSdv( const CvArr* arr, CvScalar* mean, CvScalar* std_dev, |
| RyoheiHagimoto | 0:0e0631af0305 | 1444 | const CvArr* mask CV_DEFAULT(NULL) ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1445 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1446 | /** Finds global minimum, maximum and their positions */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1447 | CVAPI(void) cvMinMaxLoc( const CvArr* arr, double* min_val, double* max_val, |
| RyoheiHagimoto | 0:0e0631af0305 | 1448 | CvPoint* min_loc CV_DEFAULT(NULL), |
| RyoheiHagimoto | 0:0e0631af0305 | 1449 | CvPoint* max_loc CV_DEFAULT(NULL), |
| RyoheiHagimoto | 0:0e0631af0305 | 1450 | const CvArr* mask CV_DEFAULT(NULL) ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1451 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1452 | /** @anchor core_c_NormFlags |
| RyoheiHagimoto | 0:0e0631af0305 | 1453 | @name Flags for cvNorm and cvNormalize |
| RyoheiHagimoto | 0:0e0631af0305 | 1454 | @{ |
| RyoheiHagimoto | 0:0e0631af0305 | 1455 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1456 | #define CV_C 1 |
| RyoheiHagimoto | 0:0e0631af0305 | 1457 | #define CV_L1 2 |
| RyoheiHagimoto | 0:0e0631af0305 | 1458 | #define CV_L2 4 |
| RyoheiHagimoto | 0:0e0631af0305 | 1459 | #define CV_NORM_MASK 7 |
| RyoheiHagimoto | 0:0e0631af0305 | 1460 | #define CV_RELATIVE 8 |
| RyoheiHagimoto | 0:0e0631af0305 | 1461 | #define CV_DIFF 16 |
| RyoheiHagimoto | 0:0e0631af0305 | 1462 | #define CV_MINMAX 32 |
| RyoheiHagimoto | 0:0e0631af0305 | 1463 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1464 | #define CV_DIFF_C (CV_DIFF | CV_C) |
| RyoheiHagimoto | 0:0e0631af0305 | 1465 | #define CV_DIFF_L1 (CV_DIFF | CV_L1) |
| RyoheiHagimoto | 0:0e0631af0305 | 1466 | #define CV_DIFF_L2 (CV_DIFF | CV_L2) |
| RyoheiHagimoto | 0:0e0631af0305 | 1467 | #define CV_RELATIVE_C (CV_RELATIVE | CV_C) |
| RyoheiHagimoto | 0:0e0631af0305 | 1468 | #define CV_RELATIVE_L1 (CV_RELATIVE | CV_L1) |
| RyoheiHagimoto | 0:0e0631af0305 | 1469 | #define CV_RELATIVE_L2 (CV_RELATIVE | CV_L2) |
| RyoheiHagimoto | 0:0e0631af0305 | 1470 | /** @} */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1471 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1472 | /** Finds norm, difference norm or relative difference norm for an array (or two arrays) |
| RyoheiHagimoto | 0:0e0631af0305 | 1473 | @see ref core_c_NormFlags "flags" |
| RyoheiHagimoto | 0:0e0631af0305 | 1474 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1475 | CVAPI(double) cvNorm( const CvArr* arr1, const CvArr* arr2 CV_DEFAULT(NULL), |
| RyoheiHagimoto | 0:0e0631af0305 | 1476 | int norm_type CV_DEFAULT(CV_L2), |
| RyoheiHagimoto | 0:0e0631af0305 | 1477 | const CvArr* mask CV_DEFAULT(NULL) ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1478 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1479 | /** @see ref core_c_NormFlags "flags" */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1480 | CVAPI(void) cvNormalize( const CvArr* src, CvArr* dst, |
| RyoheiHagimoto | 0:0e0631af0305 | 1481 | double a CV_DEFAULT(1.), double b CV_DEFAULT(0.), |
| RyoheiHagimoto | 0:0e0631af0305 | 1482 | int norm_type CV_DEFAULT(CV_L2), |
| RyoheiHagimoto | 0:0e0631af0305 | 1483 | const CvArr* mask CV_DEFAULT(NULL) ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1484 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1485 | /** @anchor core_c_ReduceFlags |
| RyoheiHagimoto | 0:0e0631af0305 | 1486 | @name Flags for cvReduce |
| RyoheiHagimoto | 0:0e0631af0305 | 1487 | @{ |
| RyoheiHagimoto | 0:0e0631af0305 | 1488 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1489 | #define CV_REDUCE_SUM 0 |
| RyoheiHagimoto | 0:0e0631af0305 | 1490 | #define CV_REDUCE_AVG 1 |
| RyoheiHagimoto | 0:0e0631af0305 | 1491 | #define CV_REDUCE_MAX 2 |
| RyoheiHagimoto | 0:0e0631af0305 | 1492 | #define CV_REDUCE_MIN 3 |
| RyoheiHagimoto | 0:0e0631af0305 | 1493 | /** @} */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1494 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1495 | /** @see @ref core_c_ReduceFlags "flags" */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1496 | CVAPI(void) cvReduce( const CvArr* src, CvArr* dst, int dim CV_DEFAULT(-1), |
| RyoheiHagimoto | 0:0e0631af0305 | 1497 | int op CV_DEFAULT(CV_REDUCE_SUM) ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1498 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1499 | /****************************************************************************************\ |
| RyoheiHagimoto | 0:0e0631af0305 | 1500 | * Discrete Linear Transforms and Related Functions * |
| RyoheiHagimoto | 0:0e0631af0305 | 1501 | \****************************************************************************************/ |
| RyoheiHagimoto | 0:0e0631af0305 | 1502 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1503 | /** @anchor core_c_DftFlags |
| RyoheiHagimoto | 0:0e0631af0305 | 1504 | @name Flags for cvDFT, cvDCT and cvMulSpectrums |
| RyoheiHagimoto | 0:0e0631af0305 | 1505 | @{ |
| RyoheiHagimoto | 0:0e0631af0305 | 1506 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1507 | #define CV_DXT_FORWARD 0 |
| RyoheiHagimoto | 0:0e0631af0305 | 1508 | #define CV_DXT_INVERSE 1 |
| RyoheiHagimoto | 0:0e0631af0305 | 1509 | #define CV_DXT_SCALE 2 /**< divide result by size of array */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1510 | #define CV_DXT_INV_SCALE (CV_DXT_INVERSE + CV_DXT_SCALE) |
| RyoheiHagimoto | 0:0e0631af0305 | 1511 | #define CV_DXT_INVERSE_SCALE CV_DXT_INV_SCALE |
| RyoheiHagimoto | 0:0e0631af0305 | 1512 | #define CV_DXT_ROWS 4 /**< transform each row individually */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1513 | #define CV_DXT_MUL_CONJ 8 /**< conjugate the second argument of cvMulSpectrums */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1514 | /** @} */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1515 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1516 | /** Discrete Fourier Transform: |
| RyoheiHagimoto | 0:0e0631af0305 | 1517 | complex->complex, |
| RyoheiHagimoto | 0:0e0631af0305 | 1518 | real->ccs (forward), |
| RyoheiHagimoto | 0:0e0631af0305 | 1519 | ccs->real (inverse) |
| RyoheiHagimoto | 0:0e0631af0305 | 1520 | @see core_c_DftFlags "flags" |
| RyoheiHagimoto | 0:0e0631af0305 | 1521 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1522 | CVAPI(void) cvDFT( const CvArr* src, CvArr* dst, int flags, |
| RyoheiHagimoto | 0:0e0631af0305 | 1523 | int nonzero_rows CV_DEFAULT(0) ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1524 | #define cvFFT cvDFT |
| RyoheiHagimoto | 0:0e0631af0305 | 1525 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1526 | /** Multiply results of DFTs: DFT(X)*DFT(Y) or DFT(X)*conj(DFT(Y)) |
| RyoheiHagimoto | 0:0e0631af0305 | 1527 | @see core_c_DftFlags "flags" |
| RyoheiHagimoto | 0:0e0631af0305 | 1528 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1529 | CVAPI(void) cvMulSpectrums( const CvArr* src1, const CvArr* src2, |
| RyoheiHagimoto | 0:0e0631af0305 | 1530 | CvArr* dst, int flags ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1531 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1532 | /** Finds optimal DFT vector size >= size0 */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1533 | CVAPI(int) cvGetOptimalDFTSize( int size0 ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1534 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1535 | /** Discrete Cosine Transform |
| RyoheiHagimoto | 0:0e0631af0305 | 1536 | @see core_c_DftFlags "flags" |
| RyoheiHagimoto | 0:0e0631af0305 | 1537 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1538 | CVAPI(void) cvDCT( const CvArr* src, CvArr* dst, int flags ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1539 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1540 | /****************************************************************************************\ |
| RyoheiHagimoto | 0:0e0631af0305 | 1541 | * Dynamic data structures * |
| RyoheiHagimoto | 0:0e0631af0305 | 1542 | \****************************************************************************************/ |
| RyoheiHagimoto | 0:0e0631af0305 | 1543 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1544 | /** Calculates length of sequence slice (with support of negative indices). */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1545 | CVAPI(int) cvSliceLength( CvSlice slice, const CvSeq* seq ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1546 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1547 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1548 | /** Creates new memory storage. |
| RyoheiHagimoto | 0:0e0631af0305 | 1549 | block_size == 0 means that default, |
| RyoheiHagimoto | 0:0e0631af0305 | 1550 | somewhat optimal size, is used (currently, it is 64K) */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1551 | CVAPI(CvMemStorage*) cvCreateMemStorage( int block_size CV_DEFAULT(0)); |
| RyoheiHagimoto | 0:0e0631af0305 | 1552 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1553 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1554 | /** Creates a memory storage that will borrow memory blocks from parent storage */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1555 | CVAPI(CvMemStorage*) cvCreateChildMemStorage( CvMemStorage* parent ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1556 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1557 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1558 | /** Releases memory storage. All the children of a parent must be released before |
| RyoheiHagimoto | 0:0e0631af0305 | 1559 | the parent. A child storage returns all the blocks to parent when it is released */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1560 | CVAPI(void) cvReleaseMemStorage( CvMemStorage** storage ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1561 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1562 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1563 | /** Clears memory storage. This is the only way(!!!) (besides cvRestoreMemStoragePos) |
| RyoheiHagimoto | 0:0e0631af0305 | 1564 | to reuse memory allocated for the storage - cvClearSeq,cvClearSet ... |
| RyoheiHagimoto | 0:0e0631af0305 | 1565 | do not free any memory. |
| RyoheiHagimoto | 0:0e0631af0305 | 1566 | A child storage returns all the blocks to the parent when it is cleared */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1567 | CVAPI(void) cvClearMemStorage( CvMemStorage* storage ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1568 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1569 | /** Remember a storage "free memory" position */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1570 | CVAPI(void) cvSaveMemStoragePos( const CvMemStorage* storage, CvMemStoragePos* pos ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1571 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1572 | /** Restore a storage "free memory" position */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1573 | CVAPI(void) cvRestoreMemStoragePos( CvMemStorage* storage, CvMemStoragePos* pos ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1574 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1575 | /** Allocates continuous buffer of the specified size in the storage */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1576 | CVAPI(void*) cvMemStorageAlloc( CvMemStorage* storage, size_t size ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1577 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1578 | /** Allocates string in memory storage */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1579 | CVAPI(CvString) cvMemStorageAllocString( CvMemStorage* storage, const char* ptr, |
| RyoheiHagimoto | 0:0e0631af0305 | 1580 | int len CV_DEFAULT(-1) ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1581 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1582 | /** Creates new empty sequence that will reside in the specified storage */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1583 | CVAPI(CvSeq*) cvCreateSeq( int seq_flags, size_t header_size, |
| RyoheiHagimoto | 0:0e0631af0305 | 1584 | size_t elem_size, CvMemStorage* storage ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1585 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1586 | /** Changes default size (granularity) of sequence blocks. |
| RyoheiHagimoto | 0:0e0631af0305 | 1587 | The default size is ~1Kbyte */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1588 | CVAPI(void) cvSetSeqBlockSize( CvSeq* seq, int delta_elems ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1589 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1590 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1591 | /** Adds new element to the end of sequence. Returns pointer to the element */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1592 | CVAPI(schar*) cvSeqPush( CvSeq* seq, const void* element CV_DEFAULT(NULL)); |
| RyoheiHagimoto | 0:0e0631af0305 | 1593 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1594 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1595 | /** Adds new element to the beginning of sequence. Returns pointer to it */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1596 | CVAPI(schar*) cvSeqPushFront( CvSeq* seq, const void* element CV_DEFAULT(NULL)); |
| RyoheiHagimoto | 0:0e0631af0305 | 1597 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1598 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1599 | /** Removes the last element from sequence and optionally saves it */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1600 | CVAPI(void) cvSeqPop( CvSeq* seq, void* element CV_DEFAULT(NULL)); |
| RyoheiHagimoto | 0:0e0631af0305 | 1601 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1602 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1603 | /** Removes the first element from sequence and optioanally saves it */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1604 | CVAPI(void) cvSeqPopFront( CvSeq* seq, void* element CV_DEFAULT(NULL)); |
| RyoheiHagimoto | 0:0e0631af0305 | 1605 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1606 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1607 | #define CV_FRONT 1 |
| RyoheiHagimoto | 0:0e0631af0305 | 1608 | #define CV_BACK 0 |
| RyoheiHagimoto | 0:0e0631af0305 | 1609 | /** Adds several new elements to the end of sequence */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1610 | CVAPI(void) cvSeqPushMulti( CvSeq* seq, const void* elements, |
| RyoheiHagimoto | 0:0e0631af0305 | 1611 | int count, int in_front CV_DEFAULT(0) ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1612 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1613 | /** Removes several elements from the end of sequence and optionally saves them */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1614 | CVAPI(void) cvSeqPopMulti( CvSeq* seq, void* elements, |
| RyoheiHagimoto | 0:0e0631af0305 | 1615 | int count, int in_front CV_DEFAULT(0) ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1616 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1617 | /** Inserts a new element in the middle of sequence. |
| RyoheiHagimoto | 0:0e0631af0305 | 1618 | cvSeqInsert(seq,0,elem) == cvSeqPushFront(seq,elem) */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1619 | CVAPI(schar*) cvSeqInsert( CvSeq* seq, int before_index, |
| RyoheiHagimoto | 0:0e0631af0305 | 1620 | const void* element CV_DEFAULT(NULL)); |
| RyoheiHagimoto | 0:0e0631af0305 | 1621 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1622 | /** Removes specified sequence element */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1623 | CVAPI(void) cvSeqRemove( CvSeq* seq, int index ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1624 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1625 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1626 | /** Removes all the elements from the sequence. The freed memory |
| RyoheiHagimoto | 0:0e0631af0305 | 1627 | can be reused later only by the same sequence unless cvClearMemStorage |
| RyoheiHagimoto | 0:0e0631af0305 | 1628 | or cvRestoreMemStoragePos is called */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1629 | CVAPI(void) cvClearSeq( CvSeq* seq ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1630 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1631 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1632 | /** Retrieves pointer to specified sequence element. |
| RyoheiHagimoto | 0:0e0631af0305 | 1633 | Negative indices are supported and mean counting from the end |
| RyoheiHagimoto | 0:0e0631af0305 | 1634 | (e.g -1 means the last sequence element) */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1635 | CVAPI(schar*) cvGetSeqElem( const CvSeq* seq, int index ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1636 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1637 | /** Calculates index of the specified sequence element. |
| RyoheiHagimoto | 0:0e0631af0305 | 1638 | Returns -1 if element does not belong to the sequence */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1639 | CVAPI(int) cvSeqElemIdx( const CvSeq* seq, const void* element, |
| RyoheiHagimoto | 0:0e0631af0305 | 1640 | CvSeqBlock** block CV_DEFAULT(NULL) ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1641 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1642 | /** Initializes sequence writer. The new elements will be added to the end of sequence */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1643 | CVAPI(void) cvStartAppendToSeq( CvSeq* seq, CvSeqWriter* writer ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1644 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1645 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1646 | /** Combination of cvCreateSeq and cvStartAppendToSeq */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1647 | CVAPI(void) cvStartWriteSeq( int seq_flags, int header_size, |
| RyoheiHagimoto | 0:0e0631af0305 | 1648 | int elem_size, CvMemStorage* storage, |
| RyoheiHagimoto | 0:0e0631af0305 | 1649 | CvSeqWriter* writer ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1650 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1651 | /** Closes sequence writer, updates sequence header and returns pointer |
| RyoheiHagimoto | 0:0e0631af0305 | 1652 | to the resultant sequence |
| RyoheiHagimoto | 0:0e0631af0305 | 1653 | (which may be useful if the sequence was created using cvStartWriteSeq)) |
| RyoheiHagimoto | 0:0e0631af0305 | 1654 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1655 | CVAPI(CvSeq*) cvEndWriteSeq( CvSeqWriter* writer ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1656 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1657 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1658 | /** Updates sequence header. May be useful to get access to some of previously |
| RyoheiHagimoto | 0:0e0631af0305 | 1659 | written elements via cvGetSeqElem or sequence reader */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1660 | CVAPI(void) cvFlushSeqWriter( CvSeqWriter* writer ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1661 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1662 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1663 | /** Initializes sequence reader. |
| RyoheiHagimoto | 0:0e0631af0305 | 1664 | The sequence can be read in forward or backward direction */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1665 | CVAPI(void) cvStartReadSeq( const CvSeq* seq, CvSeqReader* reader, |
| RyoheiHagimoto | 0:0e0631af0305 | 1666 | int reverse CV_DEFAULT(0) ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1667 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1668 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1669 | /** Returns current sequence reader position (currently observed sequence element) */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1670 | CVAPI(int) cvGetSeqReaderPos( CvSeqReader* reader ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1671 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1672 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1673 | /** Changes sequence reader position. It may seek to an absolute or |
| RyoheiHagimoto | 0:0e0631af0305 | 1674 | to relative to the current position */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1675 | CVAPI(void) cvSetSeqReaderPos( CvSeqReader* reader, int index, |
| RyoheiHagimoto | 0:0e0631af0305 | 1676 | int is_relative CV_DEFAULT(0)); |
| RyoheiHagimoto | 0:0e0631af0305 | 1677 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1678 | /** Copies sequence content to a continuous piece of memory */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1679 | CVAPI(void*) cvCvtSeqToArray( const CvSeq* seq, void* elements, |
| RyoheiHagimoto | 0:0e0631af0305 | 1680 | CvSlice slice CV_DEFAULT(CV_WHOLE_SEQ) ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1681 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1682 | /** Creates sequence header for array. |
| RyoheiHagimoto | 0:0e0631af0305 | 1683 | After that all the operations on sequences that do not alter the content |
| RyoheiHagimoto | 0:0e0631af0305 | 1684 | can be applied to the resultant sequence */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1685 | CVAPI(CvSeq*) cvMakeSeqHeaderForArray( int seq_type, int header_size, |
| RyoheiHagimoto | 0:0e0631af0305 | 1686 | int elem_size, void* elements, int total, |
| RyoheiHagimoto | 0:0e0631af0305 | 1687 | CvSeq* seq, CvSeqBlock* block ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1688 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1689 | /** Extracts sequence slice (with or without copying sequence elements) */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1690 | CVAPI(CvSeq*) cvSeqSlice( const CvSeq* seq, CvSlice slice, |
| RyoheiHagimoto | 0:0e0631af0305 | 1691 | CvMemStorage* storage CV_DEFAULT(NULL), |
| RyoheiHagimoto | 0:0e0631af0305 | 1692 | int copy_data CV_DEFAULT(0)); |
| RyoheiHagimoto | 0:0e0631af0305 | 1693 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1694 | CV_INLINE CvSeq* cvCloneSeq( const CvSeq* seq, CvMemStorage* storage CV_DEFAULT(NULL)) |
| RyoheiHagimoto | 0:0e0631af0305 | 1695 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 1696 | return cvSeqSlice( seq, CV_WHOLE_SEQ, storage, 1 ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1697 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 1698 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1699 | /** Removes sequence slice */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1700 | CVAPI(void) cvSeqRemoveSlice( CvSeq* seq, CvSlice slice ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1701 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1702 | /** Inserts a sequence or array into another sequence */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1703 | CVAPI(void) cvSeqInsertSlice( CvSeq* seq, int before_index, const CvArr* from_arr ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1704 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1705 | /** a < b ? -1 : a > b ? 1 : 0 */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1706 | typedef int (CV_CDECL* CvCmpFunc)(const void* a, const void* b, void* userdata ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1707 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1708 | /** Sorts sequence in-place given element comparison function */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1709 | CVAPI(void) cvSeqSort( CvSeq* seq, CvCmpFunc func, void* userdata CV_DEFAULT(NULL) ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1710 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1711 | /** Finds element in a [sorted] sequence */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1712 | CVAPI(schar*) cvSeqSearch( CvSeq* seq, const void* elem, CvCmpFunc func, |
| RyoheiHagimoto | 0:0e0631af0305 | 1713 | int is_sorted, int* elem_idx, |
| RyoheiHagimoto | 0:0e0631af0305 | 1714 | void* userdata CV_DEFAULT(NULL) ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1715 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1716 | /** Reverses order of sequence elements in-place */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1717 | CVAPI(void) cvSeqInvert( CvSeq* seq ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1718 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1719 | /** Splits sequence into one or more equivalence classes using the specified criteria */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1720 | CVAPI(int) cvSeqPartition( const CvSeq* seq, CvMemStorage* storage, |
| RyoheiHagimoto | 0:0e0631af0305 | 1721 | CvSeq** labels, CvCmpFunc is_equal, void* userdata ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1722 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1723 | /************ Internal sequence functions ************/ |
| RyoheiHagimoto | 0:0e0631af0305 | 1724 | CVAPI(void) cvChangeSeqBlock( void* reader, int direction ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1725 | CVAPI(void) cvCreateSeqBlock( CvSeqWriter* writer ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1726 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1727 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1728 | /** Creates a new set */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1729 | CVAPI(CvSet*) cvCreateSet( int set_flags, int header_size, |
| RyoheiHagimoto | 0:0e0631af0305 | 1730 | int elem_size, CvMemStorage* storage ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1731 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1732 | /** Adds new element to the set and returns pointer to it */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1733 | CVAPI(int) cvSetAdd( CvSet* set_header, CvSetElem* elem CV_DEFAULT(NULL), |
| RyoheiHagimoto | 0:0e0631af0305 | 1734 | CvSetElem** inserted_elem CV_DEFAULT(NULL) ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1735 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1736 | /** Fast variant of cvSetAdd */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1737 | CV_INLINE CvSetElem* cvSetNew( CvSet* set_header ) |
| RyoheiHagimoto | 0:0e0631af0305 | 1738 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 1739 | CvSetElem* elem = set_header->free_elems; |
| RyoheiHagimoto | 0:0e0631af0305 | 1740 | if( elem ) |
| RyoheiHagimoto | 0:0e0631af0305 | 1741 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 1742 | set_header->free_elems = elem->next_free; |
| RyoheiHagimoto | 0:0e0631af0305 | 1743 | elem->flags = elem->flags & CV_SET_ELEM_IDX_MASK; |
| RyoheiHagimoto | 0:0e0631af0305 | 1744 | set_header->active_count++; |
| RyoheiHagimoto | 0:0e0631af0305 | 1745 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 1746 | else |
| RyoheiHagimoto | 0:0e0631af0305 | 1747 | cvSetAdd( set_header, NULL, &elem ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1748 | return elem; |
| RyoheiHagimoto | 0:0e0631af0305 | 1749 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 1750 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1751 | /** Removes set element given its pointer */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1752 | CV_INLINE void cvSetRemoveByPtr( CvSet* set_header, void* elem ) |
| RyoheiHagimoto | 0:0e0631af0305 | 1753 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 1754 | CvSetElem* _elem = (CvSetElem*)elem; |
| RyoheiHagimoto | 0:0e0631af0305 | 1755 | assert( _elem->flags >= 0 /*&& (elem->flags & CV_SET_ELEM_IDX_MASK) < set_header->total*/ ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1756 | _elem->next_free = set_header->free_elems; |
| RyoheiHagimoto | 0:0e0631af0305 | 1757 | _elem->flags = (_elem->flags & CV_SET_ELEM_IDX_MASK) | CV_SET_ELEM_FREE_FLAG; |
| RyoheiHagimoto | 0:0e0631af0305 | 1758 | set_header->free_elems = _elem; |
| RyoheiHagimoto | 0:0e0631af0305 | 1759 | set_header->active_count--; |
| RyoheiHagimoto | 0:0e0631af0305 | 1760 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 1761 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1762 | /** Removes element from the set by its index */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1763 | CVAPI(void) cvSetRemove( CvSet* set_header, int index ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1764 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1765 | /** Returns a set element by index. If the element doesn't belong to the set, |
| RyoheiHagimoto | 0:0e0631af0305 | 1766 | NULL is returned */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1767 | CV_INLINE CvSetElem* cvGetSetElem( const CvSet* set_header, int idx ) |
| RyoheiHagimoto | 0:0e0631af0305 | 1768 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 1769 | CvSetElem* elem = (CvSetElem*)(void *)cvGetSeqElem( (CvSeq*)set_header, idx ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1770 | return elem && CV_IS_SET_ELEM( elem ) ? elem : 0; |
| RyoheiHagimoto | 0:0e0631af0305 | 1771 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 1772 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1773 | /** Removes all the elements from the set */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1774 | CVAPI(void) cvClearSet( CvSet* set_header ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1775 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1776 | /** Creates new graph */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1777 | CVAPI(CvGraph*) cvCreateGraph( int graph_flags, int header_size, |
| RyoheiHagimoto | 0:0e0631af0305 | 1778 | int vtx_size, int edge_size, |
| RyoheiHagimoto | 0:0e0631af0305 | 1779 | CvMemStorage* storage ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1780 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1781 | /** Adds new vertex to the graph */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1782 | CVAPI(int) cvGraphAddVtx( CvGraph* graph, const CvGraphVtx* vtx CV_DEFAULT(NULL), |
| RyoheiHagimoto | 0:0e0631af0305 | 1783 | CvGraphVtx** inserted_vtx CV_DEFAULT(NULL) ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1784 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1785 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1786 | /** Removes vertex from the graph together with all incident edges */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1787 | CVAPI(int) cvGraphRemoveVtx( CvGraph* graph, int index ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1788 | CVAPI(int) cvGraphRemoveVtxByPtr( CvGraph* graph, CvGraphVtx* vtx ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1789 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1790 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1791 | /** Link two vertices specifed by indices or pointers if they |
| RyoheiHagimoto | 0:0e0631af0305 | 1792 | are not connected or return pointer to already existing edge |
| RyoheiHagimoto | 0:0e0631af0305 | 1793 | connecting the vertices. |
| RyoheiHagimoto | 0:0e0631af0305 | 1794 | Functions return 1 if a new edge was created, 0 otherwise */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1795 | CVAPI(int) cvGraphAddEdge( CvGraph* graph, |
| RyoheiHagimoto | 0:0e0631af0305 | 1796 | int start_idx, int end_idx, |
| RyoheiHagimoto | 0:0e0631af0305 | 1797 | const CvGraphEdge* edge CV_DEFAULT(NULL), |
| RyoheiHagimoto | 0:0e0631af0305 | 1798 | CvGraphEdge** inserted_edge CV_DEFAULT(NULL) ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1799 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1800 | CVAPI(int) cvGraphAddEdgeByPtr( CvGraph* graph, |
| RyoheiHagimoto | 0:0e0631af0305 | 1801 | CvGraphVtx* start_vtx, CvGraphVtx* end_vtx, |
| RyoheiHagimoto | 0:0e0631af0305 | 1802 | const CvGraphEdge* edge CV_DEFAULT(NULL), |
| RyoheiHagimoto | 0:0e0631af0305 | 1803 | CvGraphEdge** inserted_edge CV_DEFAULT(NULL) ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1804 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1805 | /** Remove edge connecting two vertices */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1806 | CVAPI(void) cvGraphRemoveEdge( CvGraph* graph, int start_idx, int end_idx ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1807 | CVAPI(void) cvGraphRemoveEdgeByPtr( CvGraph* graph, CvGraphVtx* start_vtx, |
| RyoheiHagimoto | 0:0e0631af0305 | 1808 | CvGraphVtx* end_vtx ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1809 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1810 | /** Find edge connecting two vertices */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1811 | CVAPI(CvGraphEdge*) cvFindGraphEdge( const CvGraph* graph, int start_idx, int end_idx ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1812 | CVAPI(CvGraphEdge*) cvFindGraphEdgeByPtr( const CvGraph* graph, |
| RyoheiHagimoto | 0:0e0631af0305 | 1813 | const CvGraphVtx* start_vtx, |
| RyoheiHagimoto | 0:0e0631af0305 | 1814 | const CvGraphVtx* end_vtx ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1815 | #define cvGraphFindEdge cvFindGraphEdge |
| RyoheiHagimoto | 0:0e0631af0305 | 1816 | #define cvGraphFindEdgeByPtr cvFindGraphEdgeByPtr |
| RyoheiHagimoto | 0:0e0631af0305 | 1817 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1818 | /** Remove all vertices and edges from the graph */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1819 | CVAPI(void) cvClearGraph( CvGraph* graph ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1820 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1821 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1822 | /** Count number of edges incident to the vertex */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1823 | CVAPI(int) cvGraphVtxDegree( const CvGraph* graph, int vtx_idx ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1824 | CVAPI(int) cvGraphVtxDegreeByPtr( const CvGraph* graph, const CvGraphVtx* vtx ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1825 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1826 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1827 | /** Retrieves graph vertex by given index */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1828 | #define cvGetGraphVtx( graph, idx ) (CvGraphVtx*)cvGetSetElem((CvSet*)(graph), (idx)) |
| RyoheiHagimoto | 0:0e0631af0305 | 1829 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1830 | /** Retrieves index of a graph vertex given its pointer */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1831 | #define cvGraphVtxIdx( graph, vtx ) ((vtx)->flags & CV_SET_ELEM_IDX_MASK) |
| RyoheiHagimoto | 0:0e0631af0305 | 1832 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1833 | /** Retrieves index of a graph edge given its pointer */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1834 | #define cvGraphEdgeIdx( graph, edge ) ((edge)->flags & CV_SET_ELEM_IDX_MASK) |
| RyoheiHagimoto | 0:0e0631af0305 | 1835 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1836 | #define cvGraphGetVtxCount( graph ) ((graph)->active_count) |
| RyoheiHagimoto | 0:0e0631af0305 | 1837 | #define cvGraphGetEdgeCount( graph ) ((graph)->edges->active_count) |
| RyoheiHagimoto | 0:0e0631af0305 | 1838 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1839 | #define CV_GRAPH_VERTEX 1 |
| RyoheiHagimoto | 0:0e0631af0305 | 1840 | #define CV_GRAPH_TREE_EDGE 2 |
| RyoheiHagimoto | 0:0e0631af0305 | 1841 | #define CV_GRAPH_BACK_EDGE 4 |
| RyoheiHagimoto | 0:0e0631af0305 | 1842 | #define CV_GRAPH_FORWARD_EDGE 8 |
| RyoheiHagimoto | 0:0e0631af0305 | 1843 | #define CV_GRAPH_CROSS_EDGE 16 |
| RyoheiHagimoto | 0:0e0631af0305 | 1844 | #define CV_GRAPH_ANY_EDGE 30 |
| RyoheiHagimoto | 0:0e0631af0305 | 1845 | #define CV_GRAPH_NEW_TREE 32 |
| RyoheiHagimoto | 0:0e0631af0305 | 1846 | #define CV_GRAPH_BACKTRACKING 64 |
| RyoheiHagimoto | 0:0e0631af0305 | 1847 | #define CV_GRAPH_OVER -1 |
| RyoheiHagimoto | 0:0e0631af0305 | 1848 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1849 | #define CV_GRAPH_ALL_ITEMS -1 |
| RyoheiHagimoto | 0:0e0631af0305 | 1850 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1851 | /** flags for graph vertices and edges */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1852 | #define CV_GRAPH_ITEM_VISITED_FLAG (1 << 30) |
| RyoheiHagimoto | 0:0e0631af0305 | 1853 | #define CV_IS_GRAPH_VERTEX_VISITED(vtx) \ |
| RyoheiHagimoto | 0:0e0631af0305 | 1854 | (((CvGraphVtx*)(vtx))->flags & CV_GRAPH_ITEM_VISITED_FLAG) |
| RyoheiHagimoto | 0:0e0631af0305 | 1855 | #define CV_IS_GRAPH_EDGE_VISITED(edge) \ |
| RyoheiHagimoto | 0:0e0631af0305 | 1856 | (((CvGraphEdge*)(edge))->flags & CV_GRAPH_ITEM_VISITED_FLAG) |
| RyoheiHagimoto | 0:0e0631af0305 | 1857 | #define CV_GRAPH_SEARCH_TREE_NODE_FLAG (1 << 29) |
| RyoheiHagimoto | 0:0e0631af0305 | 1858 | #define CV_GRAPH_FORWARD_EDGE_FLAG (1 << 28) |
| RyoheiHagimoto | 0:0e0631af0305 | 1859 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1860 | typedef struct CvGraphScanner |
| RyoheiHagimoto | 0:0e0631af0305 | 1861 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 1862 | CvGraphVtx* vtx; /* current graph vertex (or current edge origin) */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1863 | CvGraphVtx* dst; /* current graph edge destination vertex */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1864 | CvGraphEdge* edge; /* current edge */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1865 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1866 | CvGraph* graph; /* the graph */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1867 | CvSeq* stack; /* the graph vertex stack */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1868 | int index; /* the lower bound of certainly visited vertices */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1869 | int mask; /* event mask */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1870 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 1871 | CvGraphScanner; |
| RyoheiHagimoto | 0:0e0631af0305 | 1872 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1873 | /** Creates new graph scanner. */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1874 | CVAPI(CvGraphScanner*) cvCreateGraphScanner( CvGraph* graph, |
| RyoheiHagimoto | 0:0e0631af0305 | 1875 | CvGraphVtx* vtx CV_DEFAULT(NULL), |
| RyoheiHagimoto | 0:0e0631af0305 | 1876 | int mask CV_DEFAULT(CV_GRAPH_ALL_ITEMS)); |
| RyoheiHagimoto | 0:0e0631af0305 | 1877 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1878 | /** Releases graph scanner. */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1879 | CVAPI(void) cvReleaseGraphScanner( CvGraphScanner** scanner ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1880 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1881 | /** Get next graph element */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1882 | CVAPI(int) cvNextGraphItem( CvGraphScanner* scanner ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1883 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1884 | /** Creates a copy of graph */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1885 | CVAPI(CvGraph*) cvCloneGraph( const CvGraph* graph, CvMemStorage* storage ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1886 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1887 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1888 | /** Does look-up transformation. Elements of the source array |
| RyoheiHagimoto | 0:0e0631af0305 | 1889 | (that should be 8uC1 or 8sC1) are used as indexes in lutarr 256-element table */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1890 | CVAPI(void) cvLUT( const CvArr* src, CvArr* dst, const CvArr* lut ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1891 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1892 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1893 | /******************* Iteration through the sequence tree *****************/ |
| RyoheiHagimoto | 0:0e0631af0305 | 1894 | typedef struct CvTreeNodeIterator |
| RyoheiHagimoto | 0:0e0631af0305 | 1895 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 1896 | const void* node; |
| RyoheiHagimoto | 0:0e0631af0305 | 1897 | int level; |
| RyoheiHagimoto | 0:0e0631af0305 | 1898 | int max_level; |
| RyoheiHagimoto | 0:0e0631af0305 | 1899 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 1900 | CvTreeNodeIterator; |
| RyoheiHagimoto | 0:0e0631af0305 | 1901 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1902 | CVAPI(void) cvInitTreeNodeIterator( CvTreeNodeIterator* tree_iterator, |
| RyoheiHagimoto | 0:0e0631af0305 | 1903 | const void* first, int max_level ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1904 | CVAPI(void*) cvNextTreeNode( CvTreeNodeIterator* tree_iterator ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1905 | CVAPI(void*) cvPrevTreeNode( CvTreeNodeIterator* tree_iterator ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1906 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1907 | /** Inserts sequence into tree with specified "parent" sequence. |
| RyoheiHagimoto | 0:0e0631af0305 | 1908 | If parent is equal to frame (e.g. the most external contour), |
| RyoheiHagimoto | 0:0e0631af0305 | 1909 | then added contour will have null pointer to parent. */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1910 | CVAPI(void) cvInsertNodeIntoTree( void* node, void* parent, void* frame ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1911 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1912 | /** Removes contour from tree (together with the contour children). */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1913 | CVAPI(void) cvRemoveNodeFromTree( void* node, void* frame ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1914 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1915 | /** Gathers pointers to all the sequences, |
| RyoheiHagimoto | 0:0e0631af0305 | 1916 | accessible from the `first`, to the single sequence */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1917 | CVAPI(CvSeq*) cvTreeToNodeSeq( const void* first, int header_size, |
| RyoheiHagimoto | 0:0e0631af0305 | 1918 | CvMemStorage* storage ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1919 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1920 | /** The function implements the K-means algorithm for clustering an array of sample |
| RyoheiHagimoto | 0:0e0631af0305 | 1921 | vectors in a specified number of classes */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1922 | #define CV_KMEANS_USE_INITIAL_LABELS 1 |
| RyoheiHagimoto | 0:0e0631af0305 | 1923 | CVAPI(int) cvKMeans2( const CvArr* samples, int cluster_count, CvArr* labels, |
| RyoheiHagimoto | 0:0e0631af0305 | 1924 | CvTermCriteria termcrit, int attempts CV_DEFAULT(1), |
| RyoheiHagimoto | 0:0e0631af0305 | 1925 | CvRNG* rng CV_DEFAULT(0), int flags CV_DEFAULT(0), |
| RyoheiHagimoto | 0:0e0631af0305 | 1926 | CvArr* _centers CV_DEFAULT(0), double* compactness CV_DEFAULT(0) ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1927 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1928 | /****************************************************************************************\ |
| RyoheiHagimoto | 0:0e0631af0305 | 1929 | * System functions * |
| RyoheiHagimoto | 0:0e0631af0305 | 1930 | \****************************************************************************************/ |
| RyoheiHagimoto | 0:0e0631af0305 | 1931 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1932 | /** Loads optimized functions from IPP, MKL etc. or switches back to pure C code */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1933 | CVAPI(int) cvUseOptimized( int on_off ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1934 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1935 | typedef IplImage* (CV_STDCALL* Cv_iplCreateImageHeader) |
| RyoheiHagimoto | 0:0e0631af0305 | 1936 | (int,int,int,char*,char*,int,int,int,int,int, |
| RyoheiHagimoto | 0:0e0631af0305 | 1937 | IplROI*,IplImage*,void*,IplTileInfo*); |
| RyoheiHagimoto | 0:0e0631af0305 | 1938 | typedef void (CV_STDCALL* Cv_iplAllocateImageData)(IplImage*,int,int); |
| RyoheiHagimoto | 0:0e0631af0305 | 1939 | typedef void (CV_STDCALL* Cv_iplDeallocate)(IplImage*,int); |
| RyoheiHagimoto | 0:0e0631af0305 | 1940 | typedef IplROI* (CV_STDCALL* Cv_iplCreateROI)(int,int,int,int,int); |
| RyoheiHagimoto | 0:0e0631af0305 | 1941 | typedef IplImage* (CV_STDCALL* Cv_iplCloneImage)(const IplImage*); |
| RyoheiHagimoto | 0:0e0631af0305 | 1942 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1943 | /** @brief Makes OpenCV use IPL functions for allocating IplImage and IplROI structures. |
| RyoheiHagimoto | 0:0e0631af0305 | 1944 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1945 | Normally, the function is not called directly. Instead, a simple macro |
| RyoheiHagimoto | 0:0e0631af0305 | 1946 | CV_TURN_ON_IPL_COMPATIBILITY() is used that calls cvSetIPLAllocators and passes there pointers |
| RyoheiHagimoto | 0:0e0631af0305 | 1947 | to IPL allocation functions. : |
| RyoheiHagimoto | 0:0e0631af0305 | 1948 | @code |
| RyoheiHagimoto | 0:0e0631af0305 | 1949 | ... |
| RyoheiHagimoto | 0:0e0631af0305 | 1950 | CV_TURN_ON_IPL_COMPATIBILITY() |
| RyoheiHagimoto | 0:0e0631af0305 | 1951 | ... |
| RyoheiHagimoto | 0:0e0631af0305 | 1952 | @endcode |
| RyoheiHagimoto | 0:0e0631af0305 | 1953 | @param create_header pointer to a function, creating IPL image header. |
| RyoheiHagimoto | 0:0e0631af0305 | 1954 | @param allocate_data pointer to a function, allocating IPL image data. |
| RyoheiHagimoto | 0:0e0631af0305 | 1955 | @param deallocate pointer to a function, deallocating IPL image. |
| RyoheiHagimoto | 0:0e0631af0305 | 1956 | @param create_roi pointer to a function, creating IPL image ROI (i.e. Region of Interest). |
| RyoheiHagimoto | 0:0e0631af0305 | 1957 | @param clone_image pointer to a function, cloning an IPL image. |
| RyoheiHagimoto | 0:0e0631af0305 | 1958 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1959 | CVAPI(void) cvSetIPLAllocators( Cv_iplCreateImageHeader create_header, |
| RyoheiHagimoto | 0:0e0631af0305 | 1960 | Cv_iplAllocateImageData allocate_data, |
| RyoheiHagimoto | 0:0e0631af0305 | 1961 | Cv_iplDeallocate deallocate, |
| RyoheiHagimoto | 0:0e0631af0305 | 1962 | Cv_iplCreateROI create_roi, |
| RyoheiHagimoto | 0:0e0631af0305 | 1963 | Cv_iplCloneImage clone_image ); |
| RyoheiHagimoto | 0:0e0631af0305 | 1964 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1965 | #define CV_TURN_ON_IPL_COMPATIBILITY() \ |
| RyoheiHagimoto | 0:0e0631af0305 | 1966 | cvSetIPLAllocators( iplCreateImageHeader, iplAllocateImage, \ |
| RyoheiHagimoto | 0:0e0631af0305 | 1967 | iplDeallocate, iplCreateROI, iplCloneImage ) |
| RyoheiHagimoto | 0:0e0631af0305 | 1968 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1969 | /****************************************************************************************\ |
| RyoheiHagimoto | 0:0e0631af0305 | 1970 | * Data Persistence * |
| RyoheiHagimoto | 0:0e0631af0305 | 1971 | \****************************************************************************************/ |
| RyoheiHagimoto | 0:0e0631af0305 | 1972 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1973 | /********************************** High-level functions ********************************/ |
| RyoheiHagimoto | 0:0e0631af0305 | 1974 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1975 | /** @brief Opens file storage for reading or writing data. |
| RyoheiHagimoto | 0:0e0631af0305 | 1976 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1977 | The function opens file storage for reading or writing data. In the latter case, a new file is |
| RyoheiHagimoto | 0:0e0631af0305 | 1978 | created or an existing file is rewritten. The type of the read or written file is determined by the |
| RyoheiHagimoto | 0:0e0631af0305 | 1979 | filename extension: .xml for XML, .yml or .yaml for YAML and .json for JSON. |
| RyoheiHagimoto | 0:0e0631af0305 | 1980 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1981 | At the same time, it also supports adding parameters like "example.xml?base64". The three ways |
| RyoheiHagimoto | 0:0e0631af0305 | 1982 | are the same: |
| RyoheiHagimoto | 0:0e0631af0305 | 1983 | @snippet samples/cpp/filestorage_base64.cpp suffix_in_file_name |
| RyoheiHagimoto | 0:0e0631af0305 | 1984 | @snippet samples/cpp/filestorage_base64.cpp flag_write_base64 |
| RyoheiHagimoto | 0:0e0631af0305 | 1985 | @snippet samples/cpp/filestorage_base64.cpp flag_write_and_flag_base64 |
| RyoheiHagimoto | 0:0e0631af0305 | 1986 | |
| RyoheiHagimoto | 0:0e0631af0305 | 1987 | The function returns a pointer to the CvFileStorage structure. |
| RyoheiHagimoto | 0:0e0631af0305 | 1988 | If the file cannot be opened then the function returns NULL. |
| RyoheiHagimoto | 0:0e0631af0305 | 1989 | @param filename Name of the file associated with the storage |
| RyoheiHagimoto | 0:0e0631af0305 | 1990 | @param memstorage Memory storage used for temporary data and for |
| RyoheiHagimoto | 0:0e0631af0305 | 1991 | : storing dynamic structures, such as CvSeq or CvGraph . If it is NULL, a temporary memory |
| RyoheiHagimoto | 0:0e0631af0305 | 1992 | storage is created and used. |
| RyoheiHagimoto | 0:0e0631af0305 | 1993 | @param flags Can be one of the following: |
| RyoheiHagimoto | 0:0e0631af0305 | 1994 | > - **CV_STORAGE_READ** the storage is open for reading |
| RyoheiHagimoto | 0:0e0631af0305 | 1995 | > - **CV_STORAGE_WRITE** the storage is open for writing |
| RyoheiHagimoto | 0:0e0631af0305 | 1996 | (use **CV_STORAGE_WRITE | CV_STORAGE_WRITE_BASE64** to write rawdata in Base64) |
| RyoheiHagimoto | 0:0e0631af0305 | 1997 | @param encoding |
| RyoheiHagimoto | 0:0e0631af0305 | 1998 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 1999 | CVAPI(CvFileStorage*) cvOpenFileStorage( const char* filename, CvMemStorage* memstorage, |
| RyoheiHagimoto | 0:0e0631af0305 | 2000 | int flags, const char* encoding CV_DEFAULT(NULL) ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2001 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2002 | /** @brief Releases file storage. |
| RyoheiHagimoto | 0:0e0631af0305 | 2003 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2004 | The function closes the file associated with the storage and releases all the temporary structures. |
| RyoheiHagimoto | 0:0e0631af0305 | 2005 | It must be called after all I/O operations with the storage are finished. |
| RyoheiHagimoto | 0:0e0631af0305 | 2006 | @param fs Double pointer to the released file storage |
| RyoheiHagimoto | 0:0e0631af0305 | 2007 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2008 | CVAPI(void) cvReleaseFileStorage( CvFileStorage** fs ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2009 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2010 | /** returns attribute value or 0 (NULL) if there is no such attribute */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2011 | CVAPI(const char*) cvAttrValue( const CvAttrList* attr, const char* attr_name ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2012 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2013 | /** @brief Starts writing a new structure. |
| RyoheiHagimoto | 0:0e0631af0305 | 2014 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2015 | The function starts writing a compound structure (collection) that can be a sequence or a map. After |
| RyoheiHagimoto | 0:0e0631af0305 | 2016 | all the structure fields, which can be scalars or structures, are written, cvEndWriteStruct should |
| RyoheiHagimoto | 0:0e0631af0305 | 2017 | be called. The function can be used to group some objects or to implement the write function for a |
| RyoheiHagimoto | 0:0e0631af0305 | 2018 | some user object (see CvTypeInfo). |
| RyoheiHagimoto | 0:0e0631af0305 | 2019 | @param fs File storage |
| RyoheiHagimoto | 0:0e0631af0305 | 2020 | @param name Name of the written structure. The structure can be accessed by this name when the |
| RyoheiHagimoto | 0:0e0631af0305 | 2021 | storage is read. |
| RyoheiHagimoto | 0:0e0631af0305 | 2022 | @param struct_flags A combination one of the following values: |
| RyoheiHagimoto | 0:0e0631af0305 | 2023 | - **CV_NODE_SEQ** the written structure is a sequence (see discussion of CvFileStorage ), |
| RyoheiHagimoto | 0:0e0631af0305 | 2024 | that is, its elements do not have a name. |
| RyoheiHagimoto | 0:0e0631af0305 | 2025 | - **CV_NODE_MAP** the written structure is a map (see discussion of CvFileStorage ), that |
| RyoheiHagimoto | 0:0e0631af0305 | 2026 | is, all its elements have names. |
| RyoheiHagimoto | 0:0e0631af0305 | 2027 | One and only one of the two above flags must be specified |
| RyoheiHagimoto | 0:0e0631af0305 | 2028 | - **CV_NODE_FLOW** the optional flag that makes sense only for YAML streams. It means that |
| RyoheiHagimoto | 0:0e0631af0305 | 2029 | the structure is written as a flow (not as a block), which is more compact. It is |
| RyoheiHagimoto | 0:0e0631af0305 | 2030 | recommended to use this flag for structures or arrays whose elements are all scalars. |
| RyoheiHagimoto | 0:0e0631af0305 | 2031 | @param type_name Optional parameter - the object type name. In |
| RyoheiHagimoto | 0:0e0631af0305 | 2032 | case of XML it is written as a type_id attribute of the structure opening tag. In the case of |
| RyoheiHagimoto | 0:0e0631af0305 | 2033 | YAML it is written after a colon following the structure name (see the example in |
| RyoheiHagimoto | 0:0e0631af0305 | 2034 | CvFileStorage description). In case of JSON it is written as a name/value pair. |
| RyoheiHagimoto | 0:0e0631af0305 | 2035 | Mainly it is used with user objects. When the storage is read, the |
| RyoheiHagimoto | 0:0e0631af0305 | 2036 | encoded type name is used to determine the object type (see CvTypeInfo and cvFindType ). |
| RyoheiHagimoto | 0:0e0631af0305 | 2037 | @param attributes This parameter is not used in the current implementation |
| RyoheiHagimoto | 0:0e0631af0305 | 2038 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2039 | CVAPI(void) cvStartWriteStruct( CvFileStorage* fs, const char* name, |
| RyoheiHagimoto | 0:0e0631af0305 | 2040 | int struct_flags, const char* type_name CV_DEFAULT(NULL), |
| RyoheiHagimoto | 0:0e0631af0305 | 2041 | CvAttrList attributes CV_DEFAULT(cvAttrList())); |
| RyoheiHagimoto | 0:0e0631af0305 | 2042 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2043 | /** @brief Finishes writing to a file node collection. |
| RyoheiHagimoto | 0:0e0631af0305 | 2044 | @param fs File storage |
| RyoheiHagimoto | 0:0e0631af0305 | 2045 | @sa cvStartWriteStruct. |
| RyoheiHagimoto | 0:0e0631af0305 | 2046 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2047 | CVAPI(void) cvEndWriteStruct( CvFileStorage* fs ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2048 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2049 | /** @brief Writes an integer value. |
| RyoheiHagimoto | 0:0e0631af0305 | 2050 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2051 | The function writes a single integer value (with or without a name) to the file storage. |
| RyoheiHagimoto | 0:0e0631af0305 | 2052 | @param fs File storage |
| RyoheiHagimoto | 0:0e0631af0305 | 2053 | @param name Name of the written value. Should be NULL if and only if the parent structure is a |
| RyoheiHagimoto | 0:0e0631af0305 | 2054 | sequence. |
| RyoheiHagimoto | 0:0e0631af0305 | 2055 | @param value The written value |
| RyoheiHagimoto | 0:0e0631af0305 | 2056 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2057 | CVAPI(void) cvWriteInt( CvFileStorage* fs, const char* name, int value ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2058 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2059 | /** @brief Writes a floating-point value. |
| RyoheiHagimoto | 0:0e0631af0305 | 2060 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2061 | The function writes a single floating-point value (with or without a name) to file storage. Special |
| RyoheiHagimoto | 0:0e0631af0305 | 2062 | values are encoded as follows: NaN (Not A Number) as .NaN, infinity as +.Inf or -.Inf. |
| RyoheiHagimoto | 0:0e0631af0305 | 2063 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2064 | The following example shows how to use the low-level writing functions to store custom structures, |
| RyoheiHagimoto | 0:0e0631af0305 | 2065 | such as termination criteria, without registering a new type. : |
| RyoheiHagimoto | 0:0e0631af0305 | 2066 | @code |
| RyoheiHagimoto | 0:0e0631af0305 | 2067 | void write_termcriteria( CvFileStorage* fs, const char* struct_name, |
| RyoheiHagimoto | 0:0e0631af0305 | 2068 | CvTermCriteria* termcrit ) |
| RyoheiHagimoto | 0:0e0631af0305 | 2069 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 2070 | cvStartWriteStruct( fs, struct_name, CV_NODE_MAP, NULL, cvAttrList(0,0)); |
| RyoheiHagimoto | 0:0e0631af0305 | 2071 | cvWriteComment( fs, "termination criteria", 1 ); // just a description |
| RyoheiHagimoto | 0:0e0631af0305 | 2072 | if( termcrit->type & CV_TERMCRIT_ITER ) |
| RyoheiHagimoto | 0:0e0631af0305 | 2073 | cvWriteInteger( fs, "max_iterations", termcrit->max_iter ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2074 | if( termcrit->type & CV_TERMCRIT_EPS ) |
| RyoheiHagimoto | 0:0e0631af0305 | 2075 | cvWriteReal( fs, "accuracy", termcrit->epsilon ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2076 | cvEndWriteStruct( fs ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2077 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 2078 | @endcode |
| RyoheiHagimoto | 0:0e0631af0305 | 2079 | @param fs File storage |
| RyoheiHagimoto | 0:0e0631af0305 | 2080 | @param name Name of the written value. Should be NULL if and only if the parent structure is a |
| RyoheiHagimoto | 0:0e0631af0305 | 2081 | sequence. |
| RyoheiHagimoto | 0:0e0631af0305 | 2082 | @param value The written value |
| RyoheiHagimoto | 0:0e0631af0305 | 2083 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2084 | CVAPI(void) cvWriteReal( CvFileStorage* fs, const char* name, double value ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2085 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2086 | /** @brief Writes a text string. |
| RyoheiHagimoto | 0:0e0631af0305 | 2087 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2088 | The function writes a text string to file storage. |
| RyoheiHagimoto | 0:0e0631af0305 | 2089 | @param fs File storage |
| RyoheiHagimoto | 0:0e0631af0305 | 2090 | @param name Name of the written string . Should be NULL if and only if the parent structure is a |
| RyoheiHagimoto | 0:0e0631af0305 | 2091 | sequence. |
| RyoheiHagimoto | 0:0e0631af0305 | 2092 | @param str The written text string |
| RyoheiHagimoto | 0:0e0631af0305 | 2093 | @param quote If non-zero, the written string is put in quotes, regardless of whether they are |
| RyoheiHagimoto | 0:0e0631af0305 | 2094 | required. Otherwise, if the flag is zero, quotes are used only when they are required (e.g. when |
| RyoheiHagimoto | 0:0e0631af0305 | 2095 | the string starts with a digit or contains spaces). |
| RyoheiHagimoto | 0:0e0631af0305 | 2096 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2097 | CVAPI(void) cvWriteString( CvFileStorage* fs, const char* name, |
| RyoheiHagimoto | 0:0e0631af0305 | 2098 | const char* str, int quote CV_DEFAULT(0) ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2099 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2100 | /** @brief Writes a comment. |
| RyoheiHagimoto | 0:0e0631af0305 | 2101 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2102 | The function writes a comment into file storage. The comments are skipped when the storage is read. |
| RyoheiHagimoto | 0:0e0631af0305 | 2103 | @param fs File storage |
| RyoheiHagimoto | 0:0e0631af0305 | 2104 | @param comment The written comment, single-line or multi-line |
| RyoheiHagimoto | 0:0e0631af0305 | 2105 | @param eol_comment If non-zero, the function tries to put the comment at the end of current line. |
| RyoheiHagimoto | 0:0e0631af0305 | 2106 | If the flag is zero, if the comment is multi-line, or if it does not fit at the end of the current |
| RyoheiHagimoto | 0:0e0631af0305 | 2107 | line, the comment starts a new line. |
| RyoheiHagimoto | 0:0e0631af0305 | 2108 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2109 | CVAPI(void) cvWriteComment( CvFileStorage* fs, const char* comment, |
| RyoheiHagimoto | 0:0e0631af0305 | 2110 | int eol_comment ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2111 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2112 | /** @brief Writes an object to file storage. |
| RyoheiHagimoto | 0:0e0631af0305 | 2113 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2114 | The function writes an object to file storage. First, the appropriate type info is found using |
| RyoheiHagimoto | 0:0e0631af0305 | 2115 | cvTypeOf. Then, the write method associated with the type info is called. |
| RyoheiHagimoto | 0:0e0631af0305 | 2116 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2117 | Attributes are used to customize the writing procedure. The standard types support the following |
| RyoheiHagimoto | 0:0e0631af0305 | 2118 | attributes (all the dt attributes have the same format as in cvWriteRawData): |
| RyoheiHagimoto | 0:0e0631af0305 | 2119 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2120 | -# CvSeq |
| RyoheiHagimoto | 0:0e0631af0305 | 2121 | - **header_dt** description of user fields of the sequence header that follow CvSeq, or |
| RyoheiHagimoto | 0:0e0631af0305 | 2122 | CvChain (if the sequence is a Freeman chain) or CvContour (if the sequence is a contour or |
| RyoheiHagimoto | 0:0e0631af0305 | 2123 | point sequence) |
| RyoheiHagimoto | 0:0e0631af0305 | 2124 | - **dt** description of the sequence elements. |
| RyoheiHagimoto | 0:0e0631af0305 | 2125 | - **recursive** if the attribute is present and is not equal to "0" or "false", the whole |
| RyoheiHagimoto | 0:0e0631af0305 | 2126 | tree of sequences (contours) is stored. |
| RyoheiHagimoto | 0:0e0631af0305 | 2127 | -# CvGraph |
| RyoheiHagimoto | 0:0e0631af0305 | 2128 | - **header_dt** description of user fields of the graph header that follows CvGraph; |
| RyoheiHagimoto | 0:0e0631af0305 | 2129 | - **vertex_dt** description of user fields of graph vertices |
| RyoheiHagimoto | 0:0e0631af0305 | 2130 | - **edge_dt** description of user fields of graph edges (note that the edge weight is |
| RyoheiHagimoto | 0:0e0631af0305 | 2131 | always written, so there is no need to specify it explicitly) |
| RyoheiHagimoto | 0:0e0631af0305 | 2132 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2133 | Below is the code that creates the YAML file shown in the CvFileStorage description: |
| RyoheiHagimoto | 0:0e0631af0305 | 2134 | @code |
| RyoheiHagimoto | 0:0e0631af0305 | 2135 | #include "cxcore.h" |
| RyoheiHagimoto | 0:0e0631af0305 | 2136 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2137 | int main( int argc, char** argv ) |
| RyoheiHagimoto | 0:0e0631af0305 | 2138 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 2139 | CvMat* mat = cvCreateMat( 3, 3, CV_32F ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2140 | CvFileStorage* fs = cvOpenFileStorage( "example.yml", 0, CV_STORAGE_WRITE ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2141 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2142 | cvSetIdentity( mat ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2143 | cvWrite( fs, "A", mat, cvAttrList(0,0) ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2144 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2145 | cvReleaseFileStorage( &fs ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2146 | cvReleaseMat( &mat ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2147 | return 0; |
| RyoheiHagimoto | 0:0e0631af0305 | 2148 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 2149 | @endcode |
| RyoheiHagimoto | 0:0e0631af0305 | 2150 | @param fs File storage |
| RyoheiHagimoto | 0:0e0631af0305 | 2151 | @param name Name of the written object. Should be NULL if and only if the parent structure is a |
| RyoheiHagimoto | 0:0e0631af0305 | 2152 | sequence. |
| RyoheiHagimoto | 0:0e0631af0305 | 2153 | @param ptr Pointer to the object |
| RyoheiHagimoto | 0:0e0631af0305 | 2154 | @param attributes The attributes of the object. They are specific for each particular type (see |
| RyoheiHagimoto | 0:0e0631af0305 | 2155 | the discussion below). |
| RyoheiHagimoto | 0:0e0631af0305 | 2156 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2157 | CVAPI(void) cvWrite( CvFileStorage* fs, const char* name, const void* ptr, |
| RyoheiHagimoto | 0:0e0631af0305 | 2158 | CvAttrList attributes CV_DEFAULT(cvAttrList())); |
| RyoheiHagimoto | 0:0e0631af0305 | 2159 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2160 | /** @brief Starts the next stream. |
| RyoheiHagimoto | 0:0e0631af0305 | 2161 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2162 | The function finishes the currently written stream and starts the next stream. In the case of XML |
| RyoheiHagimoto | 0:0e0631af0305 | 2163 | the file with multiple streams looks like this: |
| RyoheiHagimoto | 0:0e0631af0305 | 2164 | @code{.xml} |
| RyoheiHagimoto | 0:0e0631af0305 | 2165 | <opencv_storage> |
| RyoheiHagimoto | 0:0e0631af0305 | 2166 | <!-- stream #1 data --> |
| RyoheiHagimoto | 0:0e0631af0305 | 2167 | </opencv_storage> |
| RyoheiHagimoto | 0:0e0631af0305 | 2168 | <opencv_storage> |
| RyoheiHagimoto | 0:0e0631af0305 | 2169 | <!-- stream #2 data --> |
| RyoheiHagimoto | 0:0e0631af0305 | 2170 | </opencv_storage> |
| RyoheiHagimoto | 0:0e0631af0305 | 2171 | ... |
| RyoheiHagimoto | 0:0e0631af0305 | 2172 | @endcode |
| RyoheiHagimoto | 0:0e0631af0305 | 2173 | The YAML file will look like this: |
| RyoheiHagimoto | 0:0e0631af0305 | 2174 | @code{.yaml} |
| RyoheiHagimoto | 0:0e0631af0305 | 2175 | %YAML 1.0 |
| RyoheiHagimoto | 0:0e0631af0305 | 2176 | # stream #1 data |
| RyoheiHagimoto | 0:0e0631af0305 | 2177 | ... |
| RyoheiHagimoto | 0:0e0631af0305 | 2178 | --- |
| RyoheiHagimoto | 0:0e0631af0305 | 2179 | # stream #2 data |
| RyoheiHagimoto | 0:0e0631af0305 | 2180 | @endcode |
| RyoheiHagimoto | 0:0e0631af0305 | 2181 | This is useful for concatenating files or for resuming the writing process. |
| RyoheiHagimoto | 0:0e0631af0305 | 2182 | @param fs File storage |
| RyoheiHagimoto | 0:0e0631af0305 | 2183 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2184 | CVAPI(void) cvStartNextStream( CvFileStorage* fs ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2185 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2186 | /** @brief Writes multiple numbers. |
| RyoheiHagimoto | 0:0e0631af0305 | 2187 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2188 | The function writes an array, whose elements consist of single or multiple numbers. The function |
| RyoheiHagimoto | 0:0e0631af0305 | 2189 | call can be replaced with a loop containing a few cvWriteInt and cvWriteReal calls, but a single |
| RyoheiHagimoto | 0:0e0631af0305 | 2190 | call is more efficient. Note that because none of the elements have a name, they should be written |
| RyoheiHagimoto | 0:0e0631af0305 | 2191 | to a sequence rather than a map. |
| RyoheiHagimoto | 0:0e0631af0305 | 2192 | @param fs File storage |
| RyoheiHagimoto | 0:0e0631af0305 | 2193 | @param src Pointer to the written array |
| RyoheiHagimoto | 0:0e0631af0305 | 2194 | @param len Number of the array elements to write |
| RyoheiHagimoto | 0:0e0631af0305 | 2195 | @param dt Specification of each array element, see @ref format_spec "format specification" |
| RyoheiHagimoto | 0:0e0631af0305 | 2196 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2197 | CVAPI(void) cvWriteRawData( CvFileStorage* fs, const void* src, |
| RyoheiHagimoto | 0:0e0631af0305 | 2198 | int len, const char* dt ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2199 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2200 | /** @brief Writes multiple numbers in Base64. |
| RyoheiHagimoto | 0:0e0631af0305 | 2201 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2202 | If either CV_STORAGE_WRITE_BASE64 or cv::FileStorage::WRITE_BASE64 is used, |
| RyoheiHagimoto | 0:0e0631af0305 | 2203 | this function will be the same as cvWriteRawData. If neither, the main |
| RyoheiHagimoto | 0:0e0631af0305 | 2204 | difference is that it outputs a sequence in Base64 encoding rather than |
| RyoheiHagimoto | 0:0e0631af0305 | 2205 | in plain text. |
| RyoheiHagimoto | 0:0e0631af0305 | 2206 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2207 | This function can only be used to write a sequence with a type "binary". |
| RyoheiHagimoto | 0:0e0631af0305 | 2208 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2209 | Consider the following two examples where their output is the same: |
| RyoheiHagimoto | 0:0e0631af0305 | 2210 | @snippet samples/cpp/filestorage_base64.cpp without_base64_flag |
| RyoheiHagimoto | 0:0e0631af0305 | 2211 | and |
| RyoheiHagimoto | 0:0e0631af0305 | 2212 | @snippet samples/cpp/filestorage_base64.cpp with_write_base64_flag |
| RyoheiHagimoto | 0:0e0631af0305 | 2213 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2214 | @param fs File storage |
| RyoheiHagimoto | 0:0e0631af0305 | 2215 | @param src Pointer to the written array |
| RyoheiHagimoto | 0:0e0631af0305 | 2216 | @param len Number of the array elements to write |
| RyoheiHagimoto | 0:0e0631af0305 | 2217 | @param dt Specification of each array element, see @ref format_spec "format specification" |
| RyoheiHagimoto | 0:0e0631af0305 | 2218 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2219 | CVAPI(void) cvWriteRawDataBase64( CvFileStorage* fs, const void* src, |
| RyoheiHagimoto | 0:0e0631af0305 | 2220 | int len, const char* dt ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2221 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2222 | /** @brief Returns a unique pointer for a given name. |
| RyoheiHagimoto | 0:0e0631af0305 | 2223 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2224 | The function returns a unique pointer for each particular file node name. This pointer can be then |
| RyoheiHagimoto | 0:0e0631af0305 | 2225 | passed to the cvGetFileNode function that is faster than cvGetFileNodeByName because it compares |
| RyoheiHagimoto | 0:0e0631af0305 | 2226 | text strings by comparing pointers rather than the strings' content. |
| RyoheiHagimoto | 0:0e0631af0305 | 2227 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2228 | Consider the following example where an array of points is encoded as a sequence of 2-entry maps: |
| RyoheiHagimoto | 0:0e0631af0305 | 2229 | @code |
| RyoheiHagimoto | 0:0e0631af0305 | 2230 | points: |
| RyoheiHagimoto | 0:0e0631af0305 | 2231 | - { x: 10, y: 10 } |
| RyoheiHagimoto | 0:0e0631af0305 | 2232 | - { x: 20, y: 20 } |
| RyoheiHagimoto | 0:0e0631af0305 | 2233 | - { x: 30, y: 30 } |
| RyoheiHagimoto | 0:0e0631af0305 | 2234 | # ... |
| RyoheiHagimoto | 0:0e0631af0305 | 2235 | @endcode |
| RyoheiHagimoto | 0:0e0631af0305 | 2236 | Then, it is possible to get hashed "x" and "y" pointers to speed up decoding of the points. : |
| RyoheiHagimoto | 0:0e0631af0305 | 2237 | @code |
| RyoheiHagimoto | 0:0e0631af0305 | 2238 | #include "cxcore.h" |
| RyoheiHagimoto | 0:0e0631af0305 | 2239 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2240 | int main( int argc, char** argv ) |
| RyoheiHagimoto | 0:0e0631af0305 | 2241 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 2242 | CvFileStorage* fs = cvOpenFileStorage( "points.yml", 0, CV_STORAGE_READ ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2243 | CvStringHashNode* x_key = cvGetHashedNode( fs, "x", -1, 1 ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2244 | CvStringHashNode* y_key = cvGetHashedNode( fs, "y", -1, 1 ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2245 | CvFileNode* points = cvGetFileNodeByName( fs, 0, "points" ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2246 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2247 | if( CV_NODE_IS_SEQ(points->tag) ) |
| RyoheiHagimoto | 0:0e0631af0305 | 2248 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 2249 | CvSeq* seq = points->data.seq; |
| RyoheiHagimoto | 0:0e0631af0305 | 2250 | int i, total = seq->total; |
| RyoheiHagimoto | 0:0e0631af0305 | 2251 | CvSeqReader reader; |
| RyoheiHagimoto | 0:0e0631af0305 | 2252 | cvStartReadSeq( seq, &reader, 0 ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2253 | for( i = 0; i < total; i++ ) |
| RyoheiHagimoto | 0:0e0631af0305 | 2254 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 2255 | CvFileNode* pt = (CvFileNode*)reader.ptr; |
| RyoheiHagimoto | 0:0e0631af0305 | 2256 | #if 1 // faster variant |
| RyoheiHagimoto | 0:0e0631af0305 | 2257 | CvFileNode* xnode = cvGetFileNode( fs, pt, x_key, 0 ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2258 | CvFileNode* ynode = cvGetFileNode( fs, pt, y_key, 0 ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2259 | assert( xnode && CV_NODE_IS_INT(xnode->tag) && |
| RyoheiHagimoto | 0:0e0631af0305 | 2260 | ynode && CV_NODE_IS_INT(ynode->tag)); |
| RyoheiHagimoto | 0:0e0631af0305 | 2261 | int x = xnode->data.i; // or x = cvReadInt( xnode, 0 ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2262 | int y = ynode->data.i; // or y = cvReadInt( ynode, 0 ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2263 | #elif 1 // slower variant; does not use x_key & y_key |
| RyoheiHagimoto | 0:0e0631af0305 | 2264 | CvFileNode* xnode = cvGetFileNodeByName( fs, pt, "x" ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2265 | CvFileNode* ynode = cvGetFileNodeByName( fs, pt, "y" ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2266 | assert( xnode && CV_NODE_IS_INT(xnode->tag) && |
| RyoheiHagimoto | 0:0e0631af0305 | 2267 | ynode && CV_NODE_IS_INT(ynode->tag)); |
| RyoheiHagimoto | 0:0e0631af0305 | 2268 | int x = xnode->data.i; // or x = cvReadInt( xnode, 0 ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2269 | int y = ynode->data.i; // or y = cvReadInt( ynode, 0 ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2270 | #else // the slowest yet the easiest to use variant |
| RyoheiHagimoto | 0:0e0631af0305 | 2271 | int x = cvReadIntByName( fs, pt, "x", 0 ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2272 | int y = cvReadIntByName( fs, pt, "y", 0 ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2273 | #endif |
| RyoheiHagimoto | 0:0e0631af0305 | 2274 | CV_NEXT_SEQ_ELEM( seq->elem_size, reader ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2275 | printf(" |
| RyoheiHagimoto | 0:0e0631af0305 | 2276 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 2277 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 2278 | cvReleaseFileStorage( &fs ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2279 | return 0; |
| RyoheiHagimoto | 0:0e0631af0305 | 2280 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 2281 | @endcode |
| RyoheiHagimoto | 0:0e0631af0305 | 2282 | Please note that whatever method of accessing a map you are using, it is still much slower than |
| RyoheiHagimoto | 0:0e0631af0305 | 2283 | using plain sequences; for example, in the above example, it is more efficient to encode the points |
| RyoheiHagimoto | 0:0e0631af0305 | 2284 | as pairs of integers in a single numeric sequence. |
| RyoheiHagimoto | 0:0e0631af0305 | 2285 | @param fs File storage |
| RyoheiHagimoto | 0:0e0631af0305 | 2286 | @param name Literal node name |
| RyoheiHagimoto | 0:0e0631af0305 | 2287 | @param len Length of the name (if it is known apriori), or -1 if it needs to be calculated |
| RyoheiHagimoto | 0:0e0631af0305 | 2288 | @param create_missing Flag that specifies, whether an absent key should be added into the hash table |
| RyoheiHagimoto | 0:0e0631af0305 | 2289 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2290 | CVAPI(CvStringHashNode*) cvGetHashedKey( CvFileStorage* fs, const char* name, |
| RyoheiHagimoto | 0:0e0631af0305 | 2291 | int len CV_DEFAULT(-1), |
| RyoheiHagimoto | 0:0e0631af0305 | 2292 | int create_missing CV_DEFAULT(0)); |
| RyoheiHagimoto | 0:0e0631af0305 | 2293 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2294 | /** @brief Retrieves one of the top-level nodes of the file storage. |
| RyoheiHagimoto | 0:0e0631af0305 | 2295 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2296 | The function returns one of the top-level file nodes. The top-level nodes do not have a name, they |
| RyoheiHagimoto | 0:0e0631af0305 | 2297 | correspond to the streams that are stored one after another in the file storage. If the index is out |
| RyoheiHagimoto | 0:0e0631af0305 | 2298 | of range, the function returns a NULL pointer, so all the top-level nodes can be iterated by |
| RyoheiHagimoto | 0:0e0631af0305 | 2299 | subsequent calls to the function with stream_index=0,1,..., until the NULL pointer is returned. |
| RyoheiHagimoto | 0:0e0631af0305 | 2300 | This function can be used as a base for recursive traversal of the file storage. |
| RyoheiHagimoto | 0:0e0631af0305 | 2301 | @param fs File storage |
| RyoheiHagimoto | 0:0e0631af0305 | 2302 | @param stream_index Zero-based index of the stream. See cvStartNextStream . In most cases, |
| RyoheiHagimoto | 0:0e0631af0305 | 2303 | there is only one stream in the file; however, there can be several. |
| RyoheiHagimoto | 0:0e0631af0305 | 2304 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2305 | CVAPI(CvFileNode*) cvGetRootFileNode( const CvFileStorage* fs, |
| RyoheiHagimoto | 0:0e0631af0305 | 2306 | int stream_index CV_DEFAULT(0) ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2307 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2308 | /** @brief Finds a node in a map or file storage. |
| RyoheiHagimoto | 0:0e0631af0305 | 2309 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2310 | The function finds a file node. It is a faster version of cvGetFileNodeByName (see |
| RyoheiHagimoto | 0:0e0631af0305 | 2311 | cvGetHashedKey discussion). Also, the function can insert a new node, if it is not in the map yet. |
| RyoheiHagimoto | 0:0e0631af0305 | 2312 | @param fs File storage |
| RyoheiHagimoto | 0:0e0631af0305 | 2313 | @param map The parent map. If it is NULL, the function searches a top-level node. If both map and |
| RyoheiHagimoto | 0:0e0631af0305 | 2314 | key are NULLs, the function returns the root file node - a map that contains top-level nodes. |
| RyoheiHagimoto | 0:0e0631af0305 | 2315 | @param key Unique pointer to the node name, retrieved with cvGetHashedKey |
| RyoheiHagimoto | 0:0e0631af0305 | 2316 | @param create_missing Flag that specifies whether an absent node should be added to the map |
| RyoheiHagimoto | 0:0e0631af0305 | 2317 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2318 | CVAPI(CvFileNode*) cvGetFileNode( CvFileStorage* fs, CvFileNode* map, |
| RyoheiHagimoto | 0:0e0631af0305 | 2319 | const CvStringHashNode* key, |
| RyoheiHagimoto | 0:0e0631af0305 | 2320 | int create_missing CV_DEFAULT(0) ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2321 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2322 | /** @brief Finds a node in a map or file storage. |
| RyoheiHagimoto | 0:0e0631af0305 | 2323 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2324 | The function finds a file node by name. The node is searched either in map or, if the pointer is |
| RyoheiHagimoto | 0:0e0631af0305 | 2325 | NULL, among the top-level file storage nodes. Using this function for maps and cvGetSeqElem (or |
| RyoheiHagimoto | 0:0e0631af0305 | 2326 | sequence reader) for sequences, it is possible to navigate through the file storage. To speed up |
| RyoheiHagimoto | 0:0e0631af0305 | 2327 | multiple queries for a certain key (e.g., in the case of an array of structures) one may use a |
| RyoheiHagimoto | 0:0e0631af0305 | 2328 | combination of cvGetHashedKey and cvGetFileNode. |
| RyoheiHagimoto | 0:0e0631af0305 | 2329 | @param fs File storage |
| RyoheiHagimoto | 0:0e0631af0305 | 2330 | @param map The parent map. If it is NULL, the function searches in all the top-level nodes |
| RyoheiHagimoto | 0:0e0631af0305 | 2331 | (streams), starting with the first one. |
| RyoheiHagimoto | 0:0e0631af0305 | 2332 | @param name The file node name |
| RyoheiHagimoto | 0:0e0631af0305 | 2333 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2334 | CVAPI(CvFileNode*) cvGetFileNodeByName( const CvFileStorage* fs, |
| RyoheiHagimoto | 0:0e0631af0305 | 2335 | const CvFileNode* map, |
| RyoheiHagimoto | 0:0e0631af0305 | 2336 | const char* name ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2337 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2338 | /** @brief Retrieves an integer value from a file node. |
| RyoheiHagimoto | 0:0e0631af0305 | 2339 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2340 | The function returns an integer that is represented by the file node. If the file node is NULL, the |
| RyoheiHagimoto | 0:0e0631af0305 | 2341 | default_value is returned (thus, it is convenient to call the function right after cvGetFileNode |
| RyoheiHagimoto | 0:0e0631af0305 | 2342 | without checking for a NULL pointer). If the file node has type CV_NODE_INT, then node-\>data.i is |
| RyoheiHagimoto | 0:0e0631af0305 | 2343 | returned. If the file node has type CV_NODE_REAL, then node-\>data.f is converted to an integer |
| RyoheiHagimoto | 0:0e0631af0305 | 2344 | and returned. Otherwise the error is reported. |
| RyoheiHagimoto | 0:0e0631af0305 | 2345 | @param node File node |
| RyoheiHagimoto | 0:0e0631af0305 | 2346 | @param default_value The value that is returned if node is NULL |
| RyoheiHagimoto | 0:0e0631af0305 | 2347 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2348 | CV_INLINE int cvReadInt( const CvFileNode* node, int default_value CV_DEFAULT(0) ) |
| RyoheiHagimoto | 0:0e0631af0305 | 2349 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 2350 | return !node ? default_value : |
| RyoheiHagimoto | 0:0e0631af0305 | 2351 | CV_NODE_IS_INT(node->tag) ? node->data.i : |
| RyoheiHagimoto | 0:0e0631af0305 | 2352 | CV_NODE_IS_REAL(node->tag) ? cvRound(node->data.f) : 0x7fffffff; |
| RyoheiHagimoto | 0:0e0631af0305 | 2353 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 2354 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2355 | /** @brief Finds a file node and returns its value. |
| RyoheiHagimoto | 0:0e0631af0305 | 2356 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2357 | The function is a simple superposition of cvGetFileNodeByName and cvReadInt. |
| RyoheiHagimoto | 0:0e0631af0305 | 2358 | @param fs File storage |
| RyoheiHagimoto | 0:0e0631af0305 | 2359 | @param map The parent map. If it is NULL, the function searches a top-level node. |
| RyoheiHagimoto | 0:0e0631af0305 | 2360 | @param name The node name |
| RyoheiHagimoto | 0:0e0631af0305 | 2361 | @param default_value The value that is returned if the file node is not found |
| RyoheiHagimoto | 0:0e0631af0305 | 2362 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2363 | CV_INLINE int cvReadIntByName( const CvFileStorage* fs, const CvFileNode* map, |
| RyoheiHagimoto | 0:0e0631af0305 | 2364 | const char* name, int default_value CV_DEFAULT(0) ) |
| RyoheiHagimoto | 0:0e0631af0305 | 2365 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 2366 | return cvReadInt( cvGetFileNodeByName( fs, map, name ), default_value ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2367 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 2368 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2369 | /** @brief Retrieves a floating-point value from a file node. |
| RyoheiHagimoto | 0:0e0631af0305 | 2370 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2371 | The function returns a floating-point value that is represented by the file node. If the file node |
| RyoheiHagimoto | 0:0e0631af0305 | 2372 | is NULL, the default_value is returned (thus, it is convenient to call the function right after |
| RyoheiHagimoto | 0:0e0631af0305 | 2373 | cvGetFileNode without checking for a NULL pointer). If the file node has type CV_NODE_REAL , |
| RyoheiHagimoto | 0:0e0631af0305 | 2374 | then node-\>data.f is returned. If the file node has type CV_NODE_INT , then node-:math:\>data.f |
| RyoheiHagimoto | 0:0e0631af0305 | 2375 | is converted to floating-point and returned. Otherwise the result is not determined. |
| RyoheiHagimoto | 0:0e0631af0305 | 2376 | @param node File node |
| RyoheiHagimoto | 0:0e0631af0305 | 2377 | @param default_value The value that is returned if node is NULL |
| RyoheiHagimoto | 0:0e0631af0305 | 2378 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2379 | CV_INLINE double cvReadReal( const CvFileNode* node, double default_value CV_DEFAULT(0.) ) |
| RyoheiHagimoto | 0:0e0631af0305 | 2380 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 2381 | return !node ? default_value : |
| RyoheiHagimoto | 0:0e0631af0305 | 2382 | CV_NODE_IS_INT(node->tag) ? (double)node->data.i : |
| RyoheiHagimoto | 0:0e0631af0305 | 2383 | CV_NODE_IS_REAL(node->tag) ? node->data.f : 1e300; |
| RyoheiHagimoto | 0:0e0631af0305 | 2384 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 2385 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2386 | /** @brief Finds a file node and returns its value. |
| RyoheiHagimoto | 0:0e0631af0305 | 2387 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2388 | The function is a simple superposition of cvGetFileNodeByName and cvReadReal . |
| RyoheiHagimoto | 0:0e0631af0305 | 2389 | @param fs File storage |
| RyoheiHagimoto | 0:0e0631af0305 | 2390 | @param map The parent map. If it is NULL, the function searches a top-level node. |
| RyoheiHagimoto | 0:0e0631af0305 | 2391 | @param name The node name |
| RyoheiHagimoto | 0:0e0631af0305 | 2392 | @param default_value The value that is returned if the file node is not found |
| RyoheiHagimoto | 0:0e0631af0305 | 2393 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2394 | CV_INLINE double cvReadRealByName( const CvFileStorage* fs, const CvFileNode* map, |
| RyoheiHagimoto | 0:0e0631af0305 | 2395 | const char* name, double default_value CV_DEFAULT(0.) ) |
| RyoheiHagimoto | 0:0e0631af0305 | 2396 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 2397 | return cvReadReal( cvGetFileNodeByName( fs, map, name ), default_value ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2398 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 2399 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2400 | /** @brief Retrieves a text string from a file node. |
| RyoheiHagimoto | 0:0e0631af0305 | 2401 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2402 | The function returns a text string that is represented by the file node. If the file node is NULL, |
| RyoheiHagimoto | 0:0e0631af0305 | 2403 | the default_value is returned (thus, it is convenient to call the function right after |
| RyoheiHagimoto | 0:0e0631af0305 | 2404 | cvGetFileNode without checking for a NULL pointer). If the file node has type CV_NODE_STR , then |
| RyoheiHagimoto | 0:0e0631af0305 | 2405 | node-:math:\>data.str.ptr is returned. Otherwise the result is not determined. |
| RyoheiHagimoto | 0:0e0631af0305 | 2406 | @param node File node |
| RyoheiHagimoto | 0:0e0631af0305 | 2407 | @param default_value The value that is returned if node is NULL |
| RyoheiHagimoto | 0:0e0631af0305 | 2408 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2409 | CV_INLINE const char* cvReadString( const CvFileNode* node, |
| RyoheiHagimoto | 0:0e0631af0305 | 2410 | const char* default_value CV_DEFAULT(NULL) ) |
| RyoheiHagimoto | 0:0e0631af0305 | 2411 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 2412 | return !node ? default_value : CV_NODE_IS_STRING(node->tag) ? node->data.str.ptr : 0; |
| RyoheiHagimoto | 0:0e0631af0305 | 2413 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 2414 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2415 | /** @brief Finds a file node by its name and returns its value. |
| RyoheiHagimoto | 0:0e0631af0305 | 2416 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2417 | The function is a simple superposition of cvGetFileNodeByName and cvReadString . |
| RyoheiHagimoto | 0:0e0631af0305 | 2418 | @param fs File storage |
| RyoheiHagimoto | 0:0e0631af0305 | 2419 | @param map The parent map. If it is NULL, the function searches a top-level node. |
| RyoheiHagimoto | 0:0e0631af0305 | 2420 | @param name The node name |
| RyoheiHagimoto | 0:0e0631af0305 | 2421 | @param default_value The value that is returned if the file node is not found |
| RyoheiHagimoto | 0:0e0631af0305 | 2422 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2423 | CV_INLINE const char* cvReadStringByName( const CvFileStorage* fs, const CvFileNode* map, |
| RyoheiHagimoto | 0:0e0631af0305 | 2424 | const char* name, const char* default_value CV_DEFAULT(NULL) ) |
| RyoheiHagimoto | 0:0e0631af0305 | 2425 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 2426 | return cvReadString( cvGetFileNodeByName( fs, map, name ), default_value ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2427 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 2428 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2429 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2430 | /** @brief Decodes an object and returns a pointer to it. |
| RyoheiHagimoto | 0:0e0631af0305 | 2431 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2432 | The function decodes a user object (creates an object in a native representation from the file |
| RyoheiHagimoto | 0:0e0631af0305 | 2433 | storage subtree) and returns it. The object to be decoded must be an instance of a registered type |
| RyoheiHagimoto | 0:0e0631af0305 | 2434 | that supports the read method (see CvTypeInfo). The type of the object is determined by the type |
| RyoheiHagimoto | 0:0e0631af0305 | 2435 | name that is encoded in the file. If the object is a dynamic structure, it is created either in |
| RyoheiHagimoto | 0:0e0631af0305 | 2436 | memory storage and passed to cvOpenFileStorage or, if a NULL pointer was passed, in temporary |
| RyoheiHagimoto | 0:0e0631af0305 | 2437 | memory storage, which is released when cvReleaseFileStorage is called. Otherwise, if the object is |
| RyoheiHagimoto | 0:0e0631af0305 | 2438 | not a dynamic structure, it is created in a heap and should be released with a specialized function |
| RyoheiHagimoto | 0:0e0631af0305 | 2439 | or by using the generic cvRelease. |
| RyoheiHagimoto | 0:0e0631af0305 | 2440 | @param fs File storage |
| RyoheiHagimoto | 0:0e0631af0305 | 2441 | @param node The root object node |
| RyoheiHagimoto | 0:0e0631af0305 | 2442 | @param attributes Unused parameter |
| RyoheiHagimoto | 0:0e0631af0305 | 2443 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2444 | CVAPI(void*) cvRead( CvFileStorage* fs, CvFileNode* node, |
| RyoheiHagimoto | 0:0e0631af0305 | 2445 | CvAttrList* attributes CV_DEFAULT(NULL)); |
| RyoheiHagimoto | 0:0e0631af0305 | 2446 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2447 | /** @brief Finds an object by name and decodes it. |
| RyoheiHagimoto | 0:0e0631af0305 | 2448 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2449 | The function is a simple superposition of cvGetFileNodeByName and cvRead. |
| RyoheiHagimoto | 0:0e0631af0305 | 2450 | @param fs File storage |
| RyoheiHagimoto | 0:0e0631af0305 | 2451 | @param map The parent map. If it is NULL, the function searches a top-level node. |
| RyoheiHagimoto | 0:0e0631af0305 | 2452 | @param name The node name |
| RyoheiHagimoto | 0:0e0631af0305 | 2453 | @param attributes Unused parameter |
| RyoheiHagimoto | 0:0e0631af0305 | 2454 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2455 | CV_INLINE void* cvReadByName( CvFileStorage* fs, const CvFileNode* map, |
| RyoheiHagimoto | 0:0e0631af0305 | 2456 | const char* name, CvAttrList* attributes CV_DEFAULT(NULL) ) |
| RyoheiHagimoto | 0:0e0631af0305 | 2457 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 2458 | return cvRead( fs, cvGetFileNodeByName( fs, map, name ), attributes ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2459 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 2460 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2461 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2462 | /** @brief Initializes the file node sequence reader. |
| RyoheiHagimoto | 0:0e0631af0305 | 2463 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2464 | The function initializes the sequence reader to read data from a file node. The initialized reader |
| RyoheiHagimoto | 0:0e0631af0305 | 2465 | can be then passed to cvReadRawDataSlice. |
| RyoheiHagimoto | 0:0e0631af0305 | 2466 | @param fs File storage |
| RyoheiHagimoto | 0:0e0631af0305 | 2467 | @param src The file node (a sequence) to read numbers from |
| RyoheiHagimoto | 0:0e0631af0305 | 2468 | @param reader Pointer to the sequence reader |
| RyoheiHagimoto | 0:0e0631af0305 | 2469 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2470 | CVAPI(void) cvStartReadRawData( const CvFileStorage* fs, const CvFileNode* src, |
| RyoheiHagimoto | 0:0e0631af0305 | 2471 | CvSeqReader* reader ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2472 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2473 | /** @brief Initializes file node sequence reader. |
| RyoheiHagimoto | 0:0e0631af0305 | 2474 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2475 | The function reads one or more elements from the file node, representing a sequence, to a |
| RyoheiHagimoto | 0:0e0631af0305 | 2476 | user-specified array. The total number of read sequence elements is a product of total and the |
| RyoheiHagimoto | 0:0e0631af0305 | 2477 | number of components in each array element. For example, if dt=2if, the function will read total\*3 |
| RyoheiHagimoto | 0:0e0631af0305 | 2478 | sequence elements. As with any sequence, some parts of the file node sequence can be skipped or read |
| RyoheiHagimoto | 0:0e0631af0305 | 2479 | repeatedly by repositioning the reader using cvSetSeqReaderPos. |
| RyoheiHagimoto | 0:0e0631af0305 | 2480 | @param fs File storage |
| RyoheiHagimoto | 0:0e0631af0305 | 2481 | @param reader The sequence reader. Initialize it with cvStartReadRawData . |
| RyoheiHagimoto | 0:0e0631af0305 | 2482 | @param count The number of elements to read |
| RyoheiHagimoto | 0:0e0631af0305 | 2483 | @param dst Pointer to the destination array |
| RyoheiHagimoto | 0:0e0631af0305 | 2484 | @param dt Specification of each array element. It has the same format as in cvWriteRawData . |
| RyoheiHagimoto | 0:0e0631af0305 | 2485 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2486 | CVAPI(void) cvReadRawDataSlice( const CvFileStorage* fs, CvSeqReader* reader, |
| RyoheiHagimoto | 0:0e0631af0305 | 2487 | int count, void* dst, const char* dt ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2488 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2489 | /** @brief Reads multiple numbers. |
| RyoheiHagimoto | 0:0e0631af0305 | 2490 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2491 | The function reads elements from a file node that represents a sequence of scalars. |
| RyoheiHagimoto | 0:0e0631af0305 | 2492 | @param fs File storage |
| RyoheiHagimoto | 0:0e0631af0305 | 2493 | @param src The file node (a sequence) to read numbers from |
| RyoheiHagimoto | 0:0e0631af0305 | 2494 | @param dst Pointer to the destination array |
| RyoheiHagimoto | 0:0e0631af0305 | 2495 | @param dt Specification of each array element. It has the same format as in cvWriteRawData . |
| RyoheiHagimoto | 0:0e0631af0305 | 2496 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2497 | CVAPI(void) cvReadRawData( const CvFileStorage* fs, const CvFileNode* src, |
| RyoheiHagimoto | 0:0e0631af0305 | 2498 | void* dst, const char* dt ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2499 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2500 | /** @brief Writes a file node to another file storage. |
| RyoheiHagimoto | 0:0e0631af0305 | 2501 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2502 | The function writes a copy of a file node to file storage. Possible applications of the function are |
| RyoheiHagimoto | 0:0e0631af0305 | 2503 | merging several file storages into one and conversion between XML, YAML and JSON formats. |
| RyoheiHagimoto | 0:0e0631af0305 | 2504 | @param fs Destination file storage |
| RyoheiHagimoto | 0:0e0631af0305 | 2505 | @param new_node_name New name of the file node in the destination file storage. To keep the |
| RyoheiHagimoto | 0:0e0631af0305 | 2506 | existing name, use cvcvGetFileNodeName |
| RyoheiHagimoto | 0:0e0631af0305 | 2507 | @param node The written node |
| RyoheiHagimoto | 0:0e0631af0305 | 2508 | @param embed If the written node is a collection and this parameter is not zero, no extra level of |
| RyoheiHagimoto | 0:0e0631af0305 | 2509 | hierarchy is created. Instead, all the elements of node are written into the currently written |
| RyoheiHagimoto | 0:0e0631af0305 | 2510 | structure. Of course, map elements can only be embedded into another map, and sequence elements |
| RyoheiHagimoto | 0:0e0631af0305 | 2511 | can only be embedded into another sequence. |
| RyoheiHagimoto | 0:0e0631af0305 | 2512 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2513 | CVAPI(void) cvWriteFileNode( CvFileStorage* fs, const char* new_node_name, |
| RyoheiHagimoto | 0:0e0631af0305 | 2514 | const CvFileNode* node, int embed ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2515 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2516 | /** @brief Returns the name of a file node. |
| RyoheiHagimoto | 0:0e0631af0305 | 2517 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2518 | The function returns the name of a file node or NULL, if the file node does not have a name or if |
| RyoheiHagimoto | 0:0e0631af0305 | 2519 | node is NULL. |
| RyoheiHagimoto | 0:0e0631af0305 | 2520 | @param node File node |
| RyoheiHagimoto | 0:0e0631af0305 | 2521 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2522 | CVAPI(const char*) cvGetFileNodeName( const CvFileNode* node ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2523 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2524 | /*********************************** Adding own types ***********************************/ |
| RyoheiHagimoto | 0:0e0631af0305 | 2525 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2526 | /** @brief Registers a new type. |
| RyoheiHagimoto | 0:0e0631af0305 | 2527 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2528 | The function registers a new type, which is described by info . The function creates a copy of the |
| RyoheiHagimoto | 0:0e0631af0305 | 2529 | structure, so the user should delete it after calling the function. |
| RyoheiHagimoto | 0:0e0631af0305 | 2530 | @param info Type info structure |
| RyoheiHagimoto | 0:0e0631af0305 | 2531 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2532 | CVAPI(void) cvRegisterType( const CvTypeInfo* info ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2533 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2534 | /** @brief Unregisters the type. |
| RyoheiHagimoto | 0:0e0631af0305 | 2535 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2536 | The function unregisters a type with a specified name. If the name is unknown, it is possible to |
| RyoheiHagimoto | 0:0e0631af0305 | 2537 | locate the type info by an instance of the type using cvTypeOf or by iterating the type list, |
| RyoheiHagimoto | 0:0e0631af0305 | 2538 | starting from cvFirstType, and then calling cvUnregisterType(info-\>typeName). |
| RyoheiHagimoto | 0:0e0631af0305 | 2539 | @param type_name Name of an unregistered type |
| RyoheiHagimoto | 0:0e0631af0305 | 2540 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2541 | CVAPI(void) cvUnregisterType( const char* type_name ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2542 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2543 | /** @brief Returns the beginning of a type list. |
| RyoheiHagimoto | 0:0e0631af0305 | 2544 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2545 | The function returns the first type in the list of registered types. Navigation through the list can |
| RyoheiHagimoto | 0:0e0631af0305 | 2546 | be done via the prev and next fields of the CvTypeInfo structure. |
| RyoheiHagimoto | 0:0e0631af0305 | 2547 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2548 | CVAPI(CvTypeInfo*) cvFirstType(void); |
| RyoheiHagimoto | 0:0e0631af0305 | 2549 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2550 | /** @brief Finds a type by its name. |
| RyoheiHagimoto | 0:0e0631af0305 | 2551 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2552 | The function finds a registered type by its name. It returns NULL if there is no type with the |
| RyoheiHagimoto | 0:0e0631af0305 | 2553 | specified name. |
| RyoheiHagimoto | 0:0e0631af0305 | 2554 | @param type_name Type name |
| RyoheiHagimoto | 0:0e0631af0305 | 2555 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2556 | CVAPI(CvTypeInfo*) cvFindType( const char* type_name ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2557 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2558 | /** @brief Returns the type of an object. |
| RyoheiHagimoto | 0:0e0631af0305 | 2559 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2560 | The function finds the type of a given object. It iterates through the list of registered types and |
| RyoheiHagimoto | 0:0e0631af0305 | 2561 | calls the is_instance function/method for every type info structure with that object until one of |
| RyoheiHagimoto | 0:0e0631af0305 | 2562 | them returns non-zero or until the whole list has been traversed. In the latter case, the function |
| RyoheiHagimoto | 0:0e0631af0305 | 2563 | returns NULL. |
| RyoheiHagimoto | 0:0e0631af0305 | 2564 | @param struct_ptr The object pointer |
| RyoheiHagimoto | 0:0e0631af0305 | 2565 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2566 | CVAPI(CvTypeInfo*) cvTypeOf( const void* struct_ptr ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2567 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2568 | /** @brief Releases an object. |
| RyoheiHagimoto | 0:0e0631af0305 | 2569 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2570 | The function finds the type of a given object and calls release with the double pointer. |
| RyoheiHagimoto | 0:0e0631af0305 | 2571 | @param struct_ptr Double pointer to the object |
| RyoheiHagimoto | 0:0e0631af0305 | 2572 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2573 | CVAPI(void) cvRelease( void** struct_ptr ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2574 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2575 | /** @brief Makes a clone of an object. |
| RyoheiHagimoto | 0:0e0631af0305 | 2576 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2577 | The function finds the type of a given object and calls clone with the passed object. Of course, if |
| RyoheiHagimoto | 0:0e0631af0305 | 2578 | you know the object type, for example, struct_ptr is CvMat\*, it is faster to call the specific |
| RyoheiHagimoto | 0:0e0631af0305 | 2579 | function, like cvCloneMat. |
| RyoheiHagimoto | 0:0e0631af0305 | 2580 | @param struct_ptr The object to clone |
| RyoheiHagimoto | 0:0e0631af0305 | 2581 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2582 | CVAPI(void*) cvClone( const void* struct_ptr ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2583 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2584 | /** @brief Saves an object to a file. |
| RyoheiHagimoto | 0:0e0631af0305 | 2585 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2586 | The function saves an object to a file. It provides a simple interface to cvWrite . |
| RyoheiHagimoto | 0:0e0631af0305 | 2587 | @param filename File name |
| RyoheiHagimoto | 0:0e0631af0305 | 2588 | @param struct_ptr Object to save |
| RyoheiHagimoto | 0:0e0631af0305 | 2589 | @param name Optional object name. If it is NULL, the name will be formed from filename . |
| RyoheiHagimoto | 0:0e0631af0305 | 2590 | @param comment Optional comment to put in the beginning of the file |
| RyoheiHagimoto | 0:0e0631af0305 | 2591 | @param attributes Optional attributes passed to cvWrite |
| RyoheiHagimoto | 0:0e0631af0305 | 2592 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2593 | CVAPI(void) cvSave( const char* filename, const void* struct_ptr, |
| RyoheiHagimoto | 0:0e0631af0305 | 2594 | const char* name CV_DEFAULT(NULL), |
| RyoheiHagimoto | 0:0e0631af0305 | 2595 | const char* comment CV_DEFAULT(NULL), |
| RyoheiHagimoto | 0:0e0631af0305 | 2596 | CvAttrList attributes CV_DEFAULT(cvAttrList())); |
| RyoheiHagimoto | 0:0e0631af0305 | 2597 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2598 | /** @brief Loads an object from a file. |
| RyoheiHagimoto | 0:0e0631af0305 | 2599 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2600 | The function loads an object from a file. It basically reads the specified file, find the first |
| RyoheiHagimoto | 0:0e0631af0305 | 2601 | top-level node and calls cvRead for that node. If the file node does not have type information or |
| RyoheiHagimoto | 0:0e0631af0305 | 2602 | the type information can not be found by the type name, the function returns NULL. After the object |
| RyoheiHagimoto | 0:0e0631af0305 | 2603 | is loaded, the file storage is closed and all the temporary buffers are deleted. Thus, to load a |
| RyoheiHagimoto | 0:0e0631af0305 | 2604 | dynamic structure, such as a sequence, contour, or graph, one should pass a valid memory storage |
| RyoheiHagimoto | 0:0e0631af0305 | 2605 | destination to the function. |
| RyoheiHagimoto | 0:0e0631af0305 | 2606 | @param filename File name |
| RyoheiHagimoto | 0:0e0631af0305 | 2607 | @param memstorage Memory storage for dynamic structures, such as CvSeq or CvGraph . It is not used |
| RyoheiHagimoto | 0:0e0631af0305 | 2608 | for matrices or images. |
| RyoheiHagimoto | 0:0e0631af0305 | 2609 | @param name Optional object name. If it is NULL, the first top-level object in the storage will be |
| RyoheiHagimoto | 0:0e0631af0305 | 2610 | loaded. |
| RyoheiHagimoto | 0:0e0631af0305 | 2611 | @param real_name Optional output parameter that will contain the name of the loaded object |
| RyoheiHagimoto | 0:0e0631af0305 | 2612 | (useful if name=NULL ) |
| RyoheiHagimoto | 0:0e0631af0305 | 2613 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2614 | CVAPI(void*) cvLoad( const char* filename, |
| RyoheiHagimoto | 0:0e0631af0305 | 2615 | CvMemStorage* memstorage CV_DEFAULT(NULL), |
| RyoheiHagimoto | 0:0e0631af0305 | 2616 | const char* name CV_DEFAULT(NULL), |
| RyoheiHagimoto | 0:0e0631af0305 | 2617 | const char** real_name CV_DEFAULT(NULL) ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2618 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2619 | /*********************************** Measuring Execution Time ***************************/ |
| RyoheiHagimoto | 0:0e0631af0305 | 2620 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2621 | /** helper functions for RNG initialization and accurate time measurement: |
| RyoheiHagimoto | 0:0e0631af0305 | 2622 | uses internal clock counter on x86 */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2623 | CVAPI(int64) cvGetTickCount( void ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2624 | CVAPI(double) cvGetTickFrequency( void ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2625 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2626 | /*********************************** CPU capabilities ***********************************/ |
| RyoheiHagimoto | 0:0e0631af0305 | 2627 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2628 | CVAPI(int) cvCheckHardwareSupport(int feature); |
| RyoheiHagimoto | 0:0e0631af0305 | 2629 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2630 | /*********************************** Multi-Threading ************************************/ |
| RyoheiHagimoto | 0:0e0631af0305 | 2631 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2632 | /** retrieve/set the number of threads used in OpenMP implementations */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2633 | CVAPI(int) cvGetNumThreads( void ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2634 | CVAPI(void) cvSetNumThreads( int threads CV_DEFAULT(0) ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2635 | /** get index of the thread being executed */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2636 | CVAPI(int) cvGetThreadNum( void ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2637 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2638 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2639 | /********************************** Error Handling **************************************/ |
| RyoheiHagimoto | 0:0e0631af0305 | 2640 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2641 | /** Get current OpenCV error status */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2642 | CVAPI(int) cvGetErrStatus( void ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2643 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2644 | /** Sets error status silently */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2645 | CVAPI(void) cvSetErrStatus( int status ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2646 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2647 | #define CV_ErrModeLeaf 0 /* Print error and exit program */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2648 | #define CV_ErrModeParent 1 /* Print error and continue */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2649 | #define CV_ErrModeSilent 2 /* Don't print and continue */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2650 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2651 | /** Retrives current error processing mode */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2652 | CVAPI(int) cvGetErrMode( void ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2653 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2654 | /** Sets error processing mode, returns previously used mode */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2655 | CVAPI(int) cvSetErrMode( int mode ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2656 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2657 | /** Sets error status and performs some additonal actions (displaying message box, |
| RyoheiHagimoto | 0:0e0631af0305 | 2658 | writing message to stderr, terminating application etc.) |
| RyoheiHagimoto | 0:0e0631af0305 | 2659 | depending on the current error mode */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2660 | CVAPI(void) cvError( int status, const char* func_name, |
| RyoheiHagimoto | 0:0e0631af0305 | 2661 | const char* err_msg, const char* file_name, int line ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2662 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2663 | /** Retrieves textual description of the error given its code */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2664 | CVAPI(const char*) cvErrorStr( int status ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2665 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2666 | /** Retrieves detailed information about the last error occured */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2667 | CVAPI(int) cvGetErrInfo( const char** errcode_desc, const char** description, |
| RyoheiHagimoto | 0:0e0631af0305 | 2668 | const char** filename, int* line ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2669 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2670 | /** Maps IPP error codes to the counterparts from OpenCV */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2671 | CVAPI(int) cvErrorFromIppStatus( int ipp_status ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2672 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2673 | typedef int (CV_CDECL *CvErrorCallback)( int status, const char* func_name, |
| RyoheiHagimoto | 0:0e0631af0305 | 2674 | const char* err_msg, const char* file_name, int line, void* userdata ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2675 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2676 | /** Assigns a new error-handling function */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2677 | CVAPI(CvErrorCallback) cvRedirectError( CvErrorCallback error_handler, |
| RyoheiHagimoto | 0:0e0631af0305 | 2678 | void* userdata CV_DEFAULT(NULL), |
| RyoheiHagimoto | 0:0e0631af0305 | 2679 | void** prev_userdata CV_DEFAULT(NULL) ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2680 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2681 | /** Output nothing */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2682 | CVAPI(int) cvNulDevReport( int status, const char* func_name, const char* err_msg, |
| RyoheiHagimoto | 0:0e0631af0305 | 2683 | const char* file_name, int line, void* userdata ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2684 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2685 | /** Output to console(fprintf(stderr,...)) */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2686 | CVAPI(int) cvStdErrReport( int status, const char* func_name, const char* err_msg, |
| RyoheiHagimoto | 0:0e0631af0305 | 2687 | const char* file_name, int line, void* userdata ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2688 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2689 | /** Output to MessageBox(WIN32) */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2690 | CVAPI(int) cvGuiBoxReport( int status, const char* func_name, const char* err_msg, |
| RyoheiHagimoto | 0:0e0631af0305 | 2691 | const char* file_name, int line, void* userdata ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2692 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2693 | #define OPENCV_ERROR(status,func,context) \ |
| RyoheiHagimoto | 0:0e0631af0305 | 2694 | cvError((status),(func),(context),__FILE__,__LINE__) |
| RyoheiHagimoto | 0:0e0631af0305 | 2695 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2696 | #define OPENCV_ASSERT(expr,func,context) \ |
| RyoheiHagimoto | 0:0e0631af0305 | 2697 | {if (! (expr)) \ |
| RyoheiHagimoto | 0:0e0631af0305 | 2698 | {OPENCV_ERROR(CV_StsInternal,(func),(context));}} |
| RyoheiHagimoto | 0:0e0631af0305 | 2699 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2700 | #define OPENCV_CALL( Func ) \ |
| RyoheiHagimoto | 0:0e0631af0305 | 2701 | { \ |
| RyoheiHagimoto | 0:0e0631af0305 | 2702 | Func; \ |
| RyoheiHagimoto | 0:0e0631af0305 | 2703 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 2704 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2705 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2706 | /** CV_FUNCNAME macro defines icvFuncName constant which is used by CV_ERROR macro */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2707 | #ifdef CV_NO_FUNC_NAMES |
| RyoheiHagimoto | 0:0e0631af0305 | 2708 | #define CV_FUNCNAME( Name ) |
| RyoheiHagimoto | 0:0e0631af0305 | 2709 | #define cvFuncName "" |
| RyoheiHagimoto | 0:0e0631af0305 | 2710 | #else |
| RyoheiHagimoto | 0:0e0631af0305 | 2711 | #define CV_FUNCNAME( Name ) \ |
| RyoheiHagimoto | 0:0e0631af0305 | 2712 | static char cvFuncName[] = Name |
| RyoheiHagimoto | 0:0e0631af0305 | 2713 | #endif |
| RyoheiHagimoto | 0:0e0631af0305 | 2714 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2715 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2716 | /** |
| RyoheiHagimoto | 0:0e0631af0305 | 2717 | CV_ERROR macro unconditionally raises error with passed code and message. |
| RyoheiHagimoto | 0:0e0631af0305 | 2718 | After raising error, control will be transferred to the exit label. |
| RyoheiHagimoto | 0:0e0631af0305 | 2719 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2720 | #define CV_ERROR( Code, Msg ) \ |
| RyoheiHagimoto | 0:0e0631af0305 | 2721 | { \ |
| RyoheiHagimoto | 0:0e0631af0305 | 2722 | cvError( (Code), cvFuncName, Msg, __FILE__, __LINE__ ); \ |
| RyoheiHagimoto | 0:0e0631af0305 | 2723 | __CV_EXIT__; \ |
| RyoheiHagimoto | 0:0e0631af0305 | 2724 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 2725 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2726 | /** |
| RyoheiHagimoto | 0:0e0631af0305 | 2727 | CV_CHECK macro checks error status after CV (or IPL) |
| RyoheiHagimoto | 0:0e0631af0305 | 2728 | function call. If error detected, control will be transferred to the exit |
| RyoheiHagimoto | 0:0e0631af0305 | 2729 | label. |
| RyoheiHagimoto | 0:0e0631af0305 | 2730 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2731 | #define CV_CHECK() \ |
| RyoheiHagimoto | 0:0e0631af0305 | 2732 | { \ |
| RyoheiHagimoto | 0:0e0631af0305 | 2733 | if( cvGetErrStatus() < 0 ) \ |
| RyoheiHagimoto | 0:0e0631af0305 | 2734 | CV_ERROR( CV_StsBackTrace, "Inner function failed." ); \ |
| RyoheiHagimoto | 0:0e0631af0305 | 2735 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 2736 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2737 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2738 | /** |
| RyoheiHagimoto | 0:0e0631af0305 | 2739 | CV_CALL macro calls CV (or IPL) function, checks error status and |
| RyoheiHagimoto | 0:0e0631af0305 | 2740 | signals a error if the function failed. Useful in "parent node" |
| RyoheiHagimoto | 0:0e0631af0305 | 2741 | error procesing mode |
| RyoheiHagimoto | 0:0e0631af0305 | 2742 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2743 | #define CV_CALL( Func ) \ |
| RyoheiHagimoto | 0:0e0631af0305 | 2744 | { \ |
| RyoheiHagimoto | 0:0e0631af0305 | 2745 | Func; \ |
| RyoheiHagimoto | 0:0e0631af0305 | 2746 | CV_CHECK(); \ |
| RyoheiHagimoto | 0:0e0631af0305 | 2747 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 2748 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2749 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2750 | /** Runtime assertion macro */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2751 | #define CV_ASSERT( Condition ) \ |
| RyoheiHagimoto | 0:0e0631af0305 | 2752 | { \ |
| RyoheiHagimoto | 0:0e0631af0305 | 2753 | if( !(Condition) ) \ |
| RyoheiHagimoto | 0:0e0631af0305 | 2754 | CV_ERROR( CV_StsInternal, "Assertion: " #Condition " failed" ); \ |
| RyoheiHagimoto | 0:0e0631af0305 | 2755 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 2756 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2757 | #define __CV_BEGIN__ { |
| RyoheiHagimoto | 0:0e0631af0305 | 2758 | #define __CV_END__ goto exit; exit: ; } |
| RyoheiHagimoto | 0:0e0631af0305 | 2759 | #define __CV_EXIT__ goto exit |
| RyoheiHagimoto | 0:0e0631af0305 | 2760 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2761 | /** @} core_c */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2762 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2763 | #ifdef __cplusplus |
| RyoheiHagimoto | 0:0e0631af0305 | 2764 | } // extern "C" |
| RyoheiHagimoto | 0:0e0631af0305 | 2765 | #endif |
| RyoheiHagimoto | 0:0e0631af0305 | 2766 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2767 | #ifdef __cplusplus |
| RyoheiHagimoto | 0:0e0631af0305 | 2768 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2769 | //! @addtogroup core_c_glue |
| RyoheiHagimoto | 0:0e0631af0305 | 2770 | //! @{ |
| RyoheiHagimoto | 0:0e0631af0305 | 2771 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2772 | //! class for automatic module/RTTI data registration/unregistration |
| RyoheiHagimoto | 0:0e0631af0305 | 2773 | struct CV_EXPORTS CvType |
| RyoheiHagimoto | 0:0e0631af0305 | 2774 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 2775 | CvType( const char* type_name, |
| RyoheiHagimoto | 0:0e0631af0305 | 2776 | CvIsInstanceFunc is_instance, CvReleaseFunc release=0, |
| RyoheiHagimoto | 0:0e0631af0305 | 2777 | CvReadFunc read=0, CvWriteFunc write=0, CvCloneFunc clone=0 ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2778 | ~CvType(); |
| RyoheiHagimoto | 0:0e0631af0305 | 2779 | CvTypeInfo* info; |
| RyoheiHagimoto | 0:0e0631af0305 | 2780 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2781 | static CvTypeInfo* first; |
| RyoheiHagimoto | 0:0e0631af0305 | 2782 | static CvTypeInfo* last; |
| RyoheiHagimoto | 0:0e0631af0305 | 2783 | }; |
| RyoheiHagimoto | 0:0e0631af0305 | 2784 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2785 | //! @} |
| RyoheiHagimoto | 0:0e0631af0305 | 2786 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2787 | #include "opencv2/core/utility.hpp" |
| RyoheiHagimoto | 0:0e0631af0305 | 2788 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2789 | namespace cv |
| RyoheiHagimoto | 0:0e0631af0305 | 2790 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 2791 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2792 | //! @addtogroup core_c_glue |
| RyoheiHagimoto | 0:0e0631af0305 | 2793 | //! @{ |
| RyoheiHagimoto | 0:0e0631af0305 | 2794 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2795 | /////////////////////////////////////////// glue /////////////////////////////////////////// |
| RyoheiHagimoto | 0:0e0631af0305 | 2796 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2797 | //! converts array (CvMat or IplImage) to cv::Mat |
| RyoheiHagimoto | 0:0e0631af0305 | 2798 | CV_EXPORTS Mat cvarrToMat(const CvArr* arr, bool copyData=false, |
| RyoheiHagimoto | 0:0e0631af0305 | 2799 | bool allowND=true, int coiMode=0, |
| RyoheiHagimoto | 0:0e0631af0305 | 2800 | AutoBuffer<double>* buf=0); |
| RyoheiHagimoto | 0:0e0631af0305 | 2801 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2802 | static inline Mat cvarrToMatND(const CvArr* arr, bool copyData=false, int coiMode=0) |
| RyoheiHagimoto | 0:0e0631af0305 | 2803 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 2804 | return cvarrToMat(arr, copyData, true, coiMode); |
| RyoheiHagimoto | 0:0e0631af0305 | 2805 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 2806 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2807 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2808 | //! extracts Channel of Interest from CvMat or IplImage and makes cv::Mat out of it. |
| RyoheiHagimoto | 0:0e0631af0305 | 2809 | CV_EXPORTS void extractImageCOI(const CvArr* arr, OutputArray coiimg, int coi=-1); |
| RyoheiHagimoto | 0:0e0631af0305 | 2810 | //! inserts single-channel cv::Mat into a multi-channel CvMat or IplImage |
| RyoheiHagimoto | 0:0e0631af0305 | 2811 | CV_EXPORTS void insertImageCOI(InputArray coiimg, CvArr* arr, int coi=-1); |
| RyoheiHagimoto | 0:0e0631af0305 | 2812 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2813 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2814 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2815 | ////// specialized implementations of DefaultDeleter::operator() for classic OpenCV types ////// |
| RyoheiHagimoto | 0:0e0631af0305 | 2816 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2817 | template<> CV_EXPORTS void DefaultDeleter<CvMat>::operator ()(CvMat* obj) const; |
| RyoheiHagimoto | 0:0e0631af0305 | 2818 | template<> CV_EXPORTS void DefaultDeleter<IplImage>::operator ()(IplImage* obj) const; |
| RyoheiHagimoto | 0:0e0631af0305 | 2819 | template<> CV_EXPORTS void DefaultDeleter<CvMatND>::operator ()(CvMatND* obj) const; |
| RyoheiHagimoto | 0:0e0631af0305 | 2820 | template<> CV_EXPORTS void DefaultDeleter<CvSparseMat>::operator ()(CvSparseMat* obj) const; |
| RyoheiHagimoto | 0:0e0631af0305 | 2821 | template<> CV_EXPORTS void DefaultDeleter<CvMemStorage>::operator ()(CvMemStorage* obj) const; |
| RyoheiHagimoto | 0:0e0631af0305 | 2822 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2823 | ////////////// convenient wrappers for operating old-style dynamic structures ////////////// |
| RyoheiHagimoto | 0:0e0631af0305 | 2824 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2825 | template<typename _Tp> class SeqIterator; |
| RyoheiHagimoto | 0:0e0631af0305 | 2826 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2827 | typedef Ptr<CvMemStorage> MemStorage; |
| RyoheiHagimoto | 0:0e0631af0305 | 2828 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2829 | /*! |
| RyoheiHagimoto | 0:0e0631af0305 | 2830 | Template Sequence Class derived from CvSeq |
| RyoheiHagimoto | 0:0e0631af0305 | 2831 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2832 | The class provides more convenient access to sequence elements, |
| RyoheiHagimoto | 0:0e0631af0305 | 2833 | STL-style operations and iterators. |
| RyoheiHagimoto | 0:0e0631af0305 | 2834 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2835 | \note The class is targeted for simple data types, |
| RyoheiHagimoto | 0:0e0631af0305 | 2836 | i.e. no constructors or destructors |
| RyoheiHagimoto | 0:0e0631af0305 | 2837 | are called for the sequence elements. |
| RyoheiHagimoto | 0:0e0631af0305 | 2838 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2839 | template<typename _Tp> class Seq |
| RyoheiHagimoto | 0:0e0631af0305 | 2840 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 2841 | public: |
| RyoheiHagimoto | 0:0e0631af0305 | 2842 | typedef SeqIterator<_Tp> iterator; |
| RyoheiHagimoto | 0:0e0631af0305 | 2843 | typedef SeqIterator<_Tp> const_iterator; |
| RyoheiHagimoto | 0:0e0631af0305 | 2844 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2845 | //! the default constructor |
| RyoheiHagimoto | 0:0e0631af0305 | 2846 | Seq(); |
| RyoheiHagimoto | 0:0e0631af0305 | 2847 | //! the constructor for wrapping CvSeq structure. The real element type in CvSeq should match _Tp. |
| RyoheiHagimoto | 0:0e0631af0305 | 2848 | Seq(const CvSeq* seq); |
| RyoheiHagimoto | 0:0e0631af0305 | 2849 | //! creates the empty sequence that resides in the specified storage |
| RyoheiHagimoto | 0:0e0631af0305 | 2850 | Seq(MemStorage& storage, int headerSize = sizeof(CvSeq)); |
| RyoheiHagimoto | 0:0e0631af0305 | 2851 | //! returns read-write reference to the specified element |
| RyoheiHagimoto | 0:0e0631af0305 | 2852 | _Tp& operator [](int idx); |
| RyoheiHagimoto | 0:0e0631af0305 | 2853 | //! returns read-only reference to the specified element |
| RyoheiHagimoto | 0:0e0631af0305 | 2854 | const _Tp& operator[](int idx) const; |
| RyoheiHagimoto | 0:0e0631af0305 | 2855 | //! returns iterator pointing to the beginning of the sequence |
| RyoheiHagimoto | 0:0e0631af0305 | 2856 | SeqIterator<_Tp> begin() const; |
| RyoheiHagimoto | 0:0e0631af0305 | 2857 | //! returns iterator pointing to the element following the last sequence element |
| RyoheiHagimoto | 0:0e0631af0305 | 2858 | SeqIterator<_Tp> end() const; |
| RyoheiHagimoto | 0:0e0631af0305 | 2859 | //! returns the number of elements in the sequence |
| RyoheiHagimoto | 0:0e0631af0305 | 2860 | size_t size() const; |
| RyoheiHagimoto | 0:0e0631af0305 | 2861 | //! returns the type of sequence elements (CV_8UC1 ... CV_64FC(CV_CN_MAX) ...) |
| RyoheiHagimoto | 0:0e0631af0305 | 2862 | int type() const; |
| RyoheiHagimoto | 0:0e0631af0305 | 2863 | //! returns the depth of sequence elements (CV_8U ... CV_64F) |
| RyoheiHagimoto | 0:0e0631af0305 | 2864 | int depth() const; |
| RyoheiHagimoto | 0:0e0631af0305 | 2865 | //! returns the number of channels in each sequence element |
| RyoheiHagimoto | 0:0e0631af0305 | 2866 | int channels() const; |
| RyoheiHagimoto | 0:0e0631af0305 | 2867 | //! returns the size of each sequence element |
| RyoheiHagimoto | 0:0e0631af0305 | 2868 | size_t elemSize() const; |
| RyoheiHagimoto | 0:0e0631af0305 | 2869 | //! returns index of the specified sequence element |
| RyoheiHagimoto | 0:0e0631af0305 | 2870 | size_t index(const _Tp& elem) const; |
| RyoheiHagimoto | 0:0e0631af0305 | 2871 | //! appends the specified element to the end of the sequence |
| RyoheiHagimoto | 0:0e0631af0305 | 2872 | void push_back(const _Tp& elem); |
| RyoheiHagimoto | 0:0e0631af0305 | 2873 | //! appends the specified element to the front of the sequence |
| RyoheiHagimoto | 0:0e0631af0305 | 2874 | void push_front(const _Tp& elem); |
| RyoheiHagimoto | 0:0e0631af0305 | 2875 | //! appends zero or more elements to the end of the sequence |
| RyoheiHagimoto | 0:0e0631af0305 | 2876 | void push_back(const _Tp* elems, size_t count); |
| RyoheiHagimoto | 0:0e0631af0305 | 2877 | //! appends zero or more elements to the front of the sequence |
| RyoheiHagimoto | 0:0e0631af0305 | 2878 | void push_front(const _Tp* elems, size_t count); |
| RyoheiHagimoto | 0:0e0631af0305 | 2879 | //! inserts the specified element to the specified position |
| RyoheiHagimoto | 0:0e0631af0305 | 2880 | void insert(int idx, const _Tp& elem); |
| RyoheiHagimoto | 0:0e0631af0305 | 2881 | //! inserts zero or more elements to the specified position |
| RyoheiHagimoto | 0:0e0631af0305 | 2882 | void insert(int idx, const _Tp* elems, size_t count); |
| RyoheiHagimoto | 0:0e0631af0305 | 2883 | //! removes element at the specified position |
| RyoheiHagimoto | 0:0e0631af0305 | 2884 | void remove(int idx); |
| RyoheiHagimoto | 0:0e0631af0305 | 2885 | //! removes the specified subsequence |
| RyoheiHagimoto | 0:0e0631af0305 | 2886 | void remove(const Range& r); |
| RyoheiHagimoto | 0:0e0631af0305 | 2887 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2888 | //! returns reference to the first sequence element |
| RyoheiHagimoto | 0:0e0631af0305 | 2889 | _Tp& front(); |
| RyoheiHagimoto | 0:0e0631af0305 | 2890 | //! returns read-only reference to the first sequence element |
| RyoheiHagimoto | 0:0e0631af0305 | 2891 | const _Tp& front() const; |
| RyoheiHagimoto | 0:0e0631af0305 | 2892 | //! returns reference to the last sequence element |
| RyoheiHagimoto | 0:0e0631af0305 | 2893 | _Tp& back(); |
| RyoheiHagimoto | 0:0e0631af0305 | 2894 | //! returns read-only reference to the last sequence element |
| RyoheiHagimoto | 0:0e0631af0305 | 2895 | const _Tp& back() const; |
| RyoheiHagimoto | 0:0e0631af0305 | 2896 | //! returns true iff the sequence contains no elements |
| RyoheiHagimoto | 0:0e0631af0305 | 2897 | bool empty() const; |
| RyoheiHagimoto | 0:0e0631af0305 | 2898 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2899 | //! removes all the elements from the sequence |
| RyoheiHagimoto | 0:0e0631af0305 | 2900 | void clear(); |
| RyoheiHagimoto | 0:0e0631af0305 | 2901 | //! removes the first element from the sequence |
| RyoheiHagimoto | 0:0e0631af0305 | 2902 | void pop_front(); |
| RyoheiHagimoto | 0:0e0631af0305 | 2903 | //! removes the last element from the sequence |
| RyoheiHagimoto | 0:0e0631af0305 | 2904 | void pop_back(); |
| RyoheiHagimoto | 0:0e0631af0305 | 2905 | //! removes zero or more elements from the beginning of the sequence |
| RyoheiHagimoto | 0:0e0631af0305 | 2906 | void pop_front(_Tp* elems, size_t count); |
| RyoheiHagimoto | 0:0e0631af0305 | 2907 | //! removes zero or more elements from the end of the sequence |
| RyoheiHagimoto | 0:0e0631af0305 | 2908 | void pop_back(_Tp* elems, size_t count); |
| RyoheiHagimoto | 0:0e0631af0305 | 2909 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2910 | //! copies the whole sequence or the sequence slice to the specified vector |
| RyoheiHagimoto | 0:0e0631af0305 | 2911 | void copyTo(std::vector<_Tp>& vec, const Range& range=Range::all()) const; |
| RyoheiHagimoto | 0:0e0631af0305 | 2912 | //! returns the vector containing all the sequence elements |
| RyoheiHagimoto | 0:0e0631af0305 | 2913 | operator std::vector<_Tp>() const; |
| RyoheiHagimoto | 0:0e0631af0305 | 2914 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2915 | CvSeq* seq; |
| RyoheiHagimoto | 0:0e0631af0305 | 2916 | }; |
| RyoheiHagimoto | 0:0e0631af0305 | 2917 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2918 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2919 | /*! |
| RyoheiHagimoto | 0:0e0631af0305 | 2920 | STL-style Sequence Iterator inherited from the CvSeqReader structure |
| RyoheiHagimoto | 0:0e0631af0305 | 2921 | */ |
| RyoheiHagimoto | 0:0e0631af0305 | 2922 | template<typename _Tp> class SeqIterator : public CvSeqReader |
| RyoheiHagimoto | 0:0e0631af0305 | 2923 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 2924 | public: |
| RyoheiHagimoto | 0:0e0631af0305 | 2925 | //! the default constructor |
| RyoheiHagimoto | 0:0e0631af0305 | 2926 | SeqIterator(); |
| RyoheiHagimoto | 0:0e0631af0305 | 2927 | //! the constructor setting the iterator to the beginning or to the end of the sequence |
| RyoheiHagimoto | 0:0e0631af0305 | 2928 | SeqIterator(const Seq<_Tp>& seq, bool seekEnd=false); |
| RyoheiHagimoto | 0:0e0631af0305 | 2929 | //! positions the iterator within the sequence |
| RyoheiHagimoto | 0:0e0631af0305 | 2930 | void seek(size_t pos); |
| RyoheiHagimoto | 0:0e0631af0305 | 2931 | //! reports the current iterator position |
| RyoheiHagimoto | 0:0e0631af0305 | 2932 | size_t tell() const; |
| RyoheiHagimoto | 0:0e0631af0305 | 2933 | //! returns reference to the current sequence element |
| RyoheiHagimoto | 0:0e0631af0305 | 2934 | _Tp& operator *(); |
| RyoheiHagimoto | 0:0e0631af0305 | 2935 | //! returns read-only reference to the current sequence element |
| RyoheiHagimoto | 0:0e0631af0305 | 2936 | const _Tp& operator *() const; |
| RyoheiHagimoto | 0:0e0631af0305 | 2937 | //! moves iterator to the next sequence element |
| RyoheiHagimoto | 0:0e0631af0305 | 2938 | SeqIterator& operator ++(); |
| RyoheiHagimoto | 0:0e0631af0305 | 2939 | //! moves iterator to the next sequence element |
| RyoheiHagimoto | 0:0e0631af0305 | 2940 | SeqIterator operator ++(int) const; |
| RyoheiHagimoto | 0:0e0631af0305 | 2941 | //! moves iterator to the previous sequence element |
| RyoheiHagimoto | 0:0e0631af0305 | 2942 | SeqIterator& operator --(); |
| RyoheiHagimoto | 0:0e0631af0305 | 2943 | //! moves iterator to the previous sequence element |
| RyoheiHagimoto | 0:0e0631af0305 | 2944 | SeqIterator operator --(int) const; |
| RyoheiHagimoto | 0:0e0631af0305 | 2945 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2946 | //! moves iterator forward by the specified offset (possibly negative) |
| RyoheiHagimoto | 0:0e0631af0305 | 2947 | SeqIterator& operator +=(int); |
| RyoheiHagimoto | 0:0e0631af0305 | 2948 | //! moves iterator backward by the specified offset (possibly negative) |
| RyoheiHagimoto | 0:0e0631af0305 | 2949 | SeqIterator& operator -=(int); |
| RyoheiHagimoto | 0:0e0631af0305 | 2950 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2951 | // this is index of the current element module seq->total*2 |
| RyoheiHagimoto | 0:0e0631af0305 | 2952 | // (to distinguish between 0 and seq->total) |
| RyoheiHagimoto | 0:0e0631af0305 | 2953 | int index; |
| RyoheiHagimoto | 0:0e0631af0305 | 2954 | }; |
| RyoheiHagimoto | 0:0e0631af0305 | 2955 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2956 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2957 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2958 | // bridge C++ => C Seq API |
| RyoheiHagimoto | 0:0e0631af0305 | 2959 | CV_EXPORTS schar* seqPush( CvSeq* seq, const void* element=0); |
| RyoheiHagimoto | 0:0e0631af0305 | 2960 | CV_EXPORTS schar* seqPushFront( CvSeq* seq, const void* element=0); |
| RyoheiHagimoto | 0:0e0631af0305 | 2961 | CV_EXPORTS void seqPop( CvSeq* seq, void* element=0); |
| RyoheiHagimoto | 0:0e0631af0305 | 2962 | CV_EXPORTS void seqPopFront( CvSeq* seq, void* element=0); |
| RyoheiHagimoto | 0:0e0631af0305 | 2963 | CV_EXPORTS void seqPopMulti( CvSeq* seq, void* elements, |
| RyoheiHagimoto | 0:0e0631af0305 | 2964 | int count, int in_front=0 ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2965 | CV_EXPORTS void seqRemove( CvSeq* seq, int index ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2966 | CV_EXPORTS void clearSeq( CvSeq* seq ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2967 | CV_EXPORTS schar* getSeqElem( const CvSeq* seq, int index ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2968 | CV_EXPORTS void seqRemoveSlice( CvSeq* seq, CvSlice slice ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2969 | CV_EXPORTS void seqInsertSlice( CvSeq* seq, int before_index, const CvArr* from_arr ); |
| RyoheiHagimoto | 0:0e0631af0305 | 2970 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2971 | template<typename _Tp> inline Seq<_Tp>::Seq() : seq(0) {} |
| RyoheiHagimoto | 0:0e0631af0305 | 2972 | template<typename _Tp> inline Seq<_Tp>::Seq( const CvSeq* _seq ) : seq((CvSeq*)_seq) |
| RyoheiHagimoto | 0:0e0631af0305 | 2973 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 2974 | CV_Assert(!_seq || _seq->elem_size == sizeof(_Tp)); |
| RyoheiHagimoto | 0:0e0631af0305 | 2975 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 2976 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2977 | template<typename _Tp> inline Seq<_Tp>::Seq( MemStorage& storage, |
| RyoheiHagimoto | 0:0e0631af0305 | 2978 | int headerSize ) |
| RyoheiHagimoto | 0:0e0631af0305 | 2979 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 2980 | CV_Assert(headerSize >= (int)sizeof(CvSeq)); |
| RyoheiHagimoto | 0:0e0631af0305 | 2981 | seq = cvCreateSeq(DataType<_Tp>::type, headerSize, sizeof(_Tp), storage); |
| RyoheiHagimoto | 0:0e0631af0305 | 2982 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 2983 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2984 | template<typename _Tp> inline _Tp& Seq<_Tp>::operator [](int idx) |
| RyoheiHagimoto | 0:0e0631af0305 | 2985 | { return *(_Tp*)getSeqElem(seq, idx); } |
| RyoheiHagimoto | 0:0e0631af0305 | 2986 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2987 | template<typename _Tp> inline const _Tp& Seq<_Tp>::operator [](int idx) const |
| RyoheiHagimoto | 0:0e0631af0305 | 2988 | { return *(_Tp*)getSeqElem(seq, idx); } |
| RyoheiHagimoto | 0:0e0631af0305 | 2989 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2990 | template<typename _Tp> inline SeqIterator<_Tp> Seq<_Tp>::begin() const |
| RyoheiHagimoto | 0:0e0631af0305 | 2991 | { return SeqIterator<_Tp>(*this); } |
| RyoheiHagimoto | 0:0e0631af0305 | 2992 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2993 | template<typename _Tp> inline SeqIterator<_Tp> Seq<_Tp>::end() const |
| RyoheiHagimoto | 0:0e0631af0305 | 2994 | { return SeqIterator<_Tp>(*this, true); } |
| RyoheiHagimoto | 0:0e0631af0305 | 2995 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2996 | template<typename _Tp> inline size_t Seq<_Tp>::size() const |
| RyoheiHagimoto | 0:0e0631af0305 | 2997 | { return seq ? seq->total : 0; } |
| RyoheiHagimoto | 0:0e0631af0305 | 2998 | |
| RyoheiHagimoto | 0:0e0631af0305 | 2999 | template<typename _Tp> inline int Seq<_Tp>::type() const |
| RyoheiHagimoto | 0:0e0631af0305 | 3000 | { return seq ? CV_MAT_TYPE(seq->flags) : 0; } |
| RyoheiHagimoto | 0:0e0631af0305 | 3001 | |
| RyoheiHagimoto | 0:0e0631af0305 | 3002 | template<typename _Tp> inline int Seq<_Tp>::depth() const |
| RyoheiHagimoto | 0:0e0631af0305 | 3003 | { return seq ? CV_MAT_DEPTH(seq->flags) : 0; } |
| RyoheiHagimoto | 0:0e0631af0305 | 3004 | |
| RyoheiHagimoto | 0:0e0631af0305 | 3005 | template<typename _Tp> inline int Seq<_Tp>::channels() const |
| RyoheiHagimoto | 0:0e0631af0305 | 3006 | { return seq ? CV_MAT_CN(seq->flags) : 0; } |
| RyoheiHagimoto | 0:0e0631af0305 | 3007 | |
| RyoheiHagimoto | 0:0e0631af0305 | 3008 | template<typename _Tp> inline size_t Seq<_Tp>::elemSize() const |
| RyoheiHagimoto | 0:0e0631af0305 | 3009 | { return seq ? seq->elem_size : 0; } |
| RyoheiHagimoto | 0:0e0631af0305 | 3010 | |
| RyoheiHagimoto | 0:0e0631af0305 | 3011 | template<typename _Tp> inline size_t Seq<_Tp>::index(const _Tp& elem) const |
| RyoheiHagimoto | 0:0e0631af0305 | 3012 | { return cvSeqElemIdx(seq, &elem); } |
| RyoheiHagimoto | 0:0e0631af0305 | 3013 | |
| RyoheiHagimoto | 0:0e0631af0305 | 3014 | template<typename _Tp> inline void Seq<_Tp>::push_back(const _Tp& elem) |
| RyoheiHagimoto | 0:0e0631af0305 | 3015 | { cvSeqPush(seq, &elem); } |
| RyoheiHagimoto | 0:0e0631af0305 | 3016 | |
| RyoheiHagimoto | 0:0e0631af0305 | 3017 | template<typename _Tp> inline void Seq<_Tp>::push_front(const _Tp& elem) |
| RyoheiHagimoto | 0:0e0631af0305 | 3018 | { cvSeqPushFront(seq, &elem); } |
| RyoheiHagimoto | 0:0e0631af0305 | 3019 | |
| RyoheiHagimoto | 0:0e0631af0305 | 3020 | template<typename _Tp> inline void Seq<_Tp>::push_back(const _Tp* elem, size_t count) |
| RyoheiHagimoto | 0:0e0631af0305 | 3021 | { cvSeqPushMulti(seq, elem, (int)count, 0); } |
| RyoheiHagimoto | 0:0e0631af0305 | 3022 | |
| RyoheiHagimoto | 0:0e0631af0305 | 3023 | template<typename _Tp> inline void Seq<_Tp>::push_front(const _Tp* elem, size_t count) |
| RyoheiHagimoto | 0:0e0631af0305 | 3024 | { cvSeqPushMulti(seq, elem, (int)count, 1); } |
| RyoheiHagimoto | 0:0e0631af0305 | 3025 | |
| RyoheiHagimoto | 0:0e0631af0305 | 3026 | template<typename _Tp> inline _Tp& Seq<_Tp>::back() |
| RyoheiHagimoto | 0:0e0631af0305 | 3027 | { return *(_Tp*)getSeqElem(seq, -1); } |
| RyoheiHagimoto | 0:0e0631af0305 | 3028 | |
| RyoheiHagimoto | 0:0e0631af0305 | 3029 | template<typename _Tp> inline const _Tp& Seq<_Tp>::back() const |
| RyoheiHagimoto | 0:0e0631af0305 | 3030 | { return *(const _Tp*)getSeqElem(seq, -1); } |
| RyoheiHagimoto | 0:0e0631af0305 | 3031 | |
| RyoheiHagimoto | 0:0e0631af0305 | 3032 | template<typename _Tp> inline _Tp& Seq<_Tp>::front() |
| RyoheiHagimoto | 0:0e0631af0305 | 3033 | { return *(_Tp*)getSeqElem(seq, 0); } |
| RyoheiHagimoto | 0:0e0631af0305 | 3034 | |
| RyoheiHagimoto | 0:0e0631af0305 | 3035 | template<typename _Tp> inline const _Tp& Seq<_Tp>::front() const |
| RyoheiHagimoto | 0:0e0631af0305 | 3036 | { return *(const _Tp*)getSeqElem(seq, 0); } |
| RyoheiHagimoto | 0:0e0631af0305 | 3037 | |
| RyoheiHagimoto | 0:0e0631af0305 | 3038 | template<typename _Tp> inline bool Seq<_Tp>::empty() const |
| RyoheiHagimoto | 0:0e0631af0305 | 3039 | { return !seq || seq->total == 0; } |
| RyoheiHagimoto | 0:0e0631af0305 | 3040 | |
| RyoheiHagimoto | 0:0e0631af0305 | 3041 | template<typename _Tp> inline void Seq<_Tp>::clear() |
| RyoheiHagimoto | 0:0e0631af0305 | 3042 | { if(seq) clearSeq(seq); } |
| RyoheiHagimoto | 0:0e0631af0305 | 3043 | |
| RyoheiHagimoto | 0:0e0631af0305 | 3044 | template<typename _Tp> inline void Seq<_Tp>::pop_back() |
| RyoheiHagimoto | 0:0e0631af0305 | 3045 | { seqPop(seq); } |
| RyoheiHagimoto | 0:0e0631af0305 | 3046 | |
| RyoheiHagimoto | 0:0e0631af0305 | 3047 | template<typename _Tp> inline void Seq<_Tp>::pop_front() |
| RyoheiHagimoto | 0:0e0631af0305 | 3048 | { seqPopFront(seq); } |
| RyoheiHagimoto | 0:0e0631af0305 | 3049 | |
| RyoheiHagimoto | 0:0e0631af0305 | 3050 | template<typename _Tp> inline void Seq<_Tp>::pop_back(_Tp* elem, size_t count) |
| RyoheiHagimoto | 0:0e0631af0305 | 3051 | { seqPopMulti(seq, elem, (int)count, 0); } |
| RyoheiHagimoto | 0:0e0631af0305 | 3052 | |
| RyoheiHagimoto | 0:0e0631af0305 | 3053 | template<typename _Tp> inline void Seq<_Tp>::pop_front(_Tp* elem, size_t count) |
| RyoheiHagimoto | 0:0e0631af0305 | 3054 | { seqPopMulti(seq, elem, (int)count, 1); } |
| RyoheiHagimoto | 0:0e0631af0305 | 3055 | |
| RyoheiHagimoto | 0:0e0631af0305 | 3056 | template<typename _Tp> inline void Seq<_Tp>::insert(int idx, const _Tp& elem) |
| RyoheiHagimoto | 0:0e0631af0305 | 3057 | { seqInsert(seq, idx, &elem); } |
| RyoheiHagimoto | 0:0e0631af0305 | 3058 | |
| RyoheiHagimoto | 0:0e0631af0305 | 3059 | template<typename _Tp> inline void Seq<_Tp>::insert(int idx, const _Tp* elems, size_t count) |
| RyoheiHagimoto | 0:0e0631af0305 | 3060 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 3061 | CvMat m = cvMat(1, count, DataType<_Tp>::type, elems); |
| RyoheiHagimoto | 0:0e0631af0305 | 3062 | seqInsertSlice(seq, idx, &m); |
| RyoheiHagimoto | 0:0e0631af0305 | 3063 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 3064 | |
| RyoheiHagimoto | 0:0e0631af0305 | 3065 | template<typename _Tp> inline void Seq<_Tp>::remove(int idx) |
| RyoheiHagimoto | 0:0e0631af0305 | 3066 | { seqRemove(seq, idx); } |
| RyoheiHagimoto | 0:0e0631af0305 | 3067 | |
| RyoheiHagimoto | 0:0e0631af0305 | 3068 | template<typename _Tp> inline void Seq<_Tp>::remove(const Range& r) |
| RyoheiHagimoto | 0:0e0631af0305 | 3069 | { seqRemoveSlice(seq, cvSlice(r.start, r.end)); } |
| RyoheiHagimoto | 0:0e0631af0305 | 3070 | |
| RyoheiHagimoto | 0:0e0631af0305 | 3071 | template<typename _Tp> inline void Seq<_Tp>::copyTo(std::vector<_Tp>& vec, const Range& range) const |
| RyoheiHagimoto | 0:0e0631af0305 | 3072 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 3073 | size_t len = !seq ? 0 : range == Range::all() ? seq->total : range.end - range.start; |
| RyoheiHagimoto | 0:0e0631af0305 | 3074 | vec.resize(len); |
| RyoheiHagimoto | 0:0e0631af0305 | 3075 | if( seq && len ) |
| RyoheiHagimoto | 0:0e0631af0305 | 3076 | cvCvtSeqToArray(seq, &vec[0], range); |
| RyoheiHagimoto | 0:0e0631af0305 | 3077 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 3078 | |
| RyoheiHagimoto | 0:0e0631af0305 | 3079 | template<typename _Tp> inline Seq<_Tp>::operator std::vector<_Tp>() const |
| RyoheiHagimoto | 0:0e0631af0305 | 3080 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 3081 | std::vector<_Tp> vec; |
| RyoheiHagimoto | 0:0e0631af0305 | 3082 | copyTo(vec); |
| RyoheiHagimoto | 0:0e0631af0305 | 3083 | return vec; |
| RyoheiHagimoto | 0:0e0631af0305 | 3084 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 3085 | |
| RyoheiHagimoto | 0:0e0631af0305 | 3086 | template<typename _Tp> inline SeqIterator<_Tp>::SeqIterator() |
| RyoheiHagimoto | 0:0e0631af0305 | 3087 | { memset(this, 0, sizeof(*this)); } |
| RyoheiHagimoto | 0:0e0631af0305 | 3088 | |
| RyoheiHagimoto | 0:0e0631af0305 | 3089 | template<typename _Tp> inline SeqIterator<_Tp>::SeqIterator(const Seq<_Tp>& _seq, bool seekEnd) |
| RyoheiHagimoto | 0:0e0631af0305 | 3090 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 3091 | cvStartReadSeq(_seq.seq, this); |
| RyoheiHagimoto | 0:0e0631af0305 | 3092 | index = seekEnd ? _seq.seq->total : 0; |
| RyoheiHagimoto | 0:0e0631af0305 | 3093 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 3094 | |
| RyoheiHagimoto | 0:0e0631af0305 | 3095 | template<typename _Tp> inline void SeqIterator<_Tp>::seek(size_t pos) |
| RyoheiHagimoto | 0:0e0631af0305 | 3096 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 3097 | cvSetSeqReaderPos(this, (int)pos, false); |
| RyoheiHagimoto | 0:0e0631af0305 | 3098 | index = pos; |
| RyoheiHagimoto | 0:0e0631af0305 | 3099 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 3100 | |
| RyoheiHagimoto | 0:0e0631af0305 | 3101 | template<typename _Tp> inline size_t SeqIterator<_Tp>::tell() const |
| RyoheiHagimoto | 0:0e0631af0305 | 3102 | { return index; } |
| RyoheiHagimoto | 0:0e0631af0305 | 3103 | |
| RyoheiHagimoto | 0:0e0631af0305 | 3104 | template<typename _Tp> inline _Tp& SeqIterator<_Tp>::operator *() |
| RyoheiHagimoto | 0:0e0631af0305 | 3105 | { return *(_Tp*)ptr; } |
| RyoheiHagimoto | 0:0e0631af0305 | 3106 | |
| RyoheiHagimoto | 0:0e0631af0305 | 3107 | template<typename _Tp> inline const _Tp& SeqIterator<_Tp>::operator *() const |
| RyoheiHagimoto | 0:0e0631af0305 | 3108 | { return *(const _Tp*)ptr; } |
| RyoheiHagimoto | 0:0e0631af0305 | 3109 | |
| RyoheiHagimoto | 0:0e0631af0305 | 3110 | template<typename _Tp> inline SeqIterator<_Tp>& SeqIterator<_Tp>::operator ++() |
| RyoheiHagimoto | 0:0e0631af0305 | 3111 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 3112 | CV_NEXT_SEQ_ELEM(sizeof(_Tp), *this); |
| RyoheiHagimoto | 0:0e0631af0305 | 3113 | if( ++index >= seq->total*2 ) |
| RyoheiHagimoto | 0:0e0631af0305 | 3114 | index = 0; |
| RyoheiHagimoto | 0:0e0631af0305 | 3115 | return *this; |
| RyoheiHagimoto | 0:0e0631af0305 | 3116 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 3117 | |
| RyoheiHagimoto | 0:0e0631af0305 | 3118 | template<typename _Tp> inline SeqIterator<_Tp> SeqIterator<_Tp>::operator ++(int) const |
| RyoheiHagimoto | 0:0e0631af0305 | 3119 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 3120 | SeqIterator<_Tp> it = *this; |
| RyoheiHagimoto | 0:0e0631af0305 | 3121 | ++*this; |
| RyoheiHagimoto | 0:0e0631af0305 | 3122 | return it; |
| RyoheiHagimoto | 0:0e0631af0305 | 3123 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 3124 | |
| RyoheiHagimoto | 0:0e0631af0305 | 3125 | template<typename _Tp> inline SeqIterator<_Tp>& SeqIterator<_Tp>::operator --() |
| RyoheiHagimoto | 0:0e0631af0305 | 3126 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 3127 | CV_PREV_SEQ_ELEM(sizeof(_Tp), *this); |
| RyoheiHagimoto | 0:0e0631af0305 | 3128 | if( --index < 0 ) |
| RyoheiHagimoto | 0:0e0631af0305 | 3129 | index = seq->total*2-1; |
| RyoheiHagimoto | 0:0e0631af0305 | 3130 | return *this; |
| RyoheiHagimoto | 0:0e0631af0305 | 3131 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 3132 | |
| RyoheiHagimoto | 0:0e0631af0305 | 3133 | template<typename _Tp> inline SeqIterator<_Tp> SeqIterator<_Tp>::operator --(int) const |
| RyoheiHagimoto | 0:0e0631af0305 | 3134 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 3135 | SeqIterator<_Tp> it = *this; |
| RyoheiHagimoto | 0:0e0631af0305 | 3136 | --*this; |
| RyoheiHagimoto | 0:0e0631af0305 | 3137 | return it; |
| RyoheiHagimoto | 0:0e0631af0305 | 3138 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 3139 | |
| RyoheiHagimoto | 0:0e0631af0305 | 3140 | template<typename _Tp> inline SeqIterator<_Tp>& SeqIterator<_Tp>::operator +=(int delta) |
| RyoheiHagimoto | 0:0e0631af0305 | 3141 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 3142 | cvSetSeqReaderPos(this, delta, 1); |
| RyoheiHagimoto | 0:0e0631af0305 | 3143 | index += delta; |
| RyoheiHagimoto | 0:0e0631af0305 | 3144 | int n = seq->total*2; |
| RyoheiHagimoto | 0:0e0631af0305 | 3145 | if( index < 0 ) |
| RyoheiHagimoto | 0:0e0631af0305 | 3146 | index += n; |
| RyoheiHagimoto | 0:0e0631af0305 | 3147 | if( index >= n ) |
| RyoheiHagimoto | 0:0e0631af0305 | 3148 | index -= n; |
| RyoheiHagimoto | 0:0e0631af0305 | 3149 | return *this; |
| RyoheiHagimoto | 0:0e0631af0305 | 3150 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 3151 | |
| RyoheiHagimoto | 0:0e0631af0305 | 3152 | template<typename _Tp> inline SeqIterator<_Tp>& SeqIterator<_Tp>::operator -=(int delta) |
| RyoheiHagimoto | 0:0e0631af0305 | 3153 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 3154 | return (*this += -delta); |
| RyoheiHagimoto | 0:0e0631af0305 | 3155 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 3156 | |
| RyoheiHagimoto | 0:0e0631af0305 | 3157 | template<typename _Tp> inline ptrdiff_t operator - (const SeqIterator<_Tp>& a, |
| RyoheiHagimoto | 0:0e0631af0305 | 3158 | const SeqIterator<_Tp>& b) |
| RyoheiHagimoto | 0:0e0631af0305 | 3159 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 3160 | ptrdiff_t delta = a.index - b.index, n = a.seq->total; |
| RyoheiHagimoto | 0:0e0631af0305 | 3161 | if( delta > n || delta < -n ) |
| RyoheiHagimoto | 0:0e0631af0305 | 3162 | delta += delta < 0 ? n : -n; |
| RyoheiHagimoto | 0:0e0631af0305 | 3163 | return delta; |
| RyoheiHagimoto | 0:0e0631af0305 | 3164 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 3165 | |
| RyoheiHagimoto | 0:0e0631af0305 | 3166 | template<typename _Tp> inline bool operator == (const SeqIterator<_Tp>& a, |
| RyoheiHagimoto | 0:0e0631af0305 | 3167 | const SeqIterator<_Tp>& b) |
| RyoheiHagimoto | 0:0e0631af0305 | 3168 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 3169 | return a.seq == b.seq && a.index == b.index; |
| RyoheiHagimoto | 0:0e0631af0305 | 3170 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 3171 | |
| RyoheiHagimoto | 0:0e0631af0305 | 3172 | template<typename _Tp> inline bool operator != (const SeqIterator<_Tp>& a, |
| RyoheiHagimoto | 0:0e0631af0305 | 3173 | const SeqIterator<_Tp>& b) |
| RyoheiHagimoto | 0:0e0631af0305 | 3174 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 3175 | return !(a == b); |
| RyoheiHagimoto | 0:0e0631af0305 | 3176 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 3177 | |
| RyoheiHagimoto | 0:0e0631af0305 | 3178 | //! @} |
| RyoheiHagimoto | 0:0e0631af0305 | 3179 | |
| RyoheiHagimoto | 0:0e0631af0305 | 3180 | } // cv |
| RyoheiHagimoto | 0:0e0631af0305 | 3181 | |
| RyoheiHagimoto | 0:0e0631af0305 | 3182 | #endif |
| RyoheiHagimoto | 0:0e0631af0305 | 3183 | |
| RyoheiHagimoto | 0:0e0631af0305 | 3184 | #endif |