diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore index 46ff341..7b38fb6 100644 --- a/.gitignore +++ b/.gitignore @@ -37,4 +37,7 @@ __history *.vlb /bin/carnumdetect.ini /bin/*.bsc -/Bin/vclFaceRecogData \ No newline at end of file +/Bin/vclFaceRecogData +Debug +ipch +*.sdf diff --git a/deprecated/bin/opencv_classes.bsc b/deprecated/bin/opencv_classes.bsc new file mode 100644 index 0000000..0f18148 Binary files /dev/null and b/deprecated/bin/opencv_classes.bsc differ diff --git a/deprecated/bin/opencv_classes.dll b/deprecated/bin/opencv_classes.dll new file mode 100644 index 0000000..31e908e Binary files /dev/null and b/deprecated/bin/opencv_classes.dll differ diff --git a/include/contrib/contrib.pas b/deprecated/include/contrib/contrib.pas similarity index 100% rename from include/contrib/contrib.pas rename to deprecated/include/contrib/contrib.pas diff --git a/deprecated/include/core/Mat.pas b/deprecated/include/core/Mat.pas new file mode 100644 index 0000000..7c6cc26 --- /dev/null +++ b/deprecated/include/core/Mat.pas @@ -0,0 +1,160 @@ +// --------------------------------- 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 + // ************************************************************************************************** + // 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://opencv.org + // Online docs: http://docs.opencv.org + // Q&A forum: http://answers.opencv.org + // Dev zone: http://code.opencv.org + // ************************************************************************************************** + // Original file: + // opencv\modules\core\include\opencv2\core\mat.hpp + // ************************************************************************************************* *) + +unit Mat; + +interface + +Uses WinApi.Windows, Core.types_c; + +const + MAGIC_VAL = $42FF0000; + AUTO_STEP = 0; + CONTINUOUS_FLAG = CV_MAT_CONT_FLAG; + SUBMATRIX_FLAG = CV_SUBMAT_FLAG; + + MAGIC_MASK = $FFFF0000; + TYPE_MASK = $00000FFF; + DEPTH_MASK = 7; + +Type + + // Attention! + // The sequence of function declarations interface must match the + // sequence of function declarations in the project "opencv_classes" (C++) + + IMat = interface + ['{9C458D5C-F577-4A2D-89A0-FC426B80CC56}'] + // ! returns element size in bytes, + // similar to CV_ELEM_SIZE(cvmat->type) + function elemSize(): size_t; stdcall; + // ! returns the size of element channel in bytes. + function elemSize1(): size_t; stdcall; + // ! returns element type, similar to CV_MAT_TYPE(cvmat->type) + function _type: Integer; stdcall; + // ! returns element type, similar to CV_MAT_DEPTH(cvmat->type) + function depth: Integer; stdcall; + // ! returns element type, similar to CV_MAT_CN(cvmat->type) + function channels: Integer; stdcall; + // ! returns step/elemSize1() + function step1(i: Integer = 0): size_t; stdcall; + // ! returns true if matrix data is NULL + function empty: bool; stdcall; + // ! returns the total number of matrix elements + function total: size_t; stdcall; + // * ! includes several bit - fields: - the magic signature - continuity flag - depth - number of channels * / + function flags: Integer; stdcall; + // ! the matrix dimensionality, >= 2 + function dims: Integer; stdcall; + // ! the number of rows and columns or (-1, -1) when the matrix has more than 2 dimensions + function rows: Integer; stdcall; + function cols: Integer; stdcall; + // ! pointer to the data + function data: pByte; stdcall; + //! copies the matrix content to "m". + // It calls m.create(this->size(), this->type()). + procedure copyto(Var _mat:IMat); stdcall; + // ! pointer to the reference counter; + // when matrix points to user-allocated data, the pointer is NULL + function refcount: pInteger; stdcall; + // ----------------------------------- + function getMat(): Pointer; stdcall; + // procedure setMat(mat:Pointer); stdcall; + end; + + // ! default constructor +function CreateMat: IMat; overload; safecall; +// ! constructs 2D matrix of the specified size and type +// (_type is CV_8UC1, CV_64FC3, CV_32SC(12) etc.) +function CreateMat(rows, cols, _type: Integer): IMat; overload; safecall; +function CreateMat(_mat: Pointer): IMat; overload; safecall; + +implementation + +Uses uLibName; + +function CreateMat: IMat; external OpenCV_Classes_DLL name 'CreateMat'; +function CreateMat(rows, cols, _type: Integer): IMat; external OpenCV_Classes_DLL name 'CreateMat_rct'; +function CreateMat(_mat: Pointer): IMat; external OpenCV_Classes_DLL name 'CreateMat_Mat'; + +end. diff --git a/include/core/core.pas b/deprecated/include/core/core.pas similarity index 100% rename from include/core/core.pas rename to deprecated/include/core/core.pas diff --git a/include/core/core.types.pas b/deprecated/include/core/core.types.pas similarity index 97% rename from include/core/core.types.pas rename to deprecated/include/core/core.types.pas index 86395ed..d8c8d34 100644 --- a/include/core/core.types.pas +++ b/deprecated/include/core/core.types.pas @@ -167,15 +167,8 @@ function CString; external OpenCV_Classes_DLL index 300; function TIplImageRecordHelper.InitFromMat(const Mat: IMat): TIplImage; begin Assert(Mat.dims <= 2); - cvInitImageHeader( - @Self, - CvSize(Mat.cols, Mat.rows), - cvIplDepth(Mat.flags), - Mat.channels); - cvSetData( - @Self, - Mat.data, - Mat.step1); + cvInitImageHeader(@Self, CvSize(Mat.cols, Mat.rows), cvIplDepth(Mat.flags), Mat.channels); + cvSetData(@Self, Mat.data, Mat.step1); end; end. diff --git a/deprecated/include/highgui/highgui.pas b/deprecated/include/highgui/highgui.pas new file mode 100644 index 0000000..8709a81 --- /dev/null +++ b/deprecated/include/highgui/highgui.pas @@ -0,0 +1,245 @@ +// --------------------------------- 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 + // ************************************************************************************************** + // 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://opencv.org + // Online docs: http://docs.opencv.org + // Q&A forum: http://answers.opencv.org + // Dev zone: http://code.opencv.org + // ************************************************************************************************** + // Original file: + // opencv\modules\highgui\include\opencv2\highgui.hpp + // ************************************************************************************************* *) + +unit highgui; + +interface + +Uses + WinApi.Windows, + Mat, + Core.types_c, + Core.types, + highgui_c; + +Type + + // Attention! + // The sequence of function declarations interface must match the + // sequence of function declarations in the project "opencv_classes" (C++) + + IVideoCapture = interface + ['{3F605CF0-ECAC-4230-B30B-AF9BFD516C4F}'] + function open(device: Integer): bool; overload; stdcall; + function openfilename(filename: pAnsiChar): bool; overload; stdcall; + function isOpened(): bool; stdcall; + procedure release(); stdcall; + + function grab(): bool; stdcall; + function retrieve(Var image: IMat; flag: Integer): bool; stdcall; + function read(Var image: IMat): bool; stdcall; + + function setValue(propId: Integer; value: double): bool; stdcall; + function getValue(propId: Integer): double; stdcall; + end; + +function CreateVideoCapture: IVideoCapture; overload; safecall; +function CreateVideoCapture(device: Integer): IVideoCapture; overload; safecall; +function CreateVideoCapture(filename: pAnsiChar): IVideoCapture; overload; safecall; + +// Flags for namedWindow +Const + WINDOW_NORMAL = $00000000; + // the user can resize the window (no constraint) / also use to switch a fullscreen window to a normal size + WINDOW_AUTOSIZE = $00000001; // the user cannot resize the window, the size is constrainted by the image displayed + WINDOW_OPENGL = $00001000; // window with opengl support + + WINDOW_FULLSCREEN = 1; // change the window to fullscreen + WINDOW_FREERATIO = $00000100; // the image expends as much as it can (no ratio constraint) + WINDOW_KEEPRATIO = $00000000; // the ratio of the image is respected + + // CV_EXPORTS_W void namedWindow(const String& winname, int flags = WINDOW_AUTOSIZE); +procedure namedWindow(const winname: String; const flags: Integer = WINDOW_AUTOSIZE); +// CV_EXPORTS_W void destroyWindow(const String& winname); +procedure destroyWindow(const winname: String); +// CV_EXPORTS_W void destroyAllWindows(); +procedure destroyAllWindows(); +// CV_EXPORTS_W int startWindowThread(); +function startWindowThread(): Integer; +// CV_EXPORTS_W int waitKey(int delay = 0); +function waitKey(const delay: Integer = 0): Integer; +// CV_EXPORTS_W void imshow(const String& winname, InputArray mat); +procedure imshow(const winname: String; const Mat: IMat); +// CV_EXPORTS_W void resizeWindow(const String& winname, int width, int height); +procedure resizeWindow(const winname: String; const width, height: Integer); +// CV_EXPORTS_W void moveWindow(const String& winname, int x, int y); +procedure moveWindow(const winname: String; const x, y: Integer); +// CV_EXPORTS_W void setWindowProperty(const String& winname, int prop_id, double prop_value); +procedure setWindowProperty(const winname: String; const prop_id: Integer; const prop_value: double); +// CV_EXPORTS_W double getWindowProperty(const String& winname, int prop_id); +function getWindowProperty(const winname: String; const prop_id: Integer): double; +// CV_EXPORTS int createTrackbar(const String& trackbarname, const String& winname, +// int* value, int count, +// TrackbarCallback onChange = 0, +// void* userdata = 0); +function createTrackbar(const trackbarname: String; const winname: String; value: PInteger; count: Integer; onChange: CvTrackbarCallback2 = nil; + userdata: Pointer = nil): Integer; + +// CV_EXPORTS_W Mat imread( const string& filename, int flags=1 ); +function imread(const filename: string; flag: Integer = 1): IMat; +// CV_EXPORTS_W bool imwrite( const string& filename, InputArray img, const vector& params=vector()); +function imwrite(const filename: String; const img: IMat): bool; + +implementation + +Uses + uLibName, + cvUtils, + core_c; + +function CreateVideoCapture: IVideoCapture; external OpenCV_Classes_DLL name 'CreateVideoCapture'; +function CreateVideoCapture(device: Integer): IVideoCapture; external OpenCV_Classes_DLL name 'CreateVideoCapture_dvc'; +function CreateVideoCapture(filename: pAnsiChar): IVideoCapture; external OpenCV_Classes_DLL name 'CreateVideoCapture_fln'; +function _imread(const filename: pCvChar; flag: Integer): IMat; external OpenCV_Classes_DLL name '_imread'; +function _imwrite(const filename: pCvChar; const img: IMat): bool; external OpenCV_Classes_DLL name '_imwrite'; + +function imread(const filename: string; flag: Integer): IMat; +begin + Result := _imread(c_str(filename), flag); +end; + +function imwrite(const filename: String; const img: IMat): bool; +begin + Result := _imwrite(c_str(filename), img); +end; + +procedure namedWindow(const winname: String; const flags: Integer = WINDOW_AUTOSIZE); +begin + cvNamedWindow(c_str(winname), flags); +end; + +procedure destroyWindow(const winname: String); +begin + cvDestroyWindow(c_str(winname)); +end; + +procedure destroyAllWindows(); +begin + cvDestroyAllWindows(); +end; + +function startWindowThread(): Integer; +begin + Result := cvStartWindowThread(); +end; + +function waitKey(const delay: Integer = 0): Integer; +begin + Result := cvWaitKey(delay); +end; + +procedure imshow(const winname: String; const Mat: IMat); +Var + IplImage: TIplImage; +begin + IplImage.InitFromMat(Mat); + cvShowImage(c_str(winname), @IplImage); +end; + +procedure resizeWindow(const winname: String; const width, height: Integer); +begin + cvResizeWindow(c_str(winname), width, height); +end; + +procedure moveWindow(const winname: String; const x, y: Integer); +begin + cvMoveWindow(c_str(winname), x, y); +end; + +procedure setWindowProperty(const winname: String; const prop_id: Integer; const prop_value: double); +begin + cvSetWindowProperty(c_str(winname), prop_id, prop_value); +end; + +function getWindowProperty(const winname: String; const prop_id: Integer): double; +begin + Result := cvGetWindowProperty(c_str(winname), prop_id); +end; + +function createTrackbar(const trackbarname: String; const winname: String; value: PInteger; count: Integer; onChange: CvTrackbarCallback2 = nil; + userdata: Pointer = nil): Integer; +begin + Result := cvCreateTrackbar2(c_str(trackbarname), c_str(winname), value, count, onChange, userdata); +end; + +end. diff --git a/include/imgproc/imgproc.pas b/deprecated/include/imgproc/imgproc.pas similarity index 100% rename from include/imgproc/imgproc.pas rename to deprecated/include/imgproc/imgproc.pas diff --git a/include/imgproc/smooth.pas b/deprecated/include/imgproc/smooth.pas similarity index 100% rename from include/imgproc/smooth.pas rename to deprecated/include/imgproc/smooth.pas diff --git a/include/legacy/bgfg_estimation.pas b/deprecated/include/legacy/bgfg_estimation.pas similarity index 100% rename from include/legacy/bgfg_estimation.pas rename to deprecated/include/legacy/bgfg_estimation.pas diff --git a/include/legacy/blobtrack.pas b/deprecated/include/legacy/blobtrack.pas similarity index 100% rename from include/legacy/blobtrack.pas rename to deprecated/include/legacy/blobtrack.pas diff --git a/include/legacy/blobtrackingccwithcr.pas b/deprecated/include/legacy/blobtrackingccwithcr.pas similarity index 100% rename from include/legacy/blobtrackingccwithcr.pas rename to deprecated/include/legacy/blobtrackingccwithcr.pas diff --git a/include/legacy/enteringblobdetection.pas b/deprecated/include/legacy/enteringblobdetection.pas similarity index 100% rename from include/legacy/enteringblobdetection.pas rename to deprecated/include/legacy/enteringblobdetection.pas diff --git a/deprecated/include/ml/ml.pas b/deprecated/include/ml/ml.pas new file mode 100644 index 0000000..a46f5ef --- /dev/null +++ b/deprecated/include/ml/ml.pas @@ -0,0 +1,2244 @@ +// --------------------------------- 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 +// ************************************************************************************************** +// Contributors: +// Laentir Valetov +// email:laex@bk.ru +// Mikhail Grigorev +// Email: sleuthhound@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 +// ************************************************************************************************** +// The Initial Developer of the Original Code: +// OpenCV: open source computer vision library +// Homepage: http://opencv.org +// Online docs: http://docs.opencv.org +// Q&A forum: http://answers.opencv.org +// Dev zone: http://code.opencv.org +// ************************************************************************************************** +// Original file: +// opencv\modules\ml\include\opencv2\ml.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} +{$ELSE} +{$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} +{$ENDIF} +{$WARN SYMBOL_DEPRECATED OFF} +{$WARN SYMBOL_PLATFORM OFF} +{$WARN UNIT_PLATFORM OFF} +{$WARN UNSAFE_TYPE OFF} +{$WARN UNSAFE_CODE OFF} +{$WARN UNSAFE_CAST OFF} +{$POINTERMATH ON} +unit ml; + +interface + +Uses + WinApi.Windows, + Core.types_c; + +/// ****************************************************************************************\ +// * Main struct definitions * +// \****************************************************************************************/ +// +/// * log(2*PI) */ +// #define CV_LOG2PI (1.8378770664093454835606594728112) +// +/// * columns of matrix are training samples */ +// #define CV_COL_SAMPLE 0 +// +/// * rows of matrix are training samples */ +// #define CV_ROW_SAMPLE 1 +// +// #define CV_IS_ROW_SAMPLE(flags) ((flags) & CV_ROW_SAMPLE) +// +// struct CvVectors +// { +// int type; +// int dims, count; +// CvVectors* next; +// union +// { +// uchar** ptr; +// float** fl; +// double** db; +// } data; +// }; +// +// #if 0 +/// * A structure, representing the lattice range of statmodel parameters. +// It is used for optimizing statmodel parameters by cross-validation method. +// The lattice is logarithmic, so must be greater then 1. */ +// typedef struct CvParamLattice +// { +// double min_val; +// double max_val; +// double step; +// } +// CvParamLattice; +// +// CV_INLINE CvParamLattice cvParamLattice( double min_val, double max_val, +// double log_step ) +// { +// CvParamLattice pl; +// pl.min_val = MIN( min_val, max_val ); +// pl.max_val = MAX( min_val, max_val ); +// pl.step = MAX( log_step, 1. ); +// return pl; +// } +// +// CV_INLINE CvParamLattice cvDefaultParamLattice( void ) +// { +// CvParamLattice pl = {0,0,0}; +// return pl; +// } +// #endif + +const + /// * Variable type */ + CV_VAR_NUMERICAL = 0; + CV_VAR_ORDERED = 0; + CV_VAR_CATEGORICAL = 1; + + // + // #define CV_TYPE_NAME_ML_SVM "opencv-ml-svm" + // #define CV_TYPE_NAME_ML_KNN "opencv-ml-knn" + // #define CV_TYPE_NAME_ML_NBAYES "opencv-ml-bayesian" + // #define CV_TYPE_NAME_ML_EM "opencv-ml-em" + // #define CV_TYPE_NAME_ML_BOOSTING "opencv-ml-boost-tree" + // #define CV_TYPE_NAME_ML_TREE "opencv-ml-tree" + // #define CV_TYPE_NAME_ML_ANN_MLP "opencv-ml-ann-mlp" + // #define CV_TYPE_NAME_ML_CNN "opencv-ml-cnn" + // #define CV_TYPE_NAME_ML_RTREES "opencv-ml-random-trees" + // #define CV_TYPE_NAME_ML_ERTREES "opencv-ml-extremely-randomized-trees" + // #define CV_TYPE_NAME_ML_GBT "opencv-ml-gradient-boosting-trees" + // + // #define CV_TRAIN_ERROR 0 + // #define CV_TEST_ERROR 1 + // + // class CV_EXPORTS_W CvStatModel + // { + // public: + // CvStatModel(); + // virtual ~CvStatModel(); + // + // virtual void clear(); + // + // CV_WRAP virtual void save( const char* filename, const char* name=0 ) const; + // CV_WRAP virtual void load( const char* filename, const char* name=0 ); + // + // virtual void write( CvFileStorage* storage, const char* name ) const; + // virtual void read( CvFileStorage* storage, CvFileNode* node ); + // + // protected: + // const char* default_model_name; + // }; + // + /// ****************************************************************************************\ + // * Normal Bayes Classifier * + // \****************************************************************************************/ + // + /// * The structure, representing the grid range of statmodel parameters. + // It is used for optimizing statmodel accuracy by varying model parameters, + // the accuracy estimate being computed by cross-validation. + // The grid is logarithmic, so must be greater then 1. */ + // + // class CvMLData; + // + // struct CV_EXPORTS_W_MAP CvParamGrid + // { + // // SVM params type + // enum { SVM_C=0, SVM_GAMMA=1, SVM_P=2, SVM_NU=3, SVM_COEF=4, SVM_DEGREE=5 }; + // + // CvParamGrid() + // { + // min_val = max_val = step = 0; + // } + // + // CvParamGrid( double min_val, double max_val, double log_step ); + // //CvParamGrid( int param_id ); + // bool check() const; + // + // CV_PROP_RW double min_val; + // CV_PROP_RW double max_val; + // CV_PROP_RW double step; + // }; + // + // inline CvParamGrid::CvParamGrid( double _min_val, double _max_val, double _log_step ) + // { + // min_val = _min_val; + // max_val = _max_val; + // step = _log_step; + // } + // + // class CV_EXPORTS_W CvNormalBayesClassifier : public CvStatModel + // { + // public: + // CV_WRAP CvNormalBayesClassifier(); + // virtual ~CvNormalBayesClassifier(); + // + // CvNormalBayesClassifier( const CvMat* trainData, const CvMat* responses, + // const CvMat* varIdx=0, const CvMat* sampleIdx=0 ); + // + // virtual bool train( const CvMat* trainData, const CvMat* responses, + // const CvMat* varIdx = 0, const CvMat* sampleIdx=0, bool update=false ); + // + // virtual float predict( const CvMat* samples, CV_OUT CvMat* results=0 ) const; + // CV_WRAP virtual void clear(); + // + // CV_WRAP CvNormalBayesClassifier( const cv::Mat& trainData, const cv::Mat& responses, + // const cv::Mat& varIdx=cv::Mat(), const cv::Mat& sampleIdx=cv::Mat() ); + // CV_WRAP virtual bool train( const cv::Mat& trainData, const cv::Mat& responses, + // const cv::Mat& varIdx = cv::Mat(), const cv::Mat& sampleIdx=cv::Mat(), + // bool update=false ); + // CV_WRAP virtual float predict( const cv::Mat& samples, CV_OUT cv::Mat* results=0 ) const; + // + // virtual void write( CvFileStorage* storage, const char* name ) const; + // virtual void read( CvFileStorage* storage, CvFileNode* node ); + // + // protected: + // int var_count, var_all; + // CvMat* var_idx; + // CvMat* cls_labels; + // CvMat** count; + // CvMat** sum; + // CvMat** productsum; + // CvMat** avg; + // CvMat** inv_eigen_values; + // CvMat** cov_rotate_mats; + // CvMat* c; + // }; + // + // + /// ****************************************************************************************\ + // * K-Nearest Neighbour Classifier * + // \****************************************************************************************/ +Type + ICvKNearest = interface + ['{2F98E12A-AB71-48B5-AACC-025D0D0A3611}'] + function train(const trainData: pCvMat; const responses: pCvMat; const sampleIdx: pCvMat = nil; + is_regression: bool = false; maxK: Integer = 32; updateBase: bool = false): bool; stdcall; + function find_nearest(const samples: pCvMat; k: Integer; results: pCvMat = nil; const neighbors: pSingle = nil; + neighborResponses: pCvMat = nil; dist: pCvMat = nil): float; stdcall; + end; + + // k Nearest Neighbors + // class CV_EXPORTS_W CvKNearest : public CvStatModel + // { + // public: + // + // CV_WRAP CvKNearest(); + // virtual ~CvKNearest(); + // + // CvKNearest( const CvMat* trainData, const CvMat* responses, const CvMat* sampleIdx=0, bool isRegression=false, int max_k=32 ); + // + // virtual bool train( const CvMat* trainData, const CvMat* responses, + // const CvMat* sampleIdx=0, bool is_regression=false, + // int maxK=32, bool updateBase=false ); + // + // virtual float find_nearest( const CvMat* samples, int k, CV_OUT CvMat* results=0, + // const float** neighbors=0, CV_OUT CvMat* neighborResponses=0, CV_OUT CvMat* dist=0 ) const; + // + // CV_WRAP CvKNearest( const cv::Mat& trainData, const cv::Mat& responses, + // const cv::Mat& sampleIdx=cv::Mat(), bool isRegression=false, int max_k=32 ); + // + // CV_WRAP virtual bool train( const cv::Mat& trainData, const cv::Mat& responses, + // const cv::Mat& sampleIdx=cv::Mat(), bool isRegression=false, + // int maxK=32, bool updateBase=false ); + // + // virtual float find_nearest( const cv::Mat& samples, int k, cv::Mat* results=0, + // const float** neighbors=0, cv::Mat* neighborResponses=0, + // cv::Mat* dist=0 ) const; + // CV_WRAP virtual float find_nearest( const cv::Mat& samples, int k, CV_OUT cv::Mat& results, + // CV_OUT cv::Mat& neighborResponses, CV_OUT cv::Mat& dists) const; + // + // virtual void clear(); + // int get_max_k() const; + // int get_var_count() const; + // int get_sample_count() const; + // bool is_regression() const; + // + // virtual float write_results( int k, int k1, int start, int end, + // const float* neighbor_responses, const float* dist, CvMat* _results, + // CvMat* _neighbor_responses, CvMat* _dist, Cv32suf* sort_buf ) const; + // + // virtual void find_neighbors_direct( const CvMat* _samples, int k, int start, int end, + // float* neighbor_responses, const float** neighbors, float* dist ) const; + // + // protected: + // + // int max_k, var_count; + // int total; + // bool regression; + // CvVectors* samples; + // }; + // + /// ****************************************************************************************\ + // * Support Vector Machines * + // \****************************************************************************************/ + // + /// / SVM training parameters + // struct CV_EXPORTS_W_MAP CvSVMParams + // { + // CvSVMParams(); + // CvSVMParams( int svm_type, int kernel_type, + // double degree, double gamma, double coef0, + // double Cvalue, double nu, double p, + // CvMat* class_weights, CvTermCriteria term_crit ); + // + // CV_PROP_RW int svm_type; + // CV_PROP_RW int kernel_type; + // CV_PROP_RW double degree; // for poly + // CV_PROP_RW double gamma; // for poly/rbf/sigmoid/chi2 + // CV_PROP_RW double coef0; // for poly/sigmoid + // + // CV_PROP_RW double C; // for CV_SVM_C_SVC, CV_SVM_EPS_SVR and CV_SVM_NU_SVR + // CV_PROP_RW double nu; // for CV_SVM_NU_SVC, CV_SVM_ONE_CLASS, and CV_SVM_NU_SVR + // CV_PROP_RW double p; // for CV_SVM_EPS_SVR + // CvMat* class_weights; // for CV_SVM_C_SVC + // CV_PROP_RW CvTermCriteria term_crit; // termination criteria + // }; + // + // + // struct CV_EXPORTS CvSVMKernel + // { + // typedef void (CvSVMKernel::*Calc)( int vec_count, int vec_size, const float** vecs, + // const float* another, float* results ); + // CvSVMKernel(); + // CvSVMKernel( const CvSVMParams* params, Calc _calc_func ); + // virtual bool create( const CvSVMParams* params, Calc _calc_func ); + // virtual ~CvSVMKernel(); + // + // virtual void clear(); + // virtual void calc( int vcount, int n, const float** vecs, const float* another, float* results ); + // + // const CvSVMParams* params; + // Calc calc_func; + // + // virtual void calc_non_rbf_base( int vec_count, int vec_size, const float** vecs, + // const float* another, float* results, + // double alpha, double beta ); + // virtual void calc_intersec( int vcount, int var_count, const float** vecs, + // const float* another, float* results ); + // virtual void calc_chi2( int vec_count, int vec_size, const float** vecs, + // const float* another, float* results ); + // virtual void calc_linear( int vec_count, int vec_size, const float** vecs, + // const float* another, float* results ); + // virtual void calc_rbf( int vec_count, int vec_size, const float** vecs, + // const float* another, float* results ); + // virtual void calc_poly( int vec_count, int vec_size, const float** vecs, + // const float* another, float* results ); + // virtual void calc_sigmoid( int vec_count, int vec_size, const float** vecs, + // const float* another, float* results ); + // }; + // + // + // struct CvSVMKernelRow + // { + // CvSVMKernelRow* prev; + // CvSVMKernelRow* next; + // float* data; + // }; + // + // + // struct CvSVMSolutionInfo + // { + // double obj; + // double rho; + // double upper_bound_p; + // double upper_bound_n; + // double r; // for Solver_NU + // }; + // + // class CV_EXPORTS CvSVMSolver + // { + // public: + // typedef bool (CvSVMSolver::*SelectWorkingSet)( int& i, int& j ); + // typedef float* (CvSVMSolver::*GetRow)( int i, float* row, float* dst, bool existed ); + // typedef void (CvSVMSolver::*CalcRho)( double& rho, double& r ); + // + // CvSVMSolver(); + // + // CvSVMSolver( int count, int var_count, const float** samples, schar* y, + // int alpha_count, double* alpha, double Cp, double Cn, + // CvMemStorage* storage, CvSVMKernel* kernel, GetRow get_row, + // SelectWorkingSet select_working_set, CalcRho calc_rho ); + // virtual bool create( int count, int var_count, const float** samples, schar* y, + // int alpha_count, double* alpha, double Cp, double Cn, + // CvMemStorage* storage, CvSVMKernel* kernel, GetRow get_row, + // SelectWorkingSet select_working_set, CalcRho calc_rho ); + // virtual ~CvSVMSolver(); + // + // virtual void clear(); + // virtual bool solve_generic( CvSVMSolutionInfo& si ); + // + // virtual bool solve_c_svc( int count, int var_count, const float** samples, schar* y, + // double Cp, double Cn, CvMemStorage* storage, + // CvSVMKernel* kernel, double* alpha, CvSVMSolutionInfo& si ); + // virtual bool solve_nu_svc( int count, int var_count, const float** samples, schar* y, + // CvMemStorage* storage, CvSVMKernel* kernel, + // double* alpha, CvSVMSolutionInfo& si ); + // virtual bool solve_one_class( int count, int var_count, const float** samples, + // CvMemStorage* storage, CvSVMKernel* kernel, + // double* alpha, CvSVMSolutionInfo& si ); + // + // virtual bool solve_eps_svr( int count, int var_count, const float** samples, const float* y, + // CvMemStorage* storage, CvSVMKernel* kernel, + // double* alpha, CvSVMSolutionInfo& si ); + // + // virtual bool solve_nu_svr( int count, int var_count, const float** samples, const float* y, + // CvMemStorage* storage, CvSVMKernel* kernel, + // double* alpha, CvSVMSolutionInfo& si ); + // + // virtual float* get_row_base( int i, bool* _existed ); + // virtual float* get_row( int i, float* dst ); + // + // int sample_count; + // int var_count; + // int cache_size; + // int cache_line_size; + // const float** samples; + // const CvSVMParams* params; + // CvMemStorage* storage; + // CvSVMKernelRow lru_list; + // CvSVMKernelRow* rows; + // + // int alpha_count; + // + // double* G; + // double* alpha; + // + // // -1 - lower bound, 0 - free, 1 - upper bound + // schar* alpha_status; + // + // schar* y; + // double* b; + // float* buf[2]; + // double eps; + // int max_iter; + // double C[2]; // C[0] == Cn, C[1] == Cp + // CvSVMKernel* kernel; + // + // SelectWorkingSet select_working_set_func; + // CalcRho calc_rho_func; + // GetRow get_row_func; + // + // virtual bool select_working_set( int& i, int& j ); + // virtual bool select_working_set_nu_svm( int& i, int& j ); + // virtual void calc_rho( double& rho, double& r ); + // virtual void calc_rho_nu_svm( double& rho, double& r ); + // + // virtual float* get_row_svc( int i, float* row, float* dst, bool existed ); + // virtual float* get_row_one_class( int i, float* row, float* dst, bool existed ); + // virtual float* get_row_svr( int i, float* row, float* dst, bool existed ); + // }; + // + // + // struct CvSVMDecisionFunc + // { + // double rho; + // int sv_count; + // double* alpha; + // int* sv_index; + // }; + // + // + /// / SVM model + // class CV_EXPORTS_W CvSVM : public CvStatModel + // { + // public: + // // SVM type + // enum { C_SVC=100, NU_SVC=101, ONE_CLASS=102, EPS_SVR=103, NU_SVR=104 }; + // + // // SVM kernel type + // enum { LINEAR=0, POLY=1, RBF=2, SIGMOID=3, CHI2=4, INTER=5 }; + // + // // SVM params type + // enum { C=0, GAMMA=1, P=2, NU=3, COEF=4, DEGREE=5 }; + // + // CV_WRAP CvSVM(); + // virtual ~CvSVM(); + // + // CvSVM( const CvMat* trainData, const CvMat* responses, + // const CvMat* varIdx=0, const CvMat* sampleIdx=0, + // CvSVMParams params=CvSVMParams() ); + // + // virtual bool train( const CvMat* trainData, const CvMat* responses, + // const CvMat* varIdx=0, const CvMat* sampleIdx=0, + // CvSVMParams params=CvSVMParams() ); + // + // virtual bool train_auto( const CvMat* trainData, const CvMat* responses, + // const CvMat* varIdx, const CvMat* sampleIdx, CvSVMParams params, + // int kfold = 10, + // CvParamGrid Cgrid = get_default_grid(CvSVM::C), + // CvParamGrid gammaGrid = get_default_grid(CvSVM::GAMMA), + // CvParamGrid pGrid = get_default_grid(CvSVM::P), + // CvParamGrid nuGrid = get_default_grid(CvSVM::NU), + // CvParamGrid coeffGrid = get_default_grid(CvSVM::COEF), + // CvParamGrid degreeGrid = get_default_grid(CvSVM::DEGREE), + // bool balanced=false ); + // + // virtual float predict( const CvMat* sample, bool returnDFVal=false ) const; + // virtual float predict( const CvMat* samples, CV_OUT CvMat* results ) const; + // + // CV_WRAP CvSVM( const cv::Mat& trainData, const cv::Mat& responses, + // const cv::Mat& varIdx=cv::Mat(), const cv::Mat& sampleIdx=cv::Mat(), + // CvSVMParams params=CvSVMParams() ); + // + // CV_WRAP virtual bool train( const cv::Mat& trainData, const cv::Mat& responses, + // const cv::Mat& varIdx=cv::Mat(), const cv::Mat& sampleIdx=cv::Mat(), + // CvSVMParams params=CvSVMParams() ); + // + // CV_WRAP virtual bool train_auto( const cv::Mat& trainData, const cv::Mat& responses, + // const cv::Mat& varIdx, const cv::Mat& sampleIdx, CvSVMParams params, + // int k_fold = 10, + // CvParamGrid Cgrid = CvSVM::get_default_grid(CvSVM::C), + // CvParamGrid gammaGrid = CvSVM::get_default_grid(CvSVM::GAMMA), + // CvParamGrid pGrid = CvSVM::get_default_grid(CvSVM::P), + // CvParamGrid nuGrid = CvSVM::get_default_grid(CvSVM::NU), + // CvParamGrid coeffGrid = CvSVM::get_default_grid(CvSVM::COEF), + // CvParamGrid degreeGrid = CvSVM::get_default_grid(CvSVM::DEGREE), + // bool balanced=false); + // CV_WRAP virtual float predict( const cv::Mat& sample, bool returnDFVal=false ) const; + // CV_WRAP_AS(predict_all) virtual void predict( cv::InputArray samples, cv::OutputArray results ) const; + // + // CV_WRAP virtual int get_support_vector_count() const; + // virtual const float* get_support_vector(int i) const; + // virtual CvSVMParams get_params() const { return params; }; + // CV_WRAP virtual void clear(); + // + // static CvParamGrid get_default_grid( int param_id ); + // + // virtual void write( CvFileStorage* storage, const char* name ) const; + // virtual void read( CvFileStorage* storage, CvFileNode* node ); + // CV_WRAP int get_var_count() const { return var_idx ? var_idx->cols : var_all; } + // + // protected: + // + // virtual bool set_params( const CvSVMParams& params ); + // virtual bool train1( int sample_count, int var_count, const float** samples, + // const void* responses, double Cp, double Cn, + // CvMemStorage* _storage, double* alpha, double& rho ); + // virtual bool do_train( int svm_type, int sample_count, int var_count, const float** samples, + // const CvMat* responses, CvMemStorage* _storage, double* alpha ); + // virtual void create_kernel(); + // virtual void create_solver(); + // + // virtual float predict( const float* row_sample, int row_len, bool returnDFVal=false ) const; + // + // virtual void write_params( CvFileStorage* fs ) const; + // virtual void read_params( CvFileStorage* fs, CvFileNode* node ); + // + // void optimize_linear_svm(); + // + // CvSVMParams params; + // CvMat* class_labels; + // int var_all; + // float** sv; + // int sv_total; + // CvMat* var_idx; + // CvMat* class_weights; + // CvSVMDecisionFunc* decision_func; + // CvMemStorage* storage; + // + // CvSVMSolver* solver; + // CvSVMKernel* kernel; + // }; + // + /// ****************************************************************************************\ + // * Expectation - Maximization * + // \****************************************************************************************/ + // namespace cv + // { + // class CV_EXPORTS_W EM : public Algorithm + // { + // public: + // // Type of covariation matrices + // enum {COV_MAT_SPHERICAL=0, COV_MAT_DIAGONAL=1, COV_MAT_GENERIC=2, COV_MAT_DEFAULT=COV_MAT_DIAGONAL}; + // + // // Default parameters + // enum {DEFAULT_NCLUSTERS=5, DEFAULT_MAX_ITERS=100}; + // + // // The initial step + // enum {START_E_STEP=1, START_M_STEP=2, START_AUTO_STEP=0}; + // + // CV_WRAP EM(int nclusters=EM::DEFAULT_NCLUSTERS, int covMatType=EM::COV_MAT_DIAGONAL, + // const TermCriteria& termCrit=TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, + // EM::DEFAULT_MAX_ITERS, FLT_EPSILON)); + // + // virtual ~EM(); + // CV_WRAP virtual void clear(); + // + // CV_WRAP virtual bool train(InputArray samples, + // OutputArray logLikelihoods=noArray(), + // OutputArray labels=noArray(), + // OutputArray probs=noArray()); + // + // CV_WRAP virtual bool trainE(InputArray samples, + // InputArray means0, + // InputArray covs0=noArray(), + // InputArray weights0=noArray(), + // OutputArray logLikelihoods=noArray(), + // OutputArray labels=noArray(), + // OutputArray probs=noArray()); + // + // CV_WRAP virtual bool trainM(InputArray samples, + // InputArray probs0, + // OutputArray logLikelihoods=noArray(), + // OutputArray labels=noArray(), + // OutputArray probs=noArray()); + // + // CV_WRAP Vec2d predict(InputArray sample, + // OutputArray probs=noArray()) const; + // + // CV_WRAP bool isTrained() const; + // + // AlgorithmInfo* info() const; + // virtual void read(const FileNode& fn); + // + // protected: + // + // virtual void setTrainData(int startStep, const Mat& samples, + // const Mat* probs0, + // const Mat* means0, + // const std::vector* covs0, + // const Mat* weights0); + // + // bool doTrain(int startStep, + // OutputArray logLikelihoods, + // OutputArray labels, + // OutputArray probs); + // virtual void eStep(); + // virtual void mStep(); + // + // void clusterTrainSamples(); + // void decomposeCovs(); + // void computeLogWeightDivDet(); + // + // Vec2d computeProbabilities(const Mat& sample, Mat* probs) const; + // + // // all inner matrices have type CV_64FC1 + // CV_PROP_RW int nclusters; + // CV_PROP_RW int covMatType; + // CV_PROP_RW int maxIters; + // CV_PROP_RW double epsilon; + // + // Mat trainSamples; + // Mat trainProbs; + // Mat trainLogLikelihoods; + // Mat trainLabels; + // + // CV_PROP Mat weights; + // CV_PROP Mat means; + // CV_PROP std::vector covs; + // + // std::vector covsEigenValues; + // std::vector covsRotateMats; + // std::vector invCovsEigenValues; + // Mat logWeightDivDet; + // }; + // } // namespace cv + // + /// ****************************************************************************************\ + // * Decision Tree * + // \****************************************************************************************/\ + // struct CvPair16u32s + // { + // unsigned short* u; + // int* i; + // }; + // + // + // #define CV_DTREE_CAT_DIR(idx,subset) \ + // (2*((subset[(idx)>>5]&(1 << ((idx) & 31)))==0)-1) +Type + TOrd = packed record + c: float; + split_point: Integer; + end; + + pCvDTreeSplit = ^TCvDTreeSplit; + + TCvDTreeSplit = packed record // struct CvDTreeSplit + var_idx: Integer; // int var_idx; + condensed_idx: Integer; // int condensed_idx; + inversed: Integer; // int inversed; + quality: float; // float quality; + next: pCvDTreeSplit; // CvDTreeSplit* next; + case byte of + // union + // { + // int subset[2]; + 0: + (subset: array [0 .. 1] of Integer); + 1: + (ord: TOrd); + // struct + // { + // float c; + // int split_point; + // } + // ord; + // }; + end; + + pCvDTreeNode = ^TCvDTreeNode; + + TCvDTreeNode = packed record // struct CvDTreeNode + class_idx: Integer; // int class_idx; + Tn: Integer; // int Tn; + value: Double; // double value; + // + parent: pCvDTreeNode; // CvDTreeNode* parent; + left: pCvDTreeNode; // CvDTreeNode* left; + right: pCvDTreeNode; // CvDTreeNode* right; + // + split: pCvDTreeSplit; // CvDTreeSplit* split; + // + sample_count: Integer; // int sample_count; + depth: Integer; // int depth; + num_valid: pInteger; // int* num_valid; + offset: Integer; // int offset; + buf_idx: Integer; // int buf_idx; + maxlr: Double; // double maxlr; + // + // // global pruning data + complexity: Integer; // int complexity; + alpha: Double; // double alpha; + node_risk, tree_risk, tree_error: Double; // double node_risk, tree_risk, tree_error; + // + // // cross-validation pruning data + cv_Tn: pInteger; // int* cv_Tn; + cv_node_risk: pDouble; // double* cv_node_risk; + cv_node_error: pDouble; // double* cv_node_error; + // + // int get_num_valid(int vi) { return num_valid ? num_valid[vi] : sample_count; } + function get_num_valid(vi: Integer): Integer; + // void set_num_valid(int vi, int n) { if( num_valid ) num_valid[vi] = n; } + procedure set_num_valid(vi: Integer; n: Integer); + end; + + TCvDTreeParams = packed record // struct CV_EXPORTS_W_MAP CvDTreeParams + max_categories: Integer; // CV_PROP_RW int max_categories ; + max_depth: Integer; // CV_PROP_RW int max_depth ; + min_sample_count: Integer; // CV_PROP_RW int min_sample_count ; + cv_folds: Integer; // CV_PROP_RW int cv_folds ; + use_surrogates: ByteBool; // CV_PROP_RW bool use_surrogates ; + use_1se_rule: ByteBool; // CV_PROP_RW bool use_1se_rule ; + truncate_pruned_tree: ByteBool; // CV_PROP_RW bool truncate_pruned_tree ; + regression_accuracy: float; // CV_PROP_RW float regression_accuracy ; + priors: pFloat; // const float* priors; + // + // CvDTreeParams(); + { + CvDTreeParams( int max_depth, int min_sample_count, float regression_accuracy, + bool use_surrogates, int max_categories, int cv_folds, + bool use_1se_rule, bool truncate_pruned_tree, const float* priors ); + } + end; + + // struct CV_EXPORTS CvDTreeTrainData + // { + // CvDTreeTrainData(); + // CvDTreeTrainData( const CvMat* trainData, int tflag, + // const CvMat* responses, const CvMat* varIdx=0, + // const CvMat* sampleIdx=0, const CvMat* varType=0, + // const CvMat* missingDataMask=0, + // const CvDTreeParams& params=CvDTreeParams(), + // bool _shared=false, bool _add_labels=false ); + // virtual ~CvDTreeTrainData(); + // + // virtual void set_data( const CvMat* trainData, int tflag, + // const CvMat* responses, const CvMat* varIdx=0, + // const CvMat* sampleIdx=0, const CvMat* varType=0, + // const CvMat* missingDataMask=0, + // const CvDTreeParams& params=CvDTreeParams(), + // bool _shared=false, bool _add_labels=false, + // bool _update_data=false ); + // virtual void do_responses_copy(); + // + // virtual void get_vectors( const CvMat* _subsample_idx, + // float* values, uchar* missing, float* responses, bool get_class_idx=false ); + // + // virtual CvDTreeNode* subsample_data( const CvMat* _subsample_idx ); + // + // virtual void write_params( CvFileStorage* fs ) const; + // virtual void read_params( CvFileStorage* fs, CvFileNode* node ); + // + // // release all the data + // virtual void clear(); + // + // int get_num_classes() const; + // int get_var_type(int vi) const; + // int get_work_var_count() const {return work_var_count;} + // + // virtual const float* get_ord_responses( CvDTreeNode* n, float* values_buf, int* sample_indices_buf ); + // virtual const int* get_class_labels( CvDTreeNode* n, int* labels_buf ); + // virtual const int* get_cv_labels( CvDTreeNode* n, int* labels_buf ); + // virtual const int* get_sample_indices( CvDTreeNode* n, int* indices_buf ); + // virtual const int* get_cat_var_data( CvDTreeNode* n, int vi, int* cat_values_buf ); + // virtual void get_ord_var_data( CvDTreeNode* n, int vi, float* ord_values_buf, int* sorted_indices_buf, + // const float** ord_values, const int** sorted_indices, int* sample_indices_buf ); + // virtual int get_child_buf_idx( CvDTreeNode* n ); + // + // //////////////////////////////////// + // + // virtual bool set_params( const CvDTreeParams& params ); + // virtual CvDTreeNode* new_node( CvDTreeNode* parent, int count, + // int storage_idx, int offset ); + // + // virtual CvDTreeSplit* new_split_ord( int vi, float cmp_val, + // int split_point, int inversed, float quality ); + // virtual CvDTreeSplit* new_split_cat( int vi, float quality ); + // virtual void free_node_data( CvDTreeNode* node ); + // virtual void free_train_data(); + // virtual void free_node( CvDTreeNode* node ); + // + // int sample_count, var_all, var_count, max_c_count; + // int ord_var_count, cat_var_count, work_var_count; + // bool have_labels, have_priors; + // bool is_classifier; + // int tflag; + // + // const CvMat* train_data; + // const CvMat* responses; + // CvMat* responses_copy; // used in Boosting + // + // int buf_count, buf_size; // buf_size is obsolete, please do not use it, use expression ((int64)buf->rows * (int64)buf->cols / buf_count) instead + // bool shared; + // int is_buf_16u; + // + // CvMat* cat_count; + // CvMat* cat_ofs; + // CvMat* cat_map; + // + // CvMat* counts; + // CvMat* buf; + // inline size_t get_length_subbuf() const + // { + // size_t res = (size_t)(work_var_count + 1) * (size_t)sample_count; + // return res; + // } + // + // CvMat* direction; + // CvMat* split_buf; + // + // CvMat* var_idx; + // CvMat* var_type; // i-th element = + // // k<0 - ordered + // // k>=0 - categorical, see k-th element of cat_* arrays + // CvMat* priors; + // CvMat* priors_mult; + // + // CvDTreeParams params; + // + // CvMemStorage* tree_storage; + // CvMemStorage* temp_storage; + // + // CvDTreeNode* data_root; + // + // CvSet* node_heap; + // CvSet* split_heap; + // CvSet* cv_heap; + // CvSet* nv_heap; + // + // cv::RNG* rng; + // }; + // + // class CvDTree; + // class CvForestTree; + // + // namespace cv + // { + // struct DTreeBestSplitFinder; + // struct ForestTreeBestSplitFinder; + // } + // + // class CV_EXPORTS_W CvDTree : public CvStatModel + // { + // public: + // CV_WRAP CvDTree(); + // virtual ~CvDTree(); + // + // virtual bool train( const CvMat* trainData, int tflag, + // const CvMat* responses, const CvMat* varIdx=0, + // const CvMat* sampleIdx=0, const CvMat* varType=0, + // const CvMat* missingDataMask=0, + // CvDTreeParams params=CvDTreeParams() ); + // + // virtual bool train( CvMLData* trainData, CvDTreeParams params=CvDTreeParams() ); + // + // // type in {CV_TRAIN_ERROR, CV_TEST_ERROR} + // virtual float calc_error( CvMLData* trainData, int type, std::vector *resp = 0 ); + // + // virtual bool train( CvDTreeTrainData* trainData, const CvMat* subsampleIdx ); + // + // virtual CvDTreeNode* predict( const CvMat* sample, const CvMat* missingDataMask=0, + // bool preprocessedInput=false ) const; + // + // CV_WRAP virtual bool train( const cv::Mat& trainData, int tflag, + // const cv::Mat& responses, const cv::Mat& varIdx=cv::Mat(), + // const cv::Mat& sampleIdx=cv::Mat(), const cv::Mat& varType=cv::Mat(), + // const cv::Mat& missingDataMask=cv::Mat(), + // CvDTreeParams params=CvDTreeParams() ); + // + // CV_WRAP virtual CvDTreeNode* predict( const cv::Mat& sample, const cv::Mat& missingDataMask=cv::Mat(), + // bool preprocessedInput=false ) const; + // CV_WRAP virtual cv::Mat getVarImportance(); + // + // virtual const CvMat* get_var_importance(); + // CV_WRAP virtual void clear(); + // + // virtual void read( CvFileStorage* fs, CvFileNode* node ); + // virtual void write( CvFileStorage* fs, const char* name ) const; + // + // // special read & write methods for trees in the tree ensembles + // virtual void read( CvFileStorage* fs, CvFileNode* node, + // CvDTreeTrainData* data ); + // virtual void write( CvFileStorage* fs ) const; + // + // const CvDTreeNode* get_root() const; + // int get_pruned_tree_idx() const; + // CvDTreeTrainData* get_data(); + // + // protected: + // friend struct cv::DTreeBestSplitFinder; + // + // virtual bool do_train( const CvMat* _subsample_idx ); + // + // virtual void try_split_node( CvDTreeNode* n ); + // virtual void split_node_data( CvDTreeNode* n ); + // virtual CvDTreeSplit* find_best_split( CvDTreeNode* n ); + // virtual CvDTreeSplit* find_split_ord_class( CvDTreeNode* n, int vi, + // float init_quality = 0, CvDTreeSplit* _split = 0, uchar* ext_buf = 0 ); + // virtual CvDTreeSplit* find_split_cat_class( CvDTreeNode* n, int vi, + // float init_quality = 0, CvDTreeSplit* _split = 0, uchar* ext_buf = 0 ); + // virtual CvDTreeSplit* find_split_ord_reg( CvDTreeNode* n, int vi, + // float init_quality = 0, CvDTreeSplit* _split = 0, uchar* ext_buf = 0 ); + // virtual CvDTreeSplit* find_split_cat_reg( CvDTreeNode* n, int vi, + // float init_quality = 0, CvDTreeSplit* _split = 0, uchar* ext_buf = 0 ); + // virtual CvDTreeSplit* find_surrogate_split_ord( CvDTreeNode* n, int vi, uchar* ext_buf = 0 ); + // virtual CvDTreeSplit* find_surrogate_split_cat( CvDTreeNode* n, int vi, uchar* ext_buf = 0 ); + // virtual double calc_node_dir( CvDTreeNode* node ); + // virtual void complete_node_dir( CvDTreeNode* node ); + // virtual void cluster_categories( const int* vectors, int vector_count, + // int var_count, int* sums, int k, int* cluster_labels ); + // + // virtual void calc_node_value( CvDTreeNode* node ); + // + // virtual void prune_cv(); + // virtual double update_tree_rnc( int T, int fold ); + // virtual int cut_tree( int T, int fold, double min_alpha ); + // virtual void free_prune_data(bool cut_tree); + // virtual void free_tree(); + // + // virtual void write_node( CvFileStorage* fs, CvDTreeNode* node ) const; + // virtual void write_split( CvFileStorage* fs, CvDTreeSplit* split ) const; + // virtual CvDTreeNode* read_node( CvFileStorage* fs, CvFileNode* node, CvDTreeNode* parent ); + // virtual CvDTreeSplit* read_split( CvFileStorage* fs, CvFileNode* node ); + // virtual void write_tree_nodes( CvFileStorage* fs ) const; + // virtual void read_tree_nodes( CvFileStorage* fs, CvFileNode* node ); + // + // CvDTreeNode* root; + // CvMat* var_importance; + // CvDTreeTrainData* data; + // + // public: + // int pruned_tree_idx; + // }; + // + // + /// ****************************************************************************************\ + // * Random Trees Classifier * + // \****************************************************************************************/ + // + // class CvRTrees; + // + // class CV_EXPORTS CvForestTree: public CvDTree + // { + // public: + // CvForestTree(); + // virtual ~CvForestTree(); + // + // virtual bool train( CvDTreeTrainData* trainData, const CvMat* _subsample_idx, CvRTrees* forest ); + // + // virtual int get_var_count() const {return data ? data->var_count : 0;} + // virtual void read( CvFileStorage* fs, CvFileNode* node, CvRTrees* forest, CvDTreeTrainData* _data ); + // + // /* dummy methods to avoid warnings: BEGIN */ + // virtual bool train( const CvMat* trainData, int tflag, + // const CvMat* responses, const CvMat* varIdx=0, + // const CvMat* sampleIdx=0, const CvMat* varType=0, + // const CvMat* missingDataMask=0, + // CvDTreeParams params=CvDTreeParams() ); + // + // virtual bool train( CvDTreeTrainData* trainData, const CvMat* _subsample_idx ); + // virtual void read( CvFileStorage* fs, CvFileNode* node ); + // virtual void read( CvFileStorage* fs, CvFileNode* node, + // CvDTreeTrainData* data ); + // /* dummy methods to avoid warnings: END */ + // + // protected: + // friend struct cv::ForestTreeBestSplitFinder; + // + // virtual CvDTreeSplit* find_best_split( CvDTreeNode* n ); + // CvRTrees* forest; + // }; + // + // + // struct CV_EXPORTS_W_MAP CvRTParams : public CvDTreeParams + // { + // //Parameters for the forest + // CV_PROP_RW bool calc_var_importance; // true <=> RF processes variable importance + // CV_PROP_RW int nactive_vars; + // CV_PROP_RW CvTermCriteria term_crit; + // + // CvRTParams(); + // CvRTParams( int max_depth, int min_sample_count, + // float regression_accuracy, bool use_surrogates, + // int max_categories, const float* priors, bool calc_var_importance, + // int nactive_vars, int max_num_of_trees_in_the_forest, + // float forest_accuracy, int termcrit_type ); + // }; + // + // + // class CV_EXPORTS_W CvRTrees : public CvStatModel + // { + // public: + // CV_WRAP CvRTrees(); + // virtual ~CvRTrees(); + // virtual bool train( const CvMat* trainData, int tflag, + // const CvMat* responses, const CvMat* varIdx=0, + // const CvMat* sampleIdx=0, const CvMat* varType=0, + // const CvMat* missingDataMask=0, + // CvRTParams params=CvRTParams() ); + // + // virtual bool train( CvMLData* data, CvRTParams params=CvRTParams() ); + // virtual float predict( const CvMat* sample, const CvMat* missing = 0 ) const; + // virtual float predict_prob( const CvMat* sample, const CvMat* missing = 0 ) const; + // + // CV_WRAP virtual bool train( const cv::Mat& trainData, int tflag, + // const cv::Mat& responses, const cv::Mat& varIdx=cv::Mat(), + // const cv::Mat& sampleIdx=cv::Mat(), const cv::Mat& varType=cv::Mat(), + // const cv::Mat& missingDataMask=cv::Mat(), + // CvRTParams params=CvRTParams() ); + // CV_WRAP virtual float predict( const cv::Mat& sample, const cv::Mat& missing = cv::Mat() ) const; + // CV_WRAP virtual float predict_prob( const cv::Mat& sample, const cv::Mat& missing = cv::Mat() ) const; + // CV_WRAP virtual cv::Mat getVarImportance(); + // + // CV_WRAP virtual void clear(); + // + // virtual const CvMat* get_var_importance(); + // virtual float get_proximity( const CvMat* sample1, const CvMat* sample2, + // const CvMat* missing1 = 0, const CvMat* missing2 = 0 ) const; + // + // virtual float calc_error( CvMLData* data, int type , std::vector* resp = 0 ); // type in {CV_TRAIN_ERROR, CV_TEST_ERROR} + // + // virtual float get_train_error(); + // + // virtual void read( CvFileStorage* fs, CvFileNode* node ); + // virtual void write( CvFileStorage* fs, const char* name ) const; + // + // CvMat* get_active_var_mask(); + // CvRNG* get_rng(); + // + // int get_tree_count() const; + // CvForestTree* get_tree(int i) const; + // + // protected: + // virtual cv::String getName() const; + // + // virtual bool grow_forest( const CvTermCriteria term_crit ); + // + // // array of the trees of the forest + // CvForestTree** trees; + // CvDTreeTrainData* data; + // int ntrees; + // int nclasses; + // double oob_error; + // CvMat* var_importance; + // int nsamples; + // + // cv::RNG* rng; + // CvMat* active_var_mask; + // }; + // + /// ****************************************************************************************\ + // * Extremely randomized trees Classifier * + // \****************************************************************************************/ + // struct CV_EXPORTS CvERTreeTrainData : public CvDTreeTrainData + // { + // virtual void set_data( const CvMat* trainData, int tflag, + // const CvMat* responses, const CvMat* varIdx=0, + // const CvMat* sampleIdx=0, const CvMat* varType=0, + // const CvMat* missingDataMask=0, + // const CvDTreeParams& params=CvDTreeParams(), + // bool _shared=false, bool _add_labels=false, + // bool _update_data=false ); + // virtual void get_ord_var_data( CvDTreeNode* n, int vi, float* ord_values_buf, int* missing_buf, + // const float** ord_values, const int** missing, int* sample_buf = 0 ); + // virtual const int* get_sample_indices( CvDTreeNode* n, int* indices_buf ); + // virtual const int* get_cv_labels( CvDTreeNode* n, int* labels_buf ); + // virtual const int* get_cat_var_data( CvDTreeNode* n, int vi, int* cat_values_buf ); + // virtual void get_vectors( const CvMat* _subsample_idx, float* values, uchar* missing, + // float* responses, bool get_class_idx=false ); + // virtual CvDTreeNode* subsample_data( const CvMat* _subsample_idx ); + // const CvMat* missing_mask; + // }; + // + // class CV_EXPORTS CvForestERTree : public CvForestTree + // { + // protected: + // virtual double calc_node_dir( CvDTreeNode* node ); + // virtual CvDTreeSplit* find_split_ord_class( CvDTreeNode* n, int vi, + // float init_quality = 0, CvDTreeSplit* _split = 0, uchar* ext_buf = 0 ); + // virtual CvDTreeSplit* find_split_cat_class( CvDTreeNode* n, int vi, + // float init_quality = 0, CvDTreeSplit* _split = 0, uchar* ext_buf = 0 ); + // virtual CvDTreeSplit* find_split_ord_reg( CvDTreeNode* n, int vi, + // float init_quality = 0, CvDTreeSplit* _split = 0, uchar* ext_buf = 0 ); + // virtual CvDTreeSplit* find_split_cat_reg( CvDTreeNode* n, int vi, + // float init_quality = 0, CvDTreeSplit* _split = 0, uchar* ext_buf = 0 ); + // virtual void split_node_data( CvDTreeNode* n ); + // }; + // + // class CV_EXPORTS_W CvERTrees : public CvRTrees + // { + // public: + // CV_WRAP CvERTrees(); + // virtual ~CvERTrees(); + // virtual bool train( const CvMat* trainData, int tflag, + // const CvMat* responses, const CvMat* varIdx=0, + // const CvMat* sampleIdx=0, const CvMat* varType=0, + // const CvMat* missingDataMask=0, + // CvRTParams params=CvRTParams()); + // CV_WRAP virtual bool train( const cv::Mat& trainData, int tflag, + // const cv::Mat& responses, const cv::Mat& varIdx=cv::Mat(), + // const cv::Mat& sampleIdx=cv::Mat(), const cv::Mat& varType=cv::Mat(), + // const cv::Mat& missingDataMask=cv::Mat(), + // CvRTParams params=CvRTParams()); + // virtual bool train( CvMLData* data, CvRTParams params=CvRTParams() ); + // protected: + // virtual cv::String getName() const; + // virtual bool grow_forest( const CvTermCriteria term_crit ); + // }; + // + // + /// ****************************************************************************************\ + // * Boosted tree classifier * + // \****************************************************************************************/ + // + // struct CV_EXPORTS_W_MAP CvBoostParams : public CvDTreeParams + // { + // CV_PROP_RW int boost_type; + // CV_PROP_RW int weak_count; + // CV_PROP_RW int split_criteria; + // CV_PROP_RW double weight_trim_rate; + // + // CvBoostParams(); + // CvBoostParams( int boost_type, int weak_count, double weight_trim_rate, + // int max_depth, bool use_surrogates, const float* priors ); + // }; + // + // + // class CvBoost; + // + // class CV_EXPORTS CvBoostTree: public CvDTree + // { + // public: + // CvBoostTree(); + // virtual ~CvBoostTree(); + // + // virtual bool train( CvDTreeTrainData* trainData, + // const CvMat* subsample_idx, CvBoost* ensemble ); + // + // virtual void scale( double s ); + // virtual void read( CvFileStorage* fs, CvFileNode* node, + // CvBoost* ensemble, CvDTreeTrainData* _data ); + // virtual void clear(); + // + // /* dummy methods to avoid warnings: BEGIN */ + // virtual bool train( const CvMat* trainData, int tflag, + // const CvMat* responses, const CvMat* varIdx=0, + // const CvMat* sampleIdx=0, const CvMat* varType=0, + // const CvMat* missingDataMask=0, + // CvDTreeParams params=CvDTreeParams() ); + // virtual bool train( CvDTreeTrainData* trainData, const CvMat* _subsample_idx ); + // + // virtual void read( CvFileStorage* fs, CvFileNode* node ); + // virtual void read( CvFileStorage* fs, CvFileNode* node, + // CvDTreeTrainData* data ); + // /* dummy methods to avoid warnings: END */ + // + // protected: + // + // virtual void try_split_node( CvDTreeNode* n ); + // virtual CvDTreeSplit* find_surrogate_split_ord( CvDTreeNode* n, int vi, uchar* ext_buf = 0 ); + // virtual CvDTreeSplit* find_surrogate_split_cat( CvDTreeNode* n, int vi, uchar* ext_buf = 0 ); + // virtual CvDTreeSplit* find_split_ord_class( CvDTreeNode* n, int vi, + // float init_quality = 0, CvDTreeSplit* _split = 0, uchar* ext_buf = 0 ); + // virtual CvDTreeSplit* find_split_cat_class( CvDTreeNode* n, int vi, + // float init_quality = 0, CvDTreeSplit* _split = 0, uchar* ext_buf = 0 ); + // virtual CvDTreeSplit* find_split_ord_reg( CvDTreeNode* n, int vi, + // float init_quality = 0, CvDTreeSplit* _split = 0, uchar* ext_buf = 0 ); + // virtual CvDTreeSplit* find_split_cat_reg( CvDTreeNode* n, int vi, + // float init_quality = 0, CvDTreeSplit* _split = 0, uchar* ext_buf = 0 ); + // virtual void calc_node_value( CvDTreeNode* n ); + // virtual double calc_node_dir( CvDTreeNode* n ); + // + // CvBoost* ensemble; + // }; + // + // + // class CV_EXPORTS_W CvBoost : public CvStatModel + // { + // public: + // // Boosting type + // enum { DISCRETE=0, REAL=1, LOGIT=2, GENTLE=3 }; + // + // // Splitting criteria + // enum { DEFAULT=0, GINI=1, MISCLASS=3, SQERR=4 }; + // + // CV_WRAP CvBoost(); + // virtual ~CvBoost(); + // + // CvBoost( const CvMat* trainData, int tflag, + // const CvMat* responses, const CvMat* varIdx=0, + // const CvMat* sampleIdx=0, const CvMat* varType=0, + // const CvMat* missingDataMask=0, + // CvBoostParams params=CvBoostParams() ); + // + // virtual bool train( const CvMat* trainData, int tflag, + // const CvMat* responses, const CvMat* varIdx=0, + // const CvMat* sampleIdx=0, const CvMat* varType=0, + // const CvMat* missingDataMask=0, + // CvBoostParams params=CvBoostParams(), + // bool update=false ); + // + // virtual bool train( CvMLData* data, + // CvBoostParams params=CvBoostParams(), + // bool update=false ); + // + // virtual float predict( const CvMat* sample, const CvMat* missing=0, + // CvMat* weak_responses=0, CvSlice slice=CV_WHOLE_SEQ, + // bool raw_mode=false, bool return_sum=false ) const; + // + // CV_WRAP CvBoost( const cv::Mat& trainData, int tflag, + // const cv::Mat& responses, const cv::Mat& varIdx=cv::Mat(), + // const cv::Mat& sampleIdx=cv::Mat(), const cv::Mat& varType=cv::Mat(), + // const cv::Mat& missingDataMask=cv::Mat(), + // CvBoostParams params=CvBoostParams() ); + // + // CV_WRAP virtual bool train( const cv::Mat& trainData, int tflag, + // const cv::Mat& responses, const cv::Mat& varIdx=cv::Mat(), + // const cv::Mat& sampleIdx=cv::Mat(), const cv::Mat& varType=cv::Mat(), + // const cv::Mat& missingDataMask=cv::Mat(), + // CvBoostParams params=CvBoostParams(), + // bool update=false ); + // + // CV_WRAP virtual float predict( const cv::Mat& sample, const cv::Mat& missing=cv::Mat(), + // const cv::Range& slice=cv::Range::all(), bool rawMode=false, + // bool returnSum=false ) const; + // + // virtual float calc_error( CvMLData* _data, int type , std::vector *resp = 0 ); // type in {CV_TRAIN_ERROR, CV_TEST_ERROR} + // + // CV_WRAP virtual void prune( CvSlice slice ); + // + // CV_WRAP virtual void clear(); + // + // virtual void write( CvFileStorage* storage, const char* name ) const; + // virtual void read( CvFileStorage* storage, CvFileNode* node ); + // virtual const CvMat* get_active_vars(bool absolute_idx=true); + // + // CvSeq* get_weak_predictors(); + // + // CvMat* get_weights(); + // CvMat* get_subtree_weights(); + // CvMat* get_weak_response(); + // const CvBoostParams& get_params() const; + // const CvDTreeTrainData* get_data() const; + // + // protected: + // + // virtual bool set_params( const CvBoostParams& params ); + // virtual void update_weights( CvBoostTree* tree ); + // virtual void trim_weights(); + // virtual void write_params( CvFileStorage* fs ) const; + // virtual void read_params( CvFileStorage* fs, CvFileNode* node ); + // + // virtual void initialize_weights(double (&p)[2]); + // + // CvDTreeTrainData* data; + // CvBoostParams params; + // CvSeq* weak; + // + // CvMat* active_vars; + // CvMat* active_vars_abs; + // bool have_active_cat_vars; + // + // CvMat* orig_response; + // CvMat* sum_response; + // CvMat* weak_eval; + // CvMat* subsample_mask; + // CvMat* weights; + // CvMat* subtree_weights; + // bool have_subsample; + // }; + // + // + /// ****************************************************************************************\ + // * Gradient Boosted Trees * + // \****************************************************************************************/ + // + /// / DataType: STRUCT CvGBTreesParams + /// / Parameters of GBT (Gradient Boosted trees model), including single + /// / tree settings and ensemble parameters. + /// / + /// / weak_count - count of trees in the ensemble + /// / loss_function_type - loss function used for ensemble training + /// / subsample_portion - portion of whole training set used for + /// / every single tree training. + /// / subsample_portion value is in (0.0, 1.0]. + /// / subsample_portion == 1.0 when whole dataset is + /// / used on each step. Count of sample used on each + /// / step is computed as + /// / int(total_samples_count * subsample_portion). + /// / shrinkage - regularization parameter. + /// / Each tree prediction is multiplied on shrinkage value. + // + // + // struct CV_EXPORTS_W_MAP CvGBTreesParams : public CvDTreeParams + // { + // CV_PROP_RW int weak_count; + // CV_PROP_RW int loss_function_type; + // CV_PROP_RW float subsample_portion; + // CV_PROP_RW float shrinkage; + // + // CvGBTreesParams(); + // CvGBTreesParams( int loss_function_type, int weak_count, float shrinkage, + // float subsample_portion, int max_depth, bool use_surrogates ); + // }; + // + /// / DataType: CLASS CvGBTrees + /// / Gradient Boosting Trees (GBT) algorithm implementation. + /// / + /// / data - training dataset + /// / params - parameters of the CvGBTrees + /// / weak - array[0..(class_count-1)] of CvSeq + /// / for storing tree ensembles + /// / orig_response - original responses of the training set samples + /// / sum_response - predicitons of the current model on the training dataset. + /// / this matrix is updated on every iteration. + /// / sum_response_tmp - predicitons of the model on the training set on the next + /// / step. On every iteration values of sum_responses_tmp are + /// / computed via sum_responses values. When the current + /// / step is complete sum_response values become equal to + /// / sum_responses_tmp. + /// / sampleIdx - indices of samples used for training the ensemble. + /// / CvGBTrees training procedure takes a set of samples + /// / (train_data) and a set of responses (responses). + /// / Only pairs (train_data[i], responses[i]), where i is + /// / in sample_idx are used for training the ensemble. + /// / subsample_train - indices of samples used for training a single decision + /// / tree on the current step. This indices are countered + /// / relatively to the sample_idx, so that pairs + /// / (train_data[sample_idx[i]], responses[sample_idx[i]]) + /// / are used for training a decision tree. + /// / Training set is randomly splited + /// / in two parts (subsample_train and subsample_test) + /// / on every iteration accordingly to the portion parameter. + /// / subsample_test - relative indices of samples from the training set, + /// / which are not used for training a tree on the current + /// / step. + /// / missing - mask of the missing values in the training set. This + /// / matrix has the same size as train_data. 1 - missing + /// / value, 0 - not a missing value. + /// / class_labels - output class labels map. + /// / rng - random number generator. Used for spliting the + /// / training set. + /// / class_count - count of output classes. + /// / class_count == 1 in the case of regression, + /// / and > 1 in the case of classification. + /// / delta - Huber loss function parameter. + /// / base_value - start point of the gradient descent procedure. + /// / model prediction is + /// / f(x) = f_0 + sum_{i=1..weak_count-1}(f_i(x)), where + /// / f_0 is the base value. + // + // + // + // class CV_EXPORTS_W CvGBTrees : public CvStatModel + // { + // public: + // + // /* + // // DataType: ENUM + // // Loss functions implemented in CvGBTrees. + // // + // // SQUARED_LOSS + // // problem: regression + // // loss = (x - x')^2 + // // + // // ABSOLUTE_LOSS + // // problem: regression + // // loss = abs(x - x') + // // + // // HUBER_LOSS + // // problem: regression + // // loss = delta*( abs(x - x') - delta/2), if abs(x - x') > delta + // // 1/2*(x - x')^2, if abs(x - x') <= delta, + // // where delta is the alpha-quantile of pseudo responses from + // // the training set. + // // + // // DEVIANCE_LOSS + // // problem: classification + // // + // */ + // enum {SQUARED_LOSS=0, ABSOLUTE_LOSS, HUBER_LOSS=3, DEVIANCE_LOSS}; + // + // + // /* + // // Default constructor. Creates a model only (without training). + // // Should be followed by one form of the train(...) function. + // // + // // API + // // CvGBTrees(); + // + // // INPUT + // // OUTPUT + // // RESULT + // */ + // CV_WRAP CvGBTrees(); + // + // + // /* + // // Full form constructor. Creates a gradient boosting model and does the + // // train. + // // + // // API + // // CvGBTrees( const CvMat* trainData, int tflag, + // const CvMat* responses, const CvMat* varIdx=0, + // const CvMat* sampleIdx=0, const CvMat* varType=0, + // const CvMat* missingDataMask=0, + // CvGBTreesParams params=CvGBTreesParams() ); + // + // // INPUT + // // trainData - a set of input feature vectors. + // // size of matrix is + // // x + // // or x + // // depending on the tflag parameter. + // // matrix values are float. + // // tflag - a flag showing how do samples stored in the + // // trainData matrix row by row (tflag=CV_ROW_SAMPLE) + // // or column by column (tflag=CV_COL_SAMPLE). + // // responses - a vector of responses corresponding to the samples + // // in trainData. + // // varIdx - indices of used variables. zero value means that all + // // variables are active. + // // sampleIdx - indices of used samples. zero value means that all + // // samples from trainData are in the training set. + // // varType - vector of length. gives every + // // variable type CV_VAR_CATEGORICAL or CV_VAR_ORDERED. + // // varType = 0 means all variables are numerical. + // // missingDataMask - a mask of misiing values in trainData. + // // missingDataMask = 0 means that there are no missing + // // values. + // // params - parameters of GTB algorithm. + // // OUTPUT + // // RESULT + // */ + // CvGBTrees( const CvMat* trainData, int tflag, + // const CvMat* responses, const CvMat* varIdx=0, + // const CvMat* sampleIdx=0, const CvMat* varType=0, + // const CvMat* missingDataMask=0, + // CvGBTreesParams params=CvGBTreesParams() ); + // + // + // /* + // // Destructor. + // */ + // virtual ~CvGBTrees(); + // + // + // /* + // // Gradient tree boosting model training + // // + // // API + // // virtual bool train( const CvMat* trainData, int tflag, + // const CvMat* responses, const CvMat* varIdx=0, + // const CvMat* sampleIdx=0, const CvMat* varType=0, + // const CvMat* missingDataMask=0, + // CvGBTreesParams params=CvGBTreesParams(), + // bool update=false ); + // + // // INPUT + // // trainData - a set of input feature vectors. + // // size of matrix is + // // x + // // or x + // // depending on the tflag parameter. + // // matrix values are float. + // // tflag - a flag showing how do samples stored in the + // // trainData matrix row by row (tflag=CV_ROW_SAMPLE) + // // or column by column (tflag=CV_COL_SAMPLE). + // // responses - a vector of responses corresponding to the samples + // // in trainData. + // // varIdx - indices of used variables. zero value means that all + // // variables are active. + // // sampleIdx - indices of used samples. zero value means that all + // // samples from trainData are in the training set. + // // varType - vector of length. gives every + // // variable type CV_VAR_CATEGORICAL or CV_VAR_ORDERED. + // // varType = 0 means all variables are numerical. + // // missingDataMask - a mask of misiing values in trainData. + // // missingDataMask = 0 means that there are no missing + // // values. + // // params - parameters of GTB algorithm. + // // update - is not supported now. (!) + // // OUTPUT + // // RESULT + // // Error state. + // */ + // virtual bool train( const CvMat* trainData, int tflag, + // const CvMat* responses, const CvMat* varIdx=0, + // const CvMat* sampleIdx=0, const CvMat* varType=0, + // const CvMat* missingDataMask=0, + // CvGBTreesParams params=CvGBTreesParams(), + // bool update=false ); + // + // + // /* + // // Gradient tree boosting model training + // // + // // API + // // virtual bool train( CvMLData* data, + // CvGBTreesParams params=CvGBTreesParams(), + // bool update=false ) {return false;}; + // + // // INPUT + // // data - training set. + // // params - parameters of GTB algorithm. + // // update - is not supported now. (!) + // // OUTPUT + // // RESULT + // // Error state. + // */ + // virtual bool train( CvMLData* data, + // CvGBTreesParams params=CvGBTreesParams(), + // bool update=false ); + // + // + // /* + // // Response value prediction + // // + // // API + // // virtual float predict_serial( const CvMat* sample, const CvMat* missing=0, + // CvMat* weak_responses=0, CvSlice slice = CV_WHOLE_SEQ, + // int k=-1 ) const; + // + // // INPUT + // // sample - input sample of the same type as in the training set. + // // missing - missing values mask. missing=0 if there are no + // // missing values in sample vector. + // // weak_responses - predictions of all of the trees. + // // not implemented (!) + // // slice - part of the ensemble used for prediction. + // // slice = CV_WHOLE_SEQ when all trees are used. + // // k - number of ensemble used. + // // k is in {-1,0,1,..,}. + // // in the case of classification problem + // // ensembles are built. + // // If k = -1 ordinary prediction is the result, + // // otherwise function gives the prediction of the + // // k-th ensemble only. + // // OUTPUT + // // RESULT + // // Predicted value. + // */ + // virtual float predict_serial( const CvMat* sample, const CvMat* missing=0, + // CvMat* weakResponses=0, CvSlice slice = CV_WHOLE_SEQ, + // int k=-1 ) const; + // + // /* + // // Response value prediction. + // // Parallel version (in the case of TBB existence) + // // + // // API + // // virtual float predict( const CvMat* sample, const CvMat* missing=0, + // CvMat* weak_responses=0, CvSlice slice = CV_WHOLE_SEQ, + // int k=-1 ) const; + // + // // INPUT + // // sample - input sample of the same type as in the training set. + // // missing - missing values mask. missing=0 if there are no + // // missing values in sample vector. + // // weak_responses - predictions of all of the trees. + // // not implemented (!) + // // slice - part of the ensemble used for prediction. + // // slice = CV_WHOLE_SEQ when all trees are used. + // // k - number of ensemble used. + // // k is in {-1,0,1,..,}. + // // in the case of classification problem + // // ensembles are built. + // // If k = -1 ordinary prediction is the result, + // // otherwise function gives the prediction of the + // // k-th ensemble only. + // // OUTPUT + // // RESULT + // // Predicted value. + // */ + // virtual float predict( const CvMat* sample, const CvMat* missing=0, + // CvMat* weakResponses=0, CvSlice slice = CV_WHOLE_SEQ, + // int k=-1 ) const; + // + // /* + // // Deletes all the data. + // // + // // API + // // virtual void clear(); + // + // // INPUT + // // OUTPUT + // // delete data, weak, orig_response, sum_response, + // // weak_eval, subsample_train, subsample_test, + // // sample_idx, missing, lass_labels + // // delta = 0.0 + // // RESULT + // */ + // CV_WRAP virtual void clear(); + // + // /* + // // Compute error on the train/test set. + // // + // // API + // // virtual float calc_error( CvMLData* _data, int type, + // // std::vector *resp = 0 ); + // // + // // INPUT + // // data - dataset + // // type - defines which error is to compute: train (CV_TRAIN_ERROR) or + // // test (CV_TEST_ERROR). + // // OUTPUT + // // resp - vector of predicitons + // // RESULT + // // Error value. + // */ + // virtual float calc_error( CvMLData* _data, int type, + // std::vector *resp = 0 ); + // + // /* + // // + // // Write parameters of the gtb model and data. Write learned model. + // // + // // API + // // virtual void write( CvFileStorage* fs, const char* name ) const; + // // + // // INPUT + // // fs - file storage to read parameters from. + // // name - model name. + // // OUTPUT + // // RESULT + // */ + // virtual void write( CvFileStorage* fs, const char* name ) const; + // + // + // /* + // // + // // Read parameters of the gtb model and data. Read learned model. + // // + // // API + // // virtual void read( CvFileStorage* fs, CvFileNode* node ); + // // + // // INPUT + // // fs - file storage to read parameters from. + // // node - file node. + // // OUTPUT + // // RESULT + // */ + // virtual void read( CvFileStorage* fs, CvFileNode* node ); + // + // + // // new-style C++ interface + // CV_WRAP CvGBTrees( const cv::Mat& trainData, int tflag, + // const cv::Mat& responses, const cv::Mat& varIdx=cv::Mat(), + // const cv::Mat& sampleIdx=cv::Mat(), const cv::Mat& varType=cv::Mat(), + // const cv::Mat& missingDataMask=cv::Mat(), + // CvGBTreesParams params=CvGBTreesParams() ); + // + // CV_WRAP virtual bool train( const cv::Mat& trainData, int tflag, + // const cv::Mat& responses, const cv::Mat& varIdx=cv::Mat(), + // const cv::Mat& sampleIdx=cv::Mat(), const cv::Mat& varType=cv::Mat(), + // const cv::Mat& missingDataMask=cv::Mat(), + // CvGBTreesParams params=CvGBTreesParams(), + // bool update=false ); + // + // CV_WRAP virtual float predict( const cv::Mat& sample, const cv::Mat& missing=cv::Mat(), + // const cv::Range& slice = cv::Range::all(), + // int k=-1 ) const; + // + // protected: + // + // /* + // // Compute the gradient vector components. + // // + // // API + // // virtual void find_gradient( const int k = 0); + // + // // INPUT + // // k - used for classification problem, determining current + // // tree ensemble. + // // OUTPUT + // // changes components of data->responses + // // which correspond to samples used for training + // // on the current step. + // // RESULT + // */ + // virtual void find_gradient( const int k = 0); + // + // + // /* + // // + // // Change values in tree leaves according to the used loss function. + // // + // // API + // // virtual void change_values(CvDTree* tree, const int k = 0); + // // + // // INPUT + // // tree - decision tree to change. + // // k - used for classification problem, determining current + // // tree ensemble. + // // OUTPUT + // // changes 'value' fields of the trees' leaves. + // // changes sum_response_tmp. + // // RESULT + // */ + // virtual void change_values(CvDTree* tree, const int k = 0); + // + // + // /* + // // + // // Find optimal constant prediction value according to the used loss + // // function. + // // The goal is to find a constant which gives the minimal summary loss + // // on the _Idx samples. + // // + // // API + // // virtual float find_optimal_value( const CvMat* _Idx ); + // // + // // INPUT + // // _Idx - indices of the samples from the training set. + // // OUTPUT + // // RESULT + // // optimal constant value. + // */ + // virtual float find_optimal_value( const CvMat* _Idx ); + // + // + // /* + // // + // // Randomly split the whole training set in two parts according + // // to params.portion. + // // + // // API + // // virtual void do_subsample(); + // // + // // INPUT + // // OUTPUT + // // subsample_train - indices of samples used for training + // // subsample_test - indices of samples used for test + // // RESULT + // */ + // virtual void do_subsample(); + // + // + // /* + // // + // // Internal recursive function giving an array of subtree tree leaves. + // // + // // API + // // void leaves_get( CvDTreeNode** leaves, int& count, CvDTreeNode* node ); + // // + // // INPUT + // // node - current leaf. + // // OUTPUT + // // count - count of leaves in the subtree. + // // leaves - array of pointers to leaves. + // // RESULT + // */ + // void leaves_get( CvDTreeNode** leaves, int& count, CvDTreeNode* node ); + // + // + // /* + // // + // // Get leaves of the tree. + // // + // // API + // // CvDTreeNode** GetLeaves( const CvDTree* dtree, int& len ); + // // + // // INPUT + // // dtree - decision tree. + // // OUTPUT + // // len - count of the leaves. + // // RESULT + // // CvDTreeNode** - array of pointers to leaves. + // */ + // CvDTreeNode** GetLeaves( const CvDTree* dtree, int& len ); + // + // + // /* + // // + // // Is it a regression or a classification. + // // + // // API + // // bool problem_type(); + // // + // // INPUT + // // OUTPUT + // // RESULT + // // false if it is a classification problem, + // // true - if regression. + // */ + // virtual bool problem_type() const; + // + // + // /* + // // + // // Write parameters of the gtb model. + // // + // // API + // // virtual void write_params( CvFileStorage* fs ) const; + // // + // // INPUT + // // fs - file storage to write parameters to. + // // OUTPUT + // // RESULT + // */ + // virtual void write_params( CvFileStorage* fs ) const; + // + // + // /* + // // + // // Read parameters of the gtb model and data. + // // + // // API + // // virtual void read_params( CvFileStorage* fs ); + // // + // // INPUT + // // fs - file storage to read parameters from. + // // OUTPUT + // // params - parameters of the gtb model. + // // data - contains information about the structure + // // of the data set (count of variables, + // // their types, etc.). + // // class_labels - output class labels map. + // // RESULT + // */ + // virtual void read_params( CvFileStorage* fs, CvFileNode* fnode ); + // int get_len(const CvMat* mat) const; + // + // + // CvDTreeTrainData* data; + // CvGBTreesParams params; + // + // CvSeq** weak; + // CvMat* orig_response; + // CvMat* sum_response; + // CvMat* sum_response_tmp; + // CvMat* sample_idx; + // CvMat* subsample_train; + // CvMat* subsample_test; + // CvMat* missing; + // CvMat* class_labels; + // + // cv::RNG* rng; + // + // int class_count; + // float delta; + // float base_value; + // + // }; + // + // + // + /// ****************************************************************************************\ + // * Artificial Neural Networks (ANN) * + // \****************************************************************************************/ + // + /// ////////////////////////////////// Multi-Layer Perceptrons ////////////////////////////// + // + // struct CV_EXPORTS_W_MAP CvANN_MLP_TrainParams + // { + // CvANN_MLP_TrainParams(); + // CvANN_MLP_TrainParams( CvTermCriteria term_crit, int train_method, + // double param1, double param2=0 ); + // ~CvANN_MLP_TrainParams(); + // + // enum { BACKPROP=0, RPROP=1 }; + // + // CV_PROP_RW CvTermCriteria term_crit; + // CV_PROP_RW int train_method; + // + // // backpropagation parameters + // CV_PROP_RW double bp_dw_scale, bp_moment_scale; + // + // // rprop parameters + // CV_PROP_RW double rp_dw0, rp_dw_plus, rp_dw_minus, rp_dw_min, rp_dw_max; + // }; + // + // + // class CV_EXPORTS_W CvANN_MLP : public CvStatModel + // { + // public: + // CV_WRAP CvANN_MLP(); + // CvANN_MLP( const CvMat* layerSizes, + // int activateFunc=CvANN_MLP::SIGMOID_SYM, + // double fparam1=0, double fparam2=0 ); + // + // virtual ~CvANN_MLP(); + // + // virtual void create( const CvMat* layerSizes, + // int activateFunc=CvANN_MLP::SIGMOID_SYM, + // double fparam1=0, double fparam2=0 ); + // + // virtual int train( const CvMat* inputs, const CvMat* outputs, + // const CvMat* sampleWeights, const CvMat* sampleIdx=0, + // CvANN_MLP_TrainParams params = CvANN_MLP_TrainParams(), + // int flags=0 ); + // virtual float predict( const CvMat* inputs, CV_OUT CvMat* outputs ) const; + // + // CV_WRAP CvANN_MLP( const cv::Mat& layerSizes, + // int activateFunc=CvANN_MLP::SIGMOID_SYM, + // double fparam1=0, double fparam2=0 ); + // + // CV_WRAP virtual void create( const cv::Mat& layerSizes, + // int activateFunc=CvANN_MLP::SIGMOID_SYM, + // double fparam1=0, double fparam2=0 ); + // + // CV_WRAP virtual int train( const cv::Mat& inputs, const cv::Mat& outputs, + // const cv::Mat& sampleWeights, const cv::Mat& sampleIdx=cv::Mat(), + // CvANN_MLP_TrainParams params = CvANN_MLP_TrainParams(), + // int flags=0 ); + // + // CV_WRAP virtual float predict( const cv::Mat& inputs, CV_OUT cv::Mat& outputs ) const; + // + // CV_WRAP virtual void clear(); + // + // // possible activation functions + // enum { IDENTITY = 0, SIGMOID_SYM = 1, GAUSSIAN = 2 }; + // + // // available training flags + // enum { UPDATE_WEIGHTS = 1, NO_INPUT_SCALE = 2, NO_OUTPUT_SCALE = 4 }; + // + // virtual void read( CvFileStorage* fs, CvFileNode* node ); + // virtual void write( CvFileStorage* storage, const char* name ) const; + // + // int get_layer_count() { return layer_sizes ? layer_sizes->cols : 0; } + // const CvMat* get_layer_sizes() { return layer_sizes; } + // double* get_weights(int layer) + // { + // return layer_sizes && weights && + // (unsigned)layer <= (unsigned)layer_sizes->cols ? weights[layer] : 0; + // } + // + // virtual void calc_activ_func_deriv( CvMat* xf, CvMat* deriv, const double* bias ) const; + // + // protected: + // + // virtual bool prepare_to_train( const CvMat* _inputs, const CvMat* _outputs, + // const CvMat* _sample_weights, const CvMat* sampleIdx, + // CvVectors* _ivecs, CvVectors* _ovecs, double** _sw, int _flags ); + // + // // sequential random backpropagation + // virtual int train_backprop( CvVectors _ivecs, CvVectors _ovecs, const double* _sw ); + // + // // RPROP algorithm + // virtual int train_rprop( CvVectors _ivecs, CvVectors _ovecs, const double* _sw ); + // + // virtual void calc_activ_func( CvMat* xf, const double* bias ) const; + // virtual void set_activ_func( int _activ_func=SIGMOID_SYM, + // double _f_param1=0, double _f_param2=0 ); + // virtual void init_weights(); + // virtual void scale_input( const CvMat* _src, CvMat* _dst ) const; + // virtual void scale_output( const CvMat* _src, CvMat* _dst ) const; + // virtual void calc_input_scale( const CvVectors* vecs, int flags ); + // virtual void calc_output_scale( const CvVectors* vecs, int flags ); + // + // virtual void write_params( CvFileStorage* fs ) const; + // virtual void read_params( CvFileStorage* fs, CvFileNode* node ); + // + // CvMat* layer_sizes; + // CvMat* wbuf; + // CvMat* sample_weights; + // double** weights; + // double f_param1, f_param2; + // double min_val, max_val, min_val1, max_val1; + // int activ_func; + // int max_count, max_buf_sz; + // CvANN_MLP_TrainParams params; + // cv::RNG* rng; + // }; + // + /// ****************************************************************************************\ + // * Auxilary functions declarations * + // \****************************************************************************************/ + // + /// * Generates from multivariate normal distribution, where - is an + // average row vector, - symmetric covariation matrix */ + // CVAPI(void) cvRandMVNormal( CvMat* mean, CvMat* cov, CvMat* sample, + // CvRNG* rng CV_DEFAULT(0) ); + // + /// * Generates sample from gaussian mixture distribution */ + // CVAPI(void) cvRandGaussMixture( CvMat* means[], + // CvMat* covs[], + // float weights[], + // int clsnum, + // CvMat* sample, + // CvMat* sampClasses CV_DEFAULT(0) ); + // + // #define CV_TS_CONCENTRIC_SPHERES 0 + // + /// * creates test set */ + // CVAPI(void) cvCreateTestSet( int type, CvMat** samples, + // int num_samples, + // int num_features, + // CvMat** responses, + // int num_classes, ... ); + // + /// ****************************************************************************************\ + // * Data * + // \****************************************************************************************/ + // + // #define CV_COUNT 0 + // #define CV_PORTION 1 + // + // struct CV_EXPORTS CvTrainTestSplit + // { + // CvTrainTestSplit(); + // CvTrainTestSplit( int train_sample_count, bool mix = true); + // CvTrainTestSplit( float train_sample_portion, bool mix = true); + // + // union + // { + // int count; + // float portion; + // } train_sample_part; + // int train_sample_part_mode; + // + // bool mix; + // }; + // + // class CV_EXPORTS CvMLData + // { + // public: + // CvMLData(); + // virtual ~CvMLData(); + // + // // returns: + // // 0 - OK + // // -1 - file can not be opened or is not correct + // int read_csv( const char* filename ); + // + // const CvMat* get_values() const; + // const CvMat* get_responses(); + // const CvMat* get_missing() const; + // + // void set_header_lines_number( int n ); + // int get_header_lines_number() const; + // + // void set_response_idx( int idx ); // old response become predictors, new response_idx = idx + // // if idx < 0 there will be no response + // int get_response_idx() const; + // + // void set_train_test_split( const CvTrainTestSplit * spl ); + // const CvMat* get_train_sample_idx() const; + // const CvMat* get_test_sample_idx() const; + // void mix_train_and_test_idx(); + // + // const CvMat* get_var_idx(); + // void chahge_var_idx( int vi, bool state ); // misspelled (saved for back compitability), + // // use change_var_idx + // void change_var_idx( int vi, bool state ); // state == true to set vi-variable as predictor + // + // const CvMat* get_var_types(); + // int get_var_type( int var_idx ) const; + // // following 2 methods enable to change vars type + // // use these methods to assign CV_VAR_CATEGORICAL type for categorical variable + // // with numerical labels; in the other cases var types are correctly determined automatically + // void set_var_types( const char* str ); // str examples: + // // "ord[0-17],cat[18]", "ord[0,2,4,10-12], cat[1,3,5-9,13,14]", + // // "cat", "ord" (all vars are categorical/ordered) + // void change_var_type( int var_idx, int type); // type in { CV_VAR_ORDERED, CV_VAR_CATEGORICAL } + // + // void set_delimiter( char ch ); + // char get_delimiter() const; + // + // void set_miss_ch( char ch ); + // char get_miss_ch() const; + // + // const std::map& get_class_labels_map() const; + // + // protected: + // virtual void clear(); + // + // void str_to_flt_elem( const char* token, float& flt_elem, int& type); + // void free_train_test_idx(); + // + // char delimiter; + // char miss_ch; + // //char flt_separator; + // + // CvMat* values; + // CvMat* missing; + // CvMat* var_types; + // CvMat* var_idx_mask; + // + // CvMat* response_out; // header + // CvMat* var_idx_out; // mat + // CvMat* var_types_out; // mat + // + // int header_lines_number; + // + // int response_idx; + // + // int train_sample_count; + // bool mix; + // + // int total_class_count; + // std::map class_map; + // + // CvMat* train_sample_idx; + // CvMat* test_sample_idx; + // int* sample_idx; // data of train_sample_idx and test_sample_idx + // + // cv::RNG* rng; + // }; + // + // + // namespace cv + // { + // + // typedef CvStatModel StatModel; + // typedef CvParamGrid ParamGrid; + // typedef CvNormalBayesClassifier NormalBayesClassifier; + // typedef CvKNearest KNearest; + // typedef CvSVMParams SVMParams; + // typedef CvSVMKernel SVMKernel; + // typedef CvSVMSolver SVMSolver; + // typedef CvSVM SVM; + // typedef CvDTreeParams DTreeParams; + // typedef CvMLData TrainData; + // typedef CvDTree DecisionTree; + // typedef CvForestTree ForestTree; + // typedef CvRTParams RandomTreeParams; + // typedef CvRTrees RandomTrees; + // typedef CvERTreeTrainData ERTreeTRainData; + // typedef CvForestERTree ERTree; + // typedef CvERTrees ERTrees; + // typedef CvBoostParams BoostParams; + // typedef CvBoostTree BoostTree; + // typedef CvBoost Boost; + // typedef CvANN_MLP_TrainParams ANN_MLP_TrainParams; + // typedef CvANN_MLP NeuralNet_MLP; + // typedef CvGBTreesParams GradientBoostingTreeParams; + // typedef CvGBTrees GradientBoostingTrees; + // + // template<> CV_EXPORTS void Ptr::delete_obj(); + // + // CV_EXPORTS bool initModule_ml(void); + // } + +function CreateCvKNearest: ICvKNearest; overload; safecall; +function CreateCvKNearest(const trainData: pCvMat; const responses: pCvMat; const sampleIdx: pCvMat = nil; + isRegression: bool = false; max_k: Integer = 32): ICvKNearest; overload; safecall; + +implementation + +Uses + uLibName; + +function CreateCvKNearest: ICvKNearest; external OpenCV_Classes_DLL name 'CreateCvKNearest'; +function CreateCvKNearest(const trainData: pCvMat; const responses: pCvMat; const sampleIdx: pCvMat = nil; + isRegression: bool = false; max_k: Integer = 32): ICvKNearest; external OpenCV_Classes_DLL name 'CreateCvKNearestTR'; + +{ TCvDTreeNode } + +function TCvDTreeNode.get_num_valid(vi: Integer): Integer; +begin + if num_valid = nil then + Result := sample_count + else + Result := num_valid[vi]; +end; + +procedure TCvDTreeNode.set_num_valid(vi, n: Integer); +begin + if num_valid <> nil then + num_valid[vi] := n; +end; + +end. diff --git a/include/objdetect/objdetect.pas b/deprecated/include/objdetect/objdetect.pas similarity index 100% rename from include/objdetect/objdetect.pas rename to deprecated/include/objdetect/objdetect.pas diff --git a/include/stitching/stitcher.pas b/deprecated/include/stitching/stitcher.pas similarity index 100% rename from include/stitching/stitcher.pas rename to deprecated/include/stitching/stitcher.pas diff --git a/opencv_classes/ReadMe.txt b/deprecated/opencv_classes/ReadMe.txt similarity index 100% rename from opencv_classes/ReadMe.txt rename to deprecated/opencv_classes/ReadMe.txt diff --git a/opencv_classes/dllmain.cpp b/deprecated/opencv_classes/dllmain.cpp similarity index 100% rename from opencv_classes/dllmain.cpp rename to deprecated/opencv_classes/dllmain.cpp diff --git a/opencv_classes/opencv_classes.cpp b/deprecated/opencv_classes/opencv_classes.cpp similarity index 100% rename from opencv_classes/opencv_classes.cpp rename to deprecated/opencv_classes/opencv_classes.cpp diff --git a/opencv_classes/opencv_classes.def b/deprecated/opencv_classes/opencv_classes.def similarity index 100% rename from opencv_classes/opencv_classes.def rename to deprecated/opencv_classes/opencv_classes.def diff --git a/opencv_classes/opencv_classes.sln b/deprecated/opencv_classes/opencv_classes.sln similarity index 100% rename from opencv_classes/opencv_classes.sln rename to deprecated/opencv_classes/opencv_classes.sln diff --git a/opencv_classes/opencv_classes.vcxproj b/deprecated/opencv_classes/opencv_classes.vcxproj similarity index 100% rename from opencv_classes/opencv_classes.vcxproj rename to deprecated/opencv_classes/opencv_classes.vcxproj diff --git a/opencv_classes/opencv_classes.vcxproj.filters b/deprecated/opencv_classes/opencv_classes.vcxproj.filters similarity index 100% rename from opencv_classes/opencv_classes.vcxproj.filters rename to deprecated/opencv_classes/opencv_classes.vcxproj.filters diff --git a/opencv_classes/opencv_classes.vcxproj.user b/deprecated/opencv_classes/opencv_classes.vcxproj.user similarity index 100% rename from opencv_classes/opencv_classes.vcxproj.user rename to deprecated/opencv_classes/opencv_classes.vcxproj.user diff --git a/opencv_classes/stdafx.cpp b/deprecated/opencv_classes/stdafx.cpp similarity index 100% rename from opencv_classes/stdafx.cpp rename to deprecated/opencv_classes/stdafx.cpp diff --git a/samples/Classes/CvKNearest/Class_2D_Point_Classification.dpr b/deprecated/samples/Classes/CvKNearest/Class_2D_Point_Classification.dpr similarity index 100% rename from samples/Classes/CvKNearest/Class_2D_Point_Classification.dpr rename to deprecated/samples/Classes/CvKNearest/Class_2D_Point_Classification.dpr diff --git a/samples/Classes/CvKNearest/Class_2D_Point_Classification.dproj b/deprecated/samples/Classes/CvKNearest/Class_2D_Point_Classification.dproj similarity index 100% rename from samples/Classes/CvKNearest/Class_2D_Point_Classification.dproj rename to deprecated/samples/Classes/CvKNearest/Class_2D_Point_Classification.dproj diff --git a/samples/Classes/CvKNearest/Class_2D_Point_Classification.res b/deprecated/samples/Classes/CvKNearest/Class_2D_Point_Classification.res similarity index 100% rename from samples/Classes/CvKNearest/Class_2D_Point_Classification.res rename to deprecated/samples/Classes/CvKNearest/Class_2D_Point_Classification.res diff --git a/samples/Classes/CvKNearest/Class_labKNN.dpr b/deprecated/samples/Classes/CvKNearest/Class_labKNN.dpr similarity index 100% rename from samples/Classes/CvKNearest/Class_labKNN.dpr rename to deprecated/samples/Classes/CvKNearest/Class_labKNN.dpr diff --git a/samples/Classes/CvKNearest/Class_labKNN.dproj b/deprecated/samples/Classes/CvKNearest/Class_labKNN.dproj similarity index 100% rename from samples/Classes/CvKNearest/Class_labKNN.dproj rename to deprecated/samples/Classes/CvKNearest/Class_labKNN.dproj diff --git a/samples/Classes/CvKNearest/Class_labKNN.res b/deprecated/samples/Classes/CvKNearest/Class_labKNN.res similarity index 100% rename from samples/Classes/CvKNearest/Class_labKNN.res rename to deprecated/samples/Classes/CvKNearest/Class_labKNN.res diff --git a/samples/Classes/IPCamVideoCapture/Class_IPCamVideoCapture.dpr b/deprecated/samples/Classes/IPCamVideoCapture/Class_IPCamVideoCapture.dpr similarity index 100% rename from samples/Classes/IPCamVideoCapture/Class_IPCamVideoCapture.dpr rename to deprecated/samples/Classes/IPCamVideoCapture/Class_IPCamVideoCapture.dpr diff --git a/samples/Classes/IPCamVideoCapture/Class_IPCamVideoCapture.dproj b/deprecated/samples/Classes/IPCamVideoCapture/Class_IPCamVideoCapture.dproj similarity index 100% rename from samples/Classes/IPCamVideoCapture/Class_IPCamVideoCapture.dproj rename to deprecated/samples/Classes/IPCamVideoCapture/Class_IPCamVideoCapture.dproj diff --git a/samples/Classes/IPCamVideoCapture/Class_IPCamVideoCapture.res b/deprecated/samples/Classes/IPCamVideoCapture/Class_IPCamVideoCapture.res similarity index 100% rename from samples/Classes/IPCamVideoCapture/Class_IPCamVideoCapture.res rename to deprecated/samples/Classes/IPCamVideoCapture/Class_IPCamVideoCapture.res diff --git a/samples/Classes/Mat/Class_Mat.dpr b/deprecated/samples/Classes/Mat/Class_Mat.dpr similarity index 100% rename from samples/Classes/Mat/Class_Mat.dpr rename to deprecated/samples/Classes/Mat/Class_Mat.dpr diff --git a/samples/Classes/Mat/Class_Mat.dproj b/deprecated/samples/Classes/Mat/Class_Mat.dproj similarity index 100% rename from samples/Classes/Mat/Class_Mat.dproj rename to deprecated/samples/Classes/Mat/Class_Mat.dproj diff --git a/samples/Classes/Mat/Class_Mat.res b/deprecated/samples/Classes/Mat/Class_Mat.res similarity index 100% rename from samples/Classes/Mat/Class_Mat.res rename to deprecated/samples/Classes/Mat/Class_Mat.res diff --git a/samples/Classes/ObjectTracking/Class_ObjectTracking.dpr b/deprecated/samples/Classes/ObjectTracking/Class_ObjectTracking.dpr similarity index 100% rename from samples/Classes/ObjectTracking/Class_ObjectTracking.dpr rename to deprecated/samples/Classes/ObjectTracking/Class_ObjectTracking.dpr diff --git a/samples/Classes/ObjectTracking/Class_ObjectTracking.dproj b/deprecated/samples/Classes/ObjectTracking/Class_ObjectTracking.dproj similarity index 100% rename from samples/Classes/ObjectTracking/Class_ObjectTracking.dproj rename to deprecated/samples/Classes/ObjectTracking/Class_ObjectTracking.dproj diff --git a/samples/Classes/ObjectTracking/Class_ObjectTracking.res b/deprecated/samples/Classes/ObjectTracking/Class_ObjectTracking.res similarity index 100% rename from samples/Classes/ObjectTracking/Class_ObjectTracking.res rename to deprecated/samples/Classes/ObjectTracking/Class_ObjectTracking.res diff --git a/samples/Classes/TwoCameras/Class_TwoCameras.dpr b/deprecated/samples/Classes/TwoCameras/Class_TwoCameras.dpr similarity index 100% rename from samples/Classes/TwoCameras/Class_TwoCameras.dpr rename to deprecated/samples/Classes/TwoCameras/Class_TwoCameras.dpr diff --git a/samples/Classes/TwoCameras/Class_TwoCameras.dproj b/deprecated/samples/Classes/TwoCameras/Class_TwoCameras.dproj similarity index 100% rename from samples/Classes/TwoCameras/Class_TwoCameras.dproj rename to deprecated/samples/Classes/TwoCameras/Class_TwoCameras.dproj diff --git a/samples/Classes/TwoCameras/Class_TwoCameras.res b/deprecated/samples/Classes/TwoCameras/Class_TwoCameras.res similarity index 100% rename from samples/Classes/TwoCameras/Class_TwoCameras.res rename to deprecated/samples/Classes/TwoCameras/Class_TwoCameras.res diff --git a/samples/Classes/VideoCapture/Class_VideoCapture.dpr b/deprecated/samples/Classes/VideoCapture/Class_VideoCapture.dpr similarity index 100% rename from samples/Classes/VideoCapture/Class_VideoCapture.dpr rename to deprecated/samples/Classes/VideoCapture/Class_VideoCapture.dpr diff --git a/samples/Classes/VideoCapture/Class_VideoCapture.dproj b/deprecated/samples/Classes/VideoCapture/Class_VideoCapture.dproj similarity index 100% rename from samples/Classes/VideoCapture/Class_VideoCapture.dproj rename to deprecated/samples/Classes/VideoCapture/Class_VideoCapture.dproj diff --git a/samples/Classes/VideoCapture/Class_VideoCapture.res b/deprecated/samples/Classes/VideoCapture/Class_VideoCapture.res similarity index 100% rename from samples/Classes/VideoCapture/Class_VideoCapture.res rename to deprecated/samples/Classes/VideoCapture/Class_VideoCapture.res diff --git a/include/core/Mat.pas b/include/core/Mat.pas index 7c6cc26..9add90b 100644 --- a/include/core/Mat.pas +++ b/include/core/Mat.pas @@ -1,160 +1,77 @@ -// --------------------------------- 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. *) +// ***************************************************************** +// Delphi-OpenCV Demo +// Copyright (C) 2013 Project Delphi-OpenCV +// **************************************************************** +// Contributor: +// Laentir Valetov +// email:laex@bk.ru +// **************************************************************** +// You may retrieve the latest version of this file at the GitHub, +// located at git://github.com/Laex/Delphi-OpenCV.git +// **************************************************************** +// The contents of this file are used with permission, 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/MPL-1_1Final.html +// +// 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. +// ******************************************************************* -(* / ************************************************************************************************** - // Project Delphi-OpenCV - // ************************************************************************************************** - // Contributor: - // laentir Valetov - // email:laex@bk.ru - // ************************************************************************************************** - // 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://opencv.org - // Online docs: http://docs.opencv.org - // Q&A forum: http://answers.opencv.org - // Dev zone: http://code.opencv.org - // ************************************************************************************************** - // Original file: - // opencv\modules\core\include\opencv2\core\mat.hpp - // ************************************************************************************************* *) - -unit Mat; +unit mat; interface -Uses WinApi.Windows, Core.types_c; - -const - MAGIC_VAL = $42FF0000; - AUTO_STEP = 0; - CONTINUOUS_FLAG = CV_MAT_CONT_FLAG; - SUBMATRIX_FLAG = CV_SUBMAT_FLAG; - - MAGIC_MASK = $FFFF0000; - TYPE_MASK = $00000FFF; - DEPTH_MASK = 7; +Uses + WinApi.Windows, + core.types_c, + highgui_c; Type - - // Attention! - // The sequence of function declarations interface must match the - // sequence of function declarations in the project "opencv_classes" (C++) - - IMat = interface - ['{9C458D5C-F577-4A2D-89A0-FC426B80CC56}'] - // ! returns element size in bytes, + TOCVMat = class + public // similar to CV_ELEM_SIZE(cvmat->type) - function elemSize(): size_t; stdcall; + function elemSize(): size_t; virtual; stdcall; abstract; // ! returns the size of element channel in bytes. - function elemSize1(): size_t; stdcall; + function elemSize1(): size_t; virtual; stdcall; abstract; // ! returns element type, similar to CV_MAT_TYPE(cvmat->type) - function _type: Integer; stdcall; + function _type: Integer; virtual; stdcall; abstract; // ! returns element type, similar to CV_MAT_DEPTH(cvmat->type) - function depth: Integer; stdcall; + function depth: Integer; virtual; stdcall; abstract; // ! returns element type, similar to CV_MAT_CN(cvmat->type) - function channels: Integer; stdcall; + function channels: Integer; virtual; stdcall; abstract; // ! returns step/elemSize1() - function step1(i: Integer = 0): size_t; stdcall; + function step1(i: Integer = 0): size_t; virtual; stdcall; abstract; // ! returns true if matrix data is NULL - function empty: bool; stdcall; + function empty: bool; virtual; stdcall; abstract; // ! returns the total number of matrix elements - function total: size_t; stdcall; + function total: size_t; virtual; stdcall; abstract; // * ! includes several bit - fields: - the magic signature - continuity flag - depth - number of channels * / - function flags: Integer; stdcall; + function flags: Integer; virtual; stdcall; abstract; // ! the matrix dimensionality, >= 2 - function dims: Integer; stdcall; + function dims: Integer; virtual; stdcall; abstract; // ! the number of rows and columns or (-1, -1) when the matrix has more than 2 dimensions - function rows: Integer; stdcall; - function cols: Integer; stdcall; + function rows: Integer; virtual; stdcall; abstract; + function cols: Integer; virtual; stdcall; abstract; // ! pointer to the data - function data: pByte; stdcall; - //! copies the matrix content to "m". - // It calls m.create(this->size(), this->type()). - procedure copyto(Var _mat:IMat); stdcall; - // ! pointer to the reference counter; - // when matrix points to user-allocated data, the pointer is NULL - function refcount: pInteger; stdcall; - // ----------------------------------- - function getMat(): Pointer; stdcall; - // procedure setMat(mat:Pointer); stdcall; + function data: pByte; virtual; stdcall; abstract; + // ------------------------------------------------ end; - // ! default constructor -function CreateMat: IMat; overload; safecall; -// ! constructs 2D matrix of the specified size and type -// (_type is CV_8UC1, CV_64FC3, CV_32SC(12) etc.) -function CreateMat(rows, cols, _type: Integer): IMat; overload; safecall; -function CreateMat(_mat: Pointer): IMat; overload; safecall; +function CreateMat: TOCVMat; stdcall; overload; +function CreateMat(rows, cols, _type: Integer): TOCVMat; stdcall; overload; +procedure ReleaseMat(ex: TOCVMat); stdcall; implementation -Uses uLibName; +Uses + uLibName; -function CreateMat: IMat; external OpenCV_Classes_DLL name 'CreateMat'; -function CreateMat(rows, cols, _type: Integer): IMat; external OpenCV_Classes_DLL name 'CreateMat_rct'; -function CreateMat(_mat: Pointer): IMat; external OpenCV_Classes_DLL name 'CreateMat_Mat'; +function CreateMat: TOCVMat; stdcall; external OpenCV_Classes_DLL name 'CreateMat'; overload; +function CreateMat(rows, cols, _type: Integer): TOCVMat; stdcall; external OpenCV_Classes_DLL name 'CreateMatRCT'; overload; +procedure ReleaseMat; external OpenCV_Classes_DLL; end. diff --git a/include/highgui/highgui.pas b/include/highgui/highgui.pas index 0229b45..83ae438 100644 --- a/include/highgui/highgui.pas +++ b/include/highgui/highgui.pas @@ -1,85 +1,85 @@ // --------------------------------- 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. *) +// 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 - // ************************************************************************************************** - // 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://opencv.org - // Online docs: http://docs.opencv.org - // Q&A forum: http://answers.opencv.org - // Dev zone: http://code.opencv.org - // ************************************************************************************************** - // Original file: - // opencv\modules\highgui\include\opencv2\highgui.hpp - // ************************************************************************************************* *) +// ************************************************************************************************** +// Project Delphi-OpenCV +// ************************************************************************************************** +// Contributor: +// laentir Valetov +// email:laex@bk.ru +// ************************************************************************************************** +// 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://opencv.org +// Online docs: http://docs.opencv.org +// Q&A forum: http://answers.opencv.org +// Dev zone: http://code.opencv.org +// ************************************************************************************************** +// Original file: +// opencv\modules\highgui\include\opencv2\highgui.hpp +// ************************************************************************************************* unit highgui; @@ -87,9 +87,8 @@ interface Uses WinApi.Windows, - Mat, + mat, Core.types_c, - Core.types, highgui_c; Type @@ -98,35 +97,33 @@ Type // The sequence of function declarations interface must match the // sequence of function declarations in the project "opencv_classes" (C++) - IVideoCapture = interface - ['{3F605CF0-ECAC-4230-B30B-AF9BFD516C4F}'] - function open(device: Integer): bool; overload; stdcall; - function openfilename(filename: pAnsiChar): bool; overload; stdcall; - function isOpened(): bool; stdcall; - procedure release(); stdcall; - - function grab(): bool; stdcall; - function retrieve(Var image: IMat; flag: Integer): bool; stdcall; - function read(Var image: IMat): bool; stdcall; - - function setValue(propId: Integer; value: double): bool; stdcall; - function getValue(propId: Integer): double; stdcall; + TOCVVideoCapture = class + function open(device: Integer): bool; overload; virtual; stdcall; abstract; + function openfile(filename: pAnsiChar): bool; overload; virtual; stdcall; abstract; + function isOpened(): bool; virtual; stdcall; abstract; + procedure release(); virtual; stdcall; abstract; + function grab(): bool; virtual; stdcall; abstract; + function retrieve(Var image: TOCVMat; flag: Integer): bool; virtual; stdcall; abstract; + function read(Var image: TOCVMat): bool; virtual; stdcall; abstract; + function setValue(propId: Integer; value: double): bool; virtual; stdcall; abstract; + function getValue(propId: Integer): double; virtual; stdcall; abstract; end; -function CreateVideoCapture: IVideoCapture; overload; safecall; -function CreateVideoCapture(device: Integer): IVideoCapture; overload; safecall; -function CreateVideoCapture(filename: pAnsiChar): IVideoCapture; overload; safecall; +function CreateVideoCapture: TOCVVideoCapture; stdcall; overload; +function CreateVideoCapture(device: Integer): TOCVVideoCapture; stdcall; overload; +function CreateVideoCapture(filename: pAnsiChar): TOCVVideoCapture; stdcall; overload; +procedure DestroyVideoCapture(ex: TOCVVideoCapture); stdcall; // Flags for namedWindow Const WINDOW_NORMAL = $00000000; // the user can resize the window (no constraint) / also use to switch a fullscreen window to a normal size WINDOW_AUTOSIZE = $00000001; // the user cannot resize the window, the size is constrainted by the image displayed - WINDOW_OPENGL = $00001000; // window with opengl support + WINDOW_OPENGL = $00001000; // window with opengl support - WINDOW_FULLSCREEN = 1; // change the window to fullscreen - WINDOW_FREERATIO = $00000100; // the image expends as much as it can (no ratio constraint) - WINDOW_KEEPRATIO = $00000000; // the ratio of the image is respected + WINDOW_FULLSCREEN = 1; // change the window to fullscreen + WINDOW_FREERATIO = $00000100; // the image expends as much as it can (no ratio constraint) + WINDOW_KEEPRATIO = $00000000; // the ratio of the image is respected // CV_EXPORTS_W void namedWindow(const String& winname, int flags = WINDOW_AUTOSIZE); procedure namedWindow(const winname: String; const flags: Integer = WINDOW_AUTOSIZE); @@ -139,7 +136,7 @@ function startWindowThread(): Integer; // CV_EXPORTS_W int waitKey(int delay = 0); function waitKey(const delay: Integer = 0): Integer; // CV_EXPORTS_W void imshow(const String& winname, InputArray mat); -procedure imshow(const winname: String; const Mat: IMat); +procedure imshow(const winname: String; const mat: TOCVMat); // CV_EXPORTS_W void resizeWindow(const String& winname, int width, int height); procedure resizeWindow(const winname: String; const width, height: Integer); // CV_EXPORTS_W void moveWindow(const String& winname, int x, int y); @@ -152,13 +149,18 @@ function getWindowProperty(const winname: String; const prop_id: Integer): doubl // int* value, int count, // TrackbarCallback onChange = 0, // void* userdata = 0); -function createTrackbar(const trackbarname: String; const winname: String; value: PInteger; count: Integer; - onChange: CvTrackbarCallback2 = nil; userdata: Pointer = nil): Integer; +function createTrackbar(const trackbarname: String; const winname: String; value: PInteger; count: Integer; onChange: CvTrackbarCallback2 = nil; + userdata: Pointer = nil): Integer; // CV_EXPORTS_W Mat imread( const string& filename, int flags=1 ); -function imread(const filename: string; flag: Integer = 1): IMat; +function imread(const filename: string; flag: Integer = 1): TOCVMat; // CV_EXPORTS_W bool imwrite( const string& filename, InputArray img, const vector& params=vector()); -function imwrite(const filename: String; const img: IMat): bool; +function imwrite(const filename: String; const img: TOCVMat): bool; + +Type + TIplImageRecordHelper = record helper for TIplImage + function InitFromMat(const mat: TOCVMat): TIplImage; + end; implementation @@ -167,32 +169,27 @@ Uses cvUtils, core_c; -function CreateVideoCapture: IVideoCapture; external OpenCV_Classes_DLL name 'CreateVideoCapture'; -function CreateVideoCapture(device: Integer): IVideoCapture; external OpenCV_Classes_DLL name 'CreateVideoCapture_dvc'; -function CreateVideoCapture(filename: pAnsiChar): IVideoCapture; - external OpenCV_Classes_DLL name 'CreateVideoCapture_fln'; -function _imread(const filename: pCvChar; flag: Integer): IMat; external OpenCV_Classes_DLL name '_imread'; -function _imwrite(const filename: pCvChar; const img: IMat): bool; external OpenCV_Classes_DLL name '_imwrite'; +function CreateVideoCapture: TOCVVideoCapture; stdcall; external OpenCV_Classes_DLL name 'CreateVideoCapture'; overload; +function CreateVideoCapture(device: Integer): TOCVVideoCapture; stdcall; external OpenCV_Classes_DLL name 'CreateVideoCaptureDevice'; overload; +function CreateVideoCapture(filename: pAnsiChar): TOCVVideoCapture; stdcall; external OpenCV_Classes_DLL name 'CreateVideoCaptureFileName'; overload; +procedure DestroyVideoCapture(ex: TOCVVideoCapture); stdcall; external OpenCV_Classes_DLL; -function imread(const filename: string; flag: Integer): IMat; +function _imread(const filename: pCvChar; flag: Integer): TOCVMat; external OpenCV_Classes_DLL name '_imread'; +function _imwrite(const filename: pCvChar; const img: TOCVMat): bool; external OpenCV_Classes_DLL name '_imwrite'; + +function imread(const filename: string; flag: Integer): TOCVMat; begin - Result := _imread( - c_str(filename), - flag); + Result := _imread(c_str(filename), flag); end; -function imwrite(const filename: String; const img: IMat): bool; +function imwrite(const filename: String; const img: TOCVMat): bool; begin - Result := _imwrite( - c_str(filename), - img); + Result := _imwrite(c_str(filename), img); end; procedure namedWindow(const winname: String; const flags: Integer = WINDOW_AUTOSIZE); begin - cvNamedWindow( - c_str(winname), - flags); + cvNamedWindow(c_str(winname), flags); end; procedure destroyWindow(const winname: String); @@ -215,57 +212,47 @@ begin Result := cvWaitKey(delay); end; -procedure imshow(const winname: String; const Mat: IMat); +procedure imshow(const winname: String; const mat: TOCVMat); Var IplImage: TIplImage; begin - IplImage.InitFromMat(Mat); - cvShowImage( - c_str(winname), - @IplImage); + IplImage.InitFromMat(mat); + cvShowImage(c_str(winname), @IplImage); end; procedure resizeWindow(const winname: String; const width, height: Integer); begin - cvResizeWindow( - c_str(winname), - width, - height); + cvResizeWindow(c_str(winname), width, height); end; procedure moveWindow(const winname: String; const x, y: Integer); begin - cvMoveWindow( - c_str(winname), - x, - y); + cvMoveWindow(c_str(winname), x, y); end; procedure setWindowProperty(const winname: String; const prop_id: Integer; const prop_value: double); begin - cvSetWindowProperty( - c_str(winname), - prop_id, - prop_value); + cvSetWindowProperty(c_str(winname), prop_id, prop_value); end; function getWindowProperty(const winname: String; const prop_id: Integer): double; begin - Result := cvGetWindowProperty( - c_str(winname), - prop_id); + Result := cvGetWindowProperty(c_str(winname), prop_id); end; -function createTrackbar(const trackbarname: String; const winname: String; value: PInteger; count: Integer; - onChange: CvTrackbarCallback2 = nil; userdata: Pointer = nil): Integer; +function createTrackbar(const trackbarname: String; const winname: String; value: PInteger; count: Integer; onChange: CvTrackbarCallback2 = nil; + userdata: Pointer = nil): Integer; begin - Result := cvCreateTrackbar2( - c_str(trackbarname), - c_str(winname), - value, - count, - onChange, - userdata); + Result := cvCreateTrackbar2(c_str(trackbarname), c_str(winname), value, count, onChange, userdata); +end; + +{ TIplImageRecordHelper } + +function TIplImageRecordHelper.InitFromMat(const mat: TOCVMat): TIplImage; +begin + Assert(mat.dims <= 2); + cvInitImageHeader(@Self, CvSize(mat.cols, mat.rows), cvIplDepth(mat.flags), mat.channels); + cvSetData(@Self, mat.data, mat.step1); end; end. diff --git a/include/ml/ml.pas b/include/ml/ml.pas index a46f5ef..d5d57a9 100644 --- a/include/ml/ml.pas +++ b/include/ml/ml.pas @@ -82,20 +82,10 @@ // opencv\modules\ml\include\opencv2\ml.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} -{$ELSE} -{$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} -{$ENDIF} -{$WARN SYMBOL_DEPRECATED OFF} -{$WARN SYMBOL_PLATFORM OFF} -{$WARN UNIT_PLATFORM OFF} -{$WARN UNSAFE_TYPE OFF} -{$WARN UNSAFE_CODE OFF} -{$WARN UNSAFE_CAST OFF} -{$POINTERMATH ON} unit ml; +{$POINTERMATH ON} + interface Uses @@ -161,8 +151,8 @@ Uses const /// * Variable type */ - CV_VAR_NUMERICAL = 0; - CV_VAR_ORDERED = 0; + CV_VAR_NUMERICAL = 0; + CV_VAR_ORDERED = 0; CV_VAR_CATEGORICAL = 1; // @@ -279,12 +269,11 @@ const // * K-Nearest Neighbour Classifier * // \****************************************************************************************/ Type - ICvKNearest = interface - ['{2F98E12A-AB71-48B5-AACC-025D0D0A3611}'] + TCvKNearest = class function train(const trainData: pCvMat; const responses: pCvMat; const sampleIdx: pCvMat = nil; - is_regression: bool = false; maxK: Integer = 32; updateBase: bool = false): bool; stdcall; + is_regression: bool = false; maxK: Integer = 32; updateBase: bool = false): bool; virtual; stdcall; abstract; function find_nearest(const samples: pCvMat; k: Integer; results: pCvMat = nil; const neighbors: pSingle = nil; - neighborResponses: pCvMat = nil; dist: pCvMat = nil): float; stdcall; + neighborResponses: pCvMat = nil; dist: pCvMat = nil): float; virtual; stdcall; abstract; end; // k Nearest Neighbors @@ -725,11 +714,11 @@ Type pCvDTreeSplit = ^TCvDTreeSplit; TCvDTreeSplit = packed record // struct CvDTreeSplit - var_idx: Integer; // int var_idx; - condensed_idx: Integer; // int condensed_idx; - inversed: Integer; // int inversed; - quality: float; // float quality; - next: pCvDTreeSplit; // CvDTreeSplit* next; + var_idx: Integer; // int var_idx; + condensed_idx: Integer; // int condensed_idx; + inversed: Integer; // int inversed; + quality: float; // float quality; + next: pCvDTreeSplit; // CvDTreeSplit* next; case byte of // union // { @@ -750,31 +739,31 @@ Type pCvDTreeNode = ^TCvDTreeNode; TCvDTreeNode = packed record // struct CvDTreeNode - class_idx: Integer; // int class_idx; - Tn: Integer; // int Tn; - value: Double; // double value; + class_idx: Integer; // int class_idx; + Tn: Integer; // int Tn; + value: Double; // double value; // parent: pCvDTreeNode; // CvDTreeNode* parent; - left: pCvDTreeNode; // CvDTreeNode* left; - right: pCvDTreeNode; // CvDTreeNode* right; + left: pCvDTreeNode; // CvDTreeNode* left; + right: pCvDTreeNode; // CvDTreeNode* right; // split: pCvDTreeSplit; // CvDTreeSplit* split; // sample_count: Integer; // int sample_count; - depth: Integer; // int depth; - num_valid: pInteger; // int* num_valid; - offset: Integer; // int offset; - buf_idx: Integer; // int buf_idx; - maxlr: Double; // double maxlr; + depth: Integer; // int depth; + num_valid: pInteger; // int* num_valid; + offset: Integer; // int offset; + buf_idx: Integer; // int buf_idx; + maxlr: Double; // double maxlr; // // // global pruning data - complexity: Integer; // int complexity; - alpha: Double; // double alpha; + complexity: Integer; // int complexity; + alpha: Double; // double alpha; node_risk, tree_risk, tree_error: Double; // double node_risk, tree_risk, tree_error; // // // cross-validation pruning data - cv_Tn: pInteger; // int* cv_Tn; - cv_node_risk: pDouble; // double* cv_node_risk; + cv_Tn: pInteger; // int* cv_Tn; + cv_node_risk: pDouble; // double* cv_node_risk; cv_node_error: pDouble; // double* cv_node_error; // // int get_num_valid(int vi) { return num_valid ? num_valid[vi] : sample_count; } @@ -783,16 +772,16 @@ Type procedure set_num_valid(vi: Integer; n: Integer); end; - TCvDTreeParams = packed record // struct CV_EXPORTS_W_MAP CvDTreeParams - max_categories: Integer; // CV_PROP_RW int max_categories ; - max_depth: Integer; // CV_PROP_RW int max_depth ; - min_sample_count: Integer; // CV_PROP_RW int min_sample_count ; - cv_folds: Integer; // CV_PROP_RW int cv_folds ; - use_surrogates: ByteBool; // CV_PROP_RW bool use_surrogates ; - use_1se_rule: ByteBool; // CV_PROP_RW bool use_1se_rule ; + TCvDTreeParams = packed record // struct CV_EXPORTS_W_MAP CvDTreeParams + max_categories: Integer; // CV_PROP_RW int max_categories ; + max_depth: Integer; // CV_PROP_RW int max_depth ; + min_sample_count: Integer; // CV_PROP_RW int min_sample_count ; + cv_folds: Integer; // CV_PROP_RW int cv_folds ; + use_surrogates: ByteBool; // CV_PROP_RW bool use_surrogates ; + use_1se_rule: ByteBool; // CV_PROP_RW bool use_1se_rule ; truncate_pruned_tree: ByteBool; // CV_PROP_RW bool truncate_pruned_tree ; - regression_accuracy: float; // CV_PROP_RW float regression_accuracy ; - priors: pFloat; // const float* priors; + regression_accuracy: float; // CV_PROP_RW float regression_accuracy ; + priors: pFloat; // const float* priors; // // CvDTreeParams(); { @@ -2212,18 +2201,20 @@ Type // CV_EXPORTS bool initModule_ml(void); // } -function CreateCvKNearest: ICvKNearest; overload; safecall; -function CreateCvKNearest(const trainData: pCvMat; const responses: pCvMat; const sampleIdx: pCvMat = nil; - isRegression: bool = false; max_k: Integer = 32): ICvKNearest; overload; safecall; +function CreateCvKNearest: TCvKNearest; stdcall; overload; +function CreateCvKNearest(const trainData: pCvMat; const responses: pCvMat; const sampleIdx: pCvMat = nil; isRegression: bool = false; max_k: Integer = 32) + : TCvKNearest; stdcall; overload; +procedure ReleaseCvKNearest(ex: TCvKNearest); stdcall; implementation Uses uLibName; -function CreateCvKNearest: ICvKNearest; external OpenCV_Classes_DLL name 'CreateCvKNearest'; -function CreateCvKNearest(const trainData: pCvMat; const responses: pCvMat; const sampleIdx: pCvMat = nil; - isRegression: bool = false; max_k: Integer = 32): ICvKNearest; external OpenCV_Classes_DLL name 'CreateCvKNearestTR'; +function CreateCvKNearest: TCvKNearest; stdcall; external OpenCV_Classes_DLL name 'CreateCvKNearest'; +function CreateCvKNearest(const trainData: pCvMat; const responses: pCvMat; const sampleIdx: pCvMat = nil; isRegression: bool = false; max_k: Integer = 32) + : TCvKNearest; stdcall; external OpenCV_Classes_DLL name 'CreateCvKNearestTR'; +procedure ReleaseCvKNearest; stdcall; external OpenCV_Classes_DLL; { TCvDTreeNode } diff --git a/include/uLibName.pas b/include/uLibName.pas index 22c1b04..9717d71 100644 --- a/include/uLibName.pas +++ b/include/uLibName.pas @@ -36,40 +36,40 @@ interface const - CV_VERSION_EPOCH = '2'; - CV_VERSION_MAJOR = '4'; - CV_VERSION_MINOR = '8'; + CV_VERSION_EPOCH = '2'; + CV_VERSION_MAJOR = '4'; + CV_VERSION_MINOR = '8'; CV_VERSION_REVISION = '0'; CV_VERSION = CV_VERSION_EPOCH + '.' + CV_VERSION_MAJOR + '.' + CV_VERSION_MINOR + '.' + CV_VERSION_REVISION; // * old style version constants*/ - CV_MAJOR_VERSION = CV_VERSION_EPOCH; - CV_MINOR_VERSION = CV_VERSION_MAJOR; + CV_MAJOR_VERSION = CV_VERSION_EPOCH; + CV_MINOR_VERSION = CV_VERSION_MAJOR; CV_SUBMINOR_VERSION = CV_VERSION_MINOR; CV_VERSION_DLL = CV_VERSION_EPOCH + CV_VERSION_MAJOR + CV_VERSION_MINOR; {$IFDEF DEBUG} - Core_Dll = 'opencv_core' + CV_VERSION_DLL + 'd.dll'; - highgui_Dll = 'opencv_highgui' + CV_VERSION_DLL + 'd.dll'; - imgproc_Dll = 'opencv_imgproc' + CV_VERSION_DLL + 'd.dll'; - objdetect_dll = 'opencv_objdetect' + CV_VERSION_DLL + 'd.dll'; - legacy_dll = 'opencv_legacy' + CV_VERSION_DLL + 'd.dll'; - calib3d_dll = 'opencv_calib3d' + CV_VERSION_DLL + 'd.dll'; - tracking_DLL = 'opencv_video' + CV_VERSION_DLL + 'd.dll'; - Nonfree_DLL = 'opencv_nonfree' + CV_VERSION_DLL + 'd.dll'; - OpenCV_Classes_DLL = 'OpenCV_Classes.dll'; + Core_Dll = 'opencv_core' + CV_VERSION_DLL + 'd.dll'; + highgui_Dll = 'opencv_highgui' + CV_VERSION_DLL + 'd.dll'; + imgproc_Dll = 'opencv_imgproc' + CV_VERSION_DLL + 'd.dll'; + objdetect_dll = 'opencv_objdetect' + CV_VERSION_DLL + 'd.dll'; + legacy_dll = 'opencv_legacy' + CV_VERSION_DLL + 'd.dll'; + calib3d_dll = 'opencv_calib3d' + CV_VERSION_DLL + 'd.dll'; + tracking_DLL = 'opencv_video' + CV_VERSION_DLL + 'd.dll'; + Nonfree_DLL = 'opencv_nonfree' + CV_VERSION_DLL + 'd.dll'; + OpenCV_Classes_DLL = 'opencv_classes' + CV_VERSION_DLL + 'd.dll'; {$ELSE} - Core_Dll = 'opencv_core' + CV_VERSION_DLL + '.dll'; - highgui_Dll = 'opencv_highgui' + CV_VERSION_DLL + '.dll'; - imgproc_Dll = 'opencv_imgproc' + CV_VERSION_DLL + '.dll'; - objdetect_dll = 'opencv_objdetect' + CV_VERSION_DLL + '.dll'; - legacy_dll = 'opencv_legacy' + CV_VERSION_DLL + '.dll'; - calib3d_dll = 'opencv_calib3d' + CV_VERSION_DLL + '.dll'; - tracking_DLL = 'opencv_video' + CV_VERSION_DLL + '.dll'; - Nonfree_DLL = 'opencv_nonfree' + CV_VERSION_DLL + '.dll'; - OpenCV_Classes_DLL = 'OpenCV_Classes.dll'; + Core_Dll = 'opencv_core' + CV_VERSION_DLL + '.dll'; + highgui_Dll = 'opencv_highgui' + CV_VERSION_DLL + '.dll'; + imgproc_Dll = 'opencv_imgproc' + CV_VERSION_DLL + '.dll'; + objdetect_dll = 'opencv_objdetect' + CV_VERSION_DLL + '.dll'; + legacy_dll = 'opencv_legacy' + CV_VERSION_DLL + '.dll'; + calib3d_dll = 'opencv_calib3d' + CV_VERSION_DLL + '.dll'; + tracking_DLL = 'opencv_video' + CV_VERSION_DLL + '.dll'; + Nonfree_DLL = 'opencv_nonfree' + CV_VERSION_DLL + '.dll'; + OpenCV_Classes_DLL = 'opencv_classes' + CV_VERSION_DLL + '.dll'; {$ENDIF} implementation diff --git a/opencv_classes/ocvclasses.sln b/opencv_classes/ocvclasses.sln new file mode 100644 index 0000000..566b07f --- /dev/null +++ b/opencv_classes/ocvclasses.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.21005.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ocvclasses", "ocvclasses\ocvclasses.vcxproj", "{D15D0A8B-0AD6-4139-8354-5D1C07CC3A22}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D15D0A8B-0AD6-4139-8354-5D1C07CC3A22}.Debug|Win32.ActiveCfg = Debug|Win32 + {D15D0A8B-0AD6-4139-8354-5D1C07CC3A22}.Debug|Win32.Build.0 = Debug|Win32 + {D15D0A8B-0AD6-4139-8354-5D1C07CC3A22}.Release|Win32.ActiveCfg = Release|Win32 + {D15D0A8B-0AD6-4139-8354-5D1C07CC3A22}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/opencv_classes/ocvclasses/dllmain.cpp b/opencv_classes/ocvclasses/dllmain.cpp new file mode 100644 index 0000000..674e35a --- /dev/null +++ b/opencv_classes/ocvclasses/dllmain.cpp @@ -0,0 +1,51 @@ +// dllmain.cpp : Defines the initialization routines for the DLL. +// + +#include "stdafx.h" +#include +#include + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +static AFX_EXTENSION_MODULE ocvclassesDLL = { NULL, NULL }; + +extern "C" int APIENTRY +DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) +{ + // Remove this if you use lpReserved + UNREFERENCED_PARAMETER(lpReserved); + + if (dwReason == DLL_PROCESS_ATTACH) + { + TRACE0("ocvclasses.DLL Initializing!\n"); + + // Extension DLL one-time initialization + if (!AfxInitExtensionModule(ocvclassesDLL, hInstance)) + return 0; + + // Insert this DLL into the resource chain + // NOTE: If this Extension DLL is being implicitly linked to by + // an MFC Regular DLL (such as an ActiveX Control) + // instead of an MFC application, then you will want to + // remove this line from DllMain and put it in a separate + // function exported from this Extension DLL. The Regular DLL + // that uses this Extension DLL should then explicitly call that + // function to initialize this Extension DLL. Otherwise, + // the CDynLinkLibrary object will not be attached to the + // Regular DLL's resource chain, and serious problems will + // result. + + new CDynLinkLibrary(ocvclassesDLL); + + } + else if (dwReason == DLL_PROCESS_DETACH) + { + TRACE0("ocvclasses.DLL Terminating!\n"); + + // Terminate the library before destructors are called + AfxTermExtensionModule(ocvclassesDLL); + } + return 1; // ok +} diff --git a/opencv_classes/ocvclasses/ocvclasses.aps b/opencv_classes/ocvclasses/ocvclasses.aps new file mode 100644 index 0000000..147540c Binary files /dev/null and b/opencv_classes/ocvclasses/ocvclasses.aps differ diff --git a/opencv_classes/ocvclasses/ocvclasses.cpp b/opencv_classes/ocvclasses/ocvclasses.cpp new file mode 100644 index 0000000..af78442 --- /dev/null +++ b/opencv_classes/ocvclasses/ocvclasses.cpp @@ -0,0 +1,10 @@ +// ocvclass.cpp : Defines the initialization routines for the DLL. +// + +#include "stdafx.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + diff --git a/opencv_classes/ocvclasses/ocvclasses.def b/opencv_classes/ocvclasses/ocvclasses.def new file mode 100644 index 0000000..5dd12d1 --- /dev/null +++ b/opencv_classes/ocvclasses/ocvclasses.def @@ -0,0 +1,18 @@ +; ocvclass.def : Declares the module parameters for the DLL. + +LIBRARY "ocvclasses.DLL" +DESCRIPTION 'Wrapper for OpenCV classes' + +EXPORTS + CreateMat + CreateMatRCT + ReleaseMat + + CreateVideoCapture + CreateVideoCaptureDevice + CreateVideoCaptureFileName + ReleaseVideoCapture + + CreateCvKNearest + CreateCvKNearestTR + ReleaseCvKNearest \ No newline at end of file diff --git a/opencv_classes/ocvclasses/ocvclasses.rc b/opencv_classes/ocvclasses/ocvclasses.rc new file mode 100644 index 0000000..1679278 Binary files /dev/null and b/opencv_classes/ocvclasses/ocvclasses.rc differ diff --git a/opencv_classes/ocvclasses/ocvclasses.vcxproj b/opencv_classes/ocvclasses/ocvclasses.vcxproj new file mode 100644 index 0000000..e710715 --- /dev/null +++ b/opencv_classes/ocvclasses/ocvclasses.vcxproj @@ -0,0 +1,141 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {D15D0A8B-0AD6-4139-8354-5D1C07CC3A22} + ocvclass + MFCDLLProj + + + + DynamicLibrary + true + v120 + Unicode + Dynamic + + + DynamicLibrary + false + v120 + true + Unicode + Dynamic + + + + + + + + + + + + + true + C:\OpenCV\build\include;$(IncludePath) + C:\OpenCV\build\x86\vc12\lib\;$(LibraryPath) + ..\..\bin\ + opencv_classes248d + + + false + C:\OpenCV\build\include;$(IncludePath) + C:\OpenCV\build\x86\vc12\lib\;$(LibraryPath) + ..\bin\ + opencv_classes248 + + + + Use + Level3 + Disabled + WIN32;_WINDOWS;_DEBUG;_AFXEXT;%(PreprocessorDefinitions) + true + + + Windows + true + .\ocvclasses.def + C:\OpenCV\build\x86\vc12\lib\;%(AdditionalLibraryDirectories) + opencv_calib3d248.lib;opencv_calib3d248d.lib;opencv_contrib248.lib;opencv_contrib248d.lib;opencv_core248.lib;opencv_core248d.lib;opencv_features2d248.lib;opencv_features2d248d.lib;opencv_flann248.lib;opencv_flann248d.lib;opencv_gpu248.lib;opencv_gpu248d.lib;opencv_highgui248.lib;opencv_highgui248d.lib;opencv_imgproc248.lib;opencv_imgproc248d.lib;opencv_legacy248.lib;opencv_legacy248d.lib;opencv_ml248.lib;opencv_ml248d.lib;opencv_nonfree248.lib;opencv_nonfree248d.lib;opencv_objdetect248.lib;opencv_objdetect248d.lib;opencv_ocl248.lib;opencv_ocl248d.lib;opencv_photo248.lib;opencv_photo248d.lib;opencv_stitching248.lib;opencv_stitching248d.lib;opencv_superres248.lib;opencv_superres248d.lib;opencv_ts248.lib;opencv_ts248d.lib;opencv_video248.lib;opencv_video248d.lib;opencv_videostab248.lib;opencv_videostab248d.lib;%(AdditionalDependencies) + + + false + _DEBUG;%(PreprocessorDefinitions) + + + 0x0409 + _DEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Level3 + Use + MaxSpeed + true + true + WIN32;_WINDOWS;NDEBUG;_AFXEXT;%(PreprocessorDefinitions) + true + + + Windows + true + true + true + .\ocvclass.def + + + false + NDEBUG;%(PreprocessorDefinitions) + + + 0x0409 + NDEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + false + + + false + + + + + + + Create + Create + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/opencv_classes/ocvclasses/ocvclasses.vcxproj.filters b/opencv_classes/ocvclasses/ocvclasses.vcxproj.filters new file mode 100644 index 0000000..9b4907c --- /dev/null +++ b/opencv_classes/ocvclasses/ocvclasses.vcxproj.filters @@ -0,0 +1,55 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + + + Resource Files + + + \ No newline at end of file diff --git a/opencv_classes/ocvclasses/ocvclasses.vcxproj.user b/opencv_classes/ocvclasses/ocvclasses.vcxproj.user new file mode 100644 index 0000000..ef5ff2a --- /dev/null +++ b/opencv_classes/ocvclasses/ocvclasses.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/opencv_classes/ocvclasses/ocvclassesdll.cpp b/opencv_classes/ocvclasses/ocvclassesdll.cpp new file mode 100644 index 0000000..77017c8 --- /dev/null +++ b/opencv_classes/ocvclasses/ocvclassesdll.cpp @@ -0,0 +1,56 @@ + +#include "stdafx.h" +#include "ocvclassesdll.h" + +/////////////////////////////////////////////////// +TMat * __stdcall CreateMat() +{ + return new TMat(); +}; + +TMat * __stdcall CreateMatRCT(int rows, int cols, int type) +{ + return new TMat(rows, cols, type); +}; + +void __stdcall ReleaseMat(TMat * ex) +{ + delete ex; +}; + +////////////////////////////////////////////////// +TVideoCapture * __stdcall CreateVideoCapture() +{ + return new TVideoCapture(); +}; + +TVideoCapture * __stdcall CreateVideoCaptureDevice(int device) +{ + return new TVideoCapture(device); +}; + +TVideoCapture * __stdcall CreateVideoCaptureFileName(const char* filename) +{ + return new TVideoCapture(filename); +}; + +void __stdcall ReleaseVideoCapture(TVideoCapture * ex) +{ + delete ex; +}; + +//////////////////////////////////////////////// +TCvKNearest * __stdcall CreateCvKNearest() +{ + return new TCvKNearest(); +}; + +TCvKNearest * __stdcall CreateCvKNearestTR(CvMat* _trainData, CvMat* _responses, CvMat* _sampleIdx, BOOL _isRegression, int _max_k) +{ + return new TCvKNearest(_trainData, _responses, _sampleIdx, _isRegression, _max_k); +}; + +void __stdcall ReleaseCvKNearest(TCvKNearest * ex) +{ + delete ex; +}; \ No newline at end of file diff --git a/opencv_classes/ocvclasses/res/ocvclasses.rc2 b/opencv_classes/ocvclasses/res/ocvclasses.rc2 new file mode 100644 index 0000000..16b1732 Binary files /dev/null and b/opencv_classes/ocvclasses/res/ocvclasses.rc2 differ diff --git a/opencv_classes/ocvclasses/stdafx.cpp b/opencv_classes/ocvclasses/stdafx.cpp new file mode 100644 index 0000000..6bdd9fc --- /dev/null +++ b/opencv_classes/ocvclasses/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : source file that includes just the standard includes +// ocvclass.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + diff --git a/samples/opencv_classes/CvKNearest/cls2DPointClassification.dpr b/samples/opencv_classes/CvKNearest/cls2DPointClassification.dpr new file mode 100644 index 0000000..de274f5 --- /dev/null +++ b/samples/opencv_classes/CvKNearest/cls2DPointClassification.dpr @@ -0,0 +1,147 @@ +// ***************************************************************** +// Delphi-OpenCV Class Demo +// Copyright (C) 2013 Project Delphi-OpenCV +// **************************************************************** +// Contributor: +// laentir Valetov +// email:laex@bk.ru +// **************************************************************** +// You may retrieve the latest version of this file at the GitHub, +// located at git://github.com/Laex/Delphi-OpenCV.git +// **************************************************************** +// The contents of this file are used with permission, 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/MPL-1_1Final.html +// +// 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. +// ******************************************************************* +// Original: +// http://docs.opencv.org/modules/ml/doc/k_nearest_neighbors.html#cvknearest-is-regression +// ******************************************************************* + +program cls2DPointClassification; + +{$APPTYPE CONSOLE} +{$POINTERMATH ON} +{$R *.res} + +uses + System.SysUtils, + System.Classes, + Core.types_c, + core_c, + highgui_c, + ml; + +Const + K10: Integer = 10; + +Var + i, j, K, accuracy: Integer; + response: float; + train_sample_count: Integer = 100; + rng_state: TCvRNG; + trainData: pCvMat; + trainClasses: pCvMat; + img: pIplImage; + _sample: array [0 .. 1] of float; + sample: TCvMat; + trainData1, // + trainData2, // + trainClasses1, // + trainClasses2: TCvMat; + knn: TCvKNearest; + nearests: pCvMat; + t: TCvScalar; + pt: TCvPoint; + +begin + try + rng_state := CvRNG(-1); + trainData := cvCreateMat(train_sample_count, 2, CV_32FC1); + trainClasses := cvCreateMat(train_sample_count, 1, CV_32FC1); + img := cvCreateImage(cvSize(500, 500), 8, 3); + sample := CvMat(1, 2, CV_32FC1, @_sample); + cvZero(img); + // form the training samples + cvGetRows(trainData, @trainData1, 0, train_sample_count div 2); + cvRandArr(@rng_state, @trainData1, CV_RAND_NORMAL, cvScalar(200, 200), cvScalar(50, 50)); + + cvGetRows(trainData, @trainData2, train_sample_count div 2, train_sample_count); + cvRandArr(@rng_state, @trainData2, CV_RAND_NORMAL, cvScalar(300, 300), cvScalar(50, 50)); + + cvGetRows(trainClasses, @trainClasses1, 0, train_sample_count div 2); + cvSet(@trainClasses1, cvScalar(1)); + + cvGetRows(trainClasses, @trainClasses2, train_sample_count div 2, train_sample_count); + cvSet(@trainClasses2, cvScalar(2)); + + // learn classifier + knn := CreateCvKNearest(trainData, trainClasses, nil, false, K10); + nearests := cvCreateMat(1, K10, CV_32FC1); + + for i := 0 to img^.height - 1 do + begin + for j := 0 to img^.width - 1 do + begin + pFloat(sample.data)[0] := j; + pFloat(sample.data)[1] := i; + // estimate the response and get the neighbors' labels + response := knn.find_nearest(@sample, K10, nil, nil, nearests, nil); + + // compute the number of neighbors representing the majority + accuracy := 0; + for K := 0 to K10 - 1 do + begin + if (pFloat(nearests^.data)[K] = response) then + Inc(accuracy); + end; + // highlight the pixel depending on the accuracy (or confidence) + if response = 1 then + begin + if accuracy > 5 then + t := CV_RGB(180, 0, 0) + else + CV_RGB(180, 120, 0); + end + else + begin + if accuracy > 5 then + t := CV_RGB(0, 180, 0) + else + CV_RGB(120, 120, 0); + end; + cvSet2D(img, i, j, t); + end; + end; + + ReleaseCvKNearest(knn); + + // display the original training samples + for i := 0 to (train_sample_count div 2) - 1 do + begin + pt.x := cvRound(pFloat(trainData1.data)[i * 2]); + pt.y := cvRound(pFloat(trainData1.data)[i * 2 + 1]); + cvCircle(img, pt, 2, CV_RGB(255, 0, 0), CV_FILLED); + pt.x := cvRound(pFloat(trainData2.data)[i * 2]); + pt.y := cvRound(pFloat(trainData2.data)[i * 2 + 1]); + cvCircle(img, pt, 2, CV_RGB(0, 255, 0), CV_FILLED); + end; + + cvNamedWindow('classifier result', 1); + cvShowImage('classifier result', img); + cvWaitKey(0); + + cvReleaseMat(trainClasses); + cvReleaseMat(trainData); + except + on E: Exception do + WriteLn(E.ClassName, ': ', E.Message); + end; + +end. diff --git a/samples/opencv_classes/CvKNearest/cls2DPointClassification.dproj b/samples/opencv_classes/CvKNearest/cls2DPointClassification.dproj new file mode 100644 index 0000000..728a999 --- /dev/null +++ b/samples/opencv_classes/CvKNearest/cls2DPointClassification.dproj @@ -0,0 +1,170 @@ + + + {18754223-3415-44A1-BB17-A5574106F304} + cls2DPointClassification.dpr + True + Debug + 17 + Console + None + 15.3 + Win32 + + + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Cfg_2 + true + true + + + false + ..\..\..\bin\ + 1049 + true + 00400000 + System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace) + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=;CFBundleName=;CFBundleDisplayName=;UIDeviceFamily=;CFBundleIdentifier=;CFBundleVersion=;CFBundlePackageType=;CFBundleSignature=;CFBundleAllowMixedLocalizations=;UISupportedInterfaceOrientations=;CFBundleExecutable=;CFBundleResourceSpecification=;LSRequiresIPhoneOS=;CFBundleInfoDictionaryVersion=;CFBundleDevelopmentRegion=;package=;label=;versionCode=;versionName=;persistent=;restoreAnyVersion=;installLocation=;largeHeap=;theme= + false + None + false + false + false + + + Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) + 1033 + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= + + + 0 + 0 + false + RELEASE;$(DCC_Define) + + + DEBUG;$(DCC_Define) + true + false + + + 1033 + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= + None + + + + MainSource + + + Cfg_2 + Base + + + Base + + + Cfg_1 + Base + + + + Delphi.Personality.12 + + + + + cls2DPointClassification.dpr + + + False + False + 1 + 0 + 0 + 0 + False + False + False + False + False + 1049 + 1251 + + + + + 1.0.0.0 + + + + + + 1.0.0.0 + + + + + + + + + + + + + + + + + + + + + + + + + + + Microsoft Office 2000 Sample Automation Server Wrapper Components + Microsoft Office XP Sample Automation Server Wrapper Components + + + + True + False + True + False + + + 12 + + + + + + diff --git a/samples/opencv_classes/CvKNearest/cls2DPointClassification.res b/samples/opencv_classes/CvKNearest/cls2DPointClassification.res new file mode 100644 index 0000000..5e952b5 Binary files /dev/null and b/samples/opencv_classes/CvKNearest/cls2DPointClassification.res differ diff --git a/samples/opencv_classes/CvKNearest/clsKNN.dpr b/samples/opencv_classes/CvKNearest/clsKNN.dpr new file mode 100644 index 0000000..14cf22b --- /dev/null +++ b/samples/opencv_classes/CvKNearest/clsKNN.dpr @@ -0,0 +1,219 @@ +// ***************************************************************** +// Delphi-OpenCV Class Demo +// Copyright (C) 2013 Project Delphi-OpenCV +// **************************************************************** +// Contributor: +// laentir Valetov +// email:laex@bk.ru +// **************************************************************** +// You may retrieve the latest version of this file at the GitHub, +// located at git://github.com/Laex/Delphi-OpenCV.git +// **************************************************************** +// The contents of this file are used with permission, 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/MPL-1_1Final.html +// +// 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. +// ******************************************************************* +// Original: +// http://public.cranfield.ac.uk/c5354/teaching/ml/examples/c/knn_ex/ +// ******************************************************************* + +program clsKNN; + +{$APPTYPE CONSOLE} +{$POINTERMATH ON} +{$R *.res} + +uses + System.SysUtils, + System.Classes, + Core.types_c, + core_c, + ml; + +{ DEFINE Test } + +Const + CarTrain_FileName = 'resource\car.train'; +{$IFDEF Test} + CarTest_FileName = 'resource\car.test'; + NUMBER_OF_TESTING_SAMPLES = 345; +{$ELSE} + CarTest_FileName = 'resource\car.data'; + NUMBER_OF_TESTING_SAMPLES = 1728; +{$ENDIF} + ATTRIBUTES_PER_SAMPLE = 6; // not the last as this is the class + NUMBER_OF_CLASSES = 4; // classes 0->3 + Classes: array [0 .. NUMBER_OF_CLASSES - 1] of String = ('unacc', 'acc', 'good', 'vgood'); + NUMBER_OF_TRAINING_SAMPLES = 1383; + +function hash(str: AnsiString): Single; +Var + i, R: Integer; +begin + R := 5381; + for i := 1 to Length(str) do + R := (R shl 5) + R + ord(str[i]); + Result := R; +end; + +function read_data_from_csv(const filename: String; Var data, _classes: TCvMat): Boolean; +var + i, line, attribute: Integer; + S: TStringList; + Sp: TStringList; +begin + if not FileExists(filename) then + begin + WriteLn('ERROR: cannot read file ', filename); + Exit(False); // all not OK + end; + S := TStringList.Create; + Sp := TStringList.Create; + try + S.LoadFromFile(filename); + // for each sample in the file + for line := 0 to S.Count - 1 do + begin + Sp.CommaText := S[line]; + // for each attribute on the line in the file + for attribute := 0 to Sp.Count - 1 do + if attribute = 6 then + // last attribute is the class + begin + // find the class number and record this + for i := 0 to NUMBER_OF_CLASSES - 1 do + if SameText(Classes[i], Sp[attribute]) then + PSingle(CV_MAT_ELEM(_classes, CV_32FC1, line, 0))^ := i; + end + else + // for all other attributes just read in the string value + // and use a hash function to convert to to a float + // (N.B. openCV uses a floating point decision tree implementation!) + begin + PSingle(CV_MAT_ELEM(data, CV_32FC1, line, attribute))^ := hash(AnsiString(Sp[attribute])); + end; + end; + finally + S.Free; + Sp.Free; + end; + Result := True; +end; + +Var + k, i: Integer; + training_data, // + training_classifications: pCvMat; + testing_data, // + testing_classifications: pCvMat; + + var_type: pCvMat; + resultNode: Float; // node returned from a prediction + knn: TCvKNearest; + tsample: Integer; + test_sample: TCvMat; + + correct_class: Integer; + wrong_class: Integer; + false_positives: array [0 .. NUMBER_OF_CLASSES - 1] of Integer; + +begin + try + // lets just check the version first + // WriteLn(Format('OpenCV version %s (%d.%d.%d)', [CV_VERSION, CV_MAJOR_VERSION, CV_MINOR_VERSION,CV_SUBMINOR_VERSION]); + k := 10; + // define training data storage matrices (one for attribute examples, one + // for classifications) + training_data := cvCreateMat(NUMBER_OF_TRAINING_SAMPLES, ATTRIBUTES_PER_SAMPLE, CV_32FC1); + training_classifications := cvCreateMat(NUMBER_OF_TRAINING_SAMPLES, 1, CV_32FC1); + // define testing data storage matrices + testing_data := cvCreateMat(NUMBER_OF_TESTING_SAMPLES, ATTRIBUTES_PER_SAMPLE, CV_32FC1); + testing_classifications := cvCreateMat(NUMBER_OF_TESTING_SAMPLES, 1, CV_32FC1); + + // define all the attributes as categorical (i.e. categories) + // alternatives are CV_VAR_CATEGORICAL or CV_VAR_ORDERED(=CV_VAR_NUMERICAL) + // that can be assigned on a per attribute basis + // this is a classification problem (i.e. predict a discrete number of class + // outputs) so also the last (+1) output var_type element to CV_VAR_CATEGORICAL + + var_type := cvCreateMat(ATTRIBUTES_PER_SAMPLE + 1, 1, CV_8U); + cvSet(var_type, cvScalarAll(CV_VAR_CATEGORICAL)); // all inputs are categorical + try + // load training and testing data sets + if read_data_from_csv(CarTrain_FileName, training_data^, training_classifications^) and + read_data_from_csv(CarTest_FileName, testing_data^, testing_classifications^) then + begin + + // train K-Nearest Neighbour classifier (using training data) + + WriteLn('Using training database: ', CarTrain_FileName); + knn := CreateCvKNearest; + + knn.train(training_data, training_classifications, nil, False, k); + + // perform classifier testing and report results + + correct_class := 0; + wrong_class := 0; + FillChar(false_positives, SizeOf(false_positives), 0); + WriteLn('Using testing database: ', CarTest_FileName); + + for tsample := 0 to NUMBER_OF_TESTING_SAMPLES - 1 do + begin + // extract a row from the testing matrix + cvGetRow(testing_data, @test_sample, tsample); + // run decision tree prediction + + resultNode := knn.find_nearest(@test_sample, k, nil, nil, nil); + + WriteLn(Format('Testing Sample %d -> class result %s', [tsample, Classes[Trunc(resultNode)]])); + + // if the prediction and the (true) testing classification are the same + // (N.B. openCV uses a floating point decision tree implementation!) + + if abs(resultNode - PSingle(CV_MAT_ELEM(testing_classifications^, CV_32FC1, tsample, 0))^) >= FLT_EPSILON then + begin + // if they differ more than floating point error => wrong class + Inc(wrong_class); + Inc(false_positives[Trunc(resultNode)]); + end + else + begin + // otherwise correct + Inc(correct_class); + end; + end; + + WriteLn(Format('Results on the testing database: %s'#13#10#9'Correct classification: %d (%4.2f%%)'#13#10#9 + 'Wrong classifications: %d (%4.2f%%)', + [CarTest_FileName, correct_class, correct_class * 100 / NUMBER_OF_TESTING_SAMPLES, wrong_class, wrong_class * 100 / NUMBER_OF_TESTING_SAMPLES])); + + for i := 0 to NUMBER_OF_CLASSES - 1 do + begin + WriteLn(Format(#9'Class %s false postives %d (%4.2f%%)', [Classes[i], false_positives[i], false_positives[i] * 100 / NUMBER_OF_TESTING_SAMPLES])); + end; + end; + finally + // free all memory + ReleaseCvKNearest(knn); + cvReleaseMat(training_data); + cvReleaseMat(training_classifications); + cvReleaseMat(testing_data); + cvReleaseMat(testing_classifications); + cvReleaseMat(var_type); + + WriteLn('Press Enter to Exit'); + Readln; + end; + except + on E: Exception do + WriteLn(E.ClassName, ': ', E.Message); + end; + +end. diff --git a/samples/opencv_classes/CvKNearest/clsKNN.dproj b/samples/opencv_classes/CvKNearest/clsKNN.dproj new file mode 100644 index 0000000..56d93a5 --- /dev/null +++ b/samples/opencv_classes/CvKNearest/clsKNN.dproj @@ -0,0 +1,170 @@ + + + {6822E0E3-69E6-4818-A2F5-2D778C63AE9A} + clsKNN.dpr + True + Debug + 17 + Console + None + 15.3 + Win32 + + + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Cfg_2 + true + true + + + false + ..\..\..\bin\ + 1049 + true + 00400000 + System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace) + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=;CFBundleName=;CFBundleDisplayName=;UIDeviceFamily=;CFBundleIdentifier=;CFBundleVersion=;CFBundlePackageType=;CFBundleSignature=;CFBundleAllowMixedLocalizations=;UISupportedInterfaceOrientations=;CFBundleExecutable=;CFBundleResourceSpecification=;LSRequiresIPhoneOS=;CFBundleInfoDictionaryVersion=;CFBundleDevelopmentRegion=;package=;label=;versionCode=;versionName=;persistent=;restoreAnyVersion=;installLocation=;largeHeap=;theme= + false + None + false + false + false + + + Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) + 1033 + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= + + + 0 + 0 + false + RELEASE;$(DCC_Define) + + + DEBUG;$(DCC_Define) + true + false + + + 1033 + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= + None + + + + MainSource + + + Cfg_2 + Base + + + Base + + + Cfg_1 + Base + + + + Delphi.Personality.12 + + + + + clsKNN.dpr + + + False + False + 1 + 0 + 0 + 0 + False + False + False + False + False + 1049 + 1251 + + + + + 1.0.0.0 + + + + + + 1.0.0.0 + + + + + + + + + + + + + + + + + + + + + + + + + + + Microsoft Office 2000 Sample Automation Server Wrapper Components + Microsoft Office XP Sample Automation Server Wrapper Components + + + + True + False + True + False + + + 12 + + + + + + diff --git a/samples/opencv_classes/CvKNearest/clsKNN.res b/samples/opencv_classes/CvKNearest/clsKNN.res new file mode 100644 index 0000000..5e952b5 Binary files /dev/null and b/samples/opencv_classes/CvKNearest/clsKNN.res differ diff --git a/samples/opencv_classes/TOCVMat/clsMat.dpr b/samples/opencv_classes/TOCVMat/clsMat.dpr new file mode 100644 index 0000000..d7dd132 --- /dev/null +++ b/samples/opencv_classes/TOCVMat/clsMat.dpr @@ -0,0 +1,101 @@ +// ***************************************************************** +// Delphi-OpenCV Demo +// Copyright (C) 2013 Project Delphi-OpenCV +// **************************************************************** +// Contributor: +// Laentir Valetov +// email:laex@bk.ru +// **************************************************************** +// You may retrieve the latest version of this file at the GitHub, +// located at git://github.com/Laex/Delphi-OpenCV.git +// **************************************************************** +// The contents of this file are used with permission, 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/MPL-1_1Final.html +// +// 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. +// ******************************************************************* + +program clsMat; + +{$APPTYPE CONSOLE} +{$POINTERMATH ON} +{$R *.res} + +uses + System.SysUtils, + Core.types_c, + core_c, + mat; + +procedure Print(const M: TOCVMat); + +Var + matdata: PByte; + +begin + Writeln('M = $', IntToHex(Integer(M), 8)); + With M do + begin + Writeln('elemSize = ', elemSize); + Writeln('elemSize1 = ', elemSize1); + Writeln('type = ', _type); + Writeln('depth = ', depth); + Writeln('channels = ', channels); + Writeln('empty = ', empty); + Writeln('total = ', total); + Writeln('flags = $', IntToHex(flags, 8)); + Writeln('dims = ', dims); + Writeln('rows = ', rows); + Writeln('cols = ', cols); + Writeln('data = $', IntToHex(Integer(data), 8)); + matdata := data; + if Assigned(matdata) then + Writeln('($', IntToHex(Integer(matdata^), 2), ')') + else + Writeln; + end; +end; + +Var + mat: TOCVMat; + +begin + try + Writeln('--------- Create empty MAT'); + mat := CreateMat; + Print(mat); + DestroyMat(mat); + Readln; + Writeln('--------- Create MAT 2x2 CV_8UC1 - 1 byte, 1 channel'); + mat := CreateMat(2, 2, CV_8UC1); + Print(mat); + DestroyMat(mat); + Readln; + Writeln('--------- Create MAT 4x2 CV_32FC2 - single (4-byte floating point), 2 channel'); + mat := CreateMat(4, 2, CV_32FC2); + Print(mat); + DestroyMat(mat); + Readln; + Writeln('--------- Create 2x2 MAT'); + mat := CreateMat(2, 2, CV_8UC1); + Print(mat); + DestroyMat(mat); + Readln; + Writeln('--------- Create 3x3 MAT'); + mat := CreateMat(3, 3, CV_8UC1); + Print(mat); + DestroyMat(mat); + Readln; + + except + on E: Exception do + Writeln(E.ClassName, ': ', E.Message); + end; + +end. diff --git a/samples/opencv_classes/TOCVMat/clsMat.dproj b/samples/opencv_classes/TOCVMat/clsMat.dproj new file mode 100644 index 0000000..c350c19 --- /dev/null +++ b/samples/opencv_classes/TOCVMat/clsMat.dproj @@ -0,0 +1,170 @@ + + + {4354743C-AB35-4447-AFCE-DBE2CA117163} + clsMat.dpr + True + Debug + 17 + Console + None + 15.3 + Win32 + + + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Cfg_2 + true + true + + + false + ..\..\..\bin\ + 1049 + true + 00400000 + System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace) + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=;CFBundleName=;CFBundleDisplayName=;UIDeviceFamily=;CFBundleIdentifier=;CFBundleVersion=;CFBundlePackageType=;CFBundleSignature=;CFBundleAllowMixedLocalizations=;UISupportedInterfaceOrientations=;CFBundleExecutable=;CFBundleResourceSpecification=;LSRequiresIPhoneOS=;CFBundleInfoDictionaryVersion=;CFBundleDevelopmentRegion=;package=;label=;versionCode=;versionName=;persistent=;restoreAnyVersion=;installLocation=;largeHeap=;theme= + false + None + false + false + false + + + Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) + 1033 + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= + + + 0 + 0 + false + RELEASE;$(DCC_Define) + + + DEBUG;$(DCC_Define) + true + false + + + 1033 + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= + None + + + + MainSource + + + Cfg_2 + Base + + + Base + + + Cfg_1 + Base + + + + Delphi.Personality.12 + + + + + clsMat.dpr + + + False + False + 1 + 0 + 0 + 0 + False + False + False + False + False + 1049 + 1251 + + + + + 1.0.0.0 + + + + + + 1.0.0.0 + + + + + + + + + + + + + + + + + + + + + + + + + + + Microsoft Office 2000 Sample Automation Server Wrapper Components + Microsoft Office XP Sample Automation Server Wrapper Components + + + + True + False + True + False + + + 12 + + + + + + diff --git a/samples/opencv_classes/TOCVMat/clsMat.res b/samples/opencv_classes/TOCVMat/clsMat.res new file mode 100644 index 0000000..5e952b5 Binary files /dev/null and b/samples/opencv_classes/TOCVMat/clsMat.res differ diff --git a/samples/opencv_classes/TOCVVideoCapture/clsVideoCapture.dpr b/samples/opencv_classes/TOCVVideoCapture/clsVideoCapture.dpr new file mode 100644 index 0000000..62faab4 --- /dev/null +++ b/samples/opencv_classes/TOCVVideoCapture/clsVideoCapture.dpr @@ -0,0 +1,100 @@ +// ***************************************************************** +// Delphi-OpenCV Demo +// Copyright (C) 2013 Project Delphi-OpenCV +// **************************************************************** +// Contributor: +// Laentir Valetov +// email:laex@bk.ru +// **************************************************************** +// You may retrieve the latest version of this file at the GitHub, +// located at git://github.com/Laex/Delphi-OpenCV.git +// **************************************************************** +// The contents of this file are used with permission, 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/MPL-1_1Final.html +// +// 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. +// ******************************************************************* + +program clsVideoCapture; + +{$APPTYPE CONSOLE} +{$POINTERMATH ON} +{$R *.res} + +uses + System.SysUtils, + mat, + highgui, + highgui_c; + +Const + VK_ESCAPE = 27; + + DESIRED_CAMERA_WIDTH: Integer = 320; + DESIRED_CAMERA_HEIGHT: Integer = 200; + + windowName = 'Test VideoCapture'; // Name shown in the GUI window. + + // Get access to the webcam. +procedure initWebcam(videoCapture: TOCVVideoCapture; cameraNumber: Integer = CV_CAP_ANY); +begin + // Get access to the default camera. + // Surround the OpenCV call by a try/catch block so we can give a useful error message! + videoCapture.open(cameraNumber); + if not videoCapture.isOpened() then + begin + Writeln('ERROR: Could not access the camera!'); + Halt(1); + end; + Writeln('Loaded camera ', cameraNumber); +end; + +Var + cameraNumber: Integer = CV_CAP_ANY; + camera: TOCVVideoCapture; + cameraFrame: TOCVMat = nil; + +begin + try + camera := CreateVideoCapture(); + initWebcam(camera, cameraNumber); + // Try to set the camera resolution. Note that this only works for some cameras on + // some computers and only for some drivers, so don't rely on it to work! + camera.setValue(CV_CAP_PROP_FRAME_WIDTH, DESIRED_CAMERA_WIDTH); + camera.setValue(CV_CAP_PROP_FRAME_HEIGHT, DESIRED_CAMERA_HEIGHT); + // Create a GUI window for display on the screen. + namedWindow(windowName); // Resizable window, might not work on Windows. + // Run forever, until the user hits Escape to "break" out of this loop. + while true do + begin + // Grab the next camera frame. Note that you can't modify camera frames. + if camera.read(cameraFrame) then + begin + if Assigned(cameraFrame) and (cameraFrame.empty()) then + begin + Writeln('ERROR: Couldn''t grab the next camera frame.'); + Halt(1); + end; + if Assigned(cameraFrame) then + imshow(windowName, cameraFrame); + end; + // IMPORTANT: Wait for atleast 20 milliseconds, so that the image can be displayed on the screen! + if (waitKey(20) = VK_ESCAPE) then // Escape Key + break; // Quit the program! + end; + + camera.release; + + cvDestroyAllWindows; + except + on E: Exception do + Writeln(E.ClassName, ': ', E.Message); + end; + +end. diff --git a/samples/opencv_classes/TOCVVideoCapture/clsVideoCapture.dproj b/samples/opencv_classes/TOCVVideoCapture/clsVideoCapture.dproj new file mode 100644 index 0000000..cbcd9f9 --- /dev/null +++ b/samples/opencv_classes/TOCVVideoCapture/clsVideoCapture.dproj @@ -0,0 +1,170 @@ + + + {C63D42FE-D135-473C-A773-6EFDE83EAE78} + clsVideoCapture.dpr + True + Debug + 17 + Console + None + 15.3 + Win32 + + + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Cfg_2 + true + true + + + System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace) + true + false + ..\..\..\bin\ + false + 00400000 + false + false + 1049 + None + false + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=;CFBundleName=;CFBundleDisplayName=;UIDeviceFamily=;CFBundleIdentifier=;CFBundleVersion=;CFBundlePackageType=;CFBundleSignature=;CFBundleAllowMixedLocalizations=;UISupportedInterfaceOrientations=;CFBundleExecutable=;CFBundleResourceSpecification=;LSRequiresIPhoneOS=;CFBundleInfoDictionaryVersion=;CFBundleDevelopmentRegion=;package=;label=;versionCode=;versionName=;persistent=;restoreAnyVersion=;installLocation=;largeHeap=;theme= + + + Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= + 1033 + + + RELEASE;$(DCC_Define) + 0 + false + 0 + + + DEBUG;$(DCC_Define) + true + false + + + None + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= + 1033 + + + + MainSource + + + Cfg_2 + Base + + + Base + + + Cfg_1 + Base + + + + Delphi.Personality.12 + + + + + clsVideoCapture.dpr + + + False + False + 1 + 0 + 0 + 0 + False + False + False + False + False + 1049 + 1251 + + + + + 1.0.0.0 + + + + + + 1.0.0.0 + + + + + + + + + + + + + + + + + + + + + + + + + + + Microsoft Office 2000 Sample Automation Server Wrapper Components + Microsoft Office XP Sample Automation Server Wrapper Components + + + + True + False + True + False + + + 12 + + + + + + diff --git a/samples/opencv_classes/TOCVVideoCapture/clsVideoCapture.res b/samples/opencv_classes/TOCVVideoCapture/clsVideoCapture.res new file mode 100644 index 0000000..5e952b5 Binary files /dev/null and b/samples/opencv_classes/TOCVVideoCapture/clsVideoCapture.res differ