From 4714f021ae6f91e06e81ef74087efdcd633afb54 Mon Sep 17 00:00:00 2001 From: Laentir Valetov Date: Fri, 10 Oct 2014 23:08:51 +0400 Subject: [PATCH] Update function def Signed-off-by: Laentir Valetov --- .gitignore | 6 +- .../vclColorTracking2/vclColorTracking2.dproj | 2 +- source/ocv.calib3d_c.pas | 129 +- source/ocv.core_c.pas | 169 +- source/ocv.imgproc.pas | 4 +- source/ocv.legacy.pas | 2433 +++++++++-------- source/ocv.tracking_c.pas | 530 ++-- 7 files changed, 1653 insertions(+), 1620 deletions(-) diff --git a/.gitignore b/.gitignore index 0a57610..b2068f3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,13 @@ +buildtest __history Debug Release ipch lib /resource/result/*.* +/bin/Win32/*.exe +/bin/Win64/*.exe + *.ini *.bsc *.sdf @@ -12,8 +16,6 @@ lib *.~* *.dcu *.local -/bin/Win32/*.exe -/bin/Win64/*.exe *.dsk *.identcache *.tvsconfig diff --git a/samples/VCLDemo/vclColorTracking2/vclColorTracking2.dproj b/samples/VCLDemo/vclColorTracking2/vclColorTracking2.dproj index a715161..f3da849 100644 --- a/samples/VCLDemo/vclColorTracking2/vclColorTracking2.dproj +++ b/samples/VCLDemo/vclColorTracking2/vclColorTracking2.dproj @@ -116,7 +116,7 @@ .\$(Platform)\$(Config) true 1033 - CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=;LastCompiledTime=06.10.2014 22:47:34 + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=;LastCompiledTime=06.10.2014 22:49:19 true diff --git a/source/ocv.calib3d_c.pas b/source/ocv.calib3d_c.pas index 1b61912..a708c2e 100644 --- a/source/ocv.calib3d_c.pas +++ b/source/ocv.calib3d_c.pas @@ -1,87 +1,48 @@ -// --------------------------------- OpenCV license.txt --------------------------- -// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. - // - // By downloading, copying, installing or using the software you agree to this license. - // If you do not agree to this license, do not download, install, - // copy or use the software. - // - // - // License Agreement - // For Open Source Computer Vision Library - // - // Copyright (C) 2000-2008, Intel Corporation, all rights reserved. - // Copyright (C) 2009, Willow Garage Inc., all rights reserved. - // Third party copyrights are property of their respective owners. - // - // Redistribution and use in source and binary forms, with or without modification, - // are permitted provided that the following conditions are met: - // - // * Redistribution's of source code must retain the above copyright notice, - // this list of conditions and the following disclaimer. - // - // * Redistribution's in binary form must reproduce the above copyright notice, - // this list of conditions and the following disclaimer in the documentation - // and/or other materials provided with the distribution. - // - // * The name of the copyright holders may not be used to endorse or promote products - // derived from this software without specific prior written permission. - // - // This software is provided by the copyright holders and contributors "as is" and - // any express or implied warranties, including, but not limited to, the implied - // warranties of merchantability and fitness for a particular purpose are disclaimed. - // In no event shall the Intel Corporation or contributors be liable for any direct, - // indirect, incidental, special, exemplary, or consequential damages - // (including, but not limited to, procurement of substitute goods or services; - // loss of use, data, or profits; or business interruption) however caused - // and on any theory of liability, whether in contract, strict liability, - // or tort (including negligence or otherwise) arising in any way out of - // the use of this software, even if advised of the possibility of such damage. - -//************************************************************************************************** - // Project Delphi-OpenCV - // ************************************************************************************************** - // Contributor: - // Laentir Valetov - // email:laex@bk.ru - // Mikhail Grigorev - // email:sleuthound@gmail.com - // ************************************************************************************************** - // You may retrieve the latest version of this file at the GitHub, - // located at git://github.com/Laex/Delphi-OpenCV.git - // ************************************************************************************************** - // License: - // The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); - // you may not use this file except in compliance with the License. You may obtain a copy of the - // License at http://www.mozilla.org/MPL/ - // - // Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF - // ANY KIND, either express or implied. See the License for the specific language governing rights - // and limitations under the License. - // - // Alternatively, the contents of this file may be used under the terms of the - // GNU Lesser General Public License (the "LGPL License"), in which case the - // provisions of the LGPL License are applicable instead of those above. - // If you wish to allow use of your version of this file only under the terms - // of the LGPL License and not to allow others to use your version of this file - // under the MPL, indicate your decision by deleting the provisions above and - // replace them with the notice and other provisions required by the LGPL - // License. If you do not delete the provisions above, a recipient may use - // your version of this file under either the MPL or the LGPL License. - // - // For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html - // ************************************************************************************************** - // Warning: Using Delphi XE3 syntax! - // ************************************************************************************************** - // The Initial Developer of the Original Code: - // OpenCV: open source computer vision library - // Homepage: http://ocv.org - // Online docs: http://docs.ocv.org - // Q&A forum: http://answers.ocv.org - // Dev zone: http://code.ocv.org - // ************************************************************************************************** - // Original file: - // opencv\modules\calib3d\include\opencv2\calib3d\calib3d_c.h - // ************************************************************************************************* +// ************************************************************************************************** +// Project Delphi-OpenCV +// ************************************************************************************************** +// Contributor: +// Laentir Valetov +// email:laex@bk.ru +// Mikhail Grigorev +// email:sleuthound@gmail.com +// ************************************************************************************************** +// You may retrieve the latest version of this file at the GitHub, +// located at git://github.com/Laex/Delphi-OpenCV.git +// ************************************************************************************************** +// License: +// The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); +// you may not use this file except in compliance with the License. You may obtain a copy of the +// License at http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF +// ANY KIND, either express or implied. See the License for the specific language governing rights +// and limitations under the License. +// +// Alternatively, the contents of this file may be used under the terms of the +// GNU Lesser General Public License (the "LGPL License"), in which case the +// provisions of the LGPL License are applicable instead of those above. +// If you wish to allow use of your version of this file only under the terms +// of the LGPL License and not to allow others to use your version of this file +// under the MPL, indicate your decision by deleting the provisions above and +// replace them with the notice and other provisions required by the LGPL +// License. If you do not delete the provisions above, a recipient may use +// your version of this file under either the MPL or the LGPL License. +// +// For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html +// ************************************************************************************************** +// Warning: Using Delphi XE3 syntax! +// ************************************************************************************************** +// The Initial Developer of the Original Code: +// OpenCV: open source computer vision library +// Homepage: http://ocv.org +// Online docs: http://docs.ocv.org +// Q&A forum: http://answers.ocv.org +// Dev zone: http://code.ocv.org +// ************************************************************************************************** +// Original file: +// opencv\modules\calib3d\include\opencv2\calib3d\calib3d_c.h +// ************************************************************************************************* {$IFDEF DEBUG} {$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q+,R+,S-,T-,U-,V+,W+,X+,Y+,Z1} diff --git a/source/ocv.core_c.pas b/source/ocv.core_c.pas index 8c3c276..f617119 100644 --- a/source/ocv.core_c.pas +++ b/source/ocv.core_c.pas @@ -1,42 +1,3 @@ -// --------------------------------- OpenCV license.txt --------------------------- -// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. -// -// By downloading, copying, installing or using the software you agree to this license. -// If you do not agree to this license, do not download, install, -// copy or use the software. -// -// -// License Agreement -// For Open Source Computer Vision Library -// -// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. -// Copyright (C) 2009, Willow Garage Inc., all rights reserved. -// Third party copyrights are property of their respective owners. -// -// Redistribution and use in source and binary forms, with or without modification, -// are permitted provided that the following conditions are met: -// -// * Redistribution's of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// -// * Redistribution's in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// * The name of the copyright holders may not be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// This software is provided by the copyright holders and contributors "as is" and -// any express or implied warranties, including, but not limited to, the implied -// warranties of merchantability and fitness for a particular purpose are disclaimed. -// In no event shall the Intel Corporation or contributors be liable for any direct, -// indirect, incidental, special, exemplary, or consequential damages -// (including, but not limited to, procurement of substitute goods or services; -// loss of use, data, or profits; or business interruption) however caused -// and on any theory of liability, whether in contract, strict liability, -// or tort (including negligence or otherwise) arising in any way out of -// the use of this software, even if advised of the possibility of such damage. - // ************************************************************************************************** // Project Delphi-OpenCV // ************************************************************************************************** @@ -112,6 +73,7 @@ uses (as well as other OpenCV functions that call cvAlloc) raises an error. } +{$EXTERNALSYM cvAlloc} function cvAlloc(size: NativeUInt): Pointer; cdecl; { wrapper. @@ -120,11 +82,14 @@ function cvAlloc(size: NativeUInt): Pointer; cdecl; to clear cPointer to the data after releasing it. Passing cPointer to 0 cPointer is Ok: nothing happens in this } +{$EXTERNALSYM cvFree_} procedure cvFree_(ptr: Pointer); cdecl; +{$EXTERNALSYM cvFree} procedure cvFree(var ptr); {$IFDEF USE_INLINE}inline; {$ENDIF} { Allocates and initializes IplImage header CVAPI(IplImage*) cvCreateImageHeader( CvSize size, int depth, int channels ); } +{$EXTERNALSYM cvCreateImageHeader} function cvCreateImageHeader(size: TCvSize; depth: Integer; channels: Integer): pIplImage; cdecl; { Inializes IplImage header @@ -132,58 +97,69 @@ function cvCreateImageHeader(size: TCvSize; depth: Integer; channels: Integer): int channels, int origin CV_DEFAULT(0), int align CV_DEFAULT(4)); } +{$EXTERNALSYM cvInitImageHeader} function cvInitImageHeader(image: pIplImage; size: TCvSize; depth: Integer; channels: Integer; origin: Integer = 0; align: Integer = 4): pIplImage; cdecl; { Creates IPL image (header and data CVAPI(IplImage*) cvCreateImage( CvSize size, int depth, int channels ); } +{$EXTERNALSYM cvCreateImage} function cvCreateImage(size: TCvSize; depth, channels: Integer): pIplImage; cdecl; { Releases (i.e. deallocates) IPL image header CVAPI(void) cvReleaseImageHeader( IplImage** image ); } +{$EXTERNALSYM cvReleaseImageHeader} procedure cvReleaseImageHeader(var image: pIplImage); cdecl; { Releases IPL image header and data CVAPI(void) cvReleaseImage( IplImage** image ); } +{$EXTERNALSYM cvReleaseImage} procedure cvReleaseImage(var image: pIplImage); cdecl; { Creates a copy of IPL image (widthStep may differ) CVAPI(IplImage*) cvCloneImage( const IplImage* image ); } +{$EXTERNALSYM cvCloneImage} function cvCloneImage(const image: pIplImage): pIplImage; cdecl; { Sets a Channel Of Interest (only a few functions support COI) - use cvCopy to extract the selected channel and/or put it back CVAPI(void) cvSetImageCOI( IplImage* image, int coi ); } +{$EXTERNALSYM cvSetImageCOI} procedure cvSetImageCOI(image: pIplImage; coi: Integer); cdecl; { Retrieves image Channel Of Interest CVAPI(int) cvGetImageCOI( const IplImage* image ); } +{$EXTERNALSYM cvGetImageCOI} function cvGetImageCOI(const image: pIplImage): Integer; cdecl; { Sets image ROI (region of interest) (COI is not changed) CVAPI(void) cvSetImageROI( IplImage* image, CvRect rect ); } +{$EXTERNALSYM cvSetImageROI} procedure cvSetImageROI(image: pIplImage; rect: TCvRect); cdecl; { Resets image ROI and COI CVAPI(void) cvResetImageROI( IplImage* image ); } +{$EXTERNALSYM cvResetImageROI} procedure cvResetImageROI(image: pIplImage); cdecl; { Retrieves image ROI CVAPI(CvRect) cvGetImageROI( const IplImage* image ); } +{$EXTERNALSYM cvGetImageROI} function cvGetImageROI(const image: pIplImage): TCvRect; cdecl; { Allocates and initalizes CvMat header CVAPI(CvMat*) cvCreateMatHeader( int rows, int cols, int type ); } +{$EXTERNALSYM cvCreateMatHeader} function cvCreateMatHeader(rows: Integer; cols: Integer; cType: Integer): TCvMat; cdecl; const @@ -194,18 +170,21 @@ const int type, void* data CV_DEFAULT(NULL), int step CV_DEFAULT(CV_AUTOSTEP) ); } +{$EXTERNALSYM cvInitMatHeader} function cvInitMatHeader(mat: pCvMat; rows: Integer; cols: Integer; _type: Integer; data: Pointer = nil; step: Integer = CV_AUTOSTEP): pCvMat; cdecl; { Allocates and initializes CvMat header and allocates data CVAPI(CvMat*) cvCreateMat( int rows, int cols, int type ); } +{$EXTERNALSYM cvCreateMat} function cvCreateMat(rows, cols, cType: Integer): pCvMat; cdecl; { Releases CvMat header and deallocates matrix data (reference counting is used for data) CVAPI(void) cvReleaseMat( CvMat** mat ); } +{$EXTERNALSYM cvReleaseMat} procedure cvReleaseMat(var mat: pCvMat); cdecl; // Decrements CvMat data reference counter and deallocates the data if @@ -252,6 +231,7 @@ procedure cvReleaseMat(var mat: pCvMat); cdecl; { Creates an exact copy of the input matrix (except, may be, step value) CVAPI(CvMat*) cvCloneMat( const CvMat* mat ); } +{$EXTERNALSYM cvCloneMat} function cvCloneMat(const mat: pCvMat): pCvMat; cdecl; { Makes a new matrix from subrectangle of input array. @@ -259,6 +239,7 @@ function cvCloneMat(const mat: pCvMat): pCvMat; cdecl; CVAPI(CvMat*) cvGetSubRect( const pCvArr* arr, CvMat* submat, CvRect rect ); #define cvGetSubArr cvGetSubRect } +{$EXTERNALSYM cvGetSubRect} function cvGetSubRect(arr: pCvArr; submat: pCvArr; rect: TCvRect): pCvMat; cdecl; { Selects row span of the input array: arr(start_row:delta_row:end_row,:) @@ -267,25 +248,29 @@ function cvGetSubRect(arr: pCvArr; submat: pCvArr; rect: TCvRect): pCvMat; cdecl int start_row, int end_row, int delta_row CV_DEFAULT(1)); } +{$EXTERNALSYM cvGetRows} function cvGetRows(const arr: pCvArr; submat: pCvMat; start_row, end_row: Integer; delta_row: Integer = 1) : pCvMat; cdecl; -// CV_INLINE CvMat* cvGetRow( const pCvArr* arr, CvMat* submat, int row ) -// { -// return cvGetRows( arr, submat, row, row + 1, 1 ); -// } +(* + CV_INLINE CvMat* cvGetRow( const pCvArr* arr, CvMat* submat, int row ) + { return cvGetRows( arr, submat, row, row + 1, 1 );} +*) +{$EXTERNALSYM cvGetRow} function cvGetRow(const arr: pCvArr; submat: pCvMat; row: Integer): pCvMat; {$IFDEF USE_INLINE}inline; {$ENDIF} { Selects column span of the input array: arr(:,start_col:end_col) (end_col is not included into the span) CVAPI(CvMat*) cvGetCols( const pCvArr* arr, CvMat* submat, int start_col, int end_col ); } +{$EXTERNALSYM cvGetCols} function cvGetCols(const arr: pCvArr; submat: pCvMat; start_col, end_col: Integer): pCvMat; cdecl; -// CV_INLINE CvMat* cvGetCol( const pCvArr* arr, CvMat* submat, int col ) -// { -// return cvGetCols( arr, submat, col, col + 1 ); -// } +(* + CV_INLINE CvMat* cvGetCol( const pCvArr* arr, CvMat* submat, int col ) + {return cvGetCols( arr, submat, col, col + 1 );} +*) +{$EXTERNALSYM cvGetCol} function cvGetCol(const arr: pCvArr; submat: pCvMat; col: Integer): pCvMat; {$IFDEF USE_INLINE}inline; {$ENDIF} { Select a diagonal of the input array. (diag = 0 means the main diagonal, >0 means a diagonal above the main one, @@ -294,58 +279,70 @@ function cvGetCol(const arr: pCvArr; submat: pCvMat; col: Integer): pCvMat; {$IF CVAPI(CvMat*) cvGetDiag( const pCvArr* arr, CvMat* submat, int diag CV_DEFAULT(0)); } +{$EXTERNALSYM cvGetDiag} function cvGetDiag(const arr: pCvArr; submat: pCvMat; diag: Integer = 0): pCvMat; cdecl; { low-level scalar <-> raw data conversion functions CVAPI(void) cvScalarToRawData( const CvScalar* scalar, void* data, int type, int extend_to_12 CV_DEFAULT(0) ); } +{$EXTERNALSYM cvScalarToRawData} procedure cvScalarToRawData(const scalar: pCvScalar; data: pCvArr; cType: Integer; extend_to_12: Integer = 0); cdecl; // CVAPI(void) cvRawDataToScalar( const void* data, int type, CvScalar* scalar ); +{$EXTERNALSYM cvRawDataToScalar} procedure cvRawDataToScalar(const data: pCvArr; cType: Integer; scalar: pCvScalar); cdecl; { Allocates and initializes CvMatND header CVAPI(CvMatND*) cvCreateMatNDHeader( int dims, const int* sizes, int type ); } +{$EXTERNALSYM cvCreateMatNDHeader} function cvCreateMatNDHeader(dims: Integer; const sizes: pInteger; cType: Integer): pCvMatND; cdecl; { Allocates and initializes CvMatND header and allocates data CVAPI(CvMatND*) cvCreateMatND( int dims, const int* sizes, int type ); } +{$EXTERNALSYM cvCreateMatND} function cvCreateMatND(dims: Integer; const sizes: pInteger; cType: Integer): pCvMatND; cdecl; { Initializes preallocated CvMatND header */ CVAPI(CvMatND*) cvInitMatNDHeader( CvMatND* mat, int dims, const int* sizes, int type, void* data CV_DEFAULT(NULL) ); } +{$EXTERNALSYM cvInitMatNDHeader} function cvInitMatNDHeader(mat: pCvMatND; dims: Integer; const sizes: pInteger; cType: Integer; data: pCvArr = nil) : pCvMatND; cdecl; -// Releases CvMatND -// CV_INLINE void cvReleaseMatND( CvMatND** mat ) -// { -// cvReleaseMat( (CvMat**)mat ); -// } +(* + Releases CvMatND + + CV_INLINE void cvReleaseMatND( CvMatND** mat ) + {cvReleaseMat( (CvMat** )mat ); } +*) +{$EXTERNALSYM cvReleaseMatND} procedure cvReleaseMatND(var mat: pCvMatND); {$IFDEF USE_INLINE}inline; {$ENDIF} { Creates a copy of CvMatND (except, may be, steps) CVAPI(CvMatND*) cvCloneMatND( const CvMatND* mat ); } +{$EXTERNALSYM cvCloneMatND} function cvCloneMatND(const mat: pCvMatND): pCvMatND; cdecl; { Allocates and initializes CvSparseMat header and allocates data CVAPI(CvSparseMat*) cvCreateSparseMat( int dims, const int* sizes, int type ); } +{$EXTERNALSYM cvCreateSparseMat} function cvCreateSparseMat(dims: Integer; sizes: pInteger; cType: Integer): pCvSparseMat; cdecl; { Releases CvSparseMat CVAPI(void) cvReleaseSparseMat( CvSparseMat** mat ); } +{$EXTERNALSYM cvReleaseSparseMat} procedure cvReleaseSparseMat(mat: pCvSparseMat); cdecl; { Creates a copy of CvSparseMat (except, may be, zero items) CVAPI(CvSparseMat*) cvCloneSparseMat( const CvSparseMat* mat ); } +{$EXTERNALSYM cvCloneSparseMat} function cvCloneSparseMat(const mat: pCvSparseMat): pCvSparseMat; cdecl; { Initializes sparse array iterator @@ -353,10 +350,12 @@ function cvCloneSparseMat(const mat: pCvSparseMat): pCvSparseMat; cdecl; CVAPI(CvSparseNode*) cvInitSparseMatIterator( const CvSparseMat* mat, CvSparseMatIterator* mat_iterator ); } +{$EXTERNALSYM cvInitSparseMatIterator} function cvInitSparseMatIterator(const mat: pCvSparseMat; mat_iterator: pCvSparseMatIterator): pCvSparseNode; cdecl; // returns next sparse array node (or NULL if there is no more nodes) {$IFDEF DELPHIXE_UP} +{$EXTERNALSYM cvGetNextSparseNode} function cvGetNextSparseNode(mat_iterator: pCvSparseMatIterator): pCvSparseNode; {$IFDEF USE_INLINE}inline; {$ENDIF} {$ENDIF} @@ -376,24 +375,28 @@ const CvNArrayIterator* array_iterator, int flags CV_DEFAULT(0) ); } +{$EXTERNALSYM cvInitNArrayIterator} function cvInitNArrayIterator(count: Integer; arrs: pCvArr; const mask: pCvArr; stubs: pCvMatND; array_iterator: pCvNArrayIterator; flags: Integer = 0): Integer; cdecl; { returns zero value if iteration is finished, non-zero (slice length) otherwise */ CVAPI(int) cvNextNArraySlice( CvNArrayIterator* array_iterator ); } +{$EXTERNALSYM cvNextNArraySlice} function cvNextNArraySlice(array_iterator: pCvNArrayIterator): Integer; cdecl; { Returns type of array elements: CV_8UC1 ... CV_64FC4 ... CVAPI(int) cvGetElemType( const pCvArr* arr ); } +{$EXTERNALSYM cvGetElemType} function cvGetElemType(const arr: pCvArr): Integer; cdecl; { Retrieves number of an array dimensions and optionally sizes of the dimensions */ CVAPI(int) cvGetDims( const pCvArr* arr, int* sizes CV_DEFAULT(NULL) ); } +{$EXTERNALSYM cvGetDims} function cvGetDims(const arr: pCvArr; sizes: pInteger = nil): Integer; cdecl; { Retrieves size of a particular array dimension. @@ -401,6 +404,7 @@ function cvGetDims(const arr: pCvArr; sizes: pInteger = nil): Integer; cdecl; and cvGetDimSize(arr,1) returns number of columns (image width) */ CVAPI(int) cvGetDimSize( const pCvArr* arr, int index ); } +{$EXTERNALSYM cvGetDimSize} function cvGetDimSize(const arr: pCvArr; index: Integer): Integer; cdecl; { ptr = &arr(idx0,idx1,...). All indexes are zero-based, @@ -410,8 +414,11 @@ function cvGetDimSize(const arr: pCvArr; index: Integer): Integer; cdecl; CVAPI(uchar*) cvPtr3D( const pCvArr* arr, int idx0, int idx1, int idx2, int* type CV_DEFAULT(NULL)); } +{$EXTERNALSYM cvPtr1D} function cvPtr1D(const arr: pCvArr; idx0: Integer; cType: pInteger = nil): pCvArr; cdecl; +{$EXTERNALSYM cvPtr2D} function cvPtr2D(const arr: pCvArr; idx0, idx1: Integer; cType: pInteger = nil): pCvArr; cdecl; +{$EXTERNALSYM cvPtr3D} function cvPtr3D(const arr: pCvArr; idx0, idx1, idx2: Integer; cType: pInteger = nil): pCvArr; cdecl; { For CvMat or IplImage number of indices should be 2 @@ -422,6 +429,7 @@ function cvPtr3D(const arr: pCvArr; idx0, idx1, idx2: Integer; cType: pInteger = int create_node CV_DEFAULT(1), unsigned* precalc_hashval CV_DEFAULT(NULL)); } +{$EXTERNALSYM cvPtrND} function cvPtrND(const arr: pCvArr; idx: pInteger; cType: pInteger = nil; create_node: Integer = 1; precalc_hashval: punsigned = nil): pCvArr; cdecl; @@ -431,10 +439,14 @@ function cvPtrND(const arr: pCvArr; idx: pInteger; cType: pInteger = nil; create CVAPI(CvScalar) cvGet3D( const pCvArr* arr, int idx0, int idx1, int idx2 ); CVAPI(CvScalar) cvGetND( const pCvArr* arr, const int* idx ); } +{$EXTERNALSYM cvGet1D} function cvGet1D(const arr: pCvArr; idx0: Integer): TCvScalar; cdecl; +{$EXTERNALSYM cvGet2D} function cvGet2D(const arr: pCvMat; idx0, idx1: Integer): TCvScalar; cdecl; // function cvGet2D(const arr: pCvArr; idx0, idx1: Integer): TCvScalar; cdecl; +{$EXTERNALSYM cvGet3D} function cvGet3D(const arr: pCvArr; idx0, idx1, idx2: Integer): TCvScalar; cdecl; +{$EXTERNALSYM cvGetND} function cvGetND(const arr: pCvArr; idx: pInteger): TCvScalar; cdecl; { for 1-channel arrays @@ -443,9 +455,13 @@ function cvGetND(const arr: pCvArr; idx: pInteger): TCvScalar; cdecl; CVAPI(double) cvGetReal3D( const pCvArr* arr, int idx0, int idx1, int idx2 ); CVAPI(double) cvGetRealND( const pCvArr* arr, const int* idx ); } +{$EXTERNALSYM cvGetReal1D} function cvGetReal1D(const arr: pIplImage; idx0: Integer): double; cdecl; +{$EXTERNALSYM cvGetReal2D} function cvGetReal2D(const arr: pCvMat; idx0, idx1: Integer): double; cdecl; +{$EXTERNALSYM cvGetReal3D} function cvGetReal3D(const arr: pCvArr; idx0, idx1, idx2: Integer): double; cdecl; +{$EXTERNALSYM cvGetRealND} function cvGetRealND(const arr: pCvArr; idx: pInteger): double; cdecl; { arr(idx0,idx1,...) = value @@ -454,9 +470,13 @@ function cvGetRealND(const arr: pCvArr; idx: pInteger): double; cdecl; CVAPI(void) cvSet3D( pCvArr* arr, int idx0, int idx1, int idx2, CvScalar value ); CVAPI(void) cvSetND( pCvArr* arr, const int* idx, CvScalar value ); } +{$EXTERNALSYM cvSet1D} procedure cvSet1D(arr: pCvArr; idx0: Integer; var value: TCvScalar); cdecl; +{$EXTERNALSYM cvSet2D} procedure cvSet2D(arr: pCvArr; idx0, idx1: Integer; var value: TCvScalar); cdecl; +{$EXTERNALSYM cvSet3D} procedure cvSet3D(arr: pCvArr; idx0, idx1, idx2: Integer; var value: TCvScalar); cdecl; +{$EXTERNALSYM cvSetND} procedure cvSetND(arr: pCvArr; idx: pInteger; var value: TCvScalar); cdecl; { for 1-channel arrays */ @@ -465,15 +485,20 @@ procedure cvSetND(arr: pCvArr; idx: pInteger; var value: TCvScalar); cdecl; CVAPI(void) cvSetReal3D( pCvArr* arr, int idx0, int idx1, int idx2, double value ); CVAPI(void) cvSetRealND( pCvArr* arr, const int* idx, double value ); } +{$EXTERNALSYM cvSetReal1D} procedure cvSetReal1D(arr: pCvArr; idx0: Integer; var value: double); cdecl; +{$EXTERNALSYM cvSetReal2D} procedure cvSetReal2D(arr: pCvArr; idx0, idx1: Integer; var value: double); cdecl; +{$EXTERNALSYM cvSetReal3D} procedure cvSetReal3D(arr: pCvArr; idx0, idx1, idx2: Integer; var value: double); cdecl; +{$EXTERNALSYM cvSetRealND} procedure cvSetRealND(arr: pCvArr; idx: pInteger; var value: double); cdecl; { clears element of ND dense array, in case of sparse arrays it deletes the specified node */ CVAPI(void) cvClearND( pCvArr* arr, const int* idx ); } +{$EXTERNALSYM cvClearND} procedure cvClearND(arr: pCvArr; idx: pInteger); cdecl; { Converts pCvArr (IplImage or CvMat,...) to CvMat. @@ -485,11 +510,13 @@ procedure cvClearND(arr: pCvArr; idx: pInteger); cdecl; int* coi CV_DEFAULT(NULL), int allowND CV_DEFAULT(0)); } +{$EXTERNALSYM cvGetMat} function cvGetMat(const arr: pCvArr; header: pCvMat; coi: pInteger = nil; allowND: Integer = 0): pCvMat; cdecl; { Converts pCvArr (IplImage or CvMat) to IplImage CVAPI(IplImage*) cvGetImage( const pCvArr* arr, IplImage* image_header ); } +{$EXTERNALSYM cvGetImage} function cvGetImage(const arr: pCvArr; image_header: pIplImage): pIplImage; cdecl; { Changes a shape of multi-dimensional array. @@ -509,19 +536,23 @@ function cvGetImage(const arr: pCvArr; image_header: pIplImage): pIplImage; cdec cvReshapeMatND( (arr), sizeof(*(header)), (header), \ (new_cn), (new_dims), (new_sizes)) } +{$EXTERNALSYM cvReshapeMatND} function cvReshapeMatND(const arr: pCvArr; sizeof_header: Integer; header: pCvArr; new_cn, new_dims: Integer; new_sizes: pInteger): pCvArr; cdecl; +{$EXTERNALSYM cvReshapeND} function cvReshapeND(const arr: pCvArr; sizeof_header: Integer; header: pCvArr; new_cn, new_dims: Integer; new_sizes: pInteger): pCvArr; {$IFDEF USE_INLINE}inline; {$ENDIF} { CVAPI(CvMat*) cvReshape( const pCvArr* arr, CvMat* header, int new_cn, int new_rows CV_DEFAULT(0) ); } +{$EXTERNALSYM cvReshape} function cvReshape(const arr: pCvArr; header: pCvMat; new_cn: Integer; new_rows: Integer = 0): pCvMat; cdecl; { Repeats source 2d array several times in both horizontal and vertical direction to fill destination array CVAPI(void) cvRepeat( const pCvArr* src, pCvArr* dst ); } +{$EXTERNALSYM cvRepeat} procedure cvRepeat(src, dst: pCvArr); cdecl; { Allocates array data @@ -640,9 +671,9 @@ procedure cvConvertScaleAbs(const src: pCvArr; dst: pCvArr; scale: double = 1; s function cvCheckTermCriteria(criteria: TCvTermCriteria; default_eps: double; default_max_iters: Integer) : TCvTermCriteria; cdecl; -// *************************************************************************************** -// * Arithmetic, logic and comparison operations * -// *************************************************************************************** +{ *************************************************************************************** + * Arithmetic, logic and comparison operations * + *************************************************************************************** } { dst(mask) = src1(mask) + src2(mask) @@ -774,10 +805,9 @@ procedure cvRandArr(rng: pCvRNG; arr: pCvArr; dist_type: Integer; param1: TCvSca // CVAPI(void)cvRandShuffle(CvArr * mat, CvRNG * rng, double iter_factor CV_DEFAULT(1. )); procedure cvRandShuffle(mat: pCvArr; rng: pCvRNG; iter_factor: double = 1); cdecl; - -// (* ***************************************************************************************\ -// * Math operations * -// *************************************************************************************** *) +{ **************************************************************************************** + * Math operations * + **************************************************************************************** } // * Does cartesian->polar coordinates conversion. // Either of output components (magnitude or angle) is optional */ @@ -1061,9 +1091,9 @@ type function cvSeqPartition(const seq: pCvSeq; storage: pCvMemStorage; labels: pCvSeq; is_equal: TCvCmpFunc; userdata: Pointer): Integer; cdecl; -// **************************************************************************************** -// * Drawing * -// **************************************************************************************** +{ **************************************************************************************** + * Drawing * + **************************************************************************************** } // Following declaration is a macro definition! function CV_RGB(const r, g, B: double): TCvScalar; {$IFDEF USE_INLINE}inline; {$ENDIF} @@ -1251,11 +1281,11 @@ function cvKMeans2(const samples: pCvArr; cluster_count: Integer; labels: pCvArr attempts: Integer = 1; rng: pCvRNG = nil; flags: Integer = 0; _centers: pCvArr = nil; compactness: pDouble = nil) : Integer; cdecl; -// **************************************************************************************** -// * Data Persistence * -// **************************************************************************************** -// -// ********************************* High-level functions ********************************* +{ **************************************************************************************** + * Data Persistence * + **************************************************************************************** } + +{ ********************************* High-level functions ********************************* } { opens existing or creates new file storage CVAPI(CvFileStorage*) cvOpenFileStorage( const char* filename, CvMemStorage* memstorage, @@ -1314,8 +1344,7 @@ function cvRead(fs: pCvFileStorage; node: pCvFileNode; attributes: pCvAttrList = function cvReadByName(fs: pCvFileStorage; const map: pCvFileNode; const name: pCvChar; attributes: pCvAttrList = nil): Pointer; - -// *********************************** Adding own types ***********************************/ +{ *********************************** Adding own types *********************************** } // * universal functions */ // CVAPI(void) cvRelease( void** struct_ptr ); @@ -1341,7 +1370,7 @@ procedure cvSave(const filename: pCvChar; const struct_ptr: Pointer; const name: function cvLoad(const filename: pCvChar; memstorage: pCvMemStorage = Nil; const name: pCvChar = nil; const real_name: ppChar = nil): Pointer; cdecl; -// *********************************** Measuring Execution Time ***************************/ +{ *********************************** Measuring Execution Time *************************** } { helper functions for RNG initialization and accurate time measurement: uses internal clock counter on x86 } diff --git a/source/ocv.imgproc.pas b/source/ocv.imgproc.pas index 22bf14a..a61d681 100644 --- a/source/ocv.imgproc.pas +++ b/source/ocv.imgproc.pas @@ -276,7 +276,7 @@ function getStructuringElement(shape: Integer; ksize: TccvSize): TccvMat; overlo // ! returns "magic" border value for erosion and dilation. It is automatically transformed to Scalar::all(-DBL_MAX) for dilation. // static inline Scalar morphologyDefaultBorderValue() { return Scalar::all(DBL_MAX); } -function morphologyDefaultBorderValue: TccvScalar; inline; +function morphologyDefaultBorderValue: TccvScalar; implementation @@ -286,7 +286,7 @@ Var _morphologyDefaultBorderValue: TccvScalar = nil; // static inline Scalar morphologyDefaultBorderValue() { return Scalar::all(DBL_MAX); } -function morphologyDefaultBorderValue: TccvScalar; inline; +function morphologyDefaultBorderValue: TccvScalar; begin if not Assigned(_morphologyDefaultBorderValue) then _morphologyDefaultBorderValue := TccvScalar.Create(0, 0); diff --git a/source/ocv.legacy.pas b/source/ocv.legacy.pas index 907c9cb..6a24ba5 100644 --- a/source/ocv.legacy.pas +++ b/source/ocv.legacy.pas @@ -1,87 +1,48 @@ -// --------------------------------- OpenCV license.txt --------------------------- -// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. - // - // By downloading, copying, installing or using the software you agree to this license. - // If you do not agree to this license, do not download, install, - // copy or use the software. - // - // - // License Agreement - // For Open Source Computer Vision Library - // - // Copyright (C) 2000-2008, Intel Corporation, all rights reserved. - // Copyright (C) 2009, Willow Garage Inc., all rights reserved. - // Third party copyrights are property of their respective owners. - // - // Redistribution and use in source and binary forms, with or without modification, - // are permitted provided that the following conditions are met: - // - // * Redistribution's of source code must retain the above copyright notice, - // this list of conditions and the following disclaimer. - // - // * Redistribution's in binary form must reproduce the above copyright notice, - // this list of conditions and the following disclaimer in the documentation - // and/or other materials provided with the distribution. - // - // * The name of the copyright holders may not be used to endorse or promote products - // derived from this software without specific prior written permission. - // - // This software is provided by the copyright holders and contributors "as is" and - // any express or implied warranties, including, but not limited to, the implied - // warranties of merchantability and fitness for a particular purpose are disclaimed. - // In no event shall the Intel Corporation or contributors be liable for any direct, - // indirect, incidental, special, exemplary, or consequential damages - // (including, but not limited to, procurement of substitute goods or services; - // loss of use, data, or profits; or business interruption) however caused - // and on any theory of liability, whether in contract, strict liability, - // or tort (including negligence or otherwise) arising in any way out of - // the use of this software, even if advised of the possibility of such damage. - -//************************************************************************************************** - // Project Delphi-OpenCV - // ************************************************************************************************** - // Contributor: - // Laentir Valetov - // email:laex@bk.ru - // Mikhail Grigorev - // email:sleuthound@gmail.com - // ************************************************************************************************** - // You may retrieve the latest version of this file at the GitHub, - // located at git://github.com/Laex/Delphi-OpenCV.git - // ************************************************************************************************** - // License: - // The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); - // you may not use this file except in compliance with the License. You may obtain a copy of the - // License at http://www.mozilla.org/MPL/ - // - // Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF - // ANY KIND, either express or implied. See the License for the specific language governing rights - // and limitations under the License. - // - // Alternatively, the contents of this file may be used under the terms of the - // GNU Lesser General Public License (the "LGPL License"), in which case the - // provisions of the LGPL License are applicable instead of those above. - // If you wish to allow use of your version of this file only under the terms - // of the LGPL License and not to allow others to use your version of this file - // under the MPL, indicate your decision by deleting the provisions above and - // replace them with the notice and other provisions required by the LGPL - // License. If you do not delete the provisions above, a recipient may use - // your version of this file under either the MPL or the LGPL License. - // - // For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html - // ************************************************************************************************** - // Warning: Using Delphi XE3 syntax! - // ************************************************************************************************** - // The Initial Developer of the Original Code: - // OpenCV: open source computer vision library - // Homepage: http://ocv.org - // Online docs: http://docs.ocv.org - // Q&A forum: http://answers.ocv.org - // Dev zone: http://code.ocv.org - // ************************************************************************************************** - // Original file: - // opencv\modules\legacy\include\opencv2\legacy.hpp - // ************************************************************************************************* +// ************************************************************************************************** +// Project Delphi-OpenCV +// ************************************************************************************************** +// Contributor: +// Laentir Valetov +// email:laex@bk.ru +// Mikhail Grigorev +// email:sleuthound@gmail.com +// ************************************************************************************************** +// You may retrieve the latest version of this file at the GitHub, +// located at git://github.com/Laex/Delphi-OpenCV.git +// ************************************************************************************************** +// License: +// The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); +// you may not use this file except in compliance with the License. You may obtain a copy of the +// License at http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF +// ANY KIND, either express or implied. See the License for the specific language governing rights +// and limitations under the License. +// +// Alternatively, the contents of this file may be used under the terms of the +// GNU Lesser General Public License (the "LGPL License"), in which case the +// provisions of the LGPL License are applicable instead of those above. +// If you wish to allow use of your version of this file only under the terms +// of the LGPL License and not to allow others to use your version of this file +// under the MPL, indicate your decision by deleting the provisions above and +// replace them with the notice and other provisions required by the LGPL +// License. If you do not delete the provisions above, a recipient may use +// your version of this file under either the MPL or the LGPL License. +// +// For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html +// ************************************************************************************************** +// Warning: Using Delphi XE3 syntax! +// ************************************************************************************************** +// The Initial Developer of the Original Code: +// OpenCV: open source computer vision library +// Homepage: http://ocv.org +// Online docs: http://docs.ocv.org +// Q&A forum: http://answers.ocv.org +// Dev zone: http://code.ocv.org +// ************************************************************************************************** +// Original file: +// opencv\modules\legacy\include\opencv2\legacy.hpp +// ************************************************************************************************* {$IFDEF DEBUG} {$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q+,R+,S-,T-,U-,V+,W+,X+,Y+,Z1} @@ -95,6 +56,7 @@ {$WARN UNSAFE_CODE OFF} {$WARN UNSAFE_CAST OFF} {$POINTERMATH ON} +{$I OpenCV.inc} unit ocv.legacy; interface @@ -109,213 +71,328 @@ uses // double ffill_threshold, // CvMemStorage* storage ); +{$EXTERNALSYM cvSegmentImage} function cvSegmentImage(const srcarr: pCvArr; dstarr: pCvArr; canny_threshold: double; ffill_threshold: double; storage: pCvMemStorage): pCvSeq; cdecl; -/// ****************************************************************************************\ -// * Eigen objects * -// \****************************************************************************************/ -// -// typedef int (CV_CDECL * CvCallback)(int index, void* buffer, void* user_data); -// typedef union -// { -// CvCallback callback; -// void* data; -// } -// CvInput; +{ **************************************************************************************** + * Eigen objects * + **************************************************************************************** } + +Type + (* typedef int (CV_CDECL * CvCallback)(int index, void* buffer, void* user_data); *) + TCvCallback = function(index: Integer; buffer: pointer; user_data: pointer): Integer; cdecl; + + (* + typedef union + { + CvCallback callback; + void* data; + } + CvInput; + *) + TCvInput = record + case boolean of + True: + (callback: TCvCallback); + False: + (data: pointer); + end; + const CV_EIGOBJ_NO_CALLBACK = 0; CV_EIGOBJ_INPUT_CALLBACK = 1; CV_EIGOBJ_OUTPUT_CALLBACK = 2; CV_EIGOBJ_BOTH_CALLBACK = 3; - /// * Calculates covariation matrix of a set of arrays */ - // CVAPI(void) cvCalcCovarMatrixEx( int nObjects, void* input, int ioFlags, - // int ioBufSize, uchar* buffer, void* userData, - // IplImage* avg, float* covarMatrix ); + (* Calculates covariation matrix of a set of arrays + + CVAPI(void) cvCalcCovarMatrixEx( int nObjects, void* input, int ioFlags, + int ioBufSize, uchar* buffer, void* userData, + IplImage* avg, float* covarMatrix ); + *) +{$EXTERNALSYM cvCalcCovarMatrixEx} +procedure cvCalcCovarMatrixEx(nObjects: Integer; input: pointer; ioFlags: Integer; ioBufSize: Integer; buffer: pByte; + userData: pointer; avg: pIplImage; var covarMatrix: Single); cdecl; + +(* Calculates eigen values and vectors of covariation matrix of a set of arrays + + CVAPI(void) cvCalcEigenObjects( int nObjects, void* input, void* output, + int ioFlags, int ioBufSize, void* userData, + CvTermCriteria* calcLimit, IplImage* avg, + float* eigVals ); +*) +{$EXTERNALSYM cvCalcEigenObjects} +procedure cvCalcEigenObjects(nObjects: Integer; input: pointer; output: pointer; ioFlags: Integer; ioBufSize: Integer; + userData: pointer; calcLimit: pCvTermCriteria; avg: pIplImage; eigVals: pFloat); cdecl; + +(* Calculates dot product (obj - avg) * eigObj (i.e. projects image to eigen vector) + + CVAPI(double) cvCalcDecompCoeff( IplImage* obj, IplImage* eigObj, IplImage* avg ); +*) +{$EXTERNALSYM cvCalcDecompCoeff} +function cvCalcDecompCoeff(obj: pIplImage; eigObj: pIplImage; avg: pIplImage): double; cdecl; + +(* Projects image to eigen space (finds all decomposion coefficients + + CVAPI(void) cvEigenDecomposite( IplImage* obj, int nEigObjs, void* eigInput, + int ioFlags, void* userData, IplImage* avg, + float* coeffs ); +*) +{$EXTERNALSYM cvEigenDecomposite} +procedure cvEigenDecomposite(obj: pIplImage; nEigObjs: Integer; eigInput: pointer; ioFlags: Integer; userData: pointer; + avg: pIplImage; coeffs: pFloat); cdecl; + +(* Projects original objects used to calculate eigen space basis to that space + + CVAPI(void) cvEigenProjection( void* eigInput, int nEigObjs, int ioFlags, + void* userData, float* coeffs, IplImage* avg, + IplImage* proj ); +*) +{$EXTERNALSYM cvEigenProjection} +procedure cvEigenProjection(eigInput: pointer; nEigObjs: Integer; ioFlags: Integer; userData: pointer; coeffs: PSingle; + avg: pIplImage; proj: pIplImage); cdecl; +// +{ **************************************************************************************** + * 1D/2D HMM * + **************************************************************************************** } + +Type + // typedef struct CvImgObsInfo + // { + // int obs_x; + // int obs_y; + // int obs_size; + // float* obs;//consequtive observations // - // Calculates eigen values and vectors of covariation matrix of a set of arrays - // CVAPI(void) cvCalcEigenObjects( int nObjects, void* input, void* output, - // int ioFlags, int ioBufSize, void* userData, - // CvTermCriteria* calcLimit, IplImage* avg, - // float* eigVals ); + // int* state;(* arr of pairs superstate/state to which observation belong *) + // int* mix; (* number of mixture to which observation belong *) + // + // } CvImgObsInfo;(*struct for 1 image*) -procedure cvCalcEigenObjects(nObjects: Integer; input: Pointer; output: Pointer; ioFlags: Integer; ioBufSize: Integer; - userData: Pointer; calcLimit: pCvTermCriteria; avg: pIplImage; eigVals: pFloat); cdecl; + pCvImgObsInfo = ^TCvImgObsInfo; -/// * Calculates dot product (obj - avg) * eigObj (i.e. projects image to eigen vector) */ -// CVAPI(double) cvCalcDecompCoeff( IplImage* obj, IplImage* eigObj, IplImage* avg ); + (* struct for 1 image *) + TCvImgObsInfo = record + obs_x: Integer; + obs_y: Integer; + obs_size: Integer; + obs: PSingle; // consequtive observations + state: PInteger; (* arr of pairs superstate/state to which observation belong *) + mix: PInteger; (* number of mixture to which observation belong *) + end; -// Projects image to eigen space (finds all decomposion coefficients -// CVAPI(void) cvEigenDecomposite( IplImage* obj, int nEigObjs, void* eigInput, -// int ioFlags, void* userData, IplImage* avg, -// float* coeffs ); -procedure cvEigenDecomposite(obj: pIplImage; nEigObjs: Integer; eigInput: Pointer; ioFlags: Integer; userData: Pointer; - avg: pIplImage; coeffs: pFloat); -cdecl + // typedef CvImgObsInfo Cv1DObsInfo; + TCv1DObsInfo = TCvImgObsInfo; + pCv1DObsInfo = pCvImgObsInfo; -/// * Projects original objects used to calculate eigen space basis to that space */ -// CVAPI(void) cvEigenProjection( void* eigInput, int nEigObjs, int ioFlags, -// void* userData, float* coeffs, IplImage* avg, -// IplImage* proj ); + // typedef struct CvEHMMState + // { + // int num_mix; (*number of mixtures in this state*) + // float* mu; (*mean vectors corresponding to each mixture*) + // float* inv_var; (* square root of inversed variances corresp. to each mixture*) + // float* log_var_val; (* sum of 0.5 (LN2PI + ln(variance[i]) ) for i=1,n *) + // float* weight; (*array of mixture weights. Summ of all weights in state is 1. *) + // + // } CvEHMMState; + + pCvEHMMState = ^TCvEHMMState; + + TCvEHMMState = record + num_mix: Integer; (* number of mixtures in this state *) + mu: PSingle; (* mean vectors corresponding to each mixture *) + inv_var: PSingle; (* square root of inversed variances corresp. to each mixture *) + log_var_val: PSingle; (* sum of 0.5 (LN2PI + ln(variance[i]) ) for i=1,n *) + weight: PSingle; (* array of mixture weights. Summ of all weights in state is 1. *) + end; + + // typedef struct CvEHMM + // { + // int level; (* 0 - lowest(i.e its states are real states), ..... *) + // int num_states; (* number of HMM states *) + // float* transP;(*transition probab. matrices for states *) + // float** obsProb; (* if level == 0 - array of brob matrices corresponding to hmm + // if level == 1 - martix of matrices *) + // union + // { + // CvEHMMState* state; (* if level == 0 points to real states array, + // if not - points to embedded hmms *) + // struct CvEHMM* ehmm; (* pointer to an embedded model or NULL, if it is a leaf *) + // } u; + // + // } CvEHMM; + + pCvEHMM = ^TCvEHMM; + + TObsProb = array [0 .. 0] of PSingle; + pObsProb = ^TObsProb; + + TCvEHMM = record + level: Integer; (* 0 - lowest(i.e its states are real states), ..... *) + num_states: Integer; (* number of HMM states *) + transP: PSingle; (* transition probab. matrices for states *) + obsProb: pObsProb; (* if level == 0 - array of brob matrices corresponding to hmm + if level == 1 - martix of matrices *) + case u: boolean of + True: + (state: pCvEHMMState); (* if level == 0 points to real states array, + if not - points to embedded hmms *) + False: + (ehmm: pCvEHMM); (* pointer to an embedded model or NULL, if it is a leaf *) + end; + + (* CVAPI(int) icvCreate1DHMM( CvEHMM** this_hmm, int state_number, int* num_mix, int obs_size ); *) +{$EXTERNALSYM icvCreate1DHMM} + +function icvCreate1DHMM(var this_hmm: pCvEHMM; state_number: Integer; Var num_mix: Integer; obs_size: Integer) + : Integer; cdecl; + +(* CVAPI(int) icvRelease1DHMM( CvEHMM** phmm ); *) +{$EXTERNALSYM icvRelease1DHMM} +function icvRelease1DHMM(var phmm: pCvEHMM): Integer; cdecl; + +(* CVAPI(int) icvUniform1DSegm( Cv1DObsInfo* obs_info, CvEHMM* hmm ); *) +{$EXTERNALSYM icvUniform1DSegm} +function icvUniform1DSegm(var obs_info: TCv1DObsInfo; var hmm: TCvEHMM): Integer; cdecl; + +(* CVAPI(int) icvInit1DMixSegm( Cv1DObsInfo** obs_info_array, int num_img, CvEHMM* hmm); *) +{$EXTERNALSYM icvInit1DMixSegm} +function icvInit1DMixSegm(var obs_info_array: pCv1DObsInfo; num_img: Integer; var hmm: TCvEHMM): Integer; cdecl; + +(* CVAPI(int) icvEstimate1DHMMStateParams( CvImgObsInfo** obs_info_array, int num_img, CvEHMM* hmm); *) +{$EXTERNALSYM icvEstimate1DHMMStateParams} +function icvEstimate1DHMMStateParams(var obs_info_array: pCvImgObsInfo; num_img: Integer; var hmm: TCvEHMM) + : Integer; cdecl; + +(* CVAPI(int) icvEstimate1DObsProb( CvImgObsInfo* obs_info, CvEHMM* hmm ); *) +{$EXTERNALSYM icvEstimate1DObsProb} +function icvEstimate1DObsProb(var obs_info: TCvImgObsInfo; var hmm: TCvEHMM): Integer; cdecl; + +(* CVAPI(int) icvEstimate1DTransProb( Cv1DObsInfo** obs_info_array, int num_seq, CvEHMM* hmm ); *) +{$EXTERNALSYM icvEstimate1DTransProb} +function icvEstimate1DTransProb(var obs_info_array: pCv1DObsInfo; num_seq: Integer; var hmm: TCvEHMM): Integer; cdecl; + +(* CVAPI(float) icvViterbi( Cv1DObsInfo* obs_info, CvEHMM* hmm); *) +{$EXTERNALSYM icvViterbi} +function icvViterbi(var obs_info: TCv1DObsInfo; var hmm: TCvEHMM): Single; cdecl; + +(* CVAPI(int) icv1DMixSegmL2( CvImgObsInfo** obs_info_array, int num_img, CvEHMM* hmm ); *) +{$EXTERNALSYM icv1DMixSegmL2} +function icv1DMixSegmL2(var obs_info_array: pCvImgObsInfo; num_img: Integer; var hmm: TCvEHMM): Integer; cdecl; + +(* ********************************** Embedded HMMs ************************************ *) // -/// ****************************************************************************************\ -// * 1D/2D HMM * -// \****************************************************************************************/ -// -// typedef struct CvImgObsInfo -// { -// int obs_x; -// int obs_y; -// int obs_size; -// float* obs;//consequtive observations -// -// int* state;/* arr of pairs superstate/state to which observation belong */ -// int* mix; /* number of mixture to which observation belong */ -// -// } CvImgObsInfo;/*struct for 1 image*/ -// -// typedef CvImgObsInfo Cv1DObsInfo; -// -// typedef struct CvEHMMState -// { -// int num_mix; /*number of mixtures in this state*/ -// float* mu; /*mean vectors corresponding to each mixture*/ -// float* inv_var; /* square root of inversed variances corresp. to each mixture*/ -// float* log_var_val; /* sum of 0.5 (LN2PI + ln(variance[i]) ) for i=1,n */ -// float* weight; /*array of mixture weights. Summ of all weights in state is 1. */ -// -// } CvEHMMState; -// -// typedef struct CvEHMM -// { -// int level; /* 0 - lowest(i.e its states are real states), ..... */ -// int num_states; /* number of HMM states */ -// float* transP;/*transition probab. matrices for states */ -// float** obsProb; /* if level == 0 - array of brob matrices corresponding to hmm -// if level == 1 - martix of matrices */ -// union -// { -// CvEHMMState* state; /* if level == 0 points to real states array, -// if not - points to embedded hmms */ -// struct CvEHMM* ehmm; /* pointer to an embedded model or NULL, if it is a leaf */ -// } u; -// -// } CvEHMM; -// -/// *CVAPI(int) icvCreate1DHMM( CvEHMM** this_hmm, -// int state_number, int* num_mix, int obs_size ); -// -// CVAPI(int) icvRelease1DHMM( CvEHMM** phmm ); -// -// CVAPI(int) icvUniform1DSegm( Cv1DObsInfo* obs_info, CvEHMM* hmm ); -// -// CVAPI(int) icvInit1DMixSegm( Cv1DObsInfo** obs_info_array, int num_img, CvEHMM* hmm); -// -// CVAPI(int) icvEstimate1DHMMStateParams( CvImgObsInfo** obs_info_array, int num_img, CvEHMM* hmm); -// -// CVAPI(int) icvEstimate1DObsProb( CvImgObsInfo* obs_info, CvEHMM* hmm ); -// -// CVAPI(int) icvEstimate1DTransProb( Cv1DObsInfo** obs_info_array, -// int num_seq, -// CvEHMM* hmm ); -// -// CVAPI(float) icvViterbi( Cv1DObsInfo* obs_info, CvEHMM* hmm); -// -// CVAPI(int) icv1DMixSegmL2( CvImgObsInfo** obs_info_array, int num_img, CvEHMM* hmm );*/ -// -/// *********************************** Embedded HMMs *************************************/ -// -/// * Creates 2D HMM */ -// CVAPI(CvEHMM*) cvCreate2DHMM( int* stateNumber, int* numMix, int obsSize ); -// -/// * Releases HMM */ -// CVAPI(void) cvRelease2DHMM( CvEHMM** hmm ); -// -// #define CV_COUNT_OBS(roi, win, delta, numObs ) \ -// { \ -// (numObs)->width =((roi)->width -(win)->width +(delta)->width)/(delta)->width; \ -// (numObs)->height =((roi)->height -(win)->height +(delta)->height)/(delta)->height;\ -// } -// -/// * Creates storage for observation vectors */ -// CVAPI(CvImgObsInfo*) cvCreateObsInfo( CvSize numObs, int obsSize ); -// -/// * Releases storage for observation vectors */ -// CVAPI(void) cvReleaseObsInfo( CvImgObsInfo** obs_info ); -// -// -/// * The function takes an image on input and and returns the sequnce of observations -// to be used with an embedded HMM; Each observation is top-left block of DCT -// coefficient matrix */ -// CVAPI(void) cvImgToObs_DCT( const CvArr* arr, float* obs, CvSize dctSize, -// CvSize obsSize, CvSize delta ); -// -// -/// * Uniformly segments all observation vectors extracted from image */ -// CVAPI(void) cvUniformImgSegm( CvImgObsInfo* obs_info, CvEHMM* ehmm ); -// -/// * Does mixture segmentation of the states of embedded HMM */ -// CVAPI(void) cvInitMixSegm( CvImgObsInfo** obs_info_array, -// int num_img, CvEHMM* hmm ); -// -/// * Function calculates means, variances, weights of every Gaussian mixture -// of every low-level state of embedded HMM */ +(* Creates 2D HMM + CVAPI(CvEHMM* ) cvCreate2DHMM( int* stateNumber, int* numMix, int obsSize ); +*) +{$EXTERNALSYM cvCreate2DHMM} +function cvCreate2DHMM(Var stateNumber: Integer; Var numMix: Integer; obsSize: Integer): pCvEHMM; cdecl; + +(* Releases HMM + CVAPI(void) cvRelease2DHMM( CvEHMM** hmm ); +*) +{$EXTERNALSYM cvRelease2DHMM} +procedure cvRelease2DHMM(var hmm: pCvEHMM); cdecl; + +(* + #define CV_COUNT_OBS(roi, win, delta, numObs ) \ + { \ + (numObs)->width =((roi)->width -(win)->width +(delta)->width)/(delta)->width; \ + (numObs)->height =((roi)->height -(win)->height +(delta)->height)/(delta)->height;\ + } +*) + +(* Creates storage for observation vectors + CVAPI(CvImgObsInfo* ) cvCreateObsInfo( CvSize numObs, int obsSize ); +*) +{$EXTERNALSYM cvCreateObsInfo} +function cvCreateObsInfo(numObs: TCvSize; obsSize: Integer): pCvImgObsInfo; cdecl; + +(* Releases storage for observation vectors + CVAPI(void) cvReleaseObsInfo( CvImgObsInfo** obs_info ); +*) +{$EXTERNALSYM cvReleaseObsInfo} +procedure cvReleaseObsInfo(var obs_info: pCvImgObsInfo); cdecl; + +(* The function takes an image on input and and returns the sequnce of observations + to be used with an embedded HMM; Each observation is top-left block of DCT + coefficient matrix + CVAPI(void) cvImgToObs_DCT( const CvArr* arr, float* obs, CvSize dctSize, + CvSize obsSize, CvSize delta ); +*) +{$EXTERNALSYM cvImgToObs_DCT} +procedure cvImgToObs_DCT(const arr: pCvArr; var obs: Single; dctSize: TCvSize; obsSize: TCvSize; delta: TCvSize); cdecl; + +(* Uniformly segments all observation vectors extracted from image + CVAPI(void) cvUniformImgSegm( CvImgObsInfo* obs_info, CvEHMM* ehmm ); +*) +{$EXTERNALSYM cvUniformImgSegm} +procedure cvUniformImgSegm(var obs_info: TCvImgObsInfo; var ehmm: TCvEHMM); cdecl; + +(* Does mixture segmentation of the states of embedded HMM + CVAPI(void) cvInitMixSegm( CvImgObsInfo** obs_info_array, + int num_img, CvEHMM* hmm ); +*) +{$EXTERNALSYM cvInitMixSegm} +procedure cvInitMixSegm(var obs_info_array: pCvImgObsInfo; num_img: Integer; var hmm: TCvEHMM); cdecl; + +(* Function calculates means, variances, weights of every Gaussian mixture + // of every low-level state of embedded HMM *) // CVAPI(void) cvEstimateHMMStateParams( CvImgObsInfo** obs_info_array, // int num_img, CvEHMM* hmm ); // -/// * Function computes transition probability matrices of embedded HMM -// given observations segmentation */ +(* Function computes transition probability matrices of embedded HMM + // given observations segmentation *) // CVAPI(void) cvEstimateTransProb( CvImgObsInfo** obs_info_array, // int num_img, CvEHMM* hmm ); // -/// * Function computes probabilities of appearing observations at any state -// (i.e. computes P(obs|state) for every pair(obs,state)) */ +(* Function computes probabilities of appearing observations at any state + // (i.e. computes P(obs|state) for every pair(obs,state)) *) // CVAPI(void) cvEstimateObsProb( CvImgObsInfo* obs_info, // CvEHMM* hmm ); // -/// * Runs Viterbi algorithm for embedded HMM */ +(* Runs Viterbi algorithm for embedded HMM *) // CVAPI(float) cvEViterbi( CvImgObsInfo* obs_info, CvEHMM* hmm ); // // -/// * Function clusters observation vectors from several images -// given observations segmentation. -// Euclidean distance used for clustering vectors. -// Centers of clusters are given means of every mixture */ +(* Function clusters observation vectors from several images + // given observations segmentation. + // Euclidean distance used for clustering vectors. + // Centers of clusters are given means of every mixture *) // CVAPI(void) cvMixSegmL2( CvImgObsInfo** obs_info_array, // int num_img, CvEHMM* hmm ); // -/// ****************************************************************************************\ -// * A few functions from old stereo gesture recognition demosions * -// \****************************************************************************************/ +(* ***************************************************************************************\ + // * A few functions from old stereo gesture recognition demosions * + // \*************************************************************************************** *) // -/// * Creates hand mask image given several points on the hand */ +(* Creates hand mask image given several points on the hand *) // CVAPI(void) cvCreateHandMask( CvSeq* hand_points, // IplImage *img_mask, CvRect *roi); // -/// * Finds hand region in range image data */ +(* Finds hand region in range image data *) // CVAPI(void) cvFindHandRegion (CvPoint3D32f* points, int count, // CvSeq* indexs, // float* line, CvSize2D32f size, int flag, // CvPoint3D32f* center, // CvMemStorage* storage, CvSeq **numbers); // -/// * Finds hand region in range image data (advanced version) */ +(* Finds hand region in range image data (advanced version) *) // CVAPI(void) cvFindHandRegionA( CvPoint3D32f* points, int count, // CvSeq* indexs, // float* line, CvSize2D32f size, int jc, // CvPoint3D32f* center, // CvMemStorage* storage, CvSeq **numbers); // -/// * Calculates the cooficients of the homography matrix */ +(* Calculates the cooficients of the homography matrix *) // CVAPI(void) cvCalcImageHomography( float* line, CvPoint3D32f* center, // float* intrinsic, float* homography ); // -/// ****************************************************************************************\ -// * More operations on sequences * -// \****************************************************************************************/ +(* ***************************************************************************************\ + // * More operations on sequences * + // \*************************************************************************************** *) // -/// *****************************************************************************************/ +(* *************************************************************************************** *) // // #define CV_CURRENT_INT( reader ) (*((int *)(reader).ptr)) // #define CV_PREV_INT( reader ) (*((int *)(reader).prev_elem)) @@ -344,12 +421,12 @@ cdecl // } CvGraphWeightType; // // -/// * Calculates histogram of a contour */ +(* Calculates histogram of a contour *) // CVAPI(void) cvCalcPGH( const CvSeq* contour, CvHistogram* hist ); // // #define CV_DOMINANT_IPAN 1 // -/// * Finds high-curvature points of the contour */ +(* Finds high-curvature points of the contour *) // CVAPI(CvSeq*) cvFindDominantPoints( CvSeq* contour, CvMemStorage* storage, // int method CV_DEFAULT(CV_DOMINANT_IPAN), // double parameter1 CV_DEFAULT(0), @@ -357,10 +434,10 @@ cdecl // double parameter3 CV_DEFAULT(0), // double parameter4 CV_DEFAULT(0)); // -/// *****************************************************************************************/ +(* *************************************************************************************** *) // // -/// *******************************Stereo correspondence*************************************/ +(* ******************************Stereo correspondence************************************ *) // // typedef struct CvCliqueFinder // { @@ -394,466 +471,464 @@ cdecl // #define CLIQUE_FOUND 1 // #define CLIQUE_END 0 // -/// *CVAPI(void) cvStartFindCliques( CvGraph* graph, CvCliqueFinder* finder, int reverse, -// int weighted CV_DEFAULT(0), int weighted_edges CV_DEFAULT(0)); -// CVAPI(int) cvFindNextMaximalClique( CvCliqueFinder* finder, int* clock_rest CV_DEFAULT(0) ); -// CVAPI(void) cvEndFindCliques( CvCliqueFinder* finder ); -// -// CVAPI(void) cvBronKerbosch( CvGraph* graph );*/ -// -// -/// *F/////////////////////////////////////////////////////////////////////////////////////// -/// / -/// / Name: cvSubgraphWeight -/// / Purpose: finds weight of subgraph in a graph -/// / Context: -/// / Parameters: -/// / graph - input graph. -/// / subgraph - sequence of pairwise different ints. These are indices of vertices of subgraph. -/// / weight_type - describes the way we measure weight. -/// / one of the following: -/// / CV_NOT_WEIGHTED - weight of a clique is simply its size -/// / CV_WEIGHTED_VTX - weight of a clique is the sum of weights of its vertices -/// / CV_WEIGHTED_EDGE - the same but edges -/// / CV_WEIGHTED_ALL - the same but both edges and vertices -/// / weight_vtx - optional vector of floats, with size = graph->total. -/// / If weight_type is either CV_WEIGHTED_VTX or CV_WEIGHTED_ALL -/// / weights of vertices must be provided. If weight_vtx not zero -/// / these weights considered to be here, otherwise function assumes -/// / that vertices of graph are inherited from CvGraphWeightedVtx. -/// / weight_edge - optional matrix of floats, of width and height = graph->total. -/// / If weight_type is either CV_WEIGHTED_EDGE or CV_WEIGHTED_ALL -/// / weights of edges ought to be supplied. If weight_edge is not zero -/// / function finds them here, otherwise function expects -/// / edges of graph to be inherited from CvGraphWeightedEdge. -/// / If this parameter is not zero structure of the graph is determined from matrix -/// / rather than from CvGraphEdge's. In particular, elements corresponding to -/// / absent edges should be zero. -/// / Returns: -/// / weight of subgraph. -/// / Notes: -/// /F*/ -/// *CVAPI(float) cvSubgraphWeight( CvGraph *graph, CvSeq *subgraph, -// CvGraphWeightType weight_type CV_DEFAULT(CV_NOT_WEIGHTED), -// CvVect32f weight_vtx CV_DEFAULT(0), -// CvMatr32f weight_edge CV_DEFAULT(0) );*/ -// -// -/// *F/////////////////////////////////////////////////////////////////////////////////////// -/// / -/// / Name: cvFindCliqueEx -/// / Purpose: tries to find clique with maximum possible weight in a graph -/// / Context: -/// / Parameters: -/// / graph - input graph. -/// / storage - memory storage to be used by the result. -/// / is_complementary - optional flag showing whether function should seek for clique -/// / in complementary graph. -/// / weight_type - describes our notion about weight. -/// / one of the following: -/// / CV_NOT_WEIGHTED - weight of a clique is simply its size -/// / CV_WEIGHTED_VTX - weight of a clique is the sum of weights of its vertices -/// / CV_WEIGHTED_EDGE - the same but edges -/// / CV_WEIGHTED_ALL - the same but both edges and vertices -/// / weight_vtx - optional vector of floats, with size = graph->total. -/// / If weight_type is either CV_WEIGHTED_VTX or CV_WEIGHTED_ALL -/// / weights of vertices must be provided. If weight_vtx not zero -/// / these weights considered to be here, otherwise function assumes -/// / that vertices of graph are inherited from CvGraphWeightedVtx. -/// / weight_edge - optional matrix of floats, of width and height = graph->total. -/// / If weight_type is either CV_WEIGHTED_EDGE or CV_WEIGHTED_ALL -/// / weights of edges ought to be supplied. If weight_edge is not zero -/// / function finds them here, otherwise function expects -/// / edges of graph to be inherited from CvGraphWeightedEdge. -/// / Note that in case of CV_WEIGHTED_EDGE or CV_WEIGHTED_ALL -/// / nonzero is_complementary implies nonzero weight_edge. -/// / start_clique - optional sequence of pairwise different ints. They are indices of -/// / vertices that shall be present in the output clique. -/// / subgraph_of_ban - optional sequence of (maybe equal) ints. They are indices of -/// / vertices that shall not be present in the output clique. -/// / clique_weight_ptr - optional output parameter. Weight of found clique stored here. -/// / num_generations - optional number of generations in evolutionary part of algorithm, -/// / zero forces to return first found clique. -/// / quality - optional parameter determining degree of required quality/speed tradeoff. -/// / Must be in the range from 0 to 9. -/// / 0 is fast and dirty, 9 is slow but hopefully yields good clique. -/// / Returns: -/// / sequence of pairwise different ints. -/// / These are indices of vertices that form found clique. -/// / Notes: -/// / in cases of CV_WEIGHTED_EDGE and CV_WEIGHTED_ALL weights should be nonnegative. -/// / start_clique has a priority over subgraph_of_ban. -/// /F*/ -/// *CVAPI(CvSeq*) cvFindCliqueEx( CvGraph *graph, CvMemStorage *storage, -// int is_complementary CV_DEFAULT(0), -// CvGraphWeightType weight_type CV_DEFAULT(CV_NOT_WEIGHTED), -// CvVect32f weight_vtx CV_DEFAULT(0), -// CvMatr32f weight_edge CV_DEFAULT(0), -// CvSeq *start_clique CV_DEFAULT(0), -// CvSeq *subgraph_of_ban CV_DEFAULT(0), -// float *clique_weight_ptr CV_DEFAULT(0), -// int num_generations CV_DEFAULT(3), -// int quality CV_DEFAULT(2) );*/ -// -// -// #define CV_UNDEF_SC_PARAM 12345 //default value of parameters -// -// #define CV_IDP_BIRCHFIELD_PARAM1 25 -// #define CV_IDP_BIRCHFIELD_PARAM2 5 -// #define CV_IDP_BIRCHFIELD_PARAM3 12 -// #define CV_IDP_BIRCHFIELD_PARAM4 15 -// #define CV_IDP_BIRCHFIELD_PARAM5 25 -// -// -// #define CV_DISPARITY_BIRCHFIELD 0 -// -// -/// *F/////////////////////////////////////////////////////////////////////////// -/// / -/// / Name: cvFindStereoCorrespondence -/// / Purpose: find stereo correspondence on stereo-pair -/// / Context: -/// / Parameters: -/// / leftImage - left image of stereo-pair (format 8uC1). -/// / rightImage - right image of stereo-pair (format 8uC1). -/// / mode - mode of correspondence retrieval (now CV_DISPARITY_BIRCHFIELD only) -/// / dispImage - destination disparity image -/// / maxDisparity - maximal disparity -/// / param1, param2, param3, param4, param5 - parameters of algorithm -/// / Returns: -/// / Notes: -/// / Images must be rectified. -/// / All images must have format 8uC1. -/// /F*/ -// CVAPI(void) -// cvFindStereoCorrespondence( -// const CvArr* leftImage, const CvArr* rightImage, -// int mode, -// CvArr* dispImage, -// int maxDisparity, -// double param1 CV_DEFAULT(CV_UNDEF_SC_PARAM), -// double param2 CV_DEFAULT(CV_UNDEF_SC_PARAM), -// double param3 CV_DEFAULT(CV_UNDEF_SC_PARAM), -// double param4 CV_DEFAULT(CV_UNDEF_SC_PARAM), -// double param5 CV_DEFAULT(CV_UNDEF_SC_PARAM) ); -// -/// *****************************************************************************************/ -/// ************ Epiline functions *******************/ -// -// -// -// typedef struct CvStereoLineCoeff -// { -// double Xcoef; -// double XcoefA; -// double XcoefB; -// double XcoefAB; -// -// double Ycoef; -// double YcoefA; -// double YcoefB; -// double YcoefAB; -// -// double Zcoef; -// double ZcoefA; -// double ZcoefB; -// double ZcoefAB; -// }CvStereoLineCoeff; -// -// -// typedef struct CvCamera -// { -// float imgSize[2]; /* size of the camera view, used during calibration */ -// float matrix[9]; /* intinsic camera parameters: [ fx 0 cx; 0 fy cy; 0 0 1 ] */ -// float distortion[4]; /* distortion coefficients - two coefficients for radial distortion -// and another two for tangential: [ k1 k2 p1 p2 ] */ -// float rotMatr[9]; -// float transVect[3]; /* rotation matrix and transition vector relatively -// to some reference point in the space. */ -// } CvCamera; -// -// typedef struct CvStereoCamera -// { -// CvCamera* camera[2]; /* two individual camera parameters */ -// float fundMatr[9]; /* fundamental matrix */ -// -// /* New part for stereo */ -// CvPoint3D32f epipole[2]; -// CvPoint2D32f quad[2][4]; /* coordinates of destination quadrangle after -// epipolar geometry rectification */ -// double coeffs[2][3][3];/* coefficients for transformation */ -// CvPoint2D32f border[2][4]; -// CvSize warpSize; -// CvStereoLineCoeff* lineCoeffs; -// int needSwapCameras;/* flag set to 1 if need to swap cameras for good reconstruction */ -// float rotMatrix[9]; -// float transVector[3]; -// } CvStereoCamera; -// -// -// typedef struct CvContourOrientation -// { -// float egvals[2]; -// float egvects[4]; -// -// float max, min; // minimum and maximum projections -// int imax, imin; -// } CvContourOrientation; -// -// #define CV_CAMERA_TO_WARP 1 -// #define CV_WARP_TO_CAMERA 2 -// -// CVAPI(int) icvConvertWarpCoordinates(double coeffs[3][3], -// CvPoint2D32f* cameraPoint, -// CvPoint2D32f* warpPoint, -// int direction); -// -// CVAPI(int) icvGetSymPoint3D( CvPoint3D64f pointCorner, -// CvPoint3D64f point1, -// CvPoint3D64f point2, -// CvPoint3D64f *pointSym2); -// -// CVAPI(void) icvGetPieceLength3D(CvPoint3D64f point1,CvPoint3D64f point2,double* dist); -// -// CVAPI(int) icvCompute3DPoint( double alpha,double betta, -// CvStereoLineCoeff* coeffs, -// CvPoint3D64f* point); -// -// CVAPI(int) icvCreateConvertMatrVect( double* rotMatr1, -// double* transVect1, -// double* rotMatr2, -// double* transVect2, -// double* convRotMatr, -// double* convTransVect); -// -// CVAPI(int) icvConvertPointSystem(CvPoint3D64f M2, -// CvPoint3D64f* M1, -// double* rotMatr, -// double* transVect -// ); -// -// CVAPI(int) icvComputeCoeffForStereo( CvStereoCamera* stereoCamera); -// -// CVAPI(int) icvGetCrossPieceVector(CvPoint2D32f p1_start,CvPoint2D32f p1_end,CvPoint2D32f v2_start,CvPoint2D32f v2_end,CvPoint2D32f *cross); -// CVAPI(int) icvGetCrossLineDirect(CvPoint2D32f p1,CvPoint2D32f p2,float a,float b,float c,CvPoint2D32f* cross); -// CVAPI(float) icvDefinePointPosition(CvPoint2D32f point1,CvPoint2D32f point2,CvPoint2D32f point); -// CVAPI(int) icvStereoCalibration( int numImages, -// int* nums, -// CvSize imageSize, -// CvPoint2D32f* imagePoints1, -// CvPoint2D32f* imagePoints2, -// CvPoint3D32f* objectPoints, -// CvStereoCamera* stereoparams -// ); -// -// -// CVAPI(int) icvComputeRestStereoParams(CvStereoCamera *stereoparams); -// -// CVAPI(void) cvComputePerspectiveMap( const double coeffs[3][3], CvArr* rectMapX, CvArr* rectMapY ); -// -// CVAPI(int) icvComCoeffForLine( CvPoint2D64f point1, -// CvPoint2D64f point2, -// CvPoint2D64f point3, -// CvPoint2D64f point4, -// double* camMatr1, -// double* rotMatr1, -// double* transVect1, -// double* camMatr2, -// double* rotMatr2, -// double* transVect2, -// CvStereoLineCoeff* coeffs, -// int* needSwapCameras); -// -// CVAPI(int) icvGetDirectionForPoint( CvPoint2D64f point, -// double* camMatr, -// CvPoint3D64f* direct); -// -// CVAPI(int) icvGetCrossLines(CvPoint3D64f point11,CvPoint3D64f point12, -// CvPoint3D64f point21,CvPoint3D64f point22, -// CvPoint3D64f* midPoint); -// -// CVAPI(int) icvComputeStereoLineCoeffs( CvPoint3D64f pointA, -// CvPoint3D64f pointB, -// CvPoint3D64f pointCam1, -// double gamma, -// CvStereoLineCoeff* coeffs); -// -/// *CVAPI(int) icvComputeFundMatrEpipoles ( double* camMatr1, -// double* rotMatr1, -// double* transVect1, -// double* camMatr2, -// double* rotMatr2, -// double* transVect2, -// CvPoint2D64f* epipole1, -// CvPoint2D64f* epipole2, -// double* fundMatr);*/ -// -// CVAPI(int) icvGetAngleLine( CvPoint2D64f startPoint, CvSize imageSize,CvPoint2D64f *point1,CvPoint2D64f *point2); -// -// CVAPI(void) icvGetCoefForPiece( CvPoint2D64f p_start,CvPoint2D64f p_end, -// double *a,double *b,double *c, -// int* result); -// -/// *CVAPI(void) icvGetCommonArea( CvSize imageSize, -// CvPoint2D64f epipole1,CvPoint2D64f epipole2, -// double* fundMatr, -// double* coeff11,double* coeff12, -// double* coeff21,double* coeff22, -// int* result);*/ -// -// CVAPI(void) icvComputeeInfiniteProject1(double* rotMatr, -// double* camMatr1, -// double* camMatr2, -// CvPoint2D32f point1, -// CvPoint2D32f *point2); -// -// CVAPI(void) icvComputeeInfiniteProject2(double* rotMatr, -// double* camMatr1, -// double* camMatr2, -// CvPoint2D32f* point1, -// CvPoint2D32f point2); -// -// CVAPI(void) icvGetCrossDirectDirect( double* direct1,double* direct2, -// CvPoint2D64f *cross,int* result); -// -// CVAPI(void) icvGetCrossPieceDirect( CvPoint2D64f p_start,CvPoint2D64f p_end, -// double a,double b,double c, -// CvPoint2D64f *cross,int* result); -// -// CVAPI(void) icvGetCrossPiecePiece( CvPoint2D64f p1_start,CvPoint2D64f p1_end, -// CvPoint2D64f p2_start,CvPoint2D64f p2_end, -// CvPoint2D64f* cross, -// int* result); -// -// CVAPI(void) icvGetPieceLength(CvPoint2D64f point1,CvPoint2D64f point2,double* dist); -// -// CVAPI(void) icvGetCrossRectDirect( CvSize imageSize, -// double a,double b,double c, -// CvPoint2D64f *start,CvPoint2D64f *end, -// int* result); -// -// CVAPI(void) icvProjectPointToImage( CvPoint3D64f point, -// double* camMatr,double* rotMatr,double* transVect, -// CvPoint2D64f* projPoint); -// -// CVAPI(void) icvGetQuadsTransform( CvSize imageSize, -// double* camMatr1, -// double* rotMatr1, -// double* transVect1, -// double* camMatr2, -// double* rotMatr2, -// double* transVect2, -// CvSize* warpSize, -// double quad1[4][2], -// double quad2[4][2], -// double* fundMatr, -// CvPoint3D64f* epipole1, -// CvPoint3D64f* epipole2 -// ); -// -// CVAPI(void) icvGetQuadsTransformStruct( CvStereoCamera* stereoCamera); -// -// CVAPI(void) icvComputeStereoParamsForCameras(CvStereoCamera* stereoCamera); -// -// CVAPI(void) icvGetCutPiece( double* areaLineCoef1,double* areaLineCoef2, -// CvPoint2D64f epipole, -// CvSize imageSize, -// CvPoint2D64f* point11,CvPoint2D64f* point12, -// CvPoint2D64f* point21,CvPoint2D64f* point22, -// int* result); -// -// CVAPI(void) icvGetMiddleAnglePoint( CvPoint2D64f basePoint, -// CvPoint2D64f point1,CvPoint2D64f point2, -// CvPoint2D64f* midPoint); -// -// CVAPI(void) icvGetNormalDirect(double* direct,CvPoint2D64f point,double* normDirect); -// -// CVAPI(double) icvGetVect(CvPoint2D64f basePoint,CvPoint2D64f point1,CvPoint2D64f point2); -// -// CVAPI(void) icvProjectPointToDirect( CvPoint2D64f point,double* lineCoeff, -// CvPoint2D64f* projectPoint); -// -// CVAPI(void) icvGetDistanceFromPointToDirect( CvPoint2D64f point,double* lineCoef,double*dist); -// -// CVAPI(IplImage*) icvCreateIsometricImage( IplImage* src, IplImage* dst, -// int desired_depth, int desired_num_channels ); -// -// CVAPI(void) cvDeInterlace( const CvArr* frame, CvArr* fieldEven, CvArr* fieldOdd ); -// -/// *CVAPI(int) icvSelectBestRt( int numImages, -// int* numPoints, -// CvSize imageSize, -// CvPoint2D32f* imagePoints1, -// CvPoint2D32f* imagePoints2, -// CvPoint3D32f* objectPoints, -// -// CvMatr32f cameraMatrix1, -// CvVect32f distortion1, -// CvMatr32f rotMatrs1, -// CvVect32f transVects1, -// -// CvMatr32f cameraMatrix2, -// CvVect32f distortion2, -// CvMatr32f rotMatrs2, -// CvVect32f transVects2, -// -// CvMatr32f bestRotMatr, -// CvVect32f bestTransVect -// );*/ -// -// -/// ****************************************************************************************\ -// * Contour Tree * -// \****************************************************************************************/ -// -/// * Contour tree header */ -// typedef struct CvContourTree -// { -// CV_SEQUENCE_FIELDS() -// CvPoint p1; /* the first point of the binary tree root segment */ -// CvPoint p2; /* the last point of the binary tree root segment */ -// } CvContourTree; -// -/// * Builds hierarhical representation of a contour */ -// CVAPI(CvContourTree*) cvCreateContourTree( const CvSeq* contour, -// CvMemStorage* storage, -// double threshold ); -// -/// * Reconstruct (completelly or partially) contour a from contour tree */ -// CVAPI(CvSeq*) cvContourFromContourTree( const CvContourTree* tree, -// CvMemStorage* storage, -// CvTermCriteria criteria ); -// -/// * Compares two contour trees */ -// enum { CV_CONTOUR_TREES_MATCH_I1 = 1 }; -// -// CVAPI(double) cvMatchContourTrees( const CvContourTree* tree1, -// const CvContourTree* tree2, -// int method, double threshold ); -// -/// ****************************************************************************************\ -// * Contour Morphing * -// \****************************************************************************************/ -// -/// * finds correspondence between two contours */ -// CvSeq* cvCalcContoursCorrespondence( const CvSeq* contour1, -// const CvSeq* contour2, -// CvMemStorage* storage); -// -/// * morphs contours using the pre-calculated correspondence: -// alpha=0 ~ contour1, alpha=1 ~ contour2 */ -// CvSeq* cvMorphContours( const CvSeq* contour1, const CvSeq* contour2, -// CvSeq* corr, double alpha, -// CvMemStorage* storage ); -// +(* CVAPI(void) cvStartFindCliques( CvGraph* graph, CvCliqueFinder* finder, int reverse, + // int weighted CV_DEFAULT(0), int weighted_edges CV_DEFAULT(0)); + // CVAPI(int) cvFindNextMaximalClique( CvCliqueFinder* finder, int* clock_rest CV_DEFAULT(0) ); + // CVAPI(void) cvEndFindCliques( CvCliqueFinder* finder ); + // + // CVAPI(void) cvBronKerbosch( CvGraph* graph ); *) +// +// +(* F/////////////////////////////////////////////////////////////////////////////////////// + /// / + /// / Name: cvSubgraphWeight + /// / Purpose: finds weight of subgraph in a graph + /// / Context: + /// / Parameters: + /// / graph - input graph. + /// / subgraph - sequence of pairwise different ints. These are indices of vertices of subgraph. + /// / weight_type - describes the way we measure weight. + /// / one of the following: + /// / CV_NOT_WEIGHTED - weight of a clique is simply its size + /// / CV_WEIGHTED_VTX - weight of a clique is the sum of weights of its vertices + /// / CV_WEIGHTED_EDGE - the same but edges + /// / CV_WEIGHTED_ALL - the same but both edges and vertices + /// / weight_vtx - optional vector of floats, with size = graph->total. + /// / If weight_type is either CV_WEIGHTED_VTX or CV_WEIGHTED_ALL + /// / weights of vertices must be provided. If weight_vtx not zero + /// / these weights considered to be here, otherwise function assumes + /// / that vertices of graph are inherited from CvGraphWeightedVtx. + /// / weight_edge - optional matrix of floats, of width and height = graph->total. + /// / If weight_type is either CV_WEIGHTED_EDGE or CV_WEIGHTED_ALL + /// / weights of edges ought to be supplied. If weight_edge is not zero + /// / function finds them here, otherwise function expects + /// / edges of graph to be inherited from CvGraphWeightedEdge. + /// / If this parameter is not zero structure of the graph is determined from matrix + /// / rather than from CvGraphEdge's. In particular, elements corresponding to + /// / absent edges should be zero. + /// / Returns: + /// / weight of subgraph. + /// / Notes: + /// /F *) +(* CVAPI(float) cvSubgraphWeight( CvGraph *graph, CvSeq *subgraph, + // CvGraphWeightType weight_type CV_DEFAULT(CV_NOT_WEIGHTED), + // CvVect32f weight_vtx CV_DEFAULT(0), + // CvMatr32f weight_edge CV_DEFAULT(0) ); *) +// +// +(* F/////////////////////////////////////////////////////////////////////////////////////// + /// / + /// / Name: cvFindCliqueEx + /// / Purpose: tries to find clique with maximum possible weight in a graph + /// / Context: + /// / Parameters: + /// / graph - input graph. + /// / storage - memory storage to be used by the result. + /// / is_complementary - optional flag showing whether function should seek for clique + /// / in complementary graph. + /// / weight_type - describes our notion about weight. + /// / one of the following: + /// / CV_NOT_WEIGHTED - weight of a clique is simply its size + /// / CV_WEIGHTED_VTX - weight of a clique is the sum of weights of its vertices + /// / CV_WEIGHTED_EDGE - the same but edges + /// / CV_WEIGHTED_ALL - the same but both edges and vertices + /// / weight_vtx - optional vector of floats, with size = graph->total. + /// / If weight_type is either CV_WEIGHTED_VTX or CV_WEIGHTED_ALL + /// / weights of vertices must be provided. If weight_vtx not zero + /// / these weights considered to be here, otherwise function assumes + /// / that vertices of graph are inherited from CvGraphWeightedVtx. + /// / weight_edge - optional matrix of floats, of width and height = graph->total. + /// / If weight_type is either CV_WEIGHTED_EDGE or CV_WEIGHTED_ALL + /// / weights of edges ought to be supplied. If weight_edge is not zero + /// / function finds them here, otherwise function expects + /// / edges of graph to be inherited from CvGraphWeightedEdge. + /// / Note that in case of CV_WEIGHTED_EDGE or CV_WEIGHTED_ALL + /// / nonzero is_complementary implies nonzero weight_edge. + /// / start_clique - optional sequence of pairwise different ints. They are indices of + /// / vertices that shall be present in the output clique. + /// / subgraph_of_ban - optional sequence of (maybe equal) ints. They are indices of + /// / vertices that shall not be present in the output clique. + /// / clique_weight_ptr - optional output parameter. Weight of found clique stored here. + /// / num_generations - optional number of generations in evolutionary part of algorithm, + /// / zero forces to return first found clique. + /// / quality - optional parameter determining degree of required quality/speed tradeoff. + /// / Must be in the range from 0 to 9. + /// / 0 is fast and dirty, 9 is slow but hopefully yields good clique. + /// / Returns: + /// / sequence of pairwise different ints. + /// / These are indices of vertices that form found clique. + /// / Notes: + /// / in cases of CV_WEIGHTED_EDGE and CV_WEIGHTED_ALL weights should be nonnegative. + /// / start_clique has a priority over subgraph_of_ban. + /// /F *) +(* CVAPI(CvSeq* ) cvFindCliqueEx(CvGraph * graph, CvMemStorage * storage, + // int is_complementary CV_DEFAULT(0), + // CvGraphWeightType weight_type CV_DEFAULT(CV_NOT_WEIGHTED), + // CvVect32f weight_vtx CV_DEFAULT(0), + // CvMatr32f weight_edge CV_DEFAULT(0), + // CvSeq *start_clique CV_DEFAULT(0), + // CvSeq *subgraph_of_ban CV_DEFAULT(0), + // float *clique_weight_ptr CV_DEFAULT(0), + // int num_generations CV_DEFAULT(3), + // int quality CV_DEFAULT(2) );*) + // + // + // #define CV_UNDEF_SC_PARAM 12345 //default value of parameters + // + // #define CV_IDP_BIRCHFIELD_PARAM1 25 + // #define CV_IDP_BIRCHFIELD_PARAM2 5 + // #define CV_IDP_BIRCHFIELD_PARAM3 12 + // #define CV_IDP_BIRCHFIELD_PARAM4 15 + // #define CV_IDP_BIRCHFIELD_PARAM5 25 + // + // + // #define CV_DISPARITY_BIRCHFIELD 0 + // + // + (* F/////////////////////////////////////////////////////////////////////////// + /// / + /// / Name: cvFindStereoCorrespondence + /// / Purpose: find stereo correspondence on stereo-pair + /// / Context: + /// / Parameters: + /// / leftImage - left image of stereo-pair (format 8uC1). + /// / rightImage - right image of stereo-pair (format 8uC1). + /// / mode - mode of correspondence retrieval (now CV_DISPARITY_BIRCHFIELD only) + /// / dispImage - destination disparity image + /// / maxDisparity - maximal disparity + /// / param1, param2, param3, param4, param5 - parameters of algorithm + /// / Returns: + /// / Notes: + /// / Images must be rectified. + /// / All images must have format 8uC1. + /// /F *) + // CVAPI(void) + // cvFindStereoCorrespondence( + // const CvArr* leftImage, const CvArr* rightImage, + // int mode, + // CvArr* dispImage, + // int maxDisparity, + // double param1 CV_DEFAULT(CV_UNDEF_SC_PARAM), + // double param2 CV_DEFAULT(CV_UNDEF_SC_PARAM), + // double param3 CV_DEFAULT(CV_UNDEF_SC_PARAM), + // double param4 CV_DEFAULT(CV_UNDEF_SC_PARAM), + // double param5 CV_DEFAULT(CV_UNDEF_SC_PARAM) ); + // + (* *************************************************************************************** *) + (* *********** Epiline functions ****************** *) + // + // + // + // typedef struct CvStereoLineCoeff + // { + // double Xcoef; + // double XcoefA; + // double XcoefB; + // double XcoefAB; + // + // double Ycoef; + // double YcoefA; + // double YcoefB; + // double YcoefAB; + // + // double Zcoef; + // double ZcoefA; + // double ZcoefB; + // double ZcoefAB; + // }CvStereoLineCoeff; + // + // + // typedef struct CvCamera + // { + // float imgSize[2]; (* size of the camera view, used during calibration *) + // float matrix[9]; (* intinsic camera parameters: [ fx 0 cx; 0 fy cy; 0 0 1 ] *) + // float distortion[4]; (* distortion coefficients - two coefficients for radial distortion + // and another two for tangential: [ k1 k2 p1 p2 ] *) + // float rotMatr[9]; + // float transVect[3]; (* rotation matrix and transition vector relatively + // to some reference point in the space. *) + // } CvCamera; + // + // typedef struct CvStereoCamera + // { + // CvCamera* camera[2]; (* two individual camera parameters *) + // float fundMatr[9]; (* fundamental matrix *) + // + // (* New part for stereo *) + // CvPoint3D32f epipole[2]; + // CvPoint2D32f quad[2][4]; (* coordinates of destination quadrangle after + // epipolar geometry rectification *) + // double coeffs[2][3][3];(* coefficients for transformation *) + // CvPoint2D32f border[2][4]; + // CvSize warpSize; + // CvStereoLineCoeff* lineCoeffs; + // int needSwapCameras;(* flag set to 1 if need to swap cameras for good reconstruction *) + // float rotMatrix[9]; + // float transVector[3]; + // } CvStereoCamera; + // + // + // typedef struct CvContourOrientation + // { + // float egvals[2]; + // float egvects[4]; + // + // float max, min; // minimum and maximum projections + // int imax, imin; + // } CvContourOrientation; + // + // #define CV_CAMERA_TO_WARP 1 + // #define CV_WARP_TO_CAMERA 2 + // + // CVAPI(int) icvConvertWarpCoordinates(double coeffs[3][3], + // CvPoint2D32f* cameraPoint, + // CvPoint2D32f* warpPoint, + // int direction); + // + // CVAPI(int) icvGetSymPoint3D( CvPoint3D64f pointCorner, + // CvPoint3D64f point1, + // CvPoint3D64f point2, + // CvPoint3D64f *pointSym2); + // + // CVAPI(void) icvGetPieceLength3D(CvPoint3D64f point1,CvPoint3D64f point2,double* dist); + // + // CVAPI(int) icvCompute3DPoint( double alpha,double betta, + // CvStereoLineCoeff* coeffs, + // CvPoint3D64f* point); + // + // CVAPI(int) icvCreateConvertMatrVect( double* rotMatr1, + // double* transVect1, + // double* rotMatr2, + // double* transVect2, + // double* convRotMatr, + // double* convTransVect); + // + // CVAPI(int) icvConvertPointSystem(CvPoint3D64f M2, + // CvPoint3D64f* M1, + // double* rotMatr, + // double* transVect + // ); + // + // CVAPI(int) icvComputeCoeffForStereo( CvStereoCamera* stereoCamera); + // + // CVAPI(int) icvGetCrossPieceVector(CvPoint2D32f p1_start,CvPoint2D32f p1_end,CvPoint2D32f v2_start,CvPoint2D32f v2_end,CvPoint2D32f *cross); + // CVAPI(int) icvGetCrossLineDirect(CvPoint2D32f p1,CvPoint2D32f p2,float a,float b,float c,CvPoint2D32f* cross); + // CVAPI(float) icvDefinePointPosition(CvPoint2D32f point1,CvPoint2D32f point2,CvPoint2D32f point); + // CVAPI(int) icvStereoCalibration( int numImages, + // int* nums, + // CvSize imageSize, + // CvPoint2D32f* imagePoints1, + // CvPoint2D32f* imagePoints2, + // CvPoint3D32f* objectPoints, + // CvStereoCamera* stereoparams + // ); + // + // + // CVAPI(int) icvComputeRestStereoParams(CvStereoCamera *stereoparams); + // + // CVAPI(void) cvComputePerspectiveMap( const double coeffs[3][3], CvArr* rectMapX, CvArr* rectMapY ); + // + // CVAPI(int) icvComCoeffForLine( CvPoint2D64f point1, + // CvPoint2D64f point2, + // CvPoint2D64f point3, + // CvPoint2D64f point4, + // double* camMatr1, + // double* rotMatr1, + // double* transVect1, + // double* camMatr2, + // double* rotMatr2, + // double* transVect2, + // CvStereoLineCoeff* coeffs, + // int* needSwapCameras); + // + // CVAPI(int) icvGetDirectionForPoint( CvPoint2D64f point, + // double* camMatr, + // CvPoint3D64f* direct); + // + // CVAPI(int) icvGetCrossLines(CvPoint3D64f point11,CvPoint3D64f point12, + // CvPoint3D64f point21,CvPoint3D64f point22, + // CvPoint3D64f* midPoint); + // + // CVAPI(int) icvComputeStereoLineCoeffs( CvPoint3D64f pointA, + // CvPoint3D64f pointB, + // CvPoint3D64f pointCam1, + // double gamma, + // CvStereoLineCoeff* coeffs); + // + (* CVAPI(int) icvComputeFundMatrEpipoles ( double* camMatr1, + // double* rotMatr1, + // double* transVect1, + // double* camMatr2, + // double* rotMatr2, + // double* transVect2, + // CvPoint2D64f* epipole1, + // CvPoint2D64f* epipole2, + // double* fundMatr); *) + // + // CVAPI(int) icvGetAngleLine( CvPoint2D64f startPoint, CvSize imageSize,CvPoint2D64f *point1,CvPoint2D64f *point2); + // + // CVAPI(void) icvGetCoefForPiece( CvPoint2D64f p_start,CvPoint2D64f p_end, + // double *a,double *b,double *c, + // int* result); + // + (* CVAPI(void) icvGetCommonArea( CvSize imageSize, + // CvPoint2D64f epipole1,CvPoint2D64f epipole2, + // double* fundMatr, + // double* coeff11,double* coeff12, + // double* coeff21,double* coeff22, + // int* result); *) + // + // CVAPI(void) icvComputeeInfiniteProject1(double* rotMatr, + // double* camMatr1, + // double* camMatr2, + // CvPoint2D32f point1, + // CvPoint2D32f *point2); + // + // CVAPI(void) icvComputeeInfiniteProject2(double* rotMatr, + // double* camMatr1, + // double* camMatr2, + // CvPoint2D32f* point1, + // CvPoint2D32f point2); + // + // CVAPI(void) icvGetCrossDirectDirect( double* direct1,double* direct2, + // CvPoint2D64f *cross,int* result); + // + // CVAPI(void) icvGetCrossPieceDirect( CvPoint2D64f p_start,CvPoint2D64f p_end, + // double a,double b,double c, + // CvPoint2D64f *cross,int* result); + // + // CVAPI(void) icvGetCrossPiecePiece( CvPoint2D64f p1_start,CvPoint2D64f p1_end, + // CvPoint2D64f p2_start,CvPoint2D64f p2_end, + // CvPoint2D64f* cross, + // int* result); + // + // CVAPI(void) icvGetPieceLength(CvPoint2D64f point1,CvPoint2D64f point2,double* dist); + // + // CVAPI(void) icvGetCrossRectDirect( CvSize imageSize, + // double a,double b,double c, + // CvPoint2D64f *start,CvPoint2D64f *end, + // int* result); + // + // CVAPI(void) icvProjectPointToImage( CvPoint3D64f point, + // double* camMatr,double* rotMatr,double* transVect, + // CvPoint2D64f* projPoint); + // + // CVAPI(void) icvGetQuadsTransform( CvSize imageSize, + // double* camMatr1, + // double* rotMatr1, + // double* transVect1, + // double* camMatr2, + // double* rotMatr2, + // double* transVect2, + // CvSize* warpSize, + // double quad1[4][2], + // double quad2[4][2], + // double* fundMatr, + // CvPoint3D64f* epipole1, + // CvPoint3D64f* epipole2 + // ); + // + // CVAPI(void) icvGetQuadsTransformStruct( CvStereoCamera* stereoCamera); + // + // CVAPI(void) icvComputeStereoParamsForCameras(CvStereoCamera* stereoCamera); + // + // CVAPI(void) icvGetCutPiece( double* areaLineCoef1,double* areaLineCoef2, + // CvPoint2D64f epipole, + // CvSize imageSize, + // CvPoint2D64f* point11,CvPoint2D64f* point12, + // CvPoint2D64f* point21,CvPoint2D64f* point22, + // int* result); + // + // CVAPI(void) icvGetMiddleAnglePoint( CvPoint2D64f basePoint, + // CvPoint2D64f point1,CvPoint2D64f point2, + // CvPoint2D64f* midPoint); + // + // CVAPI(void) icvGetNormalDirect(double* direct,CvPoint2D64f point,double* normDirect); + // + // CVAPI(double) icvGetVect(CvPoint2D64f basePoint,CvPoint2D64f point1,CvPoint2D64f point2); + // + // CVAPI(void) icvProjectPointToDirect( CvPoint2D64f point,double* lineCoeff, + // CvPoint2D64f* projectPoint); + // + // CVAPI(void) icvGetDistanceFromPointToDirect( CvPoint2D64f point,double* lineCoef,double*dist); + // + // CVAPI(IplImage*) icvCreateIsometricImage( IplImage* src, IplImage* dst, + // int desired_depth, int desired_num_channels ); + // + // CVAPI(void) cvDeInterlace( const CvArr* frame, CvArr* fieldEven, CvArr* fieldOdd ); + // + (* CVAPI(int) icvSelectBestRt( int numImages, + // int* numPoints, + // CvSize imageSize, + // CvPoint2D32f* imagePoints1, + // CvPoint2D32f* imagePoints2, + // CvPoint3D32f* objectPoints, + // + // CvMatr32f cameraMatrix1, + // CvVect32f distortion1, + // CvMatr32f rotMatrs1, + // CvVect32f transVects1, + // + // CvMatr32f cameraMatrix2, + // CvVect32f distortion2, + // CvMatr32f rotMatrs2, + // CvVect32f transVects2, + // + // CvMatr32f bestRotMatr, + // CvVect32f bestTransVect + // ); *) + // + // + (* ***************************************************************************************\ + // * Contour Tree * + // \*************************************************************************************** *) + // + (* Contour tree header *) + // typedef struct CvContourTree + // { + // CV_SEQUENCE_FIELDS() + // CvPoint p1; (* the first point of the binary tree root segment *) + // CvPoint p2; (* the last point of the binary tree root segment *) + // } CvContourTree; + // + (* Builds hierarhical representation of a contour *) + // CVAPI(CvContourTree*) cvCreateContourTree( const CvSeq* contour, + // CvMemStorage* storage, + // double threshold ); + // + (* Reconstruct (completelly or partially) contour a from contour tree *) + // CVAPI(CvSeq*) cvContourFromContourTree( const CvContourTree* tree, + // CvMemStorage* storage, + // CvTermCriteria criteria ); + // + (* Compares two contour trees *) + // enum { CV_CONTOUR_TREES_MATCH_I1 = 1 }; + // + // CVAPI(double) cvMatchContourTrees( const CvContourTree* tree1, + // const CvContourTree* tree2, + // int method, double threshold ); + // + (* ***************************************************************************************\ + // * Contour Morphing * + // \*************************************************************************************** *) + // + (* finds correspondence between two contours *) + // CvSeq* cvCalcContoursCorrespondence( const CvSeq* contour1, + // const CvSeq* contour2, + // CvMemStorage* storage); + // + (* morphs contours using the pre-calculated correspondence: + // alpha=0 ~ contour1, alpha=1 ~ contour2 *) + // CvSeq* cvMorphContours( const CvSeq* contour1, const CvSeq* contour2, + // CvSeq* corr, double alpha, + // CvMemStorage* storage ); + // -// **************************************************************************************** -// * Active Contours * -// **************************************************************************************** + // **************************************************************************************** + // * Active Contours * + // **************************************************************************************** -const - CV_VALUE = 1; - CV_ARRAY = 2; + const CV_VALUE = 1; CV_ARRAY = 2; { (* Updates active contour in order to minimize its cummulative (internal and external) energy. *) @@ -866,9 +941,9 @@ const procedure cvSnakeImage(const image: pIplImage; points: pCvPointArray; length: Integer; alpha: PSingle; beta: PSingle; gamma: PSingle; coeff_usage: Integer; win: TCvSize; criteria: TCvTermCriteria; calc_gradient: Integer = 1); cdecl; -/// ****************************************************************************************\ -// * Texture Descriptors * -// \****************************************************************************************/ +(* ***************************************************************************************\ + // * Texture Descriptors * + // \*************************************************************************************** *) // // #define CV_GLCM_OPTIMIZATION_NONE -2 // #define CV_GLCM_OPTIMIZATION_LUT -1 @@ -914,9 +989,9 @@ procedure cvSnakeImage(const image: pIplImage; points: pCvPointArray; length: In // // CVAPI(IplImage*) cvCreateGLCMImage( CvGLCM* GLCM, int step ); // -/// ****************************************************************************************\ -// * Face eyes&mouth tracking * -// \****************************************************************************************/ +(* ***************************************************************************************\ + // * Face eyes&mouth tracking * + // \*************************************************************************************** *) // // // typedef struct CvFaceTracker CvFaceTracker; @@ -948,9 +1023,9 @@ procedure cvSnakeImage(const image: pIplImage; points: pCvPointArray; length: In // CvSeq * cvPostBoostingFindFace(IplImage * Image,CvMemStorage* storage); // // -/// ****************************************************************************************\ -// * 3D Tracker * -// \****************************************************************************************/ +(* ***************************************************************************************\ + // * 3D Tracker * + // \*************************************************************************************** *) // // typedef unsigned char CvBool; // @@ -985,9 +1060,9 @@ procedure cvSnakeImage(const image: pIplImage; points: pCvPointArray; length: In // typedef struct Cv3dTrackerCameraInfo // { // CvBool valid; -// float mat[4][4]; /* maps camera coordinates to world coordinates */ -// CvPoint2D32f principal_point; /* copied from intrinsics so this structure */ -// /* has all the info we need */ +// float mat[4][4]; (* maps camera coordinates to world coordinates *) +// CvPoint2D32f principal_point; (* copied from intrinsics so this structure *) +// (* has all the info we need *) // } Cv3dTrackerCameraInfo; // // typedef struct Cv3dTrackerCameraIntrinsics @@ -998,28 +1073,28 @@ procedure cvSnakeImage(const image: pIplImage; points: pCvPointArray; length: In // } Cv3dTrackerCameraIntrinsics; // // CVAPI(CvBool) cv3dTrackerCalibrateCameras(int num_cameras, -// const Cv3dTrackerCameraIntrinsics camera_intrinsics[], /* size is num_cameras */ +// const Cv3dTrackerCameraIntrinsics camera_intrinsics[], (* size is num_cameras *) // CvSize etalon_size, // float square_size, -// IplImage *samples[], /* size is num_cameras */ -// Cv3dTrackerCameraInfo camera_info[]); /* size is num_cameras */ +// IplImage *samples[], (* size is num_cameras *) +// Cv3dTrackerCameraInfo camera_info[]); (* size is num_cameras *) // // CVAPI(int) cv3dTrackerLocateObjects(int num_cameras, int num_objects, -// const Cv3dTrackerCameraInfo camera_info[], /* size is num_cameras */ -// const Cv3dTracker2dTrackedObject tracking_info[], /* size is num_objects*num_cameras */ -// Cv3dTrackerTrackedObject tracked_objects[]); /* size is num_objects */ -/// **************************************************************************************** -// tracking_info is a rectangular array; one row per camera, num_objects elements per row. -// The id field of any unused slots must be -1. Ids need not be ordered or consecutive. On -// completion, the return value is the number of objects located; i.e., the number of objects -// visible by more than one camera. The id field of any unused slots in tracked objects is -// set to -1. -// ****************************************************************************************/ +// const Cv3dTrackerCameraInfo camera_info[], (* size is num_cameras *) +// const Cv3dTracker2dTrackedObject tracking_info[], (* size is num_objects*num_cameras *) +// Cv3dTrackerTrackedObject tracked_objects[]); (* size is num_objects *) +(* *************************************************************************************** + // tracking_info is a rectangular array; one row per camera, num_objects elements per row. + // The id field of any unused slots must be -1. Ids need not be ordered or consecutive. On + // completion, the return value is the number of objects located; i.e., the number of objects + // visible by more than one camera. The id field of any unused slots in tracked objects is + // set to -1. + // *************************************************************************************** *) // // -/// ****************************************************************************************\ -// * Skeletons and Linear-Contour Models * -// \****************************************************************************************/ +(* ***************************************************************************************\ + // * Skeletons and Linear-Contour Models * + // \*************************************************************************************** *) // // typedef enum CvLeeParameters // { @@ -1081,7 +1156,7 @@ procedure cvSnakeImage(const image: pIplImage; points: pCvPointArray; length: In // CV_VORONOIDIAGRAM2D_FIELDS() // } CvVoronoiDiagram2D; // -/// * Computes Voronoi Diagram for given polygons with holes */ +(* Computes Voronoi Diagram for given polygons with holes *) // CVAPI(int) cvVoronoiDiagramFromContour(CvSeq* ContourSeq, // CvVoronoiDiagram2D** VoronoiDiagram, // CvMemStorage* VoronoiStorage, @@ -1089,7 +1164,7 @@ procedure cvSnakeImage(const image: pIplImage; points: pCvPointArray; length: In // int contour_orientation CV_DEFAULT(-1), // int attempt_number CV_DEFAULT(10)); // -/// * Computes Voronoi Diagram for domains in given image */ +(* Computes Voronoi Diagram for domains in given image *) // CVAPI(int) cvVoronoiDiagramFromImage(IplImage* pImage, // CvSeq** ContourSeq, // CvVoronoiDiagram2D** VoronoiDiagram, @@ -1097,11 +1172,11 @@ procedure cvSnakeImage(const image: pIplImage; points: pCvPointArray; length: In // CvLeeParameters regularization_method CV_DEFAULT(CV_LEE_NON), // float approx_precision CV_DEFAULT(CV_LEE_AUTO)); // -/// * Deallocates the storage */ +(* Deallocates the storage *) // CVAPI(void) cvReleaseVoronoiStorage(CvVoronoiDiagram2D* VoronoiDiagram, // CvMemStorage** pVoronoiStorage); // -/// *********************** Linear-Contour Model ****************************/ +(* ********************** Linear-Contour Model *************************** *) // // struct CvLCMEdge; // struct CvLCMNode; @@ -1122,49 +1197,49 @@ procedure cvSnakeImage(const image: pIplImage; points: pCvPointArray; length: In // } CvLCMNode; // // -/// * Computes hybrid model from Voronoi Diagram */ +(* Computes hybrid model from Voronoi Diagram *) // CVAPI(CvGraph*) cvLinearContorModelFromVoronoiDiagram(CvVoronoiDiagram2D* VoronoiDiagram, // float maxWidth); // -/// * Releases hybrid model storage */ +(* Releases hybrid model storage *) // CVAPI(int) cvReleaseLinearContorModelStorage(CvGraph** Graph); // // -/// * two stereo-related functions */ +(* two stereo-related functions *) // // CVAPI(void) cvInitPerspectiveTransform( CvSize size, const CvPoint2D32f vertex[4], double matrix[3][3], // CvArr* rectMap ); // -/// *CVAPI(void) cvInitStereoRectification( CvStereoCamera* params, -// CvArr* rectMap1, CvArr* rectMap2, -// int do_undistortion );*/ +(* CVAPI(void) cvInitStereoRectification( CvStereoCamera* params, + // CvArr* rectMap1, CvArr* rectMap2, + // int do_undistortion ); *) // -/// *************************** View Morphing Functions ************************/ +(* ************************** View Morphing Functions *********************** *) // // typedef struct CvMatrix3 // { // float m[3][3]; // } CvMatrix3; // -/// * The order of the function corresponds to the order they should appear in -// the view morphing pipeline */ +(* The order of the function corresponds to the order they should appear in + // the view morphing pipeline *) // -/// * Finds ending points of scanlines on left and right images of stereo-pair */ +(* Finds ending points of scanlines on left and right images of stereo-pair *) // CVAPI(void) cvMakeScanlines( const CvMatrix3* matrix, CvSize img_size, // int* scanlines1, int* scanlines2, // int* lengths1, int* lengths2, // int* line_count ); // -/// * Grab pixel values from scanlines and stores them sequentially -// (some sort of perspective image transform) */ +(* Grab pixel values from scanlines and stores them sequentially + // (some sort of perspective image transform) *) // CVAPI(void) cvPreWarpImage( int line_count, // IplImage* img, // uchar* dst, // int* dst_nums, // int* scanlines); // -/// * Approximate each grabbed scanline by a sequence of runs -// (lossy run-length compression) */ +(* Approximate each grabbed scanline by a sequence of runs + // (lossy run-length compression) *) // CVAPI(void) cvFindRuns( int line_count, // uchar* prewarp1, // uchar* prewarp2, @@ -1175,7 +1250,7 @@ procedure cvSnakeImage(const image: pIplImage; points: pCvPointArray; length: In // int* num_runs1, // int* num_runs2); // -/// * Compares two sets of compressed scanlines */ +(* Compares two sets of compressed scanlines *) // CVAPI(void) cvDynamicCorrespondMulti( int line_count, // int* first, // int* first_runs, @@ -1184,7 +1259,7 @@ procedure cvSnakeImage(const image: pIplImage; points: pCvPointArray; length: In // int* first_corr, // int* second_corr); // -/// * Finds scanline ending coordinates for some intermediate "virtual" camera position */ +(* Finds scanline ending coordinates for some intermediate "virtual" camera position *) // CVAPI(void) cvMakeAlphaScanlines( int* scanlines1, // int* scanlines2, // int* scanlinesA, @@ -1192,8 +1267,8 @@ procedure cvSnakeImage(const image: pIplImage; points: pCvPointArray; length: In // int line_count, // float alpha); // -/// * Blends data of the left and right image scanlines to get -// pixel values of "virtual" image scanlines */ +(* Blends data of the left and right image scanlines to get + // pixel values of "virtual" image scanlines *) // CVAPI(void) cvMorphEpilinesMulti( int line_count, // uchar* first_pix, // int* first_num, @@ -1209,15 +1284,15 @@ procedure cvSnakeImage(const image: pIplImage; points: pCvPointArray; length: In // int* first_corr, // int* second_corr); // -/// * Does reverse warping of the morphing result to make -// it fill the destination image rectangle */ +(* Does reverse warping of the morphing result to make + // it fill the destination image rectangle *) // CVAPI(void) cvPostWarpImage( int line_count, // uchar* src, // int* src_nums, // IplImage* img, // int* scanlines); // -/// * Deletes Moire (missed pixels that appear due to discretization) */ +(* Deletes Moire (missed pixels that appear due to discretization) *) // CVAPI(void) cvDeleteMoire( IplImage* img ); // // @@ -1225,30 +1300,30 @@ procedure cvSnakeImage(const image: pIplImage; points: pCvPointArray; length: In // { // int MP; // int DP; -// float* DynamMatr; /* Matrix of the linear Dynamics system */ -// float* State; /* Vector of State */ -// int SamplesNum; /* Number of the Samples */ -// float** flSamples; /* arr of the Sample Vectors */ -// float** flNewSamples; /* temporary array of the Sample Vectors */ -// float* flConfidence; /* Confidence for each Sample */ -// float* flCumulative; /* Cumulative confidence */ -// float* Temp; /* Temporary vector */ -// float* RandomSample; /* RandomVector to update sample set */ -// struct CvRandState* RandS; /* Array of structures to generate random vectors */ +// float* DynamMatr; (* Matrix of the linear Dynamics system *) +// float* State; (* Vector of State *) +// int SamplesNum; (* Number of the Samples *) +// float** flSamples; (* arr of the Sample Vectors *) +// float** flNewSamples; (* temporary array of the Sample Vectors *) +// float* flConfidence; (* Confidence for each Sample *) +// float* flCumulative; (* Cumulative confidence *) +// float* Temp; (* Temporary vector *) +// float* RandomSample; (* RandomVector to update sample set *) +// struct CvRandState* RandS; (* Array of structures to generate random vectors *) // } CvConDensation; // -/// * Creates ConDensation filter state */ +(* Creates ConDensation filter state *) // CVAPI(CvConDensation*) cvCreateConDensation( int dynam_params, // int measure_params, // int sample_count ); // -/// * Releases ConDensation filter state */ +(* Releases ConDensation filter state *) // CVAPI(void) cvReleaseConDensation( CvConDensation** condens ); // -/// * Updates ConDensation filter by time (predict future state of the system) */ +(* Updates ConDensation filter by time (predict future state of the system) *) // CVAPI(void) cvConDensUpdateByTime( CvConDensation* condens); // -/// * Initializes ConDensation filter samples */ +(* Initializes ConDensation filter samples *) // CVAPI(void) cvConDensInitSampleSet( CvConDensation* condens, CvMat* lower_bound, CvMat* upper_bound ); // // CV_INLINE int iplWidth( const IplImage* img ) @@ -1267,9 +1342,9 @@ procedure cvSnakeImage(const image: pIplImage; points: pCvPointArray; length: In // // #ifdef __cplusplus // -/// ****************************************************************************************\ -// * Calibration engine * -// \****************************************************************************************/ +(* ***************************************************************************************\ + // * Calibration engine * + // \*************************************************************************************** *) // // typedef enum CvCalibEtalonType // { @@ -1282,11 +1357,11 @@ procedure cvSnakeImage(const image: pIplImage; points: pCvPointArray; length: In // class CV_EXPORTS CvCalibFilter // { // public: -// /* Constructor & destructor */ +// (* Constructor & destructor *) // CvCalibFilter(); // virtual ~CvCalibFilter(); // -// /* Sets etalon type - one for all cameras. +// (* Sets etalon type - one for all cameras. // etalonParams is used in case of pre-defined etalons (such as chessboard). // Number of elements in etalonParams is determined by etalonType. // E.g., if etalon type is CV_ETALON_TYPE_CHESSBOARD then: @@ -1294,77 +1369,77 @@ procedure cvSnakeImage(const image: pIplImage; points: pCvPointArray; length: In // etalonParams[1] is number of squares per another side of etalon // etalonParams[2] is linear size of squares in the board in arbitrary units. // pointCount & points are used in case of -// CV_CALIB_ETALON_USER (user-defined) etalon. */ +// CV_CALIB_ETALON_USER (user-defined) etalon. *) // virtual bool // SetEtalon( CvCalibEtalonType etalonType, double* etalonParams, // int pointCount = 0, CvPoint2D32f* points = 0 ); // -// /* Retrieves etalon parameters/or and points */ +// (* Retrieves etalon parameters/or and points *) // virtual CvCalibEtalonType // GetEtalon( int* paramCount = 0, const double** etalonParams = 0, // int* pointCount = 0, const CvPoint2D32f** etalonPoints = 0 ) const; // -// /* Sets number of cameras calibrated simultaneously. It is equal to 1 initially */ +// (* Sets number of cameras calibrated simultaneously. It is equal to 1 initially *) // virtual void SetCameraCount( int cameraCount ); // -// /* Retrieves number of cameras */ +// (* Retrieves number of cameras *) // int GetCameraCount() const { return cameraCount; } // -// /* Starts cameras calibration */ +// (* Starts cameras calibration *) // virtual bool SetFrames( int totalFrames ); // -// /* Stops cameras calibration */ +// (* Stops cameras calibration *) // virtual void Stop( bool calibrate = false ); // -// /* Retrieves number of cameras */ +// (* Retrieves number of cameras *) // bool IsCalibrated() const { return isCalibrated; } // -// /* Feeds another serie of snapshots (one per each camera) to filter. +// (* Feeds another serie of snapshots (one per each camera) to filter. // Etalon points on these images are found automatically. -// If the function can't locate points, it returns false */ +// If the function can't locate points, it returns false *) // virtual bool FindEtalon( IplImage** imgs ); // -// /* The same but takes matrices */ +// (* The same but takes matrices *) // virtual bool FindEtalon( CvMat** imgs ); // -// /* Lower-level function for feeding filter with already found etalon points. -// Array of point arrays for each camera is passed. */ +// (* Lower-level function for feeding filter with already found etalon points. +// Array of point arrays for each camera is passed. *) // virtual bool Push( const CvPoint2D32f** points = 0 ); // -// /* Returns total number of accepted frames and, optionally, -// total number of frames to collect */ +// (* Returns total number of accepted frames and, optionally, +// total number of frames to collect *) // virtual int GetFrameCount( int* framesTotal = 0 ) const; // -// /* Retrieves camera parameters for specified camera. -// If camera is not calibrated the function returns 0 */ +// (* Retrieves camera parameters for specified camera. +// If camera is not calibrated the function returns 0 *) // virtual const CvCamera* GetCameraParams( int idx = 0 ) const; // // virtual const CvStereoCamera* GetStereoParams() const; // -// /* Sets camera parameters for all cameras */ +// (* Sets camera parameters for all cameras *) // virtual bool SetCameraParams( CvCamera* params ); // -// /* Saves all camera parameters to file */ +// (* Saves all camera parameters to file *) // virtual bool SaveCameraParams( const char* filename ); // -// /* Loads all camera parameters from file */ +// (* Loads all camera parameters from file *) // virtual bool LoadCameraParams( const char* filename ); // -// /* Undistorts images using camera parameters. Some of src pointers can be NULL. */ +// (* Undistorts images using camera parameters. Some of src pointers can be NULL. *) // virtual bool Undistort( IplImage** src, IplImage** dst ); // -// /* Undistorts images using camera parameters. Some of src pointers can be NULL. */ +// (* Undistorts images using camera parameters. Some of src pointers can be NULL. *) // virtual bool Undistort( CvMat** src, CvMat** dst ); // -// /* Returns array of etalon points detected/partally detected -// on the latest frame for idx-th camera */ +// (* Returns array of etalon points detected/partally detected +// on the latest frame for idx-th camera *) // virtual bool GetLatestPoints( int idx, CvPoint2D32f** pts, // int* count, bool* found ); // -// /* Draw the latest detected/partially detected etalon */ +// (* Draw the latest detected/partially detected etalon *) // virtual void DrawPoints( IplImage** dst ); // -// /* Draw the latest detected/partially detected etalon */ +// (* Draw the latest detected/partially detected etalon *) // virtual void DrawPoints( CvMat** dst ); // // virtual bool Rectify( IplImage** srcarr, IplImage** dstarr ); @@ -1374,7 +1449,7 @@ procedure cvSnakeImage(const image: pIplImage; points: pCvPointArray; length: In // // enum { MAX_CAMERAS = 3 }; // -// /* etalon data */ +// (* etalon data *) // CvCalibEtalonType etalonType; // int etalonParamCount; // double* etalonParams; @@ -1385,7 +1460,7 @@ procedure cvSnakeImage(const image: pIplImage; points: pCvPointArray; length: In // CvMat* tempImg; // CvMemStorage* storage; // -// /* camera data */ +// (* camera data *) // int cameraCount; // CvCamera cameraParams[MAX_CAMERAS]; // CvStereoCamera stereo; @@ -1396,7 +1471,7 @@ procedure cvSnakeImage(const image: pIplImage; points: pCvPointArray; length: In // CvPoint2D32f* latestPoints[MAX_CAMERAS]; // CvMat* rectMap[MAX_CAMERAS][2]; // -// /* Added by Valery */ +// (* Added by Valery *) // //CvStereoCamera stereoParams; // // int maxPoints; @@ -1713,9 +1788,9 @@ procedure cvSnakeImage(const image: pIplImage; points: pCvPointArray; length: In // CvMat* matrix; // }; // -/// ****************************************************************************************\ -// * CamShiftTracker * -// \****************************************************************************************/ +(* ***************************************************************************************\ + // * CamShiftTracker * + // \*************************************************************************************** *) // // class CV_EXPORTS CvCamShiftTracker // { @@ -1724,7 +1799,7 @@ procedure cvSnakeImage(const image: pIplImage; points: pCvPointArray; length: In // CvCamShiftTracker(); // virtual ~CvCamShiftTracker(); // -// /**** Characteristics of the object that are calculated by track_object method *****/ +// (**** Characteristics of the object that are calculated by track_object method *****) // float get_orientation() const // orientation of the object in degrees // { return m_box.angle; } // float get_length() const // the larger linear size of the object @@ -1736,7 +1811,7 @@ procedure cvSnakeImage(const image: pIplImage; points: pCvPointArray; length: In // CvRect get_window() const // bounding rectangle for the object // { return m_comp.rect; } // -// /*********************** Tracking parameters ************************/ +// (*********************** Tracking parameters ************************) // int get_threshold() const // thresholding value that applied to back project // { return m_threshold; } // @@ -1765,7 +1840,7 @@ procedure cvSnakeImage(const image: pIplImage; points: pCvPointArray; length: In // bool set_max_ch_val( int channel, int val ) // set the maximum allowed value of the specified channel // { m_max_ch_val[channel] = val; return true; } // -// /************************ The processing methods *********************************/ +// (************************ The processing methods *********************************) // // update object position // virtual bool track_object( const IplImage* cur_frame ); // @@ -1775,7 +1850,7 @@ procedure cvSnakeImage(const image: pIplImage; points: pCvPointArray; length: In // // reset histogram // virtual void reset_histogram(); // -// /************************ Retrieving internal data *******************************/ +// (************************ Retrieving internal data *******************************) // // get back project image // virtual IplImage* get_back_project() // { return m_back_project; } @@ -1806,9 +1881,9 @@ procedure cvSnakeImage(const image: pIplImage; points: pCvPointArray; length: In // IplImage* m_mask; // }; // -/// ****************************************************************************************\ -// * Expectation - Maximization * -// \****************************************************************************************/ +(* ***************************************************************************************\ + // * Expectation - Maximization * + // \*************************************************************************************** *) // struct CV_EXPORTS_W_MAP CvEMParams // { // CvEMParams(); @@ -1904,9 +1979,9 @@ procedure cvSnakeImage(const image: pIplImage; points: pCvPointArray; length: In // typedef CvEMParams EMParams; // typedef CvEM ExpectationMaximization; // -/// *! -// The Patch Generator class -// */ +(* ! + // The Patch Generator class + // *) // class CV_EXPORTS PatchGenerator // { // public: @@ -2061,9 +2136,9 @@ procedure cvSnakeImage(const image: pIplImage; points: pCvPointArray; length: In // }; // // -/// ****************************************************************************************\ -// * Calonder Classifier * -// \****************************************************************************************/ +(* ***************************************************************************************\ + // * Calonder Classifier * + // \*************************************************************************************** *) // // struct RTreeNode; // @@ -2262,9 +2337,9 @@ procedure cvSnakeImage(const image: pIplImage; points: pCvPointArray; length: In // bool keep_floats_; // }; // -/// ****************************************************************************************\ -// * One-Way Descriptor * -// \****************************************************************************************/ +(* ***************************************************************************************\ + // * One-Way Descriptor * + // \*************************************************************************************** *) // /// / CvAffinePose: defines a parameterized affine transformation of an image patch. /// / An image patch is rotated on angle phi (in degrees), then scaled lambda1 times @@ -2677,9 +2752,9 @@ procedure cvSnakeImage(const image: pIplImage; points: pCvPointArray; length: In // }; // // -/// * -// * OneWayDescriptorMatcher -// */ +(* + // * OneWayDescriptorMatcher + // *) // class OneWayDescriptorMatcher; // typedef OneWayDescriptorMatcher OneWayDescriptorMatch; // @@ -2750,9 +2825,9 @@ procedure cvSnakeImage(const image: pIplImage; points: pCvPointArray; length: In // int prevTrainCount; // }; // -/// * -// * FernDescriptorMatcher -// */ +(* + // * FernDescriptorMatcher + // *) // class FernDescriptorMatcher; // typedef FernDescriptorMatcher FernDescriptorMatch; // @@ -2817,9 +2892,9 @@ procedure cvSnakeImage(const image: pIplImage; points: pCvPointArray; length: In // }; // // -/// * -// * CalonderDescriptorExtractor -// */ +(* + // * CalonderDescriptorExtractor + // *) // template // class CV_EXPORTS CalonderDescriptorExtractor : public DescriptorExtractor // { @@ -2894,9 +2969,9 @@ procedure cvSnakeImage(const image: pIplImage; points: pCvPointArray; length: In // }; // // -/// ****************************************************************************************\ -// * Planar Object Detection * -// \****************************************************************************************/ +(* ***************************************************************************************\ + // * Planar Object Detection * + // \*************************************************************************************** *) // // class CV_EXPORTS PlanarObjectDetector // { @@ -2971,10 +3046,10 @@ procedure cvSnakeImage(const image: pIplImage; points: pCvPointArray; length: In // // #endif -/// * Splits color or grayscale image into multiple connected components -// of nearly the same color/brightness using modification of Burt algorithm. -// comp with contain a pointer to sequence (CvSeq) -// of connected components (CvConnectedComp) */ +(* Splits color or grayscale image into multiple connected components + // of nearly the same color/brightness using modification of Burt algorithm. + // comp with contain a pointer to sequence (CvSeq) + // of connected components (CvConnectedComp) *) // CVAPI(void) cvPyrSegmentation( IplImage* src, IplImage* dst, // CvMemStorage* storage, CvSeq** comp, // int level, double threshold1, @@ -2982,96 +3057,84 @@ procedure cvSnakeImage(const image: pIplImage; points: pCvPointArray; length: In procedure cvPyrSegmentation(src: pIplImage; dst: pIplImage; storage: pCvMemStorage; var comp: pCvSeq; level: Integer; threshold1: double; threshold2: double); cdecl; -/// ****************************************************************************************\ -// * Planar subdivisions * -// \****************************************************************************************/ +(* ***************************************************************************************\ + // * Planar subdivisions * + // \*************************************************************************************** *) type pCvSubdiv2DEdge = ^TCvSubdiv2DEdge; - TCvSubdiv2DEdge = size_t; - // - // #define CV_QUADEDGE2D_FIELDS() \ - // int flags; \ - // struct CvSubdiv2DPoint* pt[4]; \ - // CvSubdiv2DEdge next[4]; - // - // #define CV_SUBDIV2D_POINT_FIELDS()\ - // int flags; \ - // CvSubdiv2DEdge first; \ - // CvPoint2D32f pt; \ - // int id; - // - // #define CV_SUBDIV2D_VIRTUAL_POINT_FLAG (1 << 30) - // - // typedef struct CvQuadEdge2D - // { - // CV_QUADEDGE2D_FIELDS() - // } - // CvQuadEdge2D; - // - // typedef struct CvSubdiv2DPoint - // { - // CV_SUBDIV2D_POINT_FIELDS() - // } - // CvSubdiv2DPoint; - // - // #define CV_SUBDIV2D_FIELDS() \ - // CV_GRAPH_FIELDS() \ - // int quad_edges; \ - // int is_geometry_valid; \ - // CvSubdiv2DEdge recent_edge; \ - // CvPoint2D32f topleft; \ - // CvPoint2D32f bottomright; - // - // typedef struct CvSubdiv2D - // { - // CV_SUBDIV2D_FIELDS() - // } - // CvSubdiv2D; +TCvSubdiv2DEdge = size_t; +// +// #define CV_QUADEDGE2D_FIELDS() \ +// int flags; \ +// struct CvSubdiv2DPoint* pt[4]; \ +// CvSubdiv2DEdge next[4]; +// +// #define CV_SUBDIV2D_POINT_FIELDS()\ +// int flags; \ +// CvSubdiv2DEdge first; \ +// CvPoint2D32f pt; \ +// int id; +// +// #define CV_SUBDIV2D_VIRTUAL_POINT_FLAG (1 << 30) +// +// typedef struct CvQuadEdge2D +// { +// CV_QUADEDGE2D_FIELDS() +// } +// CvQuadEdge2D; +// +// typedef struct CvSubdiv2DPoint +// { +// CV_SUBDIV2D_POINT_FIELDS() +// } +// CvSubdiv2DPoint; +// +// #define CV_SUBDIV2D_FIELDS() \ +// CV_GRAPH_FIELDS() \ +// int quad_edges; \ +// int is_geometry_valid; \ +// CvSubdiv2DEdge recent_edge; \ +// CvPoint2D32f topleft; \ +// CvPoint2D32f bottomright; +// +// typedef struct CvSubdiv2D +// { +// CV_SUBDIV2D_FIELDS() +// } +// CvSubdiv2D; -Type - TCvSubdiv2DPointLocation = Integer; +Type TCvSubdiv2DPointLocation = Integer; const - { CvSubdiv2DPointLocation enum } - CV_PTLOC_ERROR = -2; - CV_PTLOC_OUTSIDE_RECT = -1; - CV_PTLOC_INSIDE = 0; - CV_PTLOC_VERTEX = 1; - CV_PTLOC_ON_EDGE = 2; +{ CvSubdiv2DPointLocation enum } + CV_PTLOC_ERROR = -2; CV_PTLOC_OUTSIDE_RECT = -1; CV_PTLOC_INSIDE = 0; CV_PTLOC_VERTEX = 1; CV_PTLOC_ON_EDGE = 2; -Type - TCvNextEdgeType = Integer; +Type TCvNextEdgeType = Integer; const - { CvNextEdgeType enum } - CV_NEXT_AROUND_ORG = $00; - CV_NEXT_AROUND_DST = $22; - CV_PREV_AROUND_ORG = $11; - CV_PREV_AROUND_DST = $33; - CV_NEXT_AROUND_LEFT = $13; - CV_NEXT_AROUND_RIGHT = $31; - CV_PREV_AROUND_LEFT = $20; - CV_PREV_AROUND_RIGHT = $02; +{ CvNextEdgeType enum } + CV_NEXT_AROUND_ORG = $00; CV_NEXT_AROUND_DST = $22; CV_PREV_AROUND_ORG = $11; CV_PREV_AROUND_DST = $33; +CV_NEXT_AROUND_LEFT = $13; CV_NEXT_AROUND_RIGHT = $31; CV_PREV_AROUND_LEFT = $20; CV_PREV_AROUND_RIGHT = $02; - /// * get the next edge with the same origin point (counterwise) */ - // #define CV_SUBDIV2D_NEXT_EDGE( edge ) (((CvQuadEdge2D*)((edge) & ~3))->next[(edge)&3]) +(* get the next edge with the same origin point (counterwise) *) +// #define CV_SUBDIV2D_NEXT_EDGE( edge ) (((CvQuadEdge2D*)((edge) & ~3))->next[(edge)&3]) - /// * Initializes Delaunay triangulation */ - // CVAPI(void) cvInitSubdivDelaunay2D( CvSubdiv2D* subdiv, CvRect rect ); +(* Initializes Delaunay triangulation *) +// CVAPI(void) cvInitSubdivDelaunay2D( CvSubdiv2D* subdiv, CvRect rect ); procedure cvInitSubdivDelaunay2D(subdiv: pCvSubdiv2D; rect: TCvRect); cdecl; -/// * Creates new subdivision */ +(* Creates new subdivision *) // CVAPI(CvSubdiv2D*) cvCreateSubdiv2D( int subdiv_type, int header_size, // int vtx_size, int quadedge_size, // CvMemStorage* storage ); function cvCreateSubdiv2D(subdiv_type: Integer; header_size: Integer; vtx_size: Integer; quadedge_size: Integer; storage: pCvMemStorage): pCvSubdiv2D; cdecl; -/// ************************* high-level subdivision functions ***************************/ +(* ************************ high-level subdivision functions ************************** *) // -/// * Simplified Delaunay diagram creation */ +(* Simplified Delaunay diagram creation *) // CV_INLINE CvSubdiv2D* cvCreateSubdivDelaunay2D( CvRect rect, CvMemStorage* storage ) // { // CvSubdiv2D* subdiv = cvCreateSubdiv2D( CV_SEQ_KIND_SUBDIV2D, sizeof(*subdiv), @@ -3081,13 +3144,13 @@ function cvCreateSubdiv2D(subdiv_type: Integer; header_size: Integer; vtx_size: // return subdiv; // } -/// * Inserts new point to the Delaunay triangulation */ +(* Inserts new point to the Delaunay triangulation *) // CVAPI(CvSubdiv2DPoint*) cvSubdivDelaunay2DInsert( CvSubdiv2D* subdiv, CvPoint2D32f pt); function cvSubdivDelaunay2DInsert(subdiv: pCvSubdiv2D; pt: TCvPoint2D32f): pCvSubdiv2DPoint; cdecl; -/// * Locates a point within the Delaunay triangulation (finds the edge -// the point is left to or belongs to, or the triangulation point the given -// point coinsides with */ +(* Locates a point within the Delaunay triangulation (finds the edge + // the point is left to or belongs to, or the triangulation point the given + // point coinsides with *) // CVAPI(CvSubdiv2DPointLocation) cvSubdiv2DLocate( // CvSubdiv2D* subdiv, CvPoint2D32f pt, // CvSubdiv2DEdge* edge, @@ -3096,19 +3159,19 @@ function cvSubdivDelaunay2DInsert(subdiv: pCvSubdiv2D; pt: TCvPoint2D32f): pCvSu function cvSubdiv2DLocate(subdiv: pCvSubdiv2D; pt: TCvPoint2D32f; edge: pCvSubdiv2DEdge; vertex: pCvSubdiv2DPoint = nil) : TCvSubdiv2DPointLocation; cdecl; -/// * Calculates Voronoi tesselation (i.e. coordinates of Voronoi points) */ +(* Calculates Voronoi tesselation (i.e. coordinates of Voronoi points) *) // CVAPI(void) cvCalcSubdivVoronoi2D( CvSubdiv2D* subdiv ); procedure cvCalcSubdivVoronoi2D(subdiv: pCvSubdiv2D); cdecl; -/// * Removes all Voronoi points from the tesselation */ +(* Removes all Voronoi points from the tesselation *) // CVAPI(void) cvClearSubdivVoronoi2D( CvSubdiv2D* subdiv ); // // -/// * Finds the nearest to the given point vertex in subdivision. */ +(* Finds the nearest to the given point vertex in subdivision. *) // CVAPI(CvSubdiv2DPoint*) cvFindNearestPoint2D( CvSubdiv2D* subdiv, CvPoint2D32f pt ); // // -/// ************ Basic quad-edge navigation and operations ************/ +(* *********** Basic quad-edge navigation and operations *********** *) // // CV_INLINE CvSubdiv2DEdge cvSubdiv2DNextEdge( CvSubdiv2DEdge edge ) // { @@ -3148,9 +3211,9 @@ function cvSubdiv2DEdgeOrg(edge: TCvSubdiv2DEdge): pCvSubdiv2DPoint; // inline; // } function cvSubdiv2DEdgeDst(edge: TCvSubdiv2DEdge): pCvSubdiv2DPoint; // inline; -/// ****************************************************************************************\ -// * Additional operations on Subdivisions * -// \****************************************************************************************/ +(* ***************************************************************************************\ + // * Additional operations on Subdivisions * + // \*************************************************************************************** *) // /// / paints voronoi diagram: just demo function // CVAPI(void) icvDrawMosaic( CvSubdiv2D* subdiv, IplImage* src, IplImage* dst ); @@ -3177,84 +3240,70 @@ function cvSubdiv2DEdgeDst(edge: TCvSubdiv2DEdge): pCvSubdiv2DPoint; // inline; // } // // -/// * Constructs kd-tree from set of feature descriptors */ +(* Constructs kd-tree from set of feature descriptors *) // CVAPI(struct CvFeatureTree*) cvCreateKDTree(CvMat* desc); // -/// * Constructs spill-tree from set of feature descriptors */ +(* Constructs spill-tree from set of feature descriptors *) // CVAPI(struct CvFeatureTree*) cvCreateSpillTree( const CvMat* raw_data, // const int naive CV_DEFAULT(50), // const double rho CV_DEFAULT(.7), // const double tau CV_DEFAULT(.1) ); // -/// * Release feature tree */ +(* Release feature tree *) // CVAPI(void) cvReleaseFeatureTree(struct CvFeatureTree* tr); // -/// * Searches feature tree for k nearest neighbors of given reference points, -// searching (in case of kd-tree/bbf) at most emax leaves. */ +(* Searches feature tree for k nearest neighbors of given reference points, + // searching (in case of kd-tree/bbf) at most emax leaves. *) // CVAPI(void) cvFindFeatures(struct CvFeatureTree* tr, const CvMat* query_points, // CvMat* indices, CvMat* dist, int k, int emax CV_DEFAULT(20)); // -/// * Search feature tree for all points that are inlier to given rect region. -// Only implemented for kd trees */ +(* Search feature tree for all points that are inlier to given rect region. + // Only implemented for kd trees *) // CVAPI(int) cvFindFeaturesBoxed(struct CvFeatureTree* tr, // CvMat* bounds_min, CvMat* bounds_max, // CvMat* out_indices); // // -/// * Construct a Locality Sensitive Hash (LSH) table, for indexing d-dimensional vectors of -// given type. Vectors will be hashed L times with k-dimensional p-stable (p=2) functions. */ +(* Construct a Locality Sensitive Hash (LSH) table, for indexing d-dimensional vectors of + // given type. Vectors will be hashed L times with k-dimensional p-stable (p=2) functions. *) // CVAPI(struct CvLSH*) cvCreateLSH(struct CvLSHOperations* ops, int d, // int L CV_DEFAULT(10), int k CV_DEFAULT(10), // int type CV_DEFAULT(CV_64FC1), double r CV_DEFAULT(4), // int64 seed CV_DEFAULT(-1)); // -/// * Construct in-memory LSH table, with n bins. */ +(* Construct in-memory LSH table, with n bins. *) // CVAPI(struct CvLSH*) cvCreateMemoryLSH(int d, int n, int L CV_DEFAULT(10), int k CV_DEFAULT(10), // int type CV_DEFAULT(CV_64FC1), double r CV_DEFAULT(4), // int64 seed CV_DEFAULT(-1)); // -/// * Free the given LSH structure. */ +(* Free the given LSH structure. *) // CVAPI(void) cvReleaseLSH(struct CvLSH** lsh); // -/// * Return the number of vectors in the LSH. */ +(* Return the number of vectors in the LSH. *) // CVAPI(unsigned int) LSHSize(struct CvLSH* lsh); // -/// * Add vectors to the LSH structure, optionally returning indices. */ +(* Add vectors to the LSH structure, optionally returning indices. *) // CVAPI(void) cvLSHAdd(struct CvLSH* lsh, const CvMat* data, CvMat* indices CV_DEFAULT(0)); // -/// * Remove vectors from LSH, as addressed by given indices. */ +(* Remove vectors from LSH, as addressed by given indices. *) // CVAPI(void) cvLSHRemove(struct CvLSH* lsh, const CvMat* indices); // -/// * Query the LSH n times for at most k nearest points; data is n x d, -// indices and dist are n x k. At most emax stored points will be accessed. */ +(* Query the LSH n times for at most k nearest points; data is n x d, + // indices and dist are n x k. At most emax stored points will be accessed. *) // CVAPI(void) cvLSHQuery(struct CvLSH* lsh, const CvMat* query_points, // CvMat* indices, CvMat* dist, int k, int emax); // -/// * Kolmogorov-Zabin stereo-correspondence algorithm (a.k.a. KZ1) */ +(* Kolmogorov-Zabin stereo-correspondence algorithm (a.k.a. KZ1) *) // #define CV_STEREO_GC_OCCLUDED SHRT_MAX -Type - pCvStereoGCState = ^TCvStereoGCState; +Type pCvStereoGCState = ^TCvStereoGCState; - TCvStereoGCState = record - Ithreshold: Integer; - interactionRadius: Integer; - K, lambda, lambda1, lambda2: Single; - occlusionCost: Integer; - minDisparity: Integer; - numberOfDisparities: Integer; - maxIters: Integer; - left: pCvMat; - right: pCvMat; - dispLeft: pCvMat; - dispRight: pCvMat; - ptrLeft: pCvMat; - ptrRight: pCvMat; - vtxBuf: pCvMat; - edgeBuf: pCvMat; - end; +TCvStereoGCState = record Ithreshold: Integer; interactionRadius: Integer; K, lambda, lambda1, lambda2: Single; +occlusionCost: Integer; minDisparity: Integer; numberOfDisparities: Integer; maxIters: Integer; left: pCvMat; +right: pCvMat; dispLeft: pCvMat; dispRight: pCvMat; ptrLeft: pCvMat; ptrRight: pCvMat; vtxBuf: pCvMat; +edgeBuf: pCvMat; end; - // CVAPI(CvStereoGCState*) cvCreateStereoGCState( int numberOfDisparities, int maxIters ); +// CVAPI(CvStereoGCState*) cvCreateStereoGCState( int numberOfDisparities, int maxIters ); function cvCreateStereoGCState(numberOfDisparities: Integer; maxIters: Integer): pCvStereoGCState; cdecl; // CVAPI(void) cvReleaseStereoGCState( CvStereoGCState** state ); @@ -3273,96 +3322,91 @@ procedure cvReleaseStereoGCState(Var state: pCvStereoGCState); cdecl; procedure cvFindStereoCorrespondenceGC(const left: pIplImage; const right: pIplImage; disparityLeft: pCvMat; disparityRight: pCvMat; state: pCvStereoGCState; useDisparityGuess: Integer = 0); cdecl; -/// * Calculates optical flow for 2 images using classical Lucas & Kanade algorithm */ +(* Calculates optical flow for 2 images using classical Lucas & Kanade algorithm *) // CVAPI(void) cvCalcOpticalFlowLK( const CvArr* prev, const CvArr* curr, // CvSize win_size, CvArr* velx, CvArr* vely ); // -/// * Calculates optical flow for 2 images using block matching algorithm */ +(* Calculates optical flow for 2 images using block matching algorithm *) // CVAPI(void) cvCalcOpticalFlowBM( const CvArr* prev, const CvArr* curr, // CvSize block_size, CvSize shift_size, // CvSize max_range, int use_previous, // CvArr* velx, CvArr* vely ); // -/// * Calculates Optical flow for 2 images using Horn & Schunck algorithm */ +(* Calculates Optical flow for 2 images using Horn & Schunck algorithm *) // CVAPI(void) cvCalcOpticalFlowHS( const CvArr* prev, const CvArr* curr, // int use_previous, CvArr* velx, CvArr* vely, // double lambda, CvTermCriteria criteria ); // // -/// ****************************************************************************************\ -// * Background/foreground segmentation * -// \****************************************************************************************/ +(* ***************************************************************************************\ + // * Background/foreground segmentation * + // \*************************************************************************************** *) // -/// * We discriminate between foreground and background pixels -// * by building and maintaining a model of the background. -// * Any pixel which does not fit this model is then deemed -// * to be foreground. -// * -// * At present we support two core background models, -// * one of which has two variations: -// * -// * o CV_BG_MODEL_FGD: latest and greatest algorithm, described in -// * -// * Foreground Object Detection from Videos Containing Complex Background. -// * Liyuan Li, Weimin Huang, Irene Y.H. Gu, and Qi Tian. -// * ACM MM2003 9p -// * -// * o CV_BG_MODEL_FGD_SIMPLE: -// * A code comment describes this as a simplified version of the above, -// * but the code is in fact currently identical -// * -// * o CV_BG_MODEL_MOG: "Mixture of Gaussians", older algorithm, described in -// * -// * Moving target classification and tracking from real-time video. -// * A Lipton, H Fujijoshi, R Patil -// * Proceedings IEEE Workshop on Application of Computer Vision pp 8-14 1998 -// * -// * Learning patterns of activity using real-time tracking -// * C Stauffer and W Grimson August 2000 -// * IEEE Transactions on Pattern Analysis and Machine Intelligence 22(8):747-757 -// */ +(* We discriminate between foreground and background pixels + // * by building and maintaining a model of the background. + // * Any pixel which does not fit this model is then deemed + // * to be foreground. + // * + // * At present we support two core background models, + // * one of which has two variations: + // * + // * o CV_BG_MODEL_FGD: latest and greatest algorithm, described in + // * + // * Foreground Object Detection from Videos Containing Complex Background. + // * Liyuan Li, Weimin Huang, Irene Y.H. Gu, and Qi Tian. + // * ACM MM2003 9p + // * + // * o CV_BG_MODEL_FGD_SIMPLE: + // * A code comment describes this as a simplified version of the above, + // * but the code is in fact currently identical + // * + // * o CV_BG_MODEL_MOG: "Mixture of Gaussians", older algorithm, described in + // * + // * Moving target classification and tracking from real-time video. + // * A Lipton, H Fujijoshi, R Patil + // * Proceedings IEEE Workshop on Application of Computer Vision pp 8-14 1998 + // * + // * Learning patterns of activity using real-time tracking + // * C Stauffer and W Grimson August 2000 + // * IEEE Transactions on Pattern Analysis and Machine Intelligence 22(8):747-757 + // *) // -const - CV_BG_MODEL_FGD = 0; - CV_BG_MODEL_MOG = 1; // * "Mixture of Gaussians". */ - CV_BG_MODEL_FGD_SIMPLE = 2; +const CV_BG_MODEL_FGD = 0; CV_BG_MODEL_MOG = 1; // * "Mixture of Gaussians". *) +CV_BG_MODEL_FGD_SIMPLE = 2; Type - ppCvBGStatModel = ^pCvBGStatModel; - pCvBGStatModel = ^TCvBGStatModel; + ppCvBGStatModel = ^pCvBGStatModel; pCvBGStatModel = ^TCvBGStatModel; - // typedef void (CV_CDECL * CvReleaseBGStatModel)( struct CvBGStatModel** bg_model ); - TCvReleaseBGStatModel = procedure(Var bg_model: pCvBGStatModel); cdecl; - // typedef int (CV_CDECL * CvUpdateBGStatModel)( IplImage* curr_frame, struct CvBGStatModel* bg_model, double learningRate ); - TCvUpdateBGStatModel = function(curr_frame: pIplImage; bg_model: pCvBGStatModel; learningRate: double) - : Integer; cdecl; +// typedef void (CV_CDECL * CvReleaseBGStatModel)( struct CvBGStatModel** bg_model ); +TCvReleaseBGStatModel = +procedure(Var bg_model: pCvBGStatModel); cdecl; +// typedef int (CV_CDECL * CvUpdateBGStatModel)( IplImage* curr_frame, struct CvBGStatModel* bg_model, double learningRate ); +TCvUpdateBGStatModel = +function(curr_frame: pIplImage; bg_model: pCvBGStatModel; learningRate: double): Integer; cdecl; - TCvBGStatModel = record - _type: Integer; // *type of BG model - release: TCvReleaseBGStatModel; - update: TCvUpdateBGStatModel; - background: pIplImage; // *8UC3 reference background image - foreground: pIplImage; // *8UC1 foreground image - layers: pIplImage; // *8UC3 reference background image, can be null - layer_count: Integer; // * can be zero - storage: pCvMemStorage; // *storage for foreground_regions - foreground_regions: pCvSeq; // *foreground object contours - end; +TCvBGStatModel = record _type: Integer; // *type of BG model +release: TCvReleaseBGStatModel; update: TCvUpdateBGStatModel; background: pIplImage; // *8UC3 reference background image +foreground: pIplImage; // *8UC1 foreground image +layers: pIplImage; // *8UC3 reference background image, can be null +layer_count: Integer; // * can be zero +storage: pCvMemStorage; // *storage for foreground_regions +foreground_regions: pCvSeq; // *foreground object contours +end; - // #define CV_BG_STAT_MODEL_FIELDS() \ - // int type; /*type of BG model*/ \ - // CvReleaseBGStatModel release; \ - // CvUpdateBGStatModel update; \ - // IplImage* background; /*8UC3 reference background image*/ \ - // IplImage* foreground; /*8UC1 foreground image*/ \ - // IplImage** layers; /*8UC3 reference background image, can be null */ \ - // int layer_count; /* can be zero */ \ - // CvMemStorage* storage; /*storage for foreground_regions*/ \ - // CvSeq* foreground_regions /*foreground object contours*/ +// #define CV_BG_STAT_MODEL_FIELDS() \ +// int type; (*type of BG model*) \ +// CvReleaseBGStatModel release; \ +// CvUpdateBGStatModel update; \ +// IplImage* background; (*8UC3 reference background image*) \ +// IplImage* foreground; (*8UC1 foreground image*) \ +// IplImage** layers; (*8UC3 reference background image, can be null *) \ +// int layer_count; (* can be zero *) \ +// CvMemStorage* storage; (*storage for foreground_regions*) \ +// CvSeq* foreground_regions (*foreground object contours*) - /// / Releases memory used by BGStatModel - // CVAPI(void) cvReleaseBGStatModel( CvBGStatModel** bg_model ); +/// / Releases memory used by BGStatModel +// CVAPI(void) cvReleaseBGStatModel( CvBGStatModel** bg_model ); procedure cvReleaseBGStatModel(Var bg_model: pCvBGStatModel); cdecl; // Updates statistical model and returns number of found foreground regions @@ -3378,7 +3422,7 @@ function cvUpdateBGStatModel(current_frame: pIplImage; bg_model: pCvBGStatModel; /// / bg_model - pointer to CvBGStatModel structure // CVAPI(void) cvRefineForegroundMaskBySegm( CvSeq* segments, CvBGStatModel* bg_model ); // -/// * Common use change detection function */ +(* Common use change detection function *) // CVAPI(int) cvChangeDetection( IplImage* prev_frame, // IplImage* curr_frame, // IplImage* change_mask ); @@ -3388,30 +3432,23 @@ function cvUpdateBGStatModel(current_frame: pIplImage; bg_model: pCvBGStatModel; // const - // Default parameters of foreground detection algorithm: - CV_BGFG_FGD_LC = 128; - CV_BGFG_FGD_N1C = 15; - CV_BGFG_FGD_N2C = 25; +// Default parameters of foreground detection algorithm: + CV_BGFG_FGD_LC = 128; CV_BGFG_FGD_N1C = 15; CV_BGFG_FGD_N2C = 25; - CV_BGFG_FGD_LCC = 64; - CV_BGFG_FGD_N1CC = 25; - CV_BGFG_FGD_N2CC = 40; - // Background reference image update parameter: */ - CV_BGFG_FGD_ALPHA_1 = 0.1; +CV_BGFG_FGD_LCC = 64; CV_BGFG_FGD_N1CC = 25; CV_BGFG_FGD_N2CC = 40; +// Background reference image update parameter: *) +CV_BGFG_FGD_ALPHA_1 = 0.1; - /// * stat model update parameter +(* stat model update parameter // * 0.002f ~ 1K frame(~45sec), 0.005 ~ 18sec (if 25fps and absolutely static BG) - // */ - CV_BGFG_FGD_ALPHA_2 = 0.005; + // *) +CV_BGFG_FGD_ALPHA_2 = 0.005; - // * start value for alpha parameter (to fast initiate statistic model) */ - CV_BGFG_FGD_ALPHA_3 = 0.1; - CV_BGFG_FGD_DELTA = 2; - CV_BGFG_FGD_T = 0.9; - CV_BGFG_FGD_MINAREA = 15; - CV_BGFG_FGD_BG_UPDATE_TRESH = 0.5; +// * start value for alpha parameter (to fast initiate statistic model) *) +CV_BGFG_FGD_ALPHA_3 = 0.1; CV_BGFG_FGD_DELTA = 2; CV_BGFG_FGD_T = 0.9; CV_BGFG_FGD_MINAREA = 15; +CV_BGFG_FGD_BG_UPDATE_TRESH = 0.5; - /// * See the above-referenced Li/Huang/Gu/Tian paper +(* See the above-referenced Li/Huang/Gu/Tian paper // * for a full description of these background-model // * tuning parameters. // * @@ -3423,71 +3460,69 @@ const // * RGB color for both this frame and preceding frame. // * We use histograms of these to model the range of // * color CHANGES we've seen at a given background pixel. - // */ -Type - pCvFGDStatModelParams = ^TCvFGDStatModelParams; + // *) +Type pCvFGDStatModelParams = ^TCvFGDStatModelParams; - TCvFGDStatModelParams = record - Lc: Integer; // Quantized levels per 'color' component. Power of two, typically 32, 64 or 128. - N1c: Integer; // Number of color vectors used to model normal background color variation at a given pixel. - N2c: Integer; // Number of color vectors retained at given pixel. Must be > N1c, typically ~ 5/3 of N1c. - // Used to allow the first N1c vectors to adapt over time to changing background. - Lcc: Integer; - // Quantized levels per 'color co-occurrence' component. Power of two, typically 16, 32 or 64. - N1cc: Integer; - // Number of color co-occurrence vectors used to model normal background color variation at a given pixel. - N2cc: Integer; - // Number of color co-occurrence vectors retained at given pixel. Must be > N1cc, typically ~ 5/3 of N1cc. - // Used to allow the first N1cc vectors to adapt over time to changing background. - is_obj_without_holes: Integer; // If TRUE we ignore holes within foreground blobs. Defaults to TRUE. - perform_morphing: Integer; // Number of erode-dilate-erode foreground-blob cleanup iterations. - // These erase one-pixel junk blobs and merge almost-touching blobs. Default value is 1. - alpha1: Single; // How quickly we forget old background pixel values seen. Typically set to 0.1 - alpha2: Single; // "Controls speed of feature learning". Depends on T. Typical value circa 0.005. - alpha3: Single; // Alternate to alpha2, used (e.g.) for quicker initial convergence. Typical value 0.1. - delta: Single; // Affects color and color co-occurrence quantization, typically set to 2. - T: Single; - // "A percentage value which determines when new features can be recognized as new background." (Typically 0.9). - minArea: Single; // Discard foreground blobs whose bounding box is smaller than this threshold. - end; - // - // typedef struct CvBGPixelCStatTable - // { - // float Pv, Pvb; - // uchar v[3]; - // } CvBGPixelCStatTable; - // - // typedef struct CvBGPixelCCStatTable - // { - // float Pv, Pvb; - // uchar v[6]; - // } CvBGPixelCCStatTable; - // - // typedef struct CvBGPixelStat - // { - // float Pbc; - // float Pbcc; - // CvBGPixelCStatTable* ctable; - // CvBGPixelCCStatTable* cctable; - // uchar is_trained_st_model; - // uchar is_trained_dyn_model; - // } CvBGPixelStat; - // - // - // typedef struct CvFGDStatModel - // { - // CV_BG_STAT_MODEL_FIELDS(); - // CvBGPixelStat* pixel_stat; - // IplImage* Ftd; - // IplImage* Fbd; - // IplImage* prev_frame; - // CvFGDStatModelParams params; - // } CvFGDStatModel; +TCvFGDStatModelParams = record Lc: Integer; +// Quantized levels per 'color' component. Power of two, typically 32, 64 or 128. +N1c: Integer; // Number of color vectors used to model normal background color variation at a given pixel. +N2c: Integer; // Number of color vectors retained at given pixel. Must be > N1c, typically ~ 5/3 of N1c. +// Used to allow the first N1c vectors to adapt over time to changing background. +Lcc: Integer; +// Quantized levels per 'color co-occurrence' component. Power of two, typically 16, 32 or 64. +N1cc: Integer; +// Number of color co-occurrence vectors used to model normal background color variation at a given pixel. +N2cc: Integer; +// Number of color co-occurrence vectors retained at given pixel. Must be > N1cc, typically ~ 5/3 of N1cc. +// Used to allow the first N1cc vectors to adapt over time to changing background. +is_obj_without_holes: Integer; // If TRUE we ignore holes within foreground blobs. Defaults to TRUE. +perform_morphing: Integer; // Number of erode-dilate-erode foreground-blob cleanup iterations. +// These erase one-pixel junk blobs and merge almost-touching blobs. Default value is 1. +alpha1: Single; // How quickly we forget old background pixel values seen. Typically set to 0.1 +alpha2: Single; // "Controls speed of feature learning". Depends on T. Typical value circa 0.005. +alpha3: Single; // Alternate to alpha2, used (e.g.) for quicker initial convergence. Typical value 0.1. +delta: Single; // Affects color and color co-occurrence quantization, typically set to 2. +T: Single; +// "A percentage value which determines when new features can be recognized as new background." (Typically 0.9). +minArea: Single; // Discard foreground blobs whose bounding box is smaller than this threshold. +end; +// +// typedef struct CvBGPixelCStatTable +// { +// float Pv, Pvb; +// uchar v[3]; +// } CvBGPixelCStatTable; +// +// typedef struct CvBGPixelCCStatTable +// { +// float Pv, Pvb; +// uchar v[6]; +// } CvBGPixelCCStatTable; +// +// typedef struct CvBGPixelStat +// { +// float Pbc; +// float Pbcc; +// CvBGPixelCStatTable* ctable; +// CvBGPixelCCStatTable* cctable; +// uchar is_trained_st_model; +// uchar is_trained_dyn_model; +// } CvBGPixelStat; +// +// +// typedef struct CvFGDStatModel +// { +// CV_BG_STAT_MODEL_FIELDS(); +// CvBGPixelStat* pixel_stat; +// IplImage* Ftd; +// IplImage* Fbd; +// IplImage* prev_frame; +// CvFGDStatModelParams params; +// } CvFGDStatModel; - /// * Creates FGD model */ - // CVAPI(CvBGStatModel*) cvCreateFGDStatModel( IplImage* first_frame, CvFGDStatModelParams* parameters CV_DEFAULT(NULL)); -function cvCreateFGDStatModel(first_frame: pIplImage; parameters: pCvFGDStatModelParams = nil): pCvBGStatModel; -cdecl +(* Creates FGD model *) +// CVAPI(CvBGStatModel*) cvCreateFGDStatModel( IplImage* first_frame, CvFGDStatModelParams* parameters CV_DEFAULT(NULL)); +function cvCreateFGDStatModel(first_frame: pIplImage; parameters: pCvFGDStatModelParams = nil): pCvBGStatModel; cdecl // Interface of Gaussian mixture algorithm // @@ -3496,97 +3531,62 @@ cdecl // Proc. 2nd European Workshp on Advanced Video-Based Surveillance Systems, 2001." // http://personal.ee.surrey.ac.uk/Personal/R.Bowden/publications/avbs01/avbs01.pdf // -/// * Note: "MOG" == "Mixture Of Gaussians": */ -const - CV_BGFG_MOG_MAX_NGAUSSIANS = 500; +(* Note: "MOG" == "Mixture Of Gaussians": *) + const CV_BGFG_MOG_MAX_NGAUSSIANS = 500; - // * default parameters of gaussian background detection algorithm */ - CV_BGFG_MOG_BACKGROUND_THRESHOLD = 0.7; // * threshold sum of weights for background test */ - CV_BGFG_MOG_STD_THRESHOLD = 2.5; // * lambda=2.5 is 99% */ - CV_BGFG_MOG_WINDOW_SIZE = 200; // * Learning rate; alpha = 1/CV_GBG_WINDOW_SIZE */ - CV_BGFG_MOG_NGAUSSIANS = 5; // * = K = number of Gaussians in mixture */ - CV_BGFG_MOG_WEIGHT_INIT = 0.05; - CV_BGFG_MOG_SIGMA_INIT = 30; - CV_BGFG_MOG_MINAREA = 15; +// * default parameters of gaussian background detection algorithm *) +CV_BGFG_MOG_BACKGROUND_THRESHOLD = 0.7; // * threshold sum of weights for background test *) +CV_BGFG_MOG_STD_THRESHOLD = 2.5; // * lambda=2.5 is 99% *) +CV_BGFG_MOG_WINDOW_SIZE = 200; // * Learning rate; alpha = 1/CV_GBG_WINDOW_SIZE *) +CV_BGFG_MOG_NGAUSSIANS = 5; // * = K = number of Gaussians in mixture *) +CV_BGFG_MOG_WEIGHT_INIT = 0.05; CV_BGFG_MOG_SIGMA_INIT = 30; CV_BGFG_MOG_MINAREA = 15; - CV_BGFG_MOG_NCOLORS = 3; +CV_BGFG_MOG_NCOLORS = 3; -type - pCvGaussBGStatModelParams = ^TCvGaussBGStatModelParams; +type pCvGaussBGStatModelParams = ^TCvGaussBGStatModelParams; - TCvGaussBGStatModelParams = record - win_size: Integer; // * = 1/alpha - n_gauss: Integer; - bg_threshold, std_threshold, minArea: double; - weight_init, variance_init: double; - end; +TCvGaussBGStatModelParams = record win_size: Integer; // * = 1/alpha +n_gauss: Integer; bg_threshold, std_threshold, minArea: double; weight_init, variance_init: double; end; - pCvGaussBGValues = ^TCvGaussBGValues; +pCvGaussBGValues = ^TCvGaussBGValues; - TCvGaussBGValues = record - match_sum: Integer; - weight: double; - variance: array [0 .. CV_BGFG_MOG_NCOLORS - 1] of double; - mean: array [0 .. CV_BGFG_MOG_NCOLORS - 1] of double; - end; +TCvGaussBGValues = record match_sum: Integer; weight: double; variance: array [0 .. CV_BGFG_MOG_NCOLORS - 1] of double; +mean: array [0 .. CV_BGFG_MOG_NCOLORS - 1] of double; end; - pCvGaussBGPoint = ^TCvGaussBGPoint; +pCvGaussBGPoint = ^TCvGaussBGPoint; - TCvGaussBGPoint = record - g_values: pCvGaussBGValues; - end; +TCvGaussBGPoint = record g_values: pCvGaussBGValues; end; - pCvGaussBGModel = ^TCvGaussBGModel; +pCvGaussBGModel = ^TCvGaussBGModel; - TCvGaussBGModel = record - // CV_BG_STAT_MODEL_FIELDS(); - _type: Integer; // type of BG model - release: TCvReleaseBGStatModel; - update: TCvUpdateBGStatModel; - background: pIplImage; // 8UC3 reference background image - foreground: pIplImage; // 8UC1 foreground image - layers: pIplImage; // 8UC3 reference background image, can be null - layer_count: Integer; // can be zero - storage: pCvMemStorage; // storage for foreground_regions - foreground_regions: pCvSeq; // foreground object contours - params: TCvGaussBGStatModelParams; - g_point: pCvGaussBGPoint; - countFrames: Integer; - mog: Pointer; - end; +TCvGaussBGModel = record +// CV_BG_STAT_MODEL_FIELDS(); + _type: Integer; // type of BG model +release: TCvReleaseBGStatModel; update: TCvUpdateBGStatModel; background: pIplImage; // 8UC3 reference background image +foreground: pIplImage; // 8UC1 foreground image +layers: pIplImage; // 8UC3 reference background image, can be null +layer_count: Integer; // can be zero +storage: pCvMemStorage; // storage for foreground_regions +foreground_regions: pCvSeq; // foreground object contours +params: TCvGaussBGStatModelParams; g_point: pCvGaussBGPoint; countFrames: Integer; mog: pointer; end; - // * Creates Gaussian mixture background model */ - // CVAPI(CvBGStatModel*) cvCreateGaussianBGModel( IplImage* first_frame, CvGaussBGStatModelParams* parameters CV_DEFAULT(NULL)); +// * Creates Gaussian mixture background model *) +// CVAPI(CvBGStatModel*) cvCreateGaussianBGModel( IplImage* first_frame, CvGaussBGStatModelParams* parameters CV_DEFAULT(NULL)); function cvCreateGaussianBGModel(first_frame: pIplImage; parameters: pCvGaussBGStatModelParams = nil) : pCvBGStatModel; cdecl; -type - pCvBGCodeBookElem = ^TCvBGCodeBookElem; +type pCvBGCodeBookElem = ^TCvBGCodeBookElem; - TCvBGCodeBookElem = record - next: pCvBGCodeBookElem; - tLastUpdate: Integer; - stale: Integer; - boxMin: array [0 .. 2] of byte; - boxMax: array [0 .. 2] of byte; - learnMin: array [0 .. 2] of byte; - learnMax: array [0 .. 2] of byte; - end; +TCvBGCodeBookElem = record next: pCvBGCodeBookElem; tLastUpdate: Integer; stale: Integer; +boxMin: array [0 .. 2] of byte; boxMax: array [0 .. 2] of byte; learnMin: array [0 .. 2] of byte; +learnMax: array [0 .. 2] of byte; end; - pCvBGCodeBookModel = ^TCvBGCodeBookModel; +pCvBGCodeBookModel = ^TCvBGCodeBookModel; - TCvBGCodeBookModel = record - size: TCvSize; - T: Integer; - cbBounds: array [0 .. 2] of byte; - modMin: array [0 .. 2] of byte; - modMax: array [0 .. 2] of byte; - cbmap: pCvBGCodeBookElem; - storage: pCvMemStorage; - freeList: pCvBGCodeBookElem; - end; +TCvBGCodeBookModel = record size: TCvSize; T: Integer; cbBounds: array [0 .. 2] of byte; modMin: array [0 .. 2] of byte; +modMax: array [0 .. 2] of byte; cbmap: pCvBGCodeBookElem; storage: pCvMemStorage; freeList: pCvBGCodeBookElem; end; - // CVAPI(CvBGCodeBookModel*) cvCreateBGCodeBookModel( void ); +// CVAPI(CvBGCodeBookModel*) cvCreateBGCodeBookModel( void ); function cvCreateBGCodeBookModel: pCvBGCodeBookModel; cdecl; // CVAPI(void) cvReleaseBGCodeBookModel( CvBGCodeBookModel** model ); procedure cvReleaseBGCodeBookModel(model: pCvBGCodeBookModel); cdecl; @@ -3605,7 +3605,7 @@ function cvSegmentFGMask(fgmask: pCvArr; poly1Hull0: Integer { =1 }; perimScale: implementation -uses ocv.lib; + uses ocv.lib; function cvCreateStereoGCState; external legacy_lib; procedure cvFindStereoCorrespondenceGC; external legacy_lib; @@ -3614,45 +3614,31 @@ procedure cvSnakeImage; external legacy_lib; function cvCreateSubdiv2D; external legacy_lib; procedure cvInitSubdivDelaunay2D; external legacy_lib; -function cvSubdiv2DEdgeOrg(edge: TCvSubdiv2DEdge): pCvSubdiv2DPoint; inline; -Var - e: pCvQuadEdge2D; -begin - // CvQuadEdge2D* e = (CvQuadEdge2D*)(edge & ~3); - e := pCvQuadEdge2D(edge and (not 3)); - // return (CvSubdiv2DPoint*)e->pt[edge & 3]; - Result := pCvSubdiv2DPoint(e^.pt[edge and 3]); -end; +function cvSubdiv2DEdgeOrg(edge: TCvSubdiv2DEdge): pCvSubdiv2DPoint; inline; Var e: pCvQuadEdge2D; begin +// CvQuadEdge2D* e = (CvQuadEdge2D*)(edge & ~3); +e := pCvQuadEdge2D(edge and (not 3)); +// return (CvSubdiv2DPoint*)e->pt[edge & 3]; +Result := pCvSubdiv2DPoint(e^.pt[edge and 3]); end; -function cvSubdiv2DEdgeDst(edge: TCvSubdiv2DEdge): pCvSubdiv2DPoint; -Var - e: pCvQuadEdge2D; -begin - // CvQuadEdge2D* e = (CvQuadEdge2D*)(edge & ~3); - e := pCvQuadEdge2D(edge and (not 3)); - // return (CvSubdiv2DPoint*)e->pt[(edge + 2) & 3]; - Result := pCvSubdiv2DPoint(e^.pt[(edge + 2) and 3]); -end; +function cvSubdiv2DEdgeDst(edge: TCvSubdiv2DEdge): pCvSubdiv2DPoint; Var e: pCvQuadEdge2D; begin +// CvQuadEdge2D* e = (CvQuadEdge2D*)(edge & ~3); +e := pCvQuadEdge2D(edge and (not 3)); +// return (CvSubdiv2DPoint*)e->pt[(edge + 2) & 3]; +Result := pCvSubdiv2DPoint(e^.pt[(edge + 2) and 3]); end; function cvSubdiv2DLocate; external legacy_lib; -function cvSubdiv2DGetEdge(edge: TCvSubdiv2DEdge; _type: TCvNextEdgeType): TCvSubdiv2DEdge; -Var - e: pCvQuadEdge2D; -begin - // CvQuadEdge2D* e = (CvQuadEdge2D*)(edge & ~3); - e := pCvQuadEdge2D(edge and (not 3)); - // edge = e->next[(edge + (int)type) & 3]; - edge := e^.next[(edge + _type) and 3]; - // return (edge & ~3) + ((edge + ((int)type >> 4)) & 3); - Result := (edge and (not 3)) + ((edge + (_type shr 4)) and 3); -end; +function cvSubdiv2DGetEdge(edge: TCvSubdiv2DEdge; _type: TCvNextEdgeType): TCvSubdiv2DEdge; Var e: pCvQuadEdge2D; begin +// CvQuadEdge2D* e = (CvQuadEdge2D*)(edge & ~3); +e := pCvQuadEdge2D(edge and (not 3)); +// edge = e->next[(edge + (int)type) & 3]; +edge := e^.next[(edge + _type) and 3]; +// return (edge & ~3) + ((edge + ((int)type >> 4)) & 3); +Result := (edge and (not 3)) + ((edge + (_type shr 4)) and 3); end; -function cvSubdiv2DRotateEdge(edge: TCvSubdiv2DEdge; rotate: Integer): TCvSubdiv2DEdge; -begin - // return (edge & ~3) + ((edge + rotate) & 3); - Result := (edge and (not 3)) + ((edge + rotate) and 3); -end; +function cvSubdiv2DRotateEdge(edge: TCvSubdiv2DEdge; rotate: Integer): TCvSubdiv2DEdge; begin +// return (edge & ~3) + ((edge + rotate) & 3); +Result := (edge and (not 3)) + ((edge + rotate) and 3); end; procedure cvCalcSubdivVoronoi2D; external legacy_lib; function cvSubdivDelaunay2DInsert; external legacy_lib; @@ -3670,5 +3656,24 @@ procedure cvPyrSegmentation; external legacy_lib; procedure cvCalcEigenObjects; external legacy_lib; procedure cvEigenDecomposite; external legacy_lib; function cvSegmentImage; external legacy_lib; +procedure cvCalcCovarMatrixEx; external legacy_lib; +function cvCalcDecompCoeff; external legacy_lib; +procedure cvEigenProjection; external legacy_lib; +function icvCreate1DHMM; external legacy_lib; +function icvRelease1DHMM; external legacy_lib; +function icvUniform1DSegm; external legacy_lib; +function icvInit1DMixSegm; external legacy_lib; +function icvEstimate1DHMMStateParams; external legacy_lib; +function icvEstimate1DObsProb; external legacy_lib; +function icvEstimate1DTransProb; external legacy_lib; +function icvViterbi; external legacy_lib; +function icv1DMixSegmL2; external legacy_lib; +function cvCreate2DHMM; external legacy_lib; +procedure cvRelease2DHMM; external legacy_lib; +function cvCreateObsInfo; external legacy_lib; +procedure cvReleaseObsInfo; external legacy_lib; +procedure cvImgToObs_DCT; external legacy_lib; +procedure cvUniformImgSegm; external legacy_lib; +procedure cvInitMixSegm; external legacy_lib; end. diff --git a/source/ocv.tracking_c.pas b/source/ocv.tracking_c.pas index 7de0954..db2c3af 100644 --- a/source/ocv.tracking_c.pas +++ b/source/ocv.tracking_c.pas @@ -1,87 +1,48 @@ -// --------------------------------- OpenCV license.txt --------------------------- -// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. - // - // By downloading, copying, installing or using the software you agree to this license. - // If you do not agree to this license, do not download, install, - // copy or use the software. - // - // - // License Agreement - // For Open Source Computer Vision Library - // - // Copyright (C) 2000-2008, Intel Corporation, all rights reserved. - // Copyright (C) 2009, Willow Garage Inc., all rights reserved. - // Third party copyrights are property of their respective owners. - // - // Redistribution and use in source and binary forms, with or without modification, - // are permitted provided that the following conditions are met: - // - // * Redistribution's of source code must retain the above copyright notice, - // this list of conditions and the following disclaimer. - // - // * Redistribution's in binary form must reproduce the above copyright notice, - // this list of conditions and the following disclaimer in the documentation - // and/or other materials provided with the distribution. - // - // * The name of the copyright holders may not be used to endorse or promote products - // derived from this software without specific prior written permission. - // - // This software is provided by the copyright holders and contributors "as is" and - // any express or implied warranties, including, but not limited to, the implied - // warranties of merchantability and fitness for a particular purpose are disclaimed. - // In no event shall the Intel Corporation or contributors be liable for any direct, - // indirect, incidental, special, exemplary, or consequential damages - // (including, but not limited to, procurement of substitute goods or services; - // loss of use, data, or profits; or business interruption) however caused - // and on any theory of liability, whether in contract, strict liability, - // or tort (including negligence or otherwise) arising in any way out of - // the use of this software, even if advised of the possibility of such damage. - -//************************************************************************************************** - // Project Delphi-OpenCV - // ************************************************************************************************** - // Contributor: - // Laentir Valetov - // email:laex@bk.ru - // Mikhail Grigorev - // email:sleuthound@gmail.com - // ************************************************************************************************** - // You may retrieve the latest version of this file at the GitHub, - // located at git://github.com/Laex/Delphi-OpenCV.git - // ************************************************************************************************** - // License: - // The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); - // you may not use this file except in compliance with the License. You may obtain a copy of the - // License at http://www.mozilla.org/MPL/ - // - // Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF - // ANY KIND, either express or implied. See the License for the specific language governing rights - // and limitations under the License. - // - // Alternatively, the contents of this file may be used under the terms of the - // GNU Lesser General Public License (the "LGPL License"), in which case the - // provisions of the LGPL License are applicable instead of those above. - // If you wish to allow use of your version of this file only under the terms - // of the LGPL License and not to allow others to use your version of this file - // under the MPL, indicate your decision by deleting the provisions above and - // replace them with the notice and other provisions required by the LGPL - // License. If you do not delete the provisions above, a recipient may use - // your version of this file under either the MPL or the LGPL License. - // - // For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html - // ************************************************************************************************** - // Warning: Using Delphi XE3 syntax! - // ************************************************************************************************** - // The Initial Developer of the Original Code: - // OpenCV: open source computer vision library - // Homepage: http://ocv.org - // Online docs: http://docs.ocv.org - // Q&A forum: http://answers.ocv.org - // Dev zone: http://code.ocv.org - // ************************************************************************************************** - // Original file: - // opencv\modules\video\include\opencv2\video\tracking_c.h - // ************************************************************************************************* +// ************************************************************************************************** +// Project Delphi-OpenCV +// ************************************************************************************************** +// Contributor: +// Laentir Valetov +// email:laex@bk.ru +// Mikhail Grigorev +// email:sleuthound@gmail.com +// ************************************************************************************************** +// You may retrieve the latest version of this file at the GitHub, +// located at git://github.com/Laex/Delphi-OpenCV.git +// ************************************************************************************************** +// License: +// The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); +// you may not use this file except in compliance with the License. You may obtain a copy of the +// License at http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF +// ANY KIND, either express or implied. See the License for the specific language governing rights +// and limitations under the License. +// +// Alternatively, the contents of this file may be used under the terms of the +// GNU Lesser General Public License (the "LGPL License"), in which case the +// provisions of the LGPL License are applicable instead of those above. +// If you wish to allow use of your version of this file only under the terms +// of the LGPL License and not to allow others to use your version of this file +// under the MPL, indicate your decision by deleting the provisions above and +// replace them with the notice and other provisions required by the LGPL +// License. If you do not delete the provisions above, a recipient may use +// your version of this file under either the MPL or the LGPL License. +// +// For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html +// ************************************************************************************************** +// Warning: Using Delphi XE3 syntax! +// ************************************************************************************************** +// The Initial Developer of the Original Code: +// OpenCV: open source computer vision library +// Homepage: http://ocv.org +// Online docs: http://docs.ocv.org +// Q&A forum: http://answers.ocv.org +// Dev zone: http://code.ocv.org +// ************************************************************************************************** +// Original file: +// opencv\modules\video\include\opencv2\video\tracking_c.h +// ************************************************************************************************* {$IFDEF DEBUG} {$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q+,R+,S-,T-,U-,V+,W+,X+,Y+,Z1} @@ -94,200 +55,268 @@ {$WARN UNSAFE_TYPE OFF} {$WARN UNSAFE_CODE OFF} {$WARN UNSAFE_CAST OFF} +{$I OpenCV.inc} unit ocv.tracking_c; interface uses ocv.core.types_c, ocv.imgproc.types_c; -/// ****************************************************************************************\ -// * Motion Analysis * -// \****************************************************************************************/ -// -/// ************************************ optical flow ***************************************/ +(* **************************************************************************************** + * Motion Analysis * + *************************************************************************************** *) + +// ************************************ optical flow *************************************** const - CV_LKFLOW_PYR_A_READY = 1; - CV_LKFLOW_PYR_B_READY = 2; - CV_LKFLOW_INITIAL_GUESSES = 4; + CV_LKFLOW_PYR_A_READY = 1; + CV_LKFLOW_PYR_B_READY = 2; + CV_LKFLOW_INITIAL_GUESSES = 4; CV_LKFLOW_GET_MIN_EIGENVALS = 8; - /// * It is Lucas & Kanade method, modified to use pyramids. - // Also it does several iterations to get optical flow for - // every point at every pyramid level. - // Calculates optical flow between two images for certain set of points (i.e. - // it is a "sparse" optical flow, which is opposite to the previous 3 methods) */ - // CVAPI(void) cvCalcOpticalFlowPyrLK( const CvArr* prev, const CvArr* curr, - // CvArr* prev_pyr, CvArr* curr_pyr, - // const CvPoint2D32f* prev_features, - // CvPoint2D32f* curr_features, - // int count, - // CvSize win_size, - // int level, - // char* status, - // float* track_error, - // CvTermCriteria criteria, - // int flags ); + (* + It is Lucas & Kanade method, modified to use pyramids. + Also it does several iterations to get optical flow for + every point at every pyramid level. + Calculates optical flow between two images for certain set of points (i.e. + it is a "sparse" optical flow, which is opposite to the previous 3 methods) + + CVAPI(void) cvCalcOpticalFlowPyrLK( const CvArr* prev, const CvArr* curr, + CvArr* prev_pyr, CvArr* curr_pyr, + const CvPoint2D32f* prev_features, + CvPoint2D32f* curr_features, + int count, + CvSize win_size, + int level, + char* status, + float* track_error, + CvTermCriteria criteria, + int flags ); + *) +{$EXTERNALSYM cvCalcOpticalFlowPyrLK} procedure cvCalcOpticalFlowPyrLK(const prev: pIplImage; const curr: pIplImage; prev_pyr: pIplImage; curr_pyr: pIplImage; const prev_features: pCvPoint2D32f; curr_features: pCvPoint2D32f; count: Integer; win_size: TCvSize; level: Integer; status: pCVChar; track_error: PSingle; criteria: TCvTermCriteria; flags: Integer); cdecl; - /// * Modification of a previous sparse optical flow algorithm to calculate - // affine flow */ - // CVAPI(void) cvCalcAffineFlowPyrLK( const CvArr* prev, const CvArr* curr, - // CvArr* prev_pyr, CvArr* curr_pyr, - // const CvPoint2D32f* prev_features, - // CvPoint2D32f* curr_features, - // float* matrices, int count, - // CvSize win_size, int level, - // char* status, float* track_error, - // CvTermCriteria criteria, int flags ); - // - /// * Estimate rigid transformation between 2 images or 2 point sets */ - // CVAPI(int) cvEstimateRigidTransform( const CvArr* A, const CvArr* B, - // CvMat* M, int full_affine ); - // - /// * Estimate optical flow for each pixel using the two-frame G. Farneback algorithm */ - // CVAPI(void) cvCalcOpticalFlowFarneback( const CvArr* prev, const CvArr* next, - // CvArr* flow, double pyr_scale, int levels, - // int winsize, int iterations, int poly_n, - // double poly_sigma, int flags ); +(* Modification of a previous sparse optical flow algorithm to calculate + affine flow + + CVAPI(void) cvCalcAffineFlowPyrLK( const CvArr* prev, const CvArr* curr, + CvArr* prev_pyr, CvArr* curr_pyr, + const CvPoint2D32f* prev_features, + CvPoint2D32f* curr_features, + float* matrices, int count, + CvSize win_size, int level, + char* status, float* track_error, + CvTermCriteria criteria, int flags ); +*) +{$EXTERNALSYM cvCalcAffineFlowPyrLK} +procedure cvCalcAffineFlowPyrLK(const prev: pCvArr; const curr: pCvArr; prev_pyr: pCvArr; curr_pyr: pCvArr; + const prev_features: pCvPoint2D32f; var curr_features: TCvPoint2D32f; var matrices: Single; count: Integer; + win_size: TCvSize; level: Integer; status: pCVChar; var track_error: Single; criteria: TCvTermCriteria; + flags: Integer); cdecl; + +(* + Estimate rigid transformation between 2 images or 2 point sets + + CVAPI(int) cvEstimateRigidTransform( const CvArr* A, const CvArr* B, + CvMat* M, int full_affine ); +*) + +{$EXTERNALSYM cvEstimateRigidTransform} +function cvEstimateRigidTransform(const A: pCvArr; const B: pCvArr; var M: TCvMat; full_affine: Integer) + : Integer; cdecl; + +(* + Estimate optical flow for each pixel using the two-frame G. Farneback algorithm + + CVAPI(void) cvCalcOpticalFlowFarneback( const CvArr* prev, const CvArr* next, + CvArr* flow, double pyr_scale, int levels, + int winsize, int iterations, int poly_n, + double poly_sigma, int flags ); +*) +{$EXTERNALSYM cvCalcOpticalFlowFarneback} procedure cvCalcOpticalFlowFarneback(const prev: pCvMat; const next: pCvMat; flow: pCvMat; pyr_scale: double; levels: Integer; winsize: Integer; iterations: Integer; poly_n: Integer; poly_sigma: double; flags: Integer); cdecl; - /// ********************************* motion templates *************************************/ - // - /// ****************************************************************************************\ - // * All the motion template functions work only with single channel images. * - // * Silhouette image must have depth IPL_DEPTH_8U or IPL_DEPTH_8S * - // * Motion history image must have depth IPL_DEPTH_32F, * - // * Gradient mask - IPL_DEPTH_8U or IPL_DEPTH_8S, * - // * Motion orientation image - IPL_DEPTH_32F * - // * Segmentation mask - IPL_DEPTH_32F * - // * All the angles are in degrees, all the times are in milliseconds * - // \****************************************************************************************/ +(* ******************************** motion templates ************************************ *) - /// * Updates motion history image given motion silhouette */ - // CVAPI(void) cvUpdateMotionHistory( const CvArr* silhouette, CvArr* mhi, - // double timestamp, double duration ); +(* ***************************************************************************************** + * All the motion template functions work only with single channel images. * + * Silhouette image must have depth IPL_DEPTH_8U or IPL_DEPTH_8S * + * Motion history image must have depth IPL_DEPTH_32F, * + * Gradient mask - IPL_DEPTH_8U or IPL_DEPTH_8S, * + * Motion orientation image - IPL_DEPTH_32F * + * Segmentation mask - IPL_DEPTH_32F * + * All the angles are in degrees, all the times are in milliseconds * + *************************************************************************************** *) + +(* + Updates motion history image given motion silhouette + + CVAPI(void) cvUpdateMotionHistory( const CvArr* silhouette, CvArr* mhi, + double timestamp, double duration ); +*) +{$EXTERNALSYM cvUpdateMotionHistory} procedure cvUpdateMotionHistory(const silhouette: pCvArr; mhi: pCvArr; timestamp: double; duration: double); cdecl; -/// * Calculates gradient of the motion history image and fills -// a mask indicating where the gradient is valid */ -// CVAPI(void) cvCalcMotionGradient( const CvArr* mhi, CvArr* mask, CvArr* orientation, -// double delta1, double delta2, -// int aperture_size CV_DEFAULT(3)); +(* + Calculates gradient of the motion history image and fills + a mask indicating where the gradient is valid + + CVAPI(void) cvCalcMotionGradient( const CvArr* mhi, CvArr* mask, CvArr* orientation, + double delta1, double delta2, + int aperture_size CV_DEFAULT(3)); +*) +{$EXTERNALSYM cvCalcMotionGradient} procedure cvCalcMotionGradient(const mhi: pCvArr; mask: pCvArr; orientation: pCvArr; delta1: double; delta2: double; aperture_size: Integer = 3); cdecl; -/// * Calculates average motion direction within a selected motion region -// (region can be selected by setting ROIs and/or by composing a valid gradient mask -// with the region mask) */ -// CVAPI(double) cvCalcGlobalOrientation( const CvArr* orientation, const CvArr* mask, -// const CvArr* mhi, double timestamp, -// double duration ); +(* Calculates average motion direction within a selected motion region + (region can be selected by setting ROIs and/or by composing a valid gradient mask + with the region mask) + + CVAPI(double) cvCalcGlobalOrientation( const CvArr* orientation, const CvArr* mask, + const CvArr* mhi, double timestamp, + double duration ); +*) +{$EXTERNALSYM cvCalcGlobalOrientation} function cvCalcGlobalOrientation(const orientation: pCvArr; const mask: pCvArr; const mhi: pCvArr; timestamp: double; duration: double): double; cdecl; -/// * Splits a motion history image into a few parts corresponding to separate independent motions -// (e.g. left hand, right hand) */ -// CVAPI(CvSeq*) cvSegmentMotion( const CvArr* mhi, CvArr* seg_mask, -// CvMemStorage* storage, -// double timestamp, double seg_thresh ); +(* Splits a motion history image into a few parts corresponding to separate independent motions + (e.g. left hand, right hand) + + CVAPI(CvSeq* ) cvSegmentMotion( const CvArr* mhi, CvArr* seg_mask, + CvMemStorage* storage, + double timestamp, double seg_thresh ); +*) +{$EXTERNALSYM cvSegmentMotion} function cvSegmentMotion(const mhi: pCvArr; seg_mask: pCvArr; storage: pCvMemStorage; timestamp: double; seg_thresh: double): pCvSeq; cdecl; -/// ****************************************************************************************\ -// * Tracking * -// \****************************************************************************************/ -// -/// * Implements CAMSHIFT algorithm - determines object position, size and orientation -// from the object histogram back project (extension of meanshift) */ -// CVAPI(int) cvCamShift( const CvArr* prob_image, CvRect window, -// CvTermCriteria criteria, CvConnectedComp* comp, -// CvBox2D* box CV_DEFAULT(NULL) ); +(* **************************************************************************************** + * Tracking * + *************************************************************************************** *) + +(* + Implements CAMSHIFT algorithm - determines object position, size and orientation + from the object histogram back project (extension of meanshift) + + CVAPI(int) cvCamShift( const CvArr* prob_image, CvRect window, + CvTermCriteria criteria, CvConnectedComp* comp, + CvBox2D* box CV_DEFAULT(NULL) ); +*) +{$EXTERNALSYM cvCamShift} function cvCamShift(const prob_image: pIplImage; window: TCvRect; criteria: TCvTermCriteria; comp: pCvConnectedComp; box: pCvBox2D = nil): Integer; cdecl; -/// * Implements MeanShift algorithm - determines object position -// from the object histogram back project */ -// CVAPI(int) cvMeanShift( const CvArr* prob_image, CvRect window, -// CvTermCriteria criteria, CvConnectedComp* comp ); -// -/// * -// standard Kalman filter (in G. Welch' and G. Bishop's notation): -// -// x(k)=A*x(k-1)+B*u(k)+w(k) p(w)~N(0,Q) -// z(k)=H*x(k)+v(k), p(v)~N(0,R) -// */ -// typedef struct CvKalman -// { -// int MP; /* number of measurement vector dimensions */ -// int DP; /* number of state vector dimensions */ -// int CP; /* number of control vector dimensions */ -// -// /* backward compatibility fields */ -// #if 1 -// float* PosterState; /* =state_pre->data.fl */ -// float* PriorState; /* =state_post->data.fl */ -// float* DynamMatr; /* =transition_matrix->data.fl */ -// float* MeasurementMatr; /* =measurement_matrix->data.fl */ -// float* MNCovariance; /* =measurement_noise_cov->data.fl */ -// float* PNCovariance; /* =process_noise_cov->data.fl */ -// float* KalmGainMatr; /* =gain->data.fl */ -// float* PriorErrorCovariance;/* =error_cov_pre->data.fl */ -// float* PosterErrorCovariance;/* =error_cov_post->data.fl */ -// float* Temp1; /* temp1->data.fl */ -// float* Temp2; /* temp2->data.fl */ -// #endif -// -// CvMat* state_pre; /* predicted state (x'(k)): -// x(k)=A*x(k-1)+B*u(k) */ -// CvMat* state_post; /* corrected state (x(k)): -// x(k)=x'(k)+K(k)*(z(k)-H*x'(k)) */ -// CvMat* transition_matrix; /* state transition matrix (A) */ -// CvMat* control_matrix; /* control matrix (B) -// (it is not used if there is no control)*/ -// CvMat* measurement_matrix; /* measurement matrix (H) */ -// CvMat* process_noise_cov; /* process noise covariance matrix (Q) */ -// CvMat* measurement_noise_cov; /* measurement noise covariance matrix (R) */ -// CvMat* error_cov_pre; /* priori error estimate covariance matrix (P'(k)): -// P'(k)=A*P(k-1)*At + Q)*/ -// CvMat* gain; /* Kalman gain matrix (K(k)): -// K(k)=P'(k)*Ht*inv(H*P'(k)*Ht+R)*/ -// CvMat* error_cov_post; /* posteriori error estimate covariance matrix (P(k)): -// P(k)=(I-K(k)*H)*P'(k) */ -// CvMat* temp1; /* temporary matrices */ -// CvMat* temp2; -// CvMat* temp3; -// CvMat* temp4; -// CvMat* temp5; -// } CvKalman; -// -/// * Creates Kalman filter and sets A, B, Q, R and state to some initial values */ -// CVAPI(CvKalman*) cvCreateKalman( int dynam_params, int measure_params, -// int control_params CV_DEFAULT(0)); -// -/// * Releases Kalman filter state */ -// CVAPI(void) cvReleaseKalman( CvKalman** kalman); -// -/// * Updates Kalman filter by time (predicts future state of the system) */ -// CVAPI(const CvMat*) cvKalmanPredict( CvKalman* kalman, -// const CvMat* control CV_DEFAULT(NULL)); -// -/// * Updates Kalman filter by measurement -// (corrects state of the system and internal matrices) */ -// CVAPI(const CvMat*) cvKalmanCorrect( CvKalman* kalman, const CvMat* measurement ); -// -// #define cvKalmanUpdateByTime cvKalmanPredict -// #define cvKalmanUpdateByMeasurement cvKalmanCorrect -// -// -// #ifdef __cplusplus -// } // extern "C" -// #endif -// -// -// #endif // __OPENCV_TRACKING_C_H__ +(* Implements MeanShift algorithm - determines object position + from the object histogram back project + + CVAPI(int) cvMeanShift( const CvArr* prob_image, CvRect window, + CvTermCriteria criteria, CvConnectedComp* comp ); +*) +{$EXTERNALSYM cvMeanShift} +function cvMeanShift(const prob_image: pCvArr; window: TCvRect; criteria: TCvTermCriteria; var comp: TCvConnectedComp) + : Integer; cdecl; + +(* + standard Kalman filter (in G. Welch' and G. Bishop's notation): + + x(k)=A*x(k-1)+B*u(k)+w(k) p(w)~N(0,Q) + z(k)=H*x(k)+v(k), p(v)~N(0,R) +*) +Type + pCvKalman = ^TCvKalman; + +{$EXTERNALSYM TCvKalman} + + TCvKalman = record + MP: Integer; (* number of measurement vector dimensions *) + DP: Integer; (* number of state vector dimensions *) + CP: Integer; (* number of control vector dimensions *) + + (* backward compatibility fields *) +{$IFDEF 1} + PosterState: PSingle; (* =state_pre->data.fl *) + PriorState: PSingle; (* =state_post->data.fl *) + DynamMatr: PSingle; (* =transition_matrix->data.fl *) + MeasurementMatr: PSingle; (* =measurement_matrix->data.fl *) + MNCovariance: PSingle; (* =measurement_noise_cov->data.fl *) + PNCovariance: PSingle; (* =process_noise_cov->data.fl *) + KalmGainMatr: PSingle; (* =gain->data.fl *) + PriorErrorCovariance: PSingle; (* =error_cov_pre->data.fl *) + PosterErrorCovariance: PSingle; (* =error_cov_post->data.fl *) + Temp1: PSingle; (* temp1->data.fl *) + Temp2: PSingle; (* temp2->data.fl *) +{$ENDIF} + state_pre: pCvMat; (* predicted state (x'(k)): + x(k)=A*x(k-1)+B*u(k) *) + state_post: pCvMat; (* corrected state (x(k)): + x(k)=x'(k)+K(k)*(z(k)-H*x'(k)) *) + transition_matrix: pCvMat; (* state transition matrix (A) *) + control_matrix: pCvMat; (* control matrix (B) + (it is not used if there is no control) *) + measurement_matrix: pCvMat; (* measurement matrix (H) *) + process_noise_cov: pCvMat; (* process noise covariance matrix (Q) *) + measurement_noise_cov: pCvMat; (* measurement noise covariance matrix (R) *) + error_cov_pre: pCvMat; (* priori error estimate covariance matrix (P'(k)): + P'(k)=A*P(k-1)*At + Q) *) + gain: pCvMat; (* Kalman gain matrix (K(k)): + K(k)=P'(k)*Ht*inv(H*P'(k)*Ht+R) *) + error_cov_post: pCvMat; (* posteriori error estimate covariance matrix (P(k)): + P(k)=(I-K(k)*H)*P'(k) *) + Temp1: pCvMat; (* temporary matrices *) + Temp2: pCvMat; + temp3: pCvMat; + temp4: pCvMat; + temp5: pCvMat; + end; + // + (* + Creates Kalman filter and sets A, B, Q, R and state to some initial values + + CVAPI(CvKalman* ) cvCreateKalman( int dynam_params, int measure_params, + int control_params CV_DEFAULT(0)); + *) +{$EXTERNALSYM cvCreateKalman} + +function cvCreateKalman(dynam_params: Integer; measure_params: Integer; control_params: Integer = 0): pCvKalman; cdecl; + +(* + Releases Kalman filter state + + CVAPI(void) cvReleaseKalman( CvKalman** kalman); +*) +{$EXTERNALSYM cvReleaseKalman} +procedure cvReleaseKalman(var kalman: pCvKalman); cdecl; + +(* + Updates Kalman filter by time (predicts future state of the system) + + CVAPI(const CvMat* cvKalmanPredict( CvKalman* kalman, + const CvMat* control CV_DEFAULT(NULL)); +*) +{$EXTERNALSYM cvKalmanPredict} +function cvKalmanPredict(var kalman: TCvKalman; const control: pCvMat = nil): pCvMat; cdecl; + +(* Updates Kalman filter by measurement + (corrects state of the system and internal matrices) + + CVAPI(const CvMat* ) cvKalmanCorrect( CvKalman* kalman, const CvMat* measurement ); +*) +{$EXTERNALSYM cvKalmanCorrect} +function cvKalmanCorrect(var kalman: TCvKalman; const measurement: pCvMat): pCvMat; cdecl; + +Type + TcvKalmanPredict = function(var kalman: TCvKalman; const control: pCvMat = nil): pCvMat; cdecl; + TcvKalmanCorrect = function(var kalman: TCvKalman; const measurement: pCvMat): pCvMat; cdecl; + +Var +{$EXTERNALSYM cvKalmanUpdateByTime} + cvKalmanUpdateByTime: TcvKalmanPredict = cvKalmanPredict; +{$EXTERNALSYM cvKalmanUpdateByMeasurement} + cvKalmanUpdateByMeasurement: TcvKalmanCorrect = cvKalmanCorrect; implementation @@ -302,5 +331,12 @@ procedure cvUpdateMotionHistory; external tracking_lib; procedure cvCalcMotionGradient; external tracking_lib; function cvSegmentMotion; external tracking_lib; function cvCalcGlobalOrientation; external tracking_lib; +procedure cvCalcAffineFlowPyrLK; external tracking_lib; +function cvEstimateRigidTransform; external tracking_lib; +function cvMeanShift; external tracking_lib; +function cvCreateKalman; external tracking_lib; +function cvKalmanPredict; external tracking_lib; +function cvKalmanCorrect; external tracking_lib; +procedure cvReleaseKalman; external tracking_lib; end.