From f9d1e57a2b42a6d1081466e69ce44e3ba42a7e25 Mon Sep 17 00:00:00 2001 From: shimat Date: Mon, 3 Feb 2014 19:40:47 +0900 Subject: [PATCH 01/29] Added struct tuples for Mat's indexer --- src/OpenCvSharp/Src/DisposableCvObject.cs | 2 +- src/OpenCvSharpExtern/core_Mat.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenCvSharp/Src/DisposableCvObject.cs b/src/OpenCvSharp/Src/DisposableCvObject.cs index c07d74ad5..be18a88b0 100644 --- a/src/OpenCvSharp/Src/DisposableCvObject.cs +++ b/src/OpenCvSharp/Src/DisposableCvObject.cs @@ -1,5 +1,5 @@ /* - * (C) 2008-2013 Schima + * (C) 2008-2014 shimat * This code is licenced under the LGPL. */ diff --git a/src/OpenCvSharpExtern/core_Mat.h b/src/OpenCvSharpExtern/core_Mat.h index 26e24e48c..92eb8fb72 100644 --- a/src/OpenCvSharpExtern/core_Mat.h +++ b/src/OpenCvSharpExtern/core_Mat.h @@ -1,5 +1,5 @@ /* -* (C) 2008-2014 Schima +* (C) 2008-2014 shimat * This code is licenced under the LGPL. */ From e540634fddf8e963ab1f00d4d55f3834f1dec777 Mon Sep 17 00:00:00 2001 From: shimat Date: Mon, 3 Feb 2014 20:04:07 +0900 Subject: [PATCH 02/29] Added cast operators from Mat to IplImage/CvMat --- src/OpenCvSharp/OpenCvSharp.csproj | 1 - src/OpenCvSharpExtern/core_Mat.h | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/OpenCvSharp/OpenCvSharp.csproj b/src/OpenCvSharp/OpenCvSharp.csproj index d286c835d..7d91bc639 100644 --- a/src/OpenCvSharp/OpenCvSharp.csproj +++ b/src/OpenCvSharp/OpenCvSharp.csproj @@ -397,7 +397,6 @@ - diff --git a/src/OpenCvSharpExtern/core_Mat.h b/src/OpenCvSharpExtern/core_Mat.h index 92eb8fb72..3e5efe024 100644 --- a/src/OpenCvSharpExtern/core_Mat.h +++ b/src/OpenCvSharpExtern/core_Mat.h @@ -430,4 +430,21 @@ CVAPI(uchar*) core_Mat_ptrnd(cv::Mat *self, int *idx) #pragma endregion +#pragma region Operators + +CVAPI(void) core_Mat_IplImage(cv::Mat *self, IplImage *outImage) +{ + *outImage = IplImage(); + IplImage inImage = (IplImage)(*self); + memcpy(outImage, &inImage, sizeof(IplImage)); +} +CVAPI(void) core_Mat_CvMat(cv::Mat *self, CvMat *outMat) +{ + *outMat = CvMat(); + CvMat inMat = (CvMat)(*self); + memcpy(outMat, &inMat, sizeof(CvMat)); +} + +#pragma endregion + #endif \ No newline at end of file From 9cefe48fbff2d6d0642aaa0555912d4f1f7ff60b Mon Sep 17 00:00:00 2001 From: shimat Date: Mon, 3 Feb 2014 21:58:09 +0900 Subject: [PATCH 03/29] Changed Mat subclass name From dfd11bf678863aac9125338d99de0b47f61f179a Mon Sep 17 00:00:00 2001 From: shimat Date: Mon, 3 Feb 2014 22:25:01 +0900 Subject: [PATCH 04/29] Changed Tuple's name From 3061692d72f4f59bd29d86b2449c8a13e24b0aed Mon Sep 17 00:00:00 2001 From: shimat Date: Mon, 3 Feb 2014 22:34:23 +0900 Subject: [PATCH 05/29] Updated NuGet specs --- nuget/OpenCvSharp-x64.nuspec | 2 +- nuget/OpenCvSharp-x86.nuspec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nuget/OpenCvSharp-x64.nuspec b/nuget/OpenCvSharp-x64.nuspec index 6c826f746..0c04417d7 100644 --- a/nuget/OpenCvSharp-x64.nuspec +++ b/nuget/OpenCvSharp-x64.nuspec @@ -2,7 +2,7 @@ OpenCvSharp-x64 - 2.4.8.20140131 + 2.4.8.20140203 OpenCvSharp x64 shimat http://www.gnu.org/licenses/lgpl-3.0.en.html diff --git a/nuget/OpenCvSharp-x86.nuspec b/nuget/OpenCvSharp-x86.nuspec index ecd70d433..599bc63dc 100644 --- a/nuget/OpenCvSharp-x86.nuspec +++ b/nuget/OpenCvSharp-x86.nuspec @@ -2,7 +2,7 @@ OpenCvSharp-x86 - 2.4.8.20140131 + 2.4.8.20140203 OpenCvSharp x86 shimat http://www.gnu.org/licenses/lgpl-3.0.en.html From 7466f0e6fecb18476376250430abff4e4e42328a Mon Sep 17 00:00:00 2001 From: shimat Date: Tue, 4 Feb 2014 00:01:18 +0900 Subject: [PATCH 06/29] Added Mat/MatExpr operators (not implemented) --- src/OpenCvSharp.SandBoxCpp/AssemblyInfo.cpp | 38 +++++++ .../OpenCvSharp.SandBoxCpp.cpp | 42 +++++++ .../OpenCvSharp.SandBoxCpp.vcxproj | 104 ++++++++++++++++++ .../OpenCvSharp.SandBoxCpp.vcxproj.filters | 49 +++++++++ src/OpenCvSharp.SandBoxCpp/ReadMe.txt | 26 +++++ src/OpenCvSharp.SandBoxCpp/app.ico | Bin 0 -> 11001 bytes src/OpenCvSharp.SandBoxCpp/app.rc | Bin 0 -> 2452 bytes src/OpenCvSharp.SandBoxCpp/resource.h | 3 + src/OpenCvSharp.SandBoxCpp/stdafx.cpp | 7 ++ src/OpenCvSharp.SandBoxCpp/stdafx.h | 9 ++ src/OpenCvSharp.sln | 30 ++++- 11 files changed, 307 insertions(+), 1 deletion(-) create mode 100644 src/OpenCvSharp.SandBoxCpp/AssemblyInfo.cpp create mode 100644 src/OpenCvSharp.SandBoxCpp/OpenCvSharp.SandBoxCpp.cpp create mode 100644 src/OpenCvSharp.SandBoxCpp/OpenCvSharp.SandBoxCpp.vcxproj create mode 100644 src/OpenCvSharp.SandBoxCpp/OpenCvSharp.SandBoxCpp.vcxproj.filters create mode 100644 src/OpenCvSharp.SandBoxCpp/ReadMe.txt create mode 100644 src/OpenCvSharp.SandBoxCpp/app.ico create mode 100644 src/OpenCvSharp.SandBoxCpp/app.rc create mode 100644 src/OpenCvSharp.SandBoxCpp/resource.h create mode 100644 src/OpenCvSharp.SandBoxCpp/stdafx.cpp create mode 100644 src/OpenCvSharp.SandBoxCpp/stdafx.h diff --git a/src/OpenCvSharp.SandBoxCpp/AssemblyInfo.cpp b/src/OpenCvSharp.SandBoxCpp/AssemblyInfo.cpp new file mode 100644 index 000000000..e7f303fc3 --- /dev/null +++ b/src/OpenCvSharp.SandBoxCpp/AssemblyInfo.cpp @@ -0,0 +1,38 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// ƒAƒZƒ“ƒuƒŠ‚ÉŠÖ‚·‚éˆê”Êî•ñ‚͈ȉº‚Ì‘®«ƒZƒbƒg‚ð‚Æ‚¨‚µ‚ħŒä‚³‚ê‚Ü‚·B +// ƒAƒZƒ“ƒuƒŠ‚ÉŠÖ˜A•t‚¯‚ç‚ê‚Ä‚¢‚éî•ñ‚ð•ÏX‚·‚é‚É‚ÍA +// ‚±‚ê‚ç‚Ì‘®«’l‚ð•ÏX‚µ‚Ä‚­‚¾‚³‚¢B +// +[assembly:AssemblyTitleAttribute(L"OpenCvSharpSandBoxCpp")]; +[assembly:AssemblyDescriptionAttribute(L"")]; +[assembly:AssemblyConfigurationAttribute(L"")]; +[assembly:AssemblyCompanyAttribute(L"")]; +[assembly:AssemblyProductAttribute(L"OpenCvSharpSandBoxCpp")]; +[assembly:AssemblyCopyrightAttribute(L"Copyright (c) 2014")]; +[assembly:AssemblyTrademarkAttribute(L"")]; +[assembly:AssemblyCultureAttribute(L"")]; + +// +// ƒAƒZƒ“ƒuƒŠ‚̃o[ƒWƒ‡ƒ“î•ñ‚ÍAˆÈ‰º‚Ì 4 ‚‚̒l‚Å\¬‚³‚ê‚Ä‚¢‚Ü‚·: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// ‚·‚ׂĂ̒l‚ðŽw’è‚·‚é‚©A‰º‚̂悤‚É '*' ‚ðŽg‚Á‚ăŠƒrƒWƒ‡ƒ“‚¨‚æ‚уrƒ‹ƒh”Ô†‚ð +// Šù’è’l‚É‚·‚邱‚Æ‚ª‚Å‚«‚Ü‚·: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; \ No newline at end of file diff --git a/src/OpenCvSharp.SandBoxCpp/OpenCvSharp.SandBoxCpp.cpp b/src/OpenCvSharp.SandBoxCpp/OpenCvSharp.SandBoxCpp.cpp new file mode 100644 index 000000000..435908a18 --- /dev/null +++ b/src/OpenCvSharp.SandBoxCpp/OpenCvSharp.SandBoxCpp.cpp @@ -0,0 +1,42 @@ +#include "stdafx.h" + +using namespace System; + +struct U8C3 +{ + uchar b, g, r; +}; + +// For researching native OpenCV behaviour +int main(array ^args) +{ + cv::Mat mat1 = cv::imread("C:\\Lenna.png", CV_LOAD_IMAGE_COLOR); + cv::Mat mat2 = cv::imread("C:\\Lenna.png", CV_LOAD_IMAGE_COLOR); + + for (auto it = mat1.begin(); it != mat1.end(); it++) + { + U8C3 elem = *it; + std::swap(elem.b, elem.r); + *it = elem; + } + + cv::Mat eql = (mat1 == mat2); + cv::Mat channels[3]; + cv::split(eql, channels); + + //std::cout << "b: " << cv::countNonZero(channels[0]) << std::endl; + //std::cout << "g: " << cv::countNonZero(channels[1]) << std::endl; + //std::cout << "r: " << cv::countNonZero(channels[2]) << std::endl; + std::cout << "sum: " << cv::sum(eql) << std::endl; + std::cout << "total: " << eql.total() * 255 << std::endl; + std::cout << "equals: " << (cv::sum(eql)[0] == (eql.total() * 255)) << std::endl; + + cv::Scalar sc; + std::cout << "abs: " << cv::trace(mat1 - mat2) << std::endl; + + //cv::imshow("window", abs); + //cv::waitKey(); + + getchar(); + return 0; +} diff --git a/src/OpenCvSharp.SandBoxCpp/OpenCvSharp.SandBoxCpp.vcxproj b/src/OpenCvSharp.SandBoxCpp/OpenCvSharp.SandBoxCpp.vcxproj new file mode 100644 index 000000000..067af3d3c --- /dev/null +++ b/src/OpenCvSharp.SandBoxCpp/OpenCvSharp.SandBoxCpp.vcxproj @@ -0,0 +1,104 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {6842DAB4-4808-4D24-B2BB-5EEC0E40F2D0} + v4.0 + ManagedCProj + OpenCvSharpSandBoxCpp + + + + Application + true + v120 + true + Unicode + + + Application + false + v100 + true + Unicode + + + + + + + + + + + + + true + + + false + + + + Level3 + Disabled + WIN32;_DEBUG;%(PreprocessorDefinitions) + Use + + + true + + Console + + + + + Level3 + WIN32;NDEBUG;%(PreprocessorDefinitions) + Use + + + true + opencv_calib3d248.lib;opencv_contrib248.lib;opencv_core248.lib;opencv_features2d248.lib;opencv_flann248.lib;opencv_highgui248.lib;opencv_imgproc248.lib;opencv_legacy248.lib;opencv_ml248.lib;opencv_nonfree248.lib;opencv_objdetect248.lib;opencv_photo248.lib;opencv_stitching248.lib;opencv_superres248.lib;opencv_video248.lib;opencv_videostab248.lib;%(AdditionalDependencies) + Console + + + + + + + + + + + + + + + + + + + + + + Create + Create + + + + + + + + + \ No newline at end of file diff --git a/src/OpenCvSharp.SandBoxCpp/OpenCvSharp.SandBoxCpp.vcxproj.filters b/src/OpenCvSharp.SandBoxCpp/OpenCvSharp.SandBoxCpp.vcxproj.filters new file mode 100644 index 000000000..aea1a346f --- /dev/null +++ b/src/OpenCvSharp.SandBoxCpp/OpenCvSharp.SandBoxCpp.vcxproj.filters @@ -0,0 +1,49 @@ + + + + + {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 + + + + + + + + ヘッダー ファイル + + + ヘッダー ファイル + + + + + リソース ファイル + + + + + ソース ファイル + + + ソース ファイル + + + ソース ファイル + + + + + リソース ファイル + + + \ No newline at end of file diff --git a/src/OpenCvSharp.SandBoxCpp/ReadMe.txt b/src/OpenCvSharp.SandBoxCpp/ReadMe.txt new file mode 100644 index 000000000..3b2605514 --- /dev/null +++ b/src/OpenCvSharp.SandBoxCpp/ReadMe.txt @@ -0,0 +1,26 @@ +======================================================================== + アプリケーション: OpenCvSharp.SandBoxCpp プロジェクトã®æ¦‚è¦ +======================================================================== + +ã“ã® OpenCvSharp.SandBoxCpp アプリケーションã¯ã€AppWizard ã«ã‚ˆã‚Šä½œæˆã•ã‚Œã¾ã—ãŸã€‚ + +ã“ã®ãƒ•ã‚¡ã‚¤ãƒ«ã«ã¯ã€OpenCvSharp.SandBoxCpp アプリケーションを構æˆã™ã‚‹å„ファイルã®å†…容ã®æ¦‚è¦ãŒå«ã¾ã‚Œã¦ã„ã¾ã™ã€‚ + +OpenCvSharp.SandBoxCpp.vcxproj + ã“ã‚Œã¯ã€ã‚¢ãƒ—リケーション ウィザードを使用ã—ã¦ç”Ÿæˆã•ã‚ŒãŸ VC++ プロジェクトã®ãƒ¡ã‚¤ãƒ³ プロジェクト ファイルã§ã™ã€‚ファイルを生æˆã—㟠Visual C++ ã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã«é–¢ã™ã‚‹æƒ…å ±ã¨ã€ã‚¢ãƒ—リケーション ウィザードã§é¸æŠžã•ã‚ŒãŸãƒ—ラットフォームã€æ§‹æˆã€ãŠã‚ˆã³ãƒ—ロジェクト機能ã«é–¢ã™ã‚‹æƒ…å ±ãŒå«ã¾ã‚Œã¦ã„ã¾ã™ã€‚ + +OpenCvSharp.SandBoxCpp.vcxproj.filters + ã“ã‚Œã¯ã€ã‚¢ãƒ—リケーション ウィザードã§ç”Ÿæˆã•ã‚ŒãŸ VC++ プロジェクトã®ãƒ•ã‚£ãƒ«ã‚¿ãƒ¼ ファイルã§ã™ã€‚ã“ã®ãƒ•ã‚¡ã‚¤ãƒ«ã«ã¯ã€ãƒ—ロジェクト内ã®ãƒ•ã‚¡ã‚¤ãƒ«ã¨ãƒ•ã‚£ãƒ«ã‚¿ãƒ¼ã¨ã®é–“ã®é–¢é€£ä»˜ã‘ã«é–¢ã™ã‚‹æƒ…å ±ãŒå«ã¾ã‚Œã¦ã„ã¾ã™ã€‚ã“ã®é–¢é€£ä»˜ã‘ã¯ã€ç‰¹å®šã®ãƒŽãƒ¼ãƒ‰ã§åŒæ§˜ã®æ‹¡å¼µå­ã‚’æŒã¤ãƒ•ã‚¡ã‚¤ãƒ«ã®ã‚°ãƒ«ãƒ¼ãƒ—化を示ã™ãŸã‚ã« IDE ã§ä½¿ç”¨ã•ã‚Œã¾ã™ (ãŸã¨ãˆã°ã€".cpp" ファイル㯠"ソース ファイル" フィルターã«é–¢é€£ä»˜ã‘られã¦ã„ã¾ã™)。 + +OpenCvSharp.SandBoxCpp.cpp + ã“ã‚Œã¯ã€ãƒ¡ã‚¤ãƒ³ã®ã‚¢ãƒ—リケーション ソース ファイルã§ã™ã€‚ + +AssemblyInfo.cpp + アセンブリ メタデータを変更ã™ã‚‹ã‚«ã‚¹ã‚¿ãƒ å±žæ€§ãŒå«ã¾ã‚Œã¦ã„ã¾ã™ã€‚ + +///////////////////////////////////////////////////////////////////////////// +ãã®ä»–ã®ãƒ¡ãƒ¢ : + +AppWizard ã§ã¯ "TODO:" を使用ã—ã¦ã€ãƒ¦ãƒ¼ã‚¶ãƒ¼ãŒè¿½åŠ ã¾ãŸã¯ã‚«ã‚¹ã‚¿ãƒžã‚¤ã‚ºã™ã‚‹å¿…è¦ã®ã‚るソース コードを示ã—ã¾ã™ã€‚ + +///////////////////////////////////////////////////////////////////////////// diff --git a/src/OpenCvSharp.SandBoxCpp/app.ico b/src/OpenCvSharp.SandBoxCpp/app.ico new file mode 100644 index 0000000000000000000000000000000000000000..d06d92b763b573936ea7ee8f9dde001bcd66128f GIT binary patch literal 11001 zcmZQzU}RutP*4y6(ku)wm>3w!7#J7?1R#73Mh1pBW(J@<15loWVFd>RLmLZ79>ULH zWnj?b1!@2SMg|3jV4&J*LNN6T3@d=@UW&rhD==gL^-fe{V9)@nR{&xMAO_hB20**9 zg9Zi$AYy1}fKWgZ$OPgBh64u<044r|5ySugAQlhBkO+W!@Pl#`@c%yww;aev z);<#WC;@;aJSdb$4o)m=LeYz?g^*fm%ERmhrE_2w0H<|WI&Z*f5l{vs2~5{u3P=K( zB&Bnhz270hUjH2;Kt2sK2aSf=19UAIkdf73TETf0wLAb8G9bVLp}-^~kOW~MaB^~D z`1t+lFzshIQjnswhH2NBjlhq!sd z33H7nSLDt;B=_S*Z^-i}W%pNn@l!{0@q_)A>$l2XR&J1-{*v*43}b@- z|Lc@Jz}@$_;&rt+Lks7iLAjTi>+1h4Q$H}{_Ft=C`?whnv5X=bhrqU%jN5;gRxzdQ zWKi%S8ok+bt;(mLA#DfII(*O)FoOGld!B-lK<;s+r-2|rPgg&ebxsLQpr(rg5IX=d zXs8wh8bD)HqhL^l0B~6A|0w?UA2`fMSBxI!gT;Q}Q0ISIVwgX1`Ja|{gUlYaACk^T z!ymQWgQbhn^f#LSX_*FK>1;Irjpje(GyqE%^rDgN2C?a7FU+1%`?05gSoqMI9&F){ z?w*mtA5@*e0dNd#sslvR(|VY_s8cKoU?(^rF9o5Jqo|Rd$t@FLc7ybj+O`4d8PyLd dtA|7Qk&}jy<9{Ia!`wj*O=&i!q;vx51pvcOoFo7M literal 0 HcmV?d00001 diff --git a/src/OpenCvSharp.SandBoxCpp/app.rc b/src/OpenCvSharp.SandBoxCpp/app.rc new file mode 100644 index 0000000000000000000000000000000000000000..e8f258de73b30a300f70dee131698001e1d18642 GIT binary patch literal 2452 zcmds3&r2Io5dQ3`6bk(Zq)XC6rDDb^^qgdu5ZpxZw-AtOlWjC4q6T`h(3{dr{{au; zUBpB2(0l&_|AJEJ)oW?}W}lNZBxxb1r95`uyve+IGxO&AvcG?2kb#F1>e$9US~%cS z!y$F6)E%IW*JyB+#|sV*kvwfb*;KohZD0LlOv+0MZ6T*yB?k`go5aUl;?dhn^49m-w;ig z#MWo|&J((4?aGdv(2HR#BnrwX5E)s%1NxlCD@?|-MmkMt&?pkmik<%7QpEcn$5hM+ ztsYd?iOJ#JTBN^KdYxk&ey3i^yivPFn?15ifOWn#i#$0*xhCjjp>|f!!IoM{wa9T- zA@-sxtM6dOt3dAS+qLWJ0!HHMsGeTZ*JvjX;$OYx8s6RWuw&m8DqL5{NREmB9n;Ln zF%8QyP2N{V)K0VW9j5yK1N!?->y*rX)2KAMKOeo9+F$v \ No newline at end of file diff --git a/src/OpenCvSharp.sln b/src/OpenCvSharp.sln index 6a19a4711..e642f5dc5 100644 --- a/src/OpenCvSharp.sln +++ b/src/OpenCvSharp.sln @@ -1,6 +1,8 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 +# Visual Studio 2013 +VisualStudioVersion = 12.0.30110.0 +MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenCvSharp.UserInterface", "OpenCvSharp.UserInterface\OpenCvSharp.UserInterface.csproj", "{DB12E2F1-1A50-4D12-A92F-4C3D705ECC1F}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenCvSharp.Extensions", "OpenCvSharp.Extensions\OpenCvSharp.Extensions.csproj", "{F1110C7B-46B1-4504-871E-135B57F9DE67}" @@ -27,6 +29,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenCvSharp.NUnitTest", "Op EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenCvSharp.Sandbox", "OpenCvSharp.Sandbox\OpenCvSharp.Sandbox.csproj", "{C76C33E0-6F2E-49DF-ABD2-02053CB4CCB5}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OpenCvSharp.SandBoxCpp", "OpenCvSharp.SandBoxCpp\OpenCvSharp.SandBoxCpp.vcxproj", "{6842DAB4-4808-4D24-B2BB-5EEC0E40F2D0}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -380,6 +384,30 @@ Global {C76C33E0-6F2E-49DF-ABD2-02053CB4CCB5}.Release|x64.ActiveCfg = Release|Any CPU {C76C33E0-6F2E-49DF-ABD2-02053CB4CCB5}.Release|x86.ActiveCfg = Release|x86 {C76C33E0-6F2E-49DF-ABD2-02053CB4CCB5}.Release|x86.Build.0 = Release|x86 + {6842DAB4-4808-4D24-B2BB-5EEC0E40F2D0}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {6842DAB4-4808-4D24-B2BB-5EEC0E40F2D0}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 + {6842DAB4-4808-4D24-B2BB-5EEC0E40F2D0}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {6842DAB4-4808-4D24-B2BB-5EEC0E40F2D0}.Debug|Win32.ActiveCfg = Debug|Win32 + {6842DAB4-4808-4D24-B2BB-5EEC0E40F2D0}.Debug|Win32.Build.0 = Debug|Win32 + {6842DAB4-4808-4D24-B2BB-5EEC0E40F2D0}.Debug|x64.ActiveCfg = Debug|Win32 + {6842DAB4-4808-4D24-B2BB-5EEC0E40F2D0}.Debug|x86.ActiveCfg = Debug|Win32 + {6842DAB4-4808-4D24-B2BB-5EEC0E40F2D0}.Debug|x86.Build.0 = Debug|Win32 + {6842DAB4-4808-4D24-B2BB-5EEC0E40F2D0}.Release JP|Any CPU.ActiveCfg = Release|Win32 + {6842DAB4-4808-4D24-B2BB-5EEC0E40F2D0}.Release JP|Mixed Platforms.ActiveCfg = Release|Win32 + {6842DAB4-4808-4D24-B2BB-5EEC0E40F2D0}.Release JP|Mixed Platforms.Build.0 = Release|Win32 + {6842DAB4-4808-4D24-B2BB-5EEC0E40F2D0}.Release JP|Win32.ActiveCfg = Release|Win32 + {6842DAB4-4808-4D24-B2BB-5EEC0E40F2D0}.Release JP|Win32.Build.0 = Release|Win32 + {6842DAB4-4808-4D24-B2BB-5EEC0E40F2D0}.Release JP|x64.ActiveCfg = Release|Win32 + {6842DAB4-4808-4D24-B2BB-5EEC0E40F2D0}.Release JP|x86.ActiveCfg = Release|Win32 + {6842DAB4-4808-4D24-B2BB-5EEC0E40F2D0}.Release JP|x86.Build.0 = Release|Win32 + {6842DAB4-4808-4D24-B2BB-5EEC0E40F2D0}.Release|Any CPU.ActiveCfg = Release|Win32 + {6842DAB4-4808-4D24-B2BB-5EEC0E40F2D0}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {6842DAB4-4808-4D24-B2BB-5EEC0E40F2D0}.Release|Mixed Platforms.Build.0 = Release|Win32 + {6842DAB4-4808-4D24-B2BB-5EEC0E40F2D0}.Release|Win32.ActiveCfg = Release|Win32 + {6842DAB4-4808-4D24-B2BB-5EEC0E40F2D0}.Release|Win32.Build.0 = Release|Win32 + {6842DAB4-4808-4D24-B2BB-5EEC0E40F2D0}.Release|x64.ActiveCfg = Release|Win32 + {6842DAB4-4808-4D24-B2BB-5EEC0E40F2D0}.Release|x86.ActiveCfg = Release|Win32 + {6842DAB4-4808-4D24-B2BB-5EEC0E40F2D0}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From de45d5941b72f4f03b4cc4441b892f345f4fa71c Mon Sep 17 00:00:00 2001 From: shimat Date: Tue, 4 Feb 2014 01:05:39 +0900 Subject: [PATCH 07/29] Changed project site of nuspec --- nuget/OpenCvSharp-x64.nuspec | 2 +- nuget/OpenCvSharp-x86.nuspec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nuget/OpenCvSharp-x64.nuspec b/nuget/OpenCvSharp-x64.nuspec index 0c04417d7..fde69d9bd 100644 --- a/nuget/OpenCvSharp-x64.nuspec +++ b/nuget/OpenCvSharp-x64.nuspec @@ -6,7 +6,7 @@ OpenCvSharp x64 shimat http://www.gnu.org/licenses/lgpl-3.0.en.html - http://code.google.com/p/opencvsharp/ + https://github.com/shimat/opencvsharp http://opencvsharp.googlecode.com/files/Lenna.ico false OpenCV wrapper for .NET Framework diff --git a/nuget/OpenCvSharp-x86.nuspec b/nuget/OpenCvSharp-x86.nuspec index 599bc63dc..0297319df 100644 --- a/nuget/OpenCvSharp-x86.nuspec +++ b/nuget/OpenCvSharp-x86.nuspec @@ -6,7 +6,7 @@ OpenCvSharp x86 shimat http://www.gnu.org/licenses/lgpl-3.0.en.html - http://code.google.com/p/opencvsharp/ + https://github.com/shimat/opencvsharp http://opencvsharp.googlecode.com/files/Lenna.ico false OpenCV wrapper for .NET Framework From e48a81ab9a03996ee96b9580fac022ebc480dd15 Mon Sep 17 00:00:00 2001 From: shimat Date: Tue, 4 Feb 2014 14:35:31 +0900 Subject: [PATCH 08/29] Added native cv::Mat -like submatrix accessors --- src/OpenCvSharp.SandBoxCpp/AssemblyInfo.cpp | 38 ----- .../OpenCvSharp.SandBoxCpp.cpp | 42 ------ .../OpenCvSharp.SandBoxCpp.vcxproj | 104 -------------- .../OpenCvSharp.SandBoxCpp.vcxproj.filters | 49 ------- src/OpenCvSharp.SandBoxCpp/ReadMe.txt | 26 ---- src/OpenCvSharp.SandBoxCpp/app.ico | Bin 11001 -> 0 bytes src/OpenCvSharp.SandBoxCpp/app.rc | Bin 2452 -> 0 bytes src/OpenCvSharp.SandBoxCpp/resource.h | 3 - src/OpenCvSharp.SandBoxCpp/stdafx.cpp | 7 - src/OpenCvSharp.SandBoxCpp/stdafx.h | 9 -- src/OpenCvSharp.sln | 30 +--- src/OpenCvSharp/Src/DisposableObject.cs | 2 +- src/OpenCvSharpExtern/core_Mat.h | 136 ++++++++++++++++++ src/OpenCvSharpExtern/core_MatExpr.h | 33 ++++- 14 files changed, 170 insertions(+), 309 deletions(-) delete mode 100644 src/OpenCvSharp.SandBoxCpp/AssemblyInfo.cpp delete mode 100644 src/OpenCvSharp.SandBoxCpp/OpenCvSharp.SandBoxCpp.cpp delete mode 100644 src/OpenCvSharp.SandBoxCpp/OpenCvSharp.SandBoxCpp.vcxproj delete mode 100644 src/OpenCvSharp.SandBoxCpp/OpenCvSharp.SandBoxCpp.vcxproj.filters delete mode 100644 src/OpenCvSharp.SandBoxCpp/ReadMe.txt delete mode 100644 src/OpenCvSharp.SandBoxCpp/app.ico delete mode 100644 src/OpenCvSharp.SandBoxCpp/app.rc delete mode 100644 src/OpenCvSharp.SandBoxCpp/resource.h delete mode 100644 src/OpenCvSharp.SandBoxCpp/stdafx.cpp delete mode 100644 src/OpenCvSharp.SandBoxCpp/stdafx.h diff --git a/src/OpenCvSharp.SandBoxCpp/AssemblyInfo.cpp b/src/OpenCvSharp.SandBoxCpp/AssemblyInfo.cpp deleted file mode 100644 index e7f303fc3..000000000 --- a/src/OpenCvSharp.SandBoxCpp/AssemblyInfo.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include "stdafx.h" - -using namespace System; -using namespace System::Reflection; -using namespace System::Runtime::CompilerServices; -using namespace System::Runtime::InteropServices; -using namespace System::Security::Permissions; - -// -// ƒAƒZƒ“ƒuƒŠ‚ÉŠÖ‚·‚éˆê”Êî•ñ‚͈ȉº‚Ì‘®«ƒZƒbƒg‚ð‚Æ‚¨‚µ‚ħŒä‚³‚ê‚Ü‚·B -// ƒAƒZƒ“ƒuƒŠ‚ÉŠÖ˜A•t‚¯‚ç‚ê‚Ä‚¢‚éî•ñ‚ð•ÏX‚·‚é‚É‚ÍA -// ‚±‚ê‚ç‚Ì‘®«’l‚ð•ÏX‚µ‚Ä‚­‚¾‚³‚¢B -// -[assembly:AssemblyTitleAttribute(L"OpenCvSharpSandBoxCpp")]; -[assembly:AssemblyDescriptionAttribute(L"")]; -[assembly:AssemblyConfigurationAttribute(L"")]; -[assembly:AssemblyCompanyAttribute(L"")]; -[assembly:AssemblyProductAttribute(L"OpenCvSharpSandBoxCpp")]; -[assembly:AssemblyCopyrightAttribute(L"Copyright (c) 2014")]; -[assembly:AssemblyTrademarkAttribute(L"")]; -[assembly:AssemblyCultureAttribute(L"")]; - -// -// ƒAƒZƒ“ƒuƒŠ‚̃o[ƒWƒ‡ƒ“î•ñ‚ÍAˆÈ‰º‚Ì 4 ‚‚̒l‚Å\¬‚³‚ê‚Ä‚¢‚Ü‚·: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// ‚·‚ׂĂ̒l‚ðŽw’è‚·‚é‚©A‰º‚̂悤‚É '*' ‚ðŽg‚Á‚ăŠƒrƒWƒ‡ƒ“‚¨‚æ‚уrƒ‹ƒh”Ô†‚ð -// Šù’è’l‚É‚·‚邱‚Æ‚ª‚Å‚«‚Ü‚·: - -[assembly:AssemblyVersionAttribute("1.0.*")]; - -[assembly:ComVisible(false)]; - -[assembly:CLSCompliantAttribute(true)]; \ No newline at end of file diff --git a/src/OpenCvSharp.SandBoxCpp/OpenCvSharp.SandBoxCpp.cpp b/src/OpenCvSharp.SandBoxCpp/OpenCvSharp.SandBoxCpp.cpp deleted file mode 100644 index 435908a18..000000000 --- a/src/OpenCvSharp.SandBoxCpp/OpenCvSharp.SandBoxCpp.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include "stdafx.h" - -using namespace System; - -struct U8C3 -{ - uchar b, g, r; -}; - -// For researching native OpenCV behaviour -int main(array ^args) -{ - cv::Mat mat1 = cv::imread("C:\\Lenna.png", CV_LOAD_IMAGE_COLOR); - cv::Mat mat2 = cv::imread("C:\\Lenna.png", CV_LOAD_IMAGE_COLOR); - - for (auto it = mat1.begin(); it != mat1.end(); it++) - { - U8C3 elem = *it; - std::swap(elem.b, elem.r); - *it = elem; - } - - cv::Mat eql = (mat1 == mat2); - cv::Mat channels[3]; - cv::split(eql, channels); - - //std::cout << "b: " << cv::countNonZero(channels[0]) << std::endl; - //std::cout << "g: " << cv::countNonZero(channels[1]) << std::endl; - //std::cout << "r: " << cv::countNonZero(channels[2]) << std::endl; - std::cout << "sum: " << cv::sum(eql) << std::endl; - std::cout << "total: " << eql.total() * 255 << std::endl; - std::cout << "equals: " << (cv::sum(eql)[0] == (eql.total() * 255)) << std::endl; - - cv::Scalar sc; - std::cout << "abs: " << cv::trace(mat1 - mat2) << std::endl; - - //cv::imshow("window", abs); - //cv::waitKey(); - - getchar(); - return 0; -} diff --git a/src/OpenCvSharp.SandBoxCpp/OpenCvSharp.SandBoxCpp.vcxproj b/src/OpenCvSharp.SandBoxCpp/OpenCvSharp.SandBoxCpp.vcxproj deleted file mode 100644 index 067af3d3c..000000000 --- a/src/OpenCvSharp.SandBoxCpp/OpenCvSharp.SandBoxCpp.vcxproj +++ /dev/null @@ -1,104 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {6842DAB4-4808-4D24-B2BB-5EEC0E40F2D0} - v4.0 - ManagedCProj - OpenCvSharpSandBoxCpp - - - - Application - true - v120 - true - Unicode - - - Application - false - v100 - true - Unicode - - - - - - - - - - - - - true - - - false - - - - Level3 - Disabled - WIN32;_DEBUG;%(PreprocessorDefinitions) - Use - - - true - - Console - - - - - Level3 - WIN32;NDEBUG;%(PreprocessorDefinitions) - Use - - - true - opencv_calib3d248.lib;opencv_contrib248.lib;opencv_core248.lib;opencv_features2d248.lib;opencv_flann248.lib;opencv_highgui248.lib;opencv_imgproc248.lib;opencv_legacy248.lib;opencv_ml248.lib;opencv_nonfree248.lib;opencv_objdetect248.lib;opencv_photo248.lib;opencv_stitching248.lib;opencv_superres248.lib;opencv_video248.lib;opencv_videostab248.lib;%(AdditionalDependencies) - Console - - - - - - - - - - - - - - - - - - - - - - Create - Create - - - - - - - - - \ No newline at end of file diff --git a/src/OpenCvSharp.SandBoxCpp/OpenCvSharp.SandBoxCpp.vcxproj.filters b/src/OpenCvSharp.SandBoxCpp/OpenCvSharp.SandBoxCpp.vcxproj.filters deleted file mode 100644 index aea1a346f..000000000 --- a/src/OpenCvSharp.SandBoxCpp/OpenCvSharp.SandBoxCpp.vcxproj.filters +++ /dev/null @@ -1,49 +0,0 @@ - - - - - {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 - - - - - - - - ヘッダー ファイル - - - ヘッダー ファイル - - - - - リソース ファイル - - - - - ソース ファイル - - - ソース ファイル - - - ソース ファイル - - - - - リソース ファイル - - - \ No newline at end of file diff --git a/src/OpenCvSharp.SandBoxCpp/ReadMe.txt b/src/OpenCvSharp.SandBoxCpp/ReadMe.txt deleted file mode 100644 index 3b2605514..000000000 --- a/src/OpenCvSharp.SandBoxCpp/ReadMe.txt +++ /dev/null @@ -1,26 +0,0 @@ -======================================================================== - アプリケーション: OpenCvSharp.SandBoxCpp プロジェクトã®æ¦‚è¦ -======================================================================== - -ã“ã® OpenCvSharp.SandBoxCpp アプリケーションã¯ã€AppWizard ã«ã‚ˆã‚Šä½œæˆã•ã‚Œã¾ã—ãŸã€‚ - -ã“ã®ãƒ•ã‚¡ã‚¤ãƒ«ã«ã¯ã€OpenCvSharp.SandBoxCpp アプリケーションを構æˆã™ã‚‹å„ファイルã®å†…容ã®æ¦‚è¦ãŒå«ã¾ã‚Œã¦ã„ã¾ã™ã€‚ - -OpenCvSharp.SandBoxCpp.vcxproj - ã“ã‚Œã¯ã€ã‚¢ãƒ—リケーション ウィザードを使用ã—ã¦ç”Ÿæˆã•ã‚ŒãŸ VC++ プロジェクトã®ãƒ¡ã‚¤ãƒ³ プロジェクト ファイルã§ã™ã€‚ファイルを生æˆã—㟠Visual C++ ã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã«é–¢ã™ã‚‹æƒ…å ±ã¨ã€ã‚¢ãƒ—リケーション ウィザードã§é¸æŠžã•ã‚ŒãŸãƒ—ラットフォームã€æ§‹æˆã€ãŠã‚ˆã³ãƒ—ロジェクト機能ã«é–¢ã™ã‚‹æƒ…å ±ãŒå«ã¾ã‚Œã¦ã„ã¾ã™ã€‚ - -OpenCvSharp.SandBoxCpp.vcxproj.filters - ã“ã‚Œã¯ã€ã‚¢ãƒ—リケーション ウィザードã§ç”Ÿæˆã•ã‚ŒãŸ VC++ プロジェクトã®ãƒ•ã‚£ãƒ«ã‚¿ãƒ¼ ファイルã§ã™ã€‚ã“ã®ãƒ•ã‚¡ã‚¤ãƒ«ã«ã¯ã€ãƒ—ロジェクト内ã®ãƒ•ã‚¡ã‚¤ãƒ«ã¨ãƒ•ã‚£ãƒ«ã‚¿ãƒ¼ã¨ã®é–“ã®é–¢é€£ä»˜ã‘ã«é–¢ã™ã‚‹æƒ…å ±ãŒå«ã¾ã‚Œã¦ã„ã¾ã™ã€‚ã“ã®é–¢é€£ä»˜ã‘ã¯ã€ç‰¹å®šã®ãƒŽãƒ¼ãƒ‰ã§åŒæ§˜ã®æ‹¡å¼µå­ã‚’æŒã¤ãƒ•ã‚¡ã‚¤ãƒ«ã®ã‚°ãƒ«ãƒ¼ãƒ—化を示ã™ãŸã‚ã« IDE ã§ä½¿ç”¨ã•ã‚Œã¾ã™ (ãŸã¨ãˆã°ã€".cpp" ファイル㯠"ソース ファイル" フィルターã«é–¢é€£ä»˜ã‘られã¦ã„ã¾ã™)。 - -OpenCvSharp.SandBoxCpp.cpp - ã“ã‚Œã¯ã€ãƒ¡ã‚¤ãƒ³ã®ã‚¢ãƒ—リケーション ソース ファイルã§ã™ã€‚ - -AssemblyInfo.cpp - アセンブリ メタデータを変更ã™ã‚‹ã‚«ã‚¹ã‚¿ãƒ å±žæ€§ãŒå«ã¾ã‚Œã¦ã„ã¾ã™ã€‚ - -///////////////////////////////////////////////////////////////////////////// -ãã®ä»–ã®ãƒ¡ãƒ¢ : - -AppWizard ã§ã¯ "TODO:" を使用ã—ã¦ã€ãƒ¦ãƒ¼ã‚¶ãƒ¼ãŒè¿½åŠ ã¾ãŸã¯ã‚«ã‚¹ã‚¿ãƒžã‚¤ã‚ºã™ã‚‹å¿…è¦ã®ã‚るソース コードを示ã—ã¾ã™ã€‚ - -///////////////////////////////////////////////////////////////////////////// diff --git a/src/OpenCvSharp.SandBoxCpp/app.ico b/src/OpenCvSharp.SandBoxCpp/app.ico deleted file mode 100644 index d06d92b763b573936ea7ee8f9dde001bcd66128f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 11001 zcmZQzU}RutP*4y6(ku)wm>3w!7#J7?1R#73Mh1pBW(J@<15loWVFd>RLmLZ79>ULH zWnj?b1!@2SMg|3jV4&J*LNN6T3@d=@UW&rhD==gL^-fe{V9)@nR{&xMAO_hB20**9 zg9Zi$AYy1}fKWgZ$OPgBh64u<044r|5ySugAQlhBkO+W!@Pl#`@c%yww;aev z);<#WC;@;aJSdb$4o)m=LeYz?g^*fm%ERmhrE_2w0H<|WI&Z*f5l{vs2~5{u3P=K( zB&Bnhz270hUjH2;Kt2sK2aSf=19UAIkdf73TETf0wLAb8G9bVLp}-^~kOW~MaB^~D z`1t+lFzshIQjnswhH2NBjlhq!sd z33H7nSLDt;B=_S*Z^-i}W%pNn@l!{0@q_)A>$l2XR&J1-{*v*43}b@- z|Lc@Jz}@$_;&rt+Lks7iLAjTi>+1h4Q$H}{_Ft=C`?whnv5X=bhrqU%jN5;gRxzdQ zWKi%S8ok+bt;(mLA#DfII(*O)FoOGld!B-lK<;s+r-2|rPgg&ebxsLQpr(rg5IX=d zXs8wh8bD)HqhL^l0B~6A|0w?UA2`fMSBxI!gT;Q}Q0ISIVwgX1`Ja|{gUlYaACk^T z!ymQWgQbhn^f#LSX_*FK>1;Irjpje(GyqE%^rDgN2C?a7FU+1%`?05gSoqMI9&F){ z?w*mtA5@*e0dNd#sslvR(|VY_s8cKoU?(^rF9o5Jqo|Rd$t@FLc7ybj+O`4d8PyLd dtA|7Qk&}jy<9{Ia!`wj*O=&i!q;vx51pvcOoFo7M diff --git a/src/OpenCvSharp.SandBoxCpp/app.rc b/src/OpenCvSharp.SandBoxCpp/app.rc deleted file mode 100644 index e8f258de73b30a300f70dee131698001e1d18642..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2452 zcmds3&r2Io5dQ3`6bk(Zq)XC6rDDb^^qgdu5ZpxZw-AtOlWjC4q6T`h(3{dr{{au; zUBpB2(0l&_|AJEJ)oW?}W}lNZBxxb1r95`uyve+IGxO&AvcG?2kb#F1>e$9US~%cS z!y$F6)E%IW*JyB+#|sV*kvwfb*;KohZD0LlOv+0MZ6T*yB?k`go5aUl;?dhn^49m-w;ig z#MWo|&J((4?aGdv(2HR#BnrwX5E)s%1NxlCD@?|-MmkMt&?pkmik<%7QpEcn$5hM+ ztsYd?iOJ#JTBN^KdYxk&ey3i^yivPFn?15ifOWn#i#$0*xhCjjp>|f!!IoM{wa9T- zA@-sxtM6dOt3dAS+qLWJ0!HHMsGeTZ*JvjX;$OYx8s6RWuw&m8DqL5{NREmB9n;Ln zF%8QyP2N{V)K0VW9j5yK1N!?->y*rX)2KAMKOeo9+F$v \ No newline at end of file diff --git a/src/OpenCvSharp.sln b/src/OpenCvSharp.sln index e642f5dc5..6a19a4711 100644 --- a/src/OpenCvSharp.sln +++ b/src/OpenCvSharp.sln @@ -1,8 +1,6 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.30110.0 -MinimumVisualStudioVersion = 10.0.40219.1 +# Visual Studio 2012 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenCvSharp.UserInterface", "OpenCvSharp.UserInterface\OpenCvSharp.UserInterface.csproj", "{DB12E2F1-1A50-4D12-A92F-4C3D705ECC1F}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenCvSharp.Extensions", "OpenCvSharp.Extensions\OpenCvSharp.Extensions.csproj", "{F1110C7B-46B1-4504-871E-135B57F9DE67}" @@ -29,8 +27,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenCvSharp.NUnitTest", "Op EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenCvSharp.Sandbox", "OpenCvSharp.Sandbox\OpenCvSharp.Sandbox.csproj", "{C76C33E0-6F2E-49DF-ABD2-02053CB4CCB5}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OpenCvSharp.SandBoxCpp", "OpenCvSharp.SandBoxCpp\OpenCvSharp.SandBoxCpp.vcxproj", "{6842DAB4-4808-4D24-B2BB-5EEC0E40F2D0}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -384,30 +380,6 @@ Global {C76C33E0-6F2E-49DF-ABD2-02053CB4CCB5}.Release|x64.ActiveCfg = Release|Any CPU {C76C33E0-6F2E-49DF-ABD2-02053CB4CCB5}.Release|x86.ActiveCfg = Release|x86 {C76C33E0-6F2E-49DF-ABD2-02053CB4CCB5}.Release|x86.Build.0 = Release|x86 - {6842DAB4-4808-4D24-B2BB-5EEC0E40F2D0}.Debug|Any CPU.ActiveCfg = Debug|Win32 - {6842DAB4-4808-4D24-B2BB-5EEC0E40F2D0}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 - {6842DAB4-4808-4D24-B2BB-5EEC0E40F2D0}.Debug|Mixed Platforms.Build.0 = Debug|Win32 - {6842DAB4-4808-4D24-B2BB-5EEC0E40F2D0}.Debug|Win32.ActiveCfg = Debug|Win32 - {6842DAB4-4808-4D24-B2BB-5EEC0E40F2D0}.Debug|Win32.Build.0 = Debug|Win32 - {6842DAB4-4808-4D24-B2BB-5EEC0E40F2D0}.Debug|x64.ActiveCfg = Debug|Win32 - {6842DAB4-4808-4D24-B2BB-5EEC0E40F2D0}.Debug|x86.ActiveCfg = Debug|Win32 - {6842DAB4-4808-4D24-B2BB-5EEC0E40F2D0}.Debug|x86.Build.0 = Debug|Win32 - {6842DAB4-4808-4D24-B2BB-5EEC0E40F2D0}.Release JP|Any CPU.ActiveCfg = Release|Win32 - {6842DAB4-4808-4D24-B2BB-5EEC0E40F2D0}.Release JP|Mixed Platforms.ActiveCfg = Release|Win32 - {6842DAB4-4808-4D24-B2BB-5EEC0E40F2D0}.Release JP|Mixed Platforms.Build.0 = Release|Win32 - {6842DAB4-4808-4D24-B2BB-5EEC0E40F2D0}.Release JP|Win32.ActiveCfg = Release|Win32 - {6842DAB4-4808-4D24-B2BB-5EEC0E40F2D0}.Release JP|Win32.Build.0 = Release|Win32 - {6842DAB4-4808-4D24-B2BB-5EEC0E40F2D0}.Release JP|x64.ActiveCfg = Release|Win32 - {6842DAB4-4808-4D24-B2BB-5EEC0E40F2D0}.Release JP|x86.ActiveCfg = Release|Win32 - {6842DAB4-4808-4D24-B2BB-5EEC0E40F2D0}.Release JP|x86.Build.0 = Release|Win32 - {6842DAB4-4808-4D24-B2BB-5EEC0E40F2D0}.Release|Any CPU.ActiveCfg = Release|Win32 - {6842DAB4-4808-4D24-B2BB-5EEC0E40F2D0}.Release|Mixed Platforms.ActiveCfg = Release|Win32 - {6842DAB4-4808-4D24-B2BB-5EEC0E40F2D0}.Release|Mixed Platforms.Build.0 = Release|Win32 - {6842DAB4-4808-4D24-B2BB-5EEC0E40F2D0}.Release|Win32.ActiveCfg = Release|Win32 - {6842DAB4-4808-4D24-B2BB-5EEC0E40F2D0}.Release|Win32.Build.0 = Release|Win32 - {6842DAB4-4808-4D24-B2BB-5EEC0E40F2D0}.Release|x64.ActiveCfg = Release|Win32 - {6842DAB4-4808-4D24-B2BB-5EEC0E40F2D0}.Release|x86.ActiveCfg = Release|Win32 - {6842DAB4-4808-4D24-B2BB-5EEC0E40F2D0}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/OpenCvSharp/Src/DisposableObject.cs b/src/OpenCvSharp/Src/DisposableObject.cs index 6cfbf7078..f46ba1a11 100644 --- a/src/OpenCvSharp/Src/DisposableObject.cs +++ b/src/OpenCvSharp/Src/DisposableObject.cs @@ -263,7 +263,7 @@ protected void NotifyMemoryPressure(long size) /// /// ã“ã®ã‚ªãƒ–ジェクトãŒè§£æ”¾æ¸ˆã¿ã®å ´åˆã¯ObjectDisposedExceptionを投ã’ã‚‹ /// - protected void ThrowIfDisposed() + public void ThrowIfDisposed() { if (IsDisposed) throw new ObjectDisposedException(GetType().FullName); diff --git a/src/OpenCvSharpExtern/core_Mat.h b/src/OpenCvSharpExtern/core_Mat.h index 3e5efe024..d0f3480a6 100644 --- a/src/OpenCvSharpExtern/core_Mat.h +++ b/src/OpenCvSharpExtern/core_Mat.h @@ -432,6 +432,19 @@ CVAPI(uchar*) core_Mat_ptrnd(cv::Mat *self, int *idx) #pragma region Operators +CVAPI(void) core_Mat_assignment_FromMat(cv::Mat *self, cv::Mat *newMat) +{ + *self = *newMat; +} +CVAPI(void) core_Mat_assignment_FromMatExpr(cv::Mat *self, cv::MatExpr *newMatExpr) +{ + *self = *newMatExpr; +} +CVAPI(void) core_Mat_assignment_FromScalar(cv::Mat *self, CvScalar scalar) +{ + *self = scalar; +} + CVAPI(void) core_Mat_IplImage(cv::Mat *self, IplImage *outImage) { *outImage = IplImage(); @@ -445,6 +458,129 @@ CVAPI(void) core_Mat_CvMat(cv::Mat *self, CvMat *outMat) memcpy(outMat, &inMat, sizeof(CvMat)); } +CVAPI(cv::MatExpr*) core_operatorAdd_MatMat(cv::Mat *a, cv::Mat *b) +{ + cv::MatExpr expr = (*a) + (*b); + return new cv::MatExpr(expr); +} +CVAPI(cv::MatExpr*) core_operatorAdd_MatScalar(cv::Mat *a, CvScalar s) +{ + cv::MatExpr expr = (*a) + cv::Scalar(s); + return new cv::MatExpr(expr); +} +CVAPI(cv::MatExpr*) core_operatorAdd_ScalarMat(CvScalar s, cv::Mat *a) +{ + cv::MatExpr expr = cv::Scalar(s) + (*a); + return new cv::MatExpr(expr); +} + +CVAPI(cv::MatExpr*) core_operatorMinus_Mat(cv::Mat *a) +{ + cv::MatExpr expr = -(*a); + return new cv::MatExpr(expr); +} +CVAPI(cv::MatExpr*) core_operatorSubtract_MatMat(cv::Mat *a, cv::Mat *b) +{ + cv::MatExpr expr = (*a) - (*b); + return new cv::MatExpr(expr); +} +CVAPI(cv::MatExpr*) core_operatorSubtract_MatScalar(cv::Mat *a, CvScalar s) +{ + cv::MatExpr expr = (*a) - cv::Scalar(s); + return new cv::MatExpr(expr); +} +CVAPI(cv::MatExpr*) core_operatorSubtract_ScalarMat(CvScalar s, cv::Mat *a) +{ + cv::MatExpr expr = cv::Scalar(s) - (*a); + return new cv::MatExpr(expr); +} + +CVAPI(cv::MatExpr*) core_operatorMultiply_MatMat(cv::Mat *a, cv::Mat *b) +{ + cv::MatExpr expr = (*a) * (*b); + return new cv::MatExpr(expr); +} +CVAPI(cv::MatExpr*) core_operatorMultiply_MatDouble(cv::Mat *a, double s) +{ + cv::MatExpr expr = (*a) * s; + return new cv::MatExpr(expr); +} +CVAPI(cv::MatExpr*) core_operatorMultiply_DoubleMat(double s, cv::Mat *a) +{ + cv::MatExpr expr = s * (*a); + return new cv::MatExpr(expr); +} + +CVAPI(cv::MatExpr*) core_operatorDivide_MatMat(cv::Mat *a, cv::Mat *b) +{ + cv::MatExpr expr = (*a) / (*b); + return new cv::MatExpr(expr); +} +CVAPI(cv::MatExpr*) core_operatorDivide_MatDouble(cv::Mat *a, double s) +{ + cv::MatExpr expr = (*a) / s; + return new cv::MatExpr(expr); +} +CVAPI(cv::MatExpr*) core_operatorDivide_DoubleMat(double s, cv::Mat *a) +{ + cv::MatExpr expr = s / (*a); + return new cv::MatExpr(expr); +} + +CVAPI(cv::MatExpr*) core_operatorAnd_MatMat(cv::Mat *a, cv::Mat *b) +{ + cv::MatExpr expr = (*a) & (*b); + return new cv::MatExpr(expr); +} +CVAPI(cv::MatExpr*) core_operatorAnd_MatDouble(cv::Mat *a, double s) +{ + cv::MatExpr expr = (*a) & s; + return new cv::MatExpr(expr); +} +CVAPI(cv::MatExpr*) core_operatorAnd_DoubleMat(double s, cv::Mat *a) +{ + cv::MatExpr expr = s & (*a); + return new cv::MatExpr(expr); +} + +CVAPI(cv::MatExpr*) core_operatorOr_MatMat(cv::Mat *a, cv::Mat *b) +{ + cv::MatExpr expr = (*a) | (*b); + return new cv::MatExpr(expr); +} +CVAPI(cv::MatExpr*) core_operatorOr_MatDouble(cv::Mat *a, double s) +{ + cv::MatExpr expr = (*a) | s; + return new cv::MatExpr(expr); +} +CVAPI(cv::MatExpr*) core_operatorOr_DoubleMat(double s, cv::Mat *a) +{ + cv::MatExpr expr = s | (*a); + return new cv::MatExpr(expr); +} + +CVAPI(cv::MatExpr*) core_operatorXor_MatMat(cv::Mat *a, cv::Mat *b) +{ + cv::MatExpr expr = (*a) ^ (*b); + return new cv::MatExpr(expr); +} +CVAPI(cv::MatExpr*) core_operatorXor_MatDouble(cv::Mat *a, double s) +{ + cv::MatExpr expr = (*a) ^ s; + return new cv::MatExpr(expr); +} +CVAPI(cv::MatExpr*) core_operatorXor_DoubleMat(double s, cv::Mat *a) +{ + cv::MatExpr expr = s ^ (*a); + return new cv::MatExpr(expr); +} + +CVAPI(cv::MatExpr*) core_operatorNot_Mat(cv::Mat *a) +{ + cv::MatExpr expr = ~(*a); + return new cv::MatExpr(expr); +} + #pragma endregion #endif \ No newline at end of file diff --git a/src/OpenCvSharpExtern/core_MatExpr.h b/src/OpenCvSharpExtern/core_MatExpr.h index 220f2c3a1..999e409b0 100644 --- a/src/OpenCvSharpExtern/core_MatExpr.h +++ b/src/OpenCvSharpExtern/core_MatExpr.h @@ -8,10 +8,14 @@ #include "include_opencv.h" -CVAPI(cv::MatExpr*) core_MatExpr_new() +CVAPI(cv::MatExpr*) core_MatExpr_new1() { return new cv::MatExpr(); } +CVAPI(cv::MatExpr*) core_MatExpr_new2(cv::Mat *mat) +{ + return new cv::MatExpr(*mat); +} CVAPI(void) core_MatExpr_delete(cv::MatExpr *expr) { delete expr; @@ -23,4 +27,31 @@ CVAPI(cv::Mat*) core_MatExpr_toMat(cv::MatExpr *expr) return new cv::Mat(ret); } + +CVAPI(cv::MatExpr*) core_operatorDivide_MatExprMat(cv::MatExpr *e, cv::Mat *m) +{ + cv::MatExpr ret = (*e) / (*m); + return new cv::MatExpr(ret); +} +CVAPI(cv::MatExpr*) core_operatorDivide_MatMatExpr(cv::Mat *m, cv::MatExpr *e) +{ + cv::MatExpr ret = (*m) / (*e); + return new cv::MatExpr(ret); +} +CVAPI(cv::MatExpr*) core_operatorDivide_MatExprDouble(cv::MatExpr *e, double s) +{ + cv::MatExpr ret = (*e) / s; + return new cv::MatExpr(ret); +} +CVAPI(cv::MatExpr*) core_operatorDivide_DoubleMatExpr(double s, cv::MatExpr *e) +{ + cv::MatExpr ret = s / (*e); + return new cv::MatExpr(ret); +} +CVAPI(cv::MatExpr*) core_operatorDivide_MatExprMatExpr(cv::MatExpr *e1, cv::MatExpr *e2) +{ + cv::MatExpr ret = (*e1) / (*e2); + return new cv::MatExpr(ret); +} + #endif \ No newline at end of file From e2238d73e641960b0ad4a4f6ff2f79346c388660 Mon Sep 17 00:00:00 2001 From: shimat Date: Tue, 4 Feb 2014 19:52:24 +0900 Subject: [PATCH 09/29] Fixed submatrix operations --- src/OpenCvSharp.SandboxCpp.cpp | 42 +++++++++++++++++++++++++ src/OpenCvSharp/Src/DisposableObject.cs | 6 ++++ src/OpenCvSharpExtern/core_Mat.h | 19 ++++++----- src/OpenCvSharpExtern/core_MatExpr.h | 8 +++++ 4 files changed, 67 insertions(+), 8 deletions(-) create mode 100644 src/OpenCvSharp.SandboxCpp.cpp diff --git a/src/OpenCvSharp.SandboxCpp.cpp b/src/OpenCvSharp.SandboxCpp.cpp new file mode 100644 index 000000000..435908a18 --- /dev/null +++ b/src/OpenCvSharp.SandboxCpp.cpp @@ -0,0 +1,42 @@ +#include "stdafx.h" + +using namespace System; + +struct U8C3 +{ + uchar b, g, r; +}; + +// For researching native OpenCV behaviour +int main(array ^args) +{ + cv::Mat mat1 = cv::imread("C:\\Lenna.png", CV_LOAD_IMAGE_COLOR); + cv::Mat mat2 = cv::imread("C:\\Lenna.png", CV_LOAD_IMAGE_COLOR); + + for (auto it = mat1.begin(); it != mat1.end(); it++) + { + U8C3 elem = *it; + std::swap(elem.b, elem.r); + *it = elem; + } + + cv::Mat eql = (mat1 == mat2); + cv::Mat channels[3]; + cv::split(eql, channels); + + //std::cout << "b: " << cv::countNonZero(channels[0]) << std::endl; + //std::cout << "g: " << cv::countNonZero(channels[1]) << std::endl; + //std::cout << "r: " << cv::countNonZero(channels[2]) << std::endl; + std::cout << "sum: " << cv::sum(eql) << std::endl; + std::cout << "total: " << eql.total() * 255 << std::endl; + std::cout << "equals: " << (cv::sum(eql)[0] == (eql.total() * 255)) << std::endl; + + cv::Scalar sc; + std::cout << "abs: " << cv::trace(mat1 - mat2) << std::endl; + + //cv::imshow("window", abs); + //cv::waitKey(); + + getchar(); + return 0; +} diff --git a/src/OpenCvSharp/Src/DisposableObject.cs b/src/OpenCvSharp/Src/DisposableObject.cs index f46ba1a11..1c453e44a 100644 --- a/src/OpenCvSharp/Src/DisposableObject.cs +++ b/src/OpenCvSharp/Src/DisposableObject.cs @@ -260,9 +260,15 @@ protected void NotifyMemoryPressure(long size) GC.AddMemoryPressure(size); } +#if LANG_JP /// /// ã“ã®ã‚ªãƒ–ジェクトãŒè§£æ”¾æ¸ˆã¿ã®å ´åˆã¯ObjectDisposedExceptionを投ã’ã‚‹ /// +#else + /// + /// If this object is disposed, then ObjectDisposedException is thrown. + /// +#endif public void ThrowIfDisposed() { if (IsDisposed) diff --git a/src/OpenCvSharpExtern/core_Mat.h b/src/OpenCvSharpExtern/core_Mat.h index d0f3480a6..874b91fda 100644 --- a/src/OpenCvSharpExtern/core_Mat.h +++ b/src/OpenCvSharpExtern/core_Mat.h @@ -367,10 +367,10 @@ CVAPI(cv::Mat*) core_Mat_subMat2(cv::Mat *self, int nRanges, CvSlice *ranges) return new cv::Mat(ret); } -CVAPI(cv::MatExpr*) core_Mat_t(cv::Mat *self) +CVAPI(cv::Mat*) core_Mat_t(cv::Mat *self) { - cv::MatExpr expr = self->t(); - return new cv::MatExpr(expr); + cv::Mat expr = self->t(); + return new cv::Mat(expr); } CVAPI(uint64) core_Mat_total(cv::Mat *self) @@ -388,17 +388,20 @@ CVAPI(cv::MatExpr*) core_Mat_zeros1(int rows, int cols, int type) cv::MatExpr expr = cv::Mat::zeros(rows, cols, type); return new cv::MatExpr(expr); } -CVAPI(cv::MatExpr*) core_Mat_zeros2(int ndims, const int *sz, int type) +CVAPI(cv::MatExpr*) core_Mat_zeros2(int ndims, const int *sz, int type) // Not defined in .lib { //cv::MatExpr expr = cv::Mat::zeros(ndims, sz, type); //return new cv::MatExpr(expr); return NULL; } -CVAPI(char*) core_Mat_dump(cv::Mat *self) +CVAPI(char*) core_Mat_dump(cv::Mat *self, const char *format) { - std::stringstream s; - s << *self; + std::stringstream s; + if (format == NULL) + s << *self; + else + s << cv::format(*self, format); std::string str = s.str(); const char *src = str.c_str(); @@ -408,7 +411,7 @@ CVAPI(char*) core_Mat_dump(cv::Mat *self) } CVAPI(void) core_Mat_dump_delete(char *buf) { - delete [] buf; + delete[] buf; } CVAPI(uchar*) core_Mat_ptr1d(cv::Mat *self, int i0) diff --git a/src/OpenCvSharpExtern/core_MatExpr.h b/src/OpenCvSharpExtern/core_MatExpr.h index 999e409b0..80e35fc3c 100644 --- a/src/OpenCvSharpExtern/core_MatExpr.h +++ b/src/OpenCvSharpExtern/core_MatExpr.h @@ -54,4 +54,12 @@ CVAPI(cv::MatExpr*) core_operatorDivide_MatExprMatExpr(cv::MatExpr *e1, cv::MatE return new cv::MatExpr(ret); } + + +CVAPI(cv::MatExpr*) core_MatExpr_t(cv::MatExpr *self) +{ + cv::MatExpr ret = self->t(); + return new cv::MatExpr(ret); +} + #endif \ No newline at end of file From 90c6a0fbec8f7a31ca17c359985411b3ee667b81 Mon Sep 17 00:00:00 2001 From: shimat Date: Wed, 5 Feb 2014 01:26:44 +0900 Subject: [PATCH 10/29] Added row/col indexers of Mat (with memory leak...) --- src/OpenCvSharpExtern/core_Mat.h | 29 +++++++++++++++++++++++----- src/OpenCvSharpExtern/core_MatExpr.h | 27 +++++++++++++++++++++++++- 2 files changed, 50 insertions(+), 6 deletions(-) diff --git a/src/OpenCvSharpExtern/core_Mat.h b/src/OpenCvSharpExtern/core_Mat.h index 874b91fda..4d9705fc9 100644 --- a/src/OpenCvSharpExtern/core_Mat.h +++ b/src/OpenCvSharpExtern/core_Mat.h @@ -99,23 +99,32 @@ CVAPI(cv::Mat*) core_Mat_clone(cv::Mat *self) return new cv::Mat(ret); } -CVAPI(cv::Mat*) core_Mat_col(cv::Mat *self, int x) +CVAPI(cv::Mat*) core_Mat_col_toMat(cv::Mat *self, int x) { cv::Mat ret = self->col(x); return new cv::Mat(ret); } +CVAPI(cv::MatExpr*) core_Mat_col_toMatExpr(cv::Mat *self, int x) +{ + cv::Mat ret = self->col(x); + return new cv::MatExpr(ret); +} CVAPI(int) core_Mat_cols(cv::Mat *self) { return self->cols; } -CVAPI(cv::Mat*) core_Mat_colRange(cv::Mat *self, int startCol, int endCol) +CVAPI(cv::Mat*) core_Mat_colRange_toMat(cv::Mat *self, int startCol, int endCol) { cv::Mat ret = self->colRange(startCol, endCol); return new cv::Mat(ret); } - +CVAPI(cv::MatExpr*) core_Mat_colRange_toMatExpr(cv::Mat *self, int startCol, int endCol) +{ + cv::Mat ret = self->colRange(startCol, endCol); + return new cv::MatExpr(ret); +} CVAPI(int) core_Mat_dims(cv::Mat *self) { @@ -290,17 +299,27 @@ CVAPI(cv::Mat*) core_Mat_reshape3(cv::Mat *self, int cn, int newndims, const int return new cv::Mat(ret); } -CVAPI(cv::Mat*) core_Mat_row(cv::Mat *self, int y) +CVAPI(cv::Mat*) core_Mat_row_toMat(cv::Mat *self, int y) { cv::Mat ret = self->row(y); return new cv::Mat(ret); } +CVAPI(cv::MatExpr*) core_Mat_row_toMatExpr(cv::Mat *self, int y) +{ + cv::Mat ret = self->row(y); + return new cv::MatExpr(ret); +} -CVAPI(cv::Mat*) core_Mat_rowRange(cv::Mat *self, int startRow, int endRow) +CVAPI(cv::Mat*) core_Mat_rowRange_toMat(cv::Mat *self, int startRow, int endRow) { cv::Mat ret = self->rowRange(startRow, endRow); return new cv::Mat(ret); } +CVAPI(cv::MatExpr*) core_Mat_rowRange_toMatExpr(cv::Mat *self, int startRow, int endRow) +{ + cv::Mat ret = self->rowRange(startRow, endRow); + return new cv::MatExpr(ret); +} CVAPI(int) core_Mat_rows(cv::Mat *self) { diff --git a/src/OpenCvSharpExtern/core_MatExpr.h b/src/OpenCvSharpExtern/core_MatExpr.h index 80e35fc3c..c868b1c91 100644 --- a/src/OpenCvSharpExtern/core_MatExpr.h +++ b/src/OpenCvSharpExtern/core_MatExpr.h @@ -27,8 +27,33 @@ CVAPI(cv::Mat*) core_MatExpr_toMat(cv::MatExpr *expr) return new cv::Mat(ret); } +CVAPI(cv::MatExpr*) core_operatorMultiply_MatExprMat(cv::MatExpr *e, cv::Mat *m) +{ + cv::MatExpr ret = (*e) * (*m); + return new cv::MatExpr(ret); +} +CVAPI(cv::MatExpr*) core_operatorMultiply_MatMatExpr(cv::Mat *m, cv::MatExpr *e) +{ + cv::MatExpr ret = (*m) * (*e); + return new cv::MatExpr(ret); +} +CVAPI(cv::MatExpr*) core_operatorMultiply_MatExprDouble(cv::MatExpr *e, double s) +{ + cv::MatExpr ret = (*e) * s; + return new cv::MatExpr(ret); +} +CVAPI(cv::MatExpr*) core_operatorMultiply_DoubleMatExpr(double s, cv::MatExpr *e) +{ + cv::MatExpr ret = s * (*e); + return new cv::MatExpr(ret); +} +CVAPI(cv::MatExpr*) core_operatorMultiply_MatExprMatExpr(cv::MatExpr *e1, cv::MatExpr *e2) +{ + cv::MatExpr ret = (*e1) * (*e2); + return new cv::MatExpr(ret); +} -CVAPI(cv::MatExpr*) core_operatorDivide_MatExprMat(cv::MatExpr *e, cv::Mat *m) +CVAPI(cv::MatExpr*) core_operatorDivide_MatExprMat(cv::MatExpr *e, cv::Mat *m) { cv::MatExpr ret = (*e) / (*m); return new cv::MatExpr(ret); From d9b4e09059024f685d8a503a448da949536191f5 Mon Sep 17 00:00:00 2001 From: shimat Date: Wed, 5 Feb 2014 08:21:01 +0900 Subject: [PATCH 11/29] Fixed memory leaks in row/col range indexer --- src/OpenCvSharp/Src/DisposableCvObject.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/OpenCvSharp/Src/DisposableCvObject.cs b/src/OpenCvSharp/Src/DisposableCvObject.cs index be18a88b0..4db58d71c 100644 --- a/src/OpenCvSharp/Src/DisposableCvObject.cs +++ b/src/OpenCvSharp/Src/DisposableCvObject.cs @@ -113,7 +113,6 @@ protected override void Dispose(bool disposing) { if (!disposed) { - // 継承ã—ãŸã‚¯ãƒ©ã‚¹ç‹¬è‡ªã®è§£æ”¾å‡¦ç† try { if (disposing) From 00c7ab06dd0167c004f19c873a4d0a2e803470f9 Mon Sep 17 00:00:00 2001 From: shimat Date: Wed, 5 Feb 2014 14:24:25 +0900 Subject: [PATCH 12/29] CHanged tuples' name --- src/OpenCvSharpExtern/core_MatExpr.h | 153 ++++++++++++++++++++++++--- 1 file changed, 141 insertions(+), 12 deletions(-) diff --git a/src/OpenCvSharpExtern/core_MatExpr.h b/src/OpenCvSharpExtern/core_MatExpr.h index c868b1c91..434fc5008 100644 --- a/src/OpenCvSharpExtern/core_MatExpr.h +++ b/src/OpenCvSharpExtern/core_MatExpr.h @@ -16,17 +16,153 @@ CVAPI(cv::MatExpr*) core_MatExpr_new2(cv::Mat *mat) { return new cv::MatExpr(*mat); } -CVAPI(void) core_MatExpr_delete(cv::MatExpr *expr) +CVAPI(void) core_MatExpr_delete(cv::MatExpr *self) { - delete expr; + delete self; } -CVAPI(cv::Mat*) core_MatExpr_toMat(cv::MatExpr *expr) +CVAPI(cv::Mat*) core_MatExpr_toMat(cv::MatExpr *self) { - cv::Mat ret = (*expr); + cv::Mat ret = (*self); return new cv::Mat(ret); } +#pragma region Functions +CVAPI(cv::MatExpr*) core_MatExpr_row(cv::MatExpr *self, int y) +{ + cv::MatExpr ret = self->row(y); + return new cv::MatExpr(ret); +} +CVAPI(cv::MatExpr*) core_MatExpr_col(cv::MatExpr *self, int x) +{ + cv::MatExpr ret = self->col(x); + return new cv::MatExpr(ret); +} +CVAPI(cv::MatExpr*) core_MatExpr_diag1(cv::MatExpr *self) +{ + cv::MatExpr ret = self->diag(); + return new cv::MatExpr(ret); +} +CVAPI(cv::MatExpr*) core_MatExpr_diag2(cv::MatExpr *self, int d) +{ + cv::MatExpr ret = self->diag(d); + return new cv::MatExpr(ret); +} +CVAPI(cv::MatExpr*) core_MatExpr_submat(cv::MatExpr *self, int rowStart, int rowEnd, int colStart, int colEnd) +{ + cv::Range rowRange(rowStart, rowEnd); + cv::Range colRange(colStart, colEnd); + cv::MatExpr ret = (*self)(rowRange, colRange); + return new cv::MatExpr(ret); +} +CVAPI(cv::Mat*) core_MatExpr_cross(cv::MatExpr *self, cv::Mat *m) +{ + cv::Mat ret = self->cross(*m); + return new cv::Mat(ret); +} +CVAPI(double) core_MatExpr_dot(cv::MatExpr *self, cv::Mat *m) +{ + return self->dot(*m); +} +CVAPI(cv::MatExpr*) core_MatExpr_t(cv::MatExpr *self) +{ + cv::MatExpr ret = self->t(); + return new cv::MatExpr(ret); +} +CVAPI(cv::MatExpr*) core_MatExpr_inv1(cv::MatExpr *self) +{ + cv::MatExpr ret = self->inv(); + return new cv::MatExpr(ret); +} +CVAPI(cv::MatExpr*) core_MatExpr_inv2(cv::MatExpr *self, int method) +{ + cv::MatExpr ret = self->inv(method); + return new cv::MatExpr(ret); +} +CVAPI(cv::MatExpr*) core_MatExpr_mul_toMatExpr(cv::MatExpr *self, cv::MatExpr *e, double scale) +{ + cv::MatExpr ret = self->mul(*e, scale); + return new cv::MatExpr(ret); +} +CVAPI(cv::MatExpr*) core_MatExpr_mul_toMat(cv::MatExpr *self, cv::Mat *m, double scale) +{ + cv::MatExpr ret = self->mul(*m, scale); + return new cv::MatExpr(ret); +} +CVAPI(CvSize) core_MatExpr_size(cv::MatExpr *self) +{ + return (CvSize)self->size(); +} +CVAPI(int) core_MatExpr_type(cv::MatExpr *self) +{ + return self->type(); +} +#pragma endregion + +#pragma region Operators +CVAPI(cv::MatExpr*) core_operatorUnaryMinus_MatExpr(cv::MatExpr *e) +{ + cv::MatExpr expr = -(*e); + return new cv::MatExpr(expr); +} +CVAPI(cv::MatExpr*) core_operatorUnaryNot_MatExpr(cv::MatExpr *e) +{ + cv::MatExpr expr = ~(*e); + return new cv::MatExpr(expr); +} + +CVAPI(cv::MatExpr*) core_operatorAdd_MatExprMat(cv::MatExpr *e, cv:: Mat *m) +{ + cv::MatExpr expr = (*e) + (*m); + return new cv::MatExpr(expr); +} +CVAPI(cv::MatExpr*) core_operatorAdd_MatMatExpr(cv::Mat *m, cv::MatExpr *e) +{ + cv::MatExpr expr = (*m) + (*e); + return new cv::MatExpr(expr); +} +CVAPI(cv::MatExpr*) core_operatorAdd_MatExprScalar(cv::MatExpr *e, CvScalar s) +{ + cv::MatExpr expr = s + (*e); + return new cv::MatExpr(expr); +} +CVAPI(cv::MatExpr*) core_operatorAdd_ScalarMatExpr(CvScalar s, cv::MatExpr *e) +{ + cv::MatExpr expr = (*e) + s; + return new cv::MatExpr(expr); +} +CVAPI(cv::MatExpr*) core_operatorAdd_MatExprMatExpr(cv::MatExpr *e1, cv::MatExpr *e2) +{ + cv::MatExpr expr = (*e1) + (*e2); + return new cv::MatExpr(expr); +} + +CVAPI(cv::MatExpr*) core_operatorSubtract_MatExprMat(cv::MatExpr *e, cv::Mat *m) +{ + cv::MatExpr expr = (*e) - (*m); + return new cv::MatExpr(expr); +} +CVAPI(cv::MatExpr*) core_operatorSubtract_MatMatExpr(cv::Mat *m, cv::MatExpr *e) +{ + cv::MatExpr expr = (*m) - (*e); + return new cv::MatExpr(expr); +} +CVAPI(cv::MatExpr*) core_operatorSubtract_MatExprScalar(cv::MatExpr *e, CvScalar s) +{ + cv::MatExpr expr = s - (*e); + return new cv::MatExpr(expr); +} +CVAPI(cv::MatExpr*) core_operatorSubtract_ScalarMatExpr(CvScalar s, cv::MatExpr *e) +{ + cv::MatExpr expr = (*e) - s; + return new cv::MatExpr(expr); +} +CVAPI(cv::MatExpr*) core_operatorSubtract_MatExprMatExpr(cv::MatExpr *e1, cv::MatExpr *e2) +{ + cv::MatExpr expr = (*e1) - (*e2); + return new cv::MatExpr(expr); +} + CVAPI(cv::MatExpr*) core_operatorMultiply_MatExprMat(cv::MatExpr *e, cv::Mat *m) { cv::MatExpr ret = (*e) * (*m); @@ -78,13 +214,6 @@ CVAPI(cv::MatExpr*) core_operatorDivide_MatExprMatExpr(cv::MatExpr *e1, cv::MatE cv::MatExpr ret = (*e1) / (*e2); return new cv::MatExpr(ret); } - - - -CVAPI(cv::MatExpr*) core_MatExpr_t(cv::MatExpr *self) -{ - cv::MatExpr ret = self->t(); - return new cv::MatExpr(ret); -} +#pragma endregion #endif \ No newline at end of file From 51dabc3f3ff3c2bfd08338eaf370cf65bd7ef7a2 Mon Sep 17 00:00:00 2001 From: shimat Date: Wed, 5 Feb 2014 19:53:20 +0900 Subject: [PATCH 13/29] Added InputArray / OutputArray (don't work) --- src/OpenCvSharp.sln | 26 ++++++++++ src/OpenCvSharp/Src/DisposableCvObject.cs | 11 ++++- .../OpenCvSharpExtern.vcxproj | 6 +++ .../OpenCvSharpExtern.vcxproj.filters | 18 +++++++ src/OpenCvSharpExtern/core_InputArray.cpp | 6 +++ src/OpenCvSharpExtern/core_InputArray.h | 27 +++++++++++ src/OpenCvSharpExtern/core_OutputArray.cpp | 6 +++ src/OpenCvSharpExtern/core_OutputArray.h | 28 +++++++++++ src/OpenCvSharpExtern/imgproc.cpp | 6 +++ src/OpenCvSharpExtern/imgproc.h | 47 +++++++++++++++++++ 10 files changed, 180 insertions(+), 1 deletion(-) create mode 100644 src/OpenCvSharpExtern/core_InputArray.cpp create mode 100644 src/OpenCvSharpExtern/core_InputArray.h create mode 100644 src/OpenCvSharpExtern/core_OutputArray.cpp create mode 100644 src/OpenCvSharpExtern/core_OutputArray.h create mode 100644 src/OpenCvSharpExtern/imgproc.cpp create mode 100644 src/OpenCvSharpExtern/imgproc.h diff --git a/src/OpenCvSharp.sln b/src/OpenCvSharp.sln index 6a19a4711..76c71626f 100644 --- a/src/OpenCvSharp.sln +++ b/src/OpenCvSharp.sln @@ -27,6 +27,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenCvSharp.NUnitTest", "Op EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenCvSharp.Sandbox", "OpenCvSharp.Sandbox\OpenCvSharp.Sandbox.csproj", "{C76C33E0-6F2E-49DF-ABD2-02053CB4CCB5}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OpenCvSharp.SandboxCpp", "OpenCvSharp.SandboxCpp\OpenCvSharp.SandboxCpp.vcxproj", "{8516D7EB-E716-4BC1-92DB-751E6BF13AE1}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -380,6 +382,30 @@ Global {C76C33E0-6F2E-49DF-ABD2-02053CB4CCB5}.Release|x64.ActiveCfg = Release|Any CPU {C76C33E0-6F2E-49DF-ABD2-02053CB4CCB5}.Release|x86.ActiveCfg = Release|x86 {C76C33E0-6F2E-49DF-ABD2-02053CB4CCB5}.Release|x86.Build.0 = Release|x86 + {8516D7EB-E716-4BC1-92DB-751E6BF13AE1}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {8516D7EB-E716-4BC1-92DB-751E6BF13AE1}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 + {8516D7EB-E716-4BC1-92DB-751E6BF13AE1}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {8516D7EB-E716-4BC1-92DB-751E6BF13AE1}.Debug|Win32.ActiveCfg = Debug|Win32 + {8516D7EB-E716-4BC1-92DB-751E6BF13AE1}.Debug|Win32.Build.0 = Debug|Win32 + {8516D7EB-E716-4BC1-92DB-751E6BF13AE1}.Debug|x64.ActiveCfg = Debug|Win32 + {8516D7EB-E716-4BC1-92DB-751E6BF13AE1}.Debug|x86.ActiveCfg = Debug|Win32 + {8516D7EB-E716-4BC1-92DB-751E6BF13AE1}.Debug|x86.Build.0 = Debug|Win32 + {8516D7EB-E716-4BC1-92DB-751E6BF13AE1}.Release JP|Any CPU.ActiveCfg = Release|Win32 + {8516D7EB-E716-4BC1-92DB-751E6BF13AE1}.Release JP|Mixed Platforms.ActiveCfg = Release|Win32 + {8516D7EB-E716-4BC1-92DB-751E6BF13AE1}.Release JP|Mixed Platforms.Build.0 = Release|Win32 + {8516D7EB-E716-4BC1-92DB-751E6BF13AE1}.Release JP|Win32.ActiveCfg = Release|Win32 + {8516D7EB-E716-4BC1-92DB-751E6BF13AE1}.Release JP|Win32.Build.0 = Release|Win32 + {8516D7EB-E716-4BC1-92DB-751E6BF13AE1}.Release JP|x64.ActiveCfg = Release|Win32 + {8516D7EB-E716-4BC1-92DB-751E6BF13AE1}.Release JP|x86.ActiveCfg = Release|Win32 + {8516D7EB-E716-4BC1-92DB-751E6BF13AE1}.Release JP|x86.Build.0 = Release|Win32 + {8516D7EB-E716-4BC1-92DB-751E6BF13AE1}.Release|Any CPU.ActiveCfg = Release|Win32 + {8516D7EB-E716-4BC1-92DB-751E6BF13AE1}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {8516D7EB-E716-4BC1-92DB-751E6BF13AE1}.Release|Mixed Platforms.Build.0 = Release|Win32 + {8516D7EB-E716-4BC1-92DB-751E6BF13AE1}.Release|Win32.ActiveCfg = Release|Win32 + {8516D7EB-E716-4BC1-92DB-751E6BF13AE1}.Release|Win32.Build.0 = Release|Win32 + {8516D7EB-E716-4BC1-92DB-751E6BF13AE1}.Release|x64.ActiveCfg = Release|Win32 + {8516D7EB-E716-4BC1-92DB-751E6BF13AE1}.Release|x86.ActiveCfg = Release|Win32 + {8516D7EB-E716-4BC1-92DB-751E6BF13AE1}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/OpenCvSharp/Src/DisposableCvObject.cs b/src/OpenCvSharp/Src/DisposableCvObject.cs index 4db58d71c..6f14a79f6 100644 --- a/src/OpenCvSharp/Src/DisposableCvObject.cs +++ b/src/OpenCvSharp/Src/DisposableCvObject.cs @@ -148,7 +148,7 @@ public IntPtr CvPtr } /// - /// Get native pointer of OpenCV structure + /// Get a native pointer of OpenCV structure /// /// /// IntPtr.Zero if obj==null, obj.CvPtr otherwise @@ -156,5 +156,14 @@ protected static IntPtr GetCvPtr(DisposableCvObject obj) { return (obj == null) ? IntPtr.Zero : obj.CvPtr; } + + /// + /// Set a native pointer of OpenCV structure (dangerous) + /// + /// + public void SetPtr(IntPtr p) + { + this.ptr = p; + } } } diff --git a/src/OpenCvSharpExtern/OpenCvSharpExtern.vcxproj b/src/OpenCvSharpExtern/OpenCvSharpExtern.vcxproj index 5960ef89d..9c08d7188 100644 --- a/src/OpenCvSharpExtern/OpenCvSharpExtern.vcxproj +++ b/src/OpenCvSharpExtern/OpenCvSharpExtern.vcxproj @@ -211,9 +211,12 @@ + + + @@ -249,9 +252,12 @@ + + + diff --git a/src/OpenCvSharpExtern/OpenCvSharpExtern.vcxproj.filters b/src/OpenCvSharpExtern/OpenCvSharpExtern.vcxproj.filters index 2b9931046..0933ca6b8 100644 --- a/src/OpenCvSharpExtern/OpenCvSharpExtern.vcxproj.filters +++ b/src/OpenCvSharpExtern/OpenCvSharpExtern.vcxproj.filters @@ -109,6 +109,15 @@ Sources\cpp + + Sources\cpp + + + Sources\cpp + + + Sources\cpp + @@ -207,6 +216,15 @@ Headers + + Headers\cpp + + + Headers\cpp + + + Headers\cpp + diff --git a/src/OpenCvSharpExtern/core_InputArray.cpp b/src/OpenCvSharpExtern/core_InputArray.cpp new file mode 100644 index 000000000..f8da7ac5a --- /dev/null +++ b/src/OpenCvSharpExtern/core_InputArray.cpp @@ -0,0 +1,6 @@ +/* +* (C) 2008-2014 shimat +* This code is licenced under the LGPL. +*/ + +#include "core_InputArray.h" \ No newline at end of file diff --git a/src/OpenCvSharpExtern/core_InputArray.h b/src/OpenCvSharpExtern/core_InputArray.h new file mode 100644 index 000000000..3573243df --- /dev/null +++ b/src/OpenCvSharpExtern/core_InputArray.h @@ -0,0 +1,27 @@ +/* + * (C) 2008-2014 shimat + * This code is licenced under the LGPL. + */ + +#ifndef _CPP_CORE_INPUTARRAY_H_ +#define _CPP_CORE_INPUTARRAY_H_ + +#include "include_opencv.h" + +CVAPI(cv::_InputArray*) core_InputArray_new_byMat(cv::Mat *mat) +{ + cv::_InputArray ia(*mat); + return new cv::_InputArray(ia); +} + +CVAPI(void) core_InputArray_delete(cv::_InputArray *ia) +{ + delete ia; +} + +CVAPI(int) core_InputArray_kind(cv::_InputArray *ia) +{ + return ia->kind(); +} + +#endif \ No newline at end of file diff --git a/src/OpenCvSharpExtern/core_OutputArray.cpp b/src/OpenCvSharpExtern/core_OutputArray.cpp new file mode 100644 index 000000000..7599cd5dd --- /dev/null +++ b/src/OpenCvSharpExtern/core_OutputArray.cpp @@ -0,0 +1,6 @@ +/* +* (C) 2008-2014 shimat +* This code is licenced under the LGPL. +*/ + +#include "core_OutputArray.h" \ No newline at end of file diff --git a/src/OpenCvSharpExtern/core_OutputArray.h b/src/OpenCvSharpExtern/core_OutputArray.h new file mode 100644 index 000000000..1f4451af9 --- /dev/null +++ b/src/OpenCvSharpExtern/core_OutputArray.h @@ -0,0 +1,28 @@ +/* + * (C) 2008-2014 shimat + * This code is licenced under the LGPL. + */ + +#ifndef _CPP_CORE_OUTPUTARRAY_H_ +#define _CPP_CORE_OUTPUTARRAY_H_ + +#include "include_opencv.h" + +CVAPI(cv::_OutputArray*) core_OutputArray_new_byMat(cv::Mat *mat) +{ + cv::_OutputArray ia(*mat); + return new cv::_OutputArray(ia); +} + +CVAPI(void) core_OutputArray_delete(cv::_OutputArray *oa) +{ + delete oa; +} + +CVAPI(cv::Mat*) core_OutputArray_getMat(cv::_OutputArray *oa) +{ + cv::Mat &mat = oa->getMatRef(); + return new cv::Mat(mat); +} + +#endif \ No newline at end of file diff --git a/src/OpenCvSharpExtern/imgproc.cpp b/src/OpenCvSharpExtern/imgproc.cpp new file mode 100644 index 000000000..d5206ede2 --- /dev/null +++ b/src/OpenCvSharpExtern/imgproc.cpp @@ -0,0 +1,6 @@ +/* +* (C) 2008-2014 shimat +* This code is licenced under the LGPL. +*/ + +#include "imgproc.h" \ No newline at end of file diff --git a/src/OpenCvSharpExtern/imgproc.h b/src/OpenCvSharpExtern/imgproc.h new file mode 100644 index 000000000..8adfb34fd --- /dev/null +++ b/src/OpenCvSharpExtern/imgproc.h @@ -0,0 +1,47 @@ +/* + * (C) 2008-2014 shimat + * This code is licenced under the LGPL. + */ + +#ifndef _CPP_IMGPROC_H_ +#define _CPP_IMGPROC_H_ + +#include "include_opencv.h" + + +CVAPI(void) imgproc_cvtColor(cv::_InputArray *src, cv::_OutputArray *dst, int code, int dstCn) +{ + cv::cvtColor(*src, *dst, code, dstCn); +} + +CVAPI(void) imgproc_copyMakeBorder(cv::_InputArray *src, cv::_OutputArray *dst, int top, int bottom, int left, int right, int borderType, CvScalar value) +{ + cv::copyMakeBorder(*src, *dst, top, bottom, left, right, borderType, value); +} + +CVAPI(void) imgproc_medianBlur(cv::_InputArray *src, cv::_OutputArray *dst, int ksize) +{ + cv::medianBlur(*src, *dst, ksize); +} + +CVAPI(void) imgproc_GaussianBlur(cv::_InputArray *src, cv::_OutputArray *dst, CvSize ksize, double sigmaX, double sigmaY, int borderType) +{ + cv::GaussianBlur(*src, *dst, ksize, sigmaX, sigmaY, borderType); +} + +CVAPI(void) imgproc_bilateralFilter(cv::_InputArray *src, cv::_OutputArray *dst, int d, double sigmaColor, double sigmaSpace, int borderType) +{ + cv::bilateralFilter(*src, *dst, d, sigmaColor, sigmaSpace, borderType); +} + +CVAPI(void) imgproc_boxFilter(cv::_InputArray *src, cv::_OutputArray *dst, int ddepth, CvSize ksize, CvPoint anchor, int normalize, int borderType) +{ + cv::boxFilter(*src, *dst, ddepth, ksize, anchor, normalize != 0, borderType); +} + +CVAPI(void) imgproc_blur(cv::_InputArray *src, cv::_OutputArray *dst, CvSize ksize, CvPoint anchor, int borderType) +{ + cv::blur(*src, *dst, ksize, anchor, borderType); +} + +#endif \ No newline at end of file From d8290897e80762143dcf76168339afc7d6095440 Mon Sep 17 00:00:00 2001 From: shimat Date: Thu, 6 Feb 2014 00:53:12 +0900 Subject: [PATCH 14/29] CvCpp -> Cv2 --- src/OpenCvSharp/Src/DisposableCvObject.cs | 9 --------- src/OpenCvSharp/Src/PInvoke/PInvokeHelper.cs | 4 +++- src/OpenCvSharpExtern/imgproc.h | 2 +- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/OpenCvSharp/Src/DisposableCvObject.cs b/src/OpenCvSharp/Src/DisposableCvObject.cs index 6f14a79f6..bad97da04 100644 --- a/src/OpenCvSharp/Src/DisposableCvObject.cs +++ b/src/OpenCvSharp/Src/DisposableCvObject.cs @@ -156,14 +156,5 @@ protected static IntPtr GetCvPtr(DisposableCvObject obj) { return (obj == null) ? IntPtr.Zero : obj.CvPtr; } - - /// - /// Set a native pointer of OpenCV structure (dangerous) - /// - /// - public void SetPtr(IntPtr p) - { - this.ptr = p; - } } } diff --git a/src/OpenCvSharp/Src/PInvoke/PInvokeHelper.cs b/src/OpenCvSharp/Src/PInvoke/PInvokeHelper.cs index d0e3818c5..f43ddc728 100644 --- a/src/OpenCvSharp/Src/PInvoke/PInvokeHelper.cs +++ b/src/OpenCvSharp/Src/PInvoke/PInvokeHelper.cs @@ -58,6 +58,7 @@ public static OpenCvSharpException CreateException(Exception ex) StringBuilder message = new StringBuilder(); if (System.Globalization.CultureInfo.CurrentCulture.Name.Contains("ja")) { + message.AppendFormat("{0}\n", ex.Message); message.Append("*** P/InvokeãŒåŽŸå› ã§ä¾‹å¤–ãŒç™ºç”Ÿã—ã¾ã—ãŸã€‚***\n") .Append("以下ã®é …目を確èªã—ã¦ä¸‹ã•ã„。\n") .Append("(1) OpenCVã®DLLãŒå®Ÿè¡Œãƒ•ã‚¡ã‚¤ãƒ«ã¨åŒã˜å ´æ‰€ã«ç½®ã‹ã‚Œã¦ã„ã¾ã™ã‹? ã¾ãŸã¯ãƒ‘スãŒæ­£ã—ã通ã£ã¦ã„ã¾ã™ã‹?\n") @@ -68,6 +69,7 @@ public static OpenCvSharpException CreateException(Exception ex) } else { + message.AppendFormat("{0}\n", ex.Message); message.Append("*** An exception has occurred because of P/Invoke. ***\n") .Append("Please check the following:\n") .Append("(1) OpenCV's DLL files exist in the same directory as the executable file.\n") @@ -75,7 +77,7 @@ public static OpenCvSharpException CreateException(Exception ex) .Append("(3) The target platform(x86/x64) of OpenCV's DLL files and OpenCvSharp is the same as your project's.\n") .Append("\n") .Append(ex.ToString()); - } + } return new OpenCvSharpException(message.ToString(), ex); } } diff --git a/src/OpenCvSharpExtern/imgproc.h b/src/OpenCvSharpExtern/imgproc.h index 8adfb34fd..77ab8c79a 100644 --- a/src/OpenCvSharpExtern/imgproc.h +++ b/src/OpenCvSharpExtern/imgproc.h @@ -11,7 +11,7 @@ CVAPI(void) imgproc_cvtColor(cv::_InputArray *src, cv::_OutputArray *dst, int code, int dstCn) { - cv::cvtColor(*src, *dst, code, dstCn); + cv::cvtColor(*src, *dst, code, dstCn); } CVAPI(void) imgproc_copyMakeBorder(cv::_InputArray *src, cv::_OutputArray *dst, int top, int bottom, int left, int right, int borderType, CvScalar value) From c07c5ec253444668b912c9e159da2a368ac00afa Mon Sep 17 00:00:00 2001 From: shimat Date: Fri, 7 Feb 2014 08:10:00 +0900 Subject: [PATCH 15/29] Added imgproc functions to adaptiveBilateralFilter --- src/OpenCvSharpExtern/imgproc.h | 84 +++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/src/OpenCvSharpExtern/imgproc.h b/src/OpenCvSharpExtern/imgproc.h index 77ab8c79a..fc44dab31 100644 --- a/src/OpenCvSharpExtern/imgproc.h +++ b/src/OpenCvSharpExtern/imgproc.h @@ -8,6 +8,17 @@ #include "include_opencv.h" +CVAPI(cv::Mat*) imgproc_getGaborKernel(CvSize ksize, double sigma, double theta, double lambd, double gamma, double psi, int ktype) +{ + cv::Mat ret = cv::getGaborKernel(ksize, sigma, theta, lambd, gamma, ktype); + return new cv::Mat(ret); +} + +CVAPI(cv::Mat*) imgproc_getStructuringElement(int shape, CvSize ksize, CvPoint anchor) +{ + cv::Mat ret = cv::getStructuringElement(shape, ksize, anchor); + return new cv::Mat(ret); +} CVAPI(void) imgproc_cvtColor(cv::_InputArray *src, cv::_OutputArray *dst, int code, int dstCn) { @@ -34,6 +45,12 @@ CVAPI(void) imgproc_bilateralFilter(cv::_InputArray *src, cv::_OutputArray *dst, cv::bilateralFilter(*src, *dst, d, sigmaColor, sigmaSpace, borderType); } +CVAPI(void) imgproc_adaptiveBilateralFilter(cv::_InputArray *src, cv::_OutputArray *dst, CvSize ksize, double sigmaSpace, + double maxSigmaColor, CvPoint anchor, int borderType) +{ + cv::adaptiveBilateralFilter(*src, *dst, ksize, sigmaSpace, maxSigmaColor, anchor, borderType); +} + CVAPI(void) imgproc_boxFilter(cv::_InputArray *src, cv::_OutputArray *dst, int ddepth, CvSize ksize, CvPoint anchor, int normalize, int borderType) { cv::boxFilter(*src, *dst, ddepth, ksize, anchor, normalize != 0, borderType); @@ -43,5 +60,72 @@ CVAPI(void) imgproc_blur(cv::_InputArray *src, cv::_OutputArray *dst, CvSize ksi { cv::blur(*src, *dst, ksize, anchor, borderType); } +//! applies non-separable 2D linear filter to the image +CVAPI(void) imgproc_filter2D(cv::_InputArray *src, cv::_OutputArray *dst, int ddepth, + cv::_InputArray *kernel, CvPoint anchor, double delta, int borderType); + +//! applies separable 2D linear filter to the image +CVAPI(void) imgproc_sepFilter2D(cv::_InputArray *src, cv::_OutputArray *dst, int ddepth, + cv::_InputArray *kernelX, cv::_InputArray kernelY, + CvPoint anchor, double delta, int borderType); + +//! applies generalized Sobel operator to the image +CVAPI(void) imgproc_Sobel(cv::_InputArray *src, cv::_OutputArray *dst, int ddepth, + int dx, int dy, int ksize, double scale, double delta, int borderType); + +//! applies the vertical or horizontal Scharr operator to the image +CVAPI(void) imgproc_Scharr(cv::_InputArray *src, cv::_OutputArray *dst, int ddepth, + int dx, int dy, double scale, double delta, int borderType); + +//! applies Laplacian operator to the image +CVAPI(void) imgproc_Laplacian(cv::_InputArray *src, cv::_OutputArray *dst, int ddepth, + int ksize, double scale, double delta, int borderType); + +//! applies Canny edge detector and produces the edge map. +CVAPI(void) imgproc_Canny(cv::_InputArray *src, cv::_OutputArray *edges, + double threshold1, double threshold2, int apertureSize, bool L2gradient); + +//! computes minimum eigen value of 2x2 derivative covariation matrix at each pixel - the cornerness criteria +CVAPI(void) imgproc_cornerMinEigenVal(cv::_InputArray *src, cv::_OutputArray *dst, + int blockSize, int ksize, int borderType); + +//! computes Harris cornerness criteria at each image pixel +CVAPI(void) imgproc_cornerHarris(cv::_InputArray *src, cv::_OutputArray *dst, int blockSize, + int ksize, double k, int borderType); + +// low-level function for computing eigenvalues and eigenvectors of 2x2 matrices +CVAPI(void) imgproc_eigen2x2(const float* a, float* e, int n); + +//! computes both eigenvalues and the eigenvectors of 2x2 derivative covariation matrix at each pixel. The output is stored as 6-channel matrix. +CVAPI(void) imgproc_cornerEigenValsAndVecs(cv::_InputArray *src, cv::_OutputArray *dst, + int blockSize, int ksize, int borderType); + +//! computes another complex cornerness criteria at each pixel +CVAPI(void) imgproc_preCornerDetect(cv::_InputArray *src, cv::_OutputArray *dst, int ksize, int borderType); + +//! adjusts the corner locations with sub-pixel accuracy to maximize the certain cornerness criteria +CVAPI(void) imgproc_cornerSubPix(cv::_InputArray *src, cv::_OutputArray *corners, + CvSize winSize, CvSize zeroZone, CvTermCriteria criteria); + +//! finds the strong enough corners where the cornerMinEigenVal() or cornerHarris() report the local maxima +CVAPI(void) imgproc_goodFeaturesToTrack(cv::_InputArray *src, cv::_OutputArray *corners, + int maxCorners, double qualityLevel, double minDistance, + cv::_InputArray *mask, int blockSize, bool useHarrisDetector, double k); + +//! finds lines in the black-n-white image using the standard or pyramid Hough transform +CVAPI(void) imgproc_HoughLines(cv::_InputArray *src, cv::_OutputArray *lines, + double rho, double theta, int threshold, + double srn = 0, double stn = 0); + +//! finds line segments in the black-n-white image using probabilistic Hough transform +CVAPI(void) imgproc_HoughLinesP(cv::_InputArray *src, cv::_OutputArray *lines, + double rho, double theta, int threshold, + double minLineLength = 0, double maxLineGap = 0); + +//! finds circles in the grayscale image using 2+1 gradient Hough transform +CVAPI(void) imgproc_HoughCircles(cv::_InputArray *src, cv::_OutputArray *circles, + int method, double dp, double minDist, + double param1 = 100, double param2 = 100, + int minRadius = 0, int maxRadius = 0); #endif \ No newline at end of file From e5f8cc18e76efc997933e97f958db8600f2af011 Mon Sep 17 00:00:00 2001 From: shimat Date: Fri, 7 Feb 2014 10:21:42 +0900 Subject: [PATCH 16/29] Minor updates From 6fe3d426770d1fd966fcba5a1bd21685e3b5b8c8 Mon Sep 17 00:00:00 2001 From: shimat Date: Fri, 7 Feb 2014 11:03:24 +0900 Subject: [PATCH 17/29] Added Hough transform methods --- .../OpenCvSharpExtern.vcxproj | 4 +- .../OpenCvSharpExtern.vcxproj.filters | 12 ++-- src/OpenCvSharpExtern/imgproc.h | 66 ++++++++++++++----- .../{WVector.cpp => std_vector.cpp} | 2 +- .../{WVector.h => std_vector.h} | 60 ++++++++--------- 5 files changed, 88 insertions(+), 56 deletions(-) rename src/OpenCvSharpExtern/{WVector.cpp => std_vector.cpp} (76%) rename src/OpenCvSharpExtern/{WVector.h => std_vector.h} (66%) diff --git a/src/OpenCvSharpExtern/OpenCvSharpExtern.vcxproj b/src/OpenCvSharpExtern/OpenCvSharpExtern.vcxproj index 9c08d7188..9a75571b4 100644 --- a/src/OpenCvSharpExtern/OpenCvSharpExtern.vcxproj +++ b/src/OpenCvSharpExtern/OpenCvSharpExtern.vcxproj @@ -240,7 +240,7 @@ - + @@ -277,7 +277,7 @@ - + diff --git a/src/OpenCvSharpExtern/OpenCvSharpExtern.vcxproj.filters b/src/OpenCvSharpExtern/OpenCvSharpExtern.vcxproj.filters index 0933ca6b8..a1316789e 100644 --- a/src/OpenCvSharpExtern/OpenCvSharpExtern.vcxproj.filters +++ b/src/OpenCvSharpExtern/OpenCvSharpExtern.vcxproj.filters @@ -91,9 +91,6 @@ Sources - - Sources - Sources @@ -118,6 +115,9 @@ Sources\cpp + + Sources\cpp + @@ -198,9 +198,6 @@ Headers - - Headers - Headers @@ -225,6 +222,9 @@ Headers\cpp + + Headers\cpp + diff --git a/src/OpenCvSharpExtern/imgproc.h b/src/OpenCvSharpExtern/imgproc.h index fc44dab31..262d933c9 100644 --- a/src/OpenCvSharpExtern/imgproc.h +++ b/src/OpenCvSharpExtern/imgproc.h @@ -62,70 +62,102 @@ CVAPI(void) imgproc_blur(cv::_InputArray *src, cv::_OutputArray *dst, CvSize ksi } //! applies non-separable 2D linear filter to the image CVAPI(void) imgproc_filter2D(cv::_InputArray *src, cv::_OutputArray *dst, int ddepth, - cv::_InputArray *kernel, CvPoint anchor, double delta, int borderType); + cv::_InputArray *kernel, CvPoint anchor, double delta, int borderType) +{ +} //! applies separable 2D linear filter to the image CVAPI(void) imgproc_sepFilter2D(cv::_InputArray *src, cv::_OutputArray *dst, int ddepth, cv::_InputArray *kernelX, cv::_InputArray kernelY, - CvPoint anchor, double delta, int borderType); + CvPoint anchor, double delta, int borderType) +{ +} //! applies generalized Sobel operator to the image CVAPI(void) imgproc_Sobel(cv::_InputArray *src, cv::_OutputArray *dst, int ddepth, - int dx, int dy, int ksize, double scale, double delta, int borderType); + int dx, int dy, int ksize, double scale, double delta, int borderType) +{ +} //! applies the vertical or horizontal Scharr operator to the image CVAPI(void) imgproc_Scharr(cv::_InputArray *src, cv::_OutputArray *dst, int ddepth, - int dx, int dy, double scale, double delta, int borderType); + int dx, int dy, double scale, double delta, int borderType) +{ +} //! applies Laplacian operator to the image CVAPI(void) imgproc_Laplacian(cv::_InputArray *src, cv::_OutputArray *dst, int ddepth, - int ksize, double scale, double delta, int borderType); + int ksize, double scale, double delta, int borderType) +{ +} //! applies Canny edge detector and produces the edge map. CVAPI(void) imgproc_Canny(cv::_InputArray *src, cv::_OutputArray *edges, - double threshold1, double threshold2, int apertureSize, bool L2gradient); + double threshold1, double threshold2, int apertureSize, bool L2gradient) +{ +} //! computes minimum eigen value of 2x2 derivative covariation matrix at each pixel - the cornerness criteria CVAPI(void) imgproc_cornerMinEigenVal(cv::_InputArray *src, cv::_OutputArray *dst, - int blockSize, int ksize, int borderType); + int blockSize, int ksize, int borderType) +{ +} //! computes Harris cornerness criteria at each image pixel CVAPI(void) imgproc_cornerHarris(cv::_InputArray *src, cv::_OutputArray *dst, int blockSize, - int ksize, double k, int borderType); + int ksize, double k, int borderType) +{ +} // low-level function for computing eigenvalues and eigenvectors of 2x2 matrices CVAPI(void) imgproc_eigen2x2(const float* a, float* e, int n); //! computes both eigenvalues and the eigenvectors of 2x2 derivative covariation matrix at each pixel. The output is stored as 6-channel matrix. CVAPI(void) imgproc_cornerEigenValsAndVecs(cv::_InputArray *src, cv::_OutputArray *dst, - int blockSize, int ksize, int borderType); + int blockSize, int ksize, int borderType) +{ +} //! computes another complex cornerness criteria at each pixel -CVAPI(void) imgproc_preCornerDetect(cv::_InputArray *src, cv::_OutputArray *dst, int ksize, int borderType); +CVAPI(void) imgproc_preCornerDetect(cv::_InputArray *src, cv::_OutputArray *dst, int ksize, int borderType) +{ +} //! adjusts the corner locations with sub-pixel accuracy to maximize the certain cornerness criteria CVAPI(void) imgproc_cornerSubPix(cv::_InputArray *src, cv::_OutputArray *corners, - CvSize winSize, CvSize zeroZone, CvTermCriteria criteria); + CvSize winSize, CvSize zeroZone, CvTermCriteria criteria) +{ +} //! finds the strong enough corners where the cornerMinEigenVal() or cornerHarris() report the local maxima CVAPI(void) imgproc_goodFeaturesToTrack(cv::_InputArray *src, cv::_OutputArray *corners, int maxCorners, double qualityLevel, double minDistance, - cv::_InputArray *mask, int blockSize, bool useHarrisDetector, double k); + cv::_InputArray *mask, int blockSize, bool useHarrisDetector, double k) +{ +} //! finds lines in the black-n-white image using the standard or pyramid Hough transform CVAPI(void) imgproc_HoughLines(cv::_InputArray *src, cv::_OutputArray *lines, double rho, double theta, int threshold, - double srn = 0, double stn = 0); + double srn, double stn) +{ + cv::HoughLines(*src, *lines, rho, theta, threshold, srn, stn); +} //! finds line segments in the black-n-white image using probabilistic Hough transform -CVAPI(void) imgproc_HoughLinesP(cv::_InputArray *src, cv::_OutputArray *lines, +CVAPI(void) imgproc_HoughLinesP(cv::_InputArray *src, std::vector *lines, double rho, double theta, int threshold, - double minLineLength = 0, double maxLineGap = 0); + double minLineLength, double maxLineGap) +{ + cv::HoughLinesP(*src, *lines, rho, theta, threshold, minLineLength, maxLineGap); +} //! finds circles in the grayscale image using 2+1 gradient Hough transform CVAPI(void) imgproc_HoughCircles(cv::_InputArray *src, cv::_OutputArray *circles, int method, double dp, double minDist, - double param1 = 100, double param2 = 100, - int minRadius = 0, int maxRadius = 0); + double param1, double param2, int minRadius, int maxRadius) +{ + cv::HoughCircles(*src, *circles, method, dp, minDist, param1, param2, minRadius, maxRadius); +} #endif \ No newline at end of file diff --git a/src/OpenCvSharpExtern/WVector.cpp b/src/OpenCvSharpExtern/std_vector.cpp similarity index 76% rename from src/OpenCvSharpExtern/WVector.cpp rename to src/OpenCvSharpExtern/std_vector.cpp index 442e48c46..362fc8df3 100644 --- a/src/OpenCvSharpExtern/WVector.cpp +++ b/src/OpenCvSharpExtern/std_vector.cpp @@ -3,4 +3,4 @@ * This code is licenced under the LGPL. */ -#include "WVector.h" \ No newline at end of file +#include "std_vector.h" \ No newline at end of file diff --git a/src/OpenCvSharpExtern/WVector.h b/src/OpenCvSharpExtern/std_vector.h similarity index 66% rename from src/OpenCvSharpExtern/WVector.h rename to src/OpenCvSharpExtern/std_vector.h index 07f1efba6..e98d1a313 100644 --- a/src/OpenCvSharpExtern/WVector.h +++ b/src/OpenCvSharpExtern/std_vector.h @@ -70,15 +70,15 @@ CVAPI(void) vector_float_delete(vector* vector) #pragma endregion #pragma region cv::Vec2f -CVAPI(vector*) vector_cvVec2f_new1() +CVAPI(vector*) vector_Vec2f_new1() { return new vector; } -CVAPI(vector*) vector_cvVec2f_new2(size_t size) +CVAPI(vector*) vector_Vec2f_new2(size_t size) { return new vector(size); } -CVAPI(vector*) vector_cvVec2f_new3(cv::Vec2f* data, size_t data_length) +CVAPI(vector*) vector_Vec2f_new3(cv::Vec2f* data, size_t data_length) { vector* vec = new vector(data_length); for(size_t i=0; i*) vector_cvVec2f_new3(cv::Vec2f* data, size_t data_lengt } return vec; } -CVAPI(size_t) vector_cvVec2f_getSize(vector* vector) +CVAPI(size_t) vector_Vec2f_getSize(vector* vector) { return vector->size(); } -CVAPI(cv::Vec2f*) vector_cvVec2f_getPointer(vector* vector) +CVAPI(cv::Vec2f*) vector_Vec2f_getPointer(vector* vector) { return &(vector->at(0)); } -CVAPI(void) vector_cvVec2f_delete(vector* vector) +CVAPI(void) vector_Vec2f_delete(vector* vector) { delete vector; } #pragma endregion #pragma region cv::Vec3f -CVAPI(vector*) vector_cvVec3f_new1() +CVAPI(vector*) vector_Vec3f_new1() { return new vector; } -CVAPI(vector*) vector_cvVec3f_new2(size_t size) +CVAPI(vector*) vector_Vec3f_new2(size_t size) { return new vector(size); } -CVAPI(vector*) vector_cvVec3f_new3(cv::Vec3f* data, size_t data_length) +CVAPI(vector*) vector_Vec3f_new3(cv::Vec3f* data, size_t data_length) { vector* vec = new vector(data_length); for(size_t i=0; i*) vector_cvVec3f_new3(cv::Vec3f* data, size_t data_lengt } return vec; } -CVAPI(size_t) vector_cvVec3f_getSize(vector* vector) +CVAPI(size_t) vector_Vec3f_getSize(vector* vector) { return vector->size(); } -CVAPI(cv::Vec3f*) vector_cvVec3f_getPointer(vector* vector) +CVAPI(cv::Vec3f*) vector_Vec3f_getPointer(vector* vector) { return &(vector->at(0)); } -CVAPI(void) vector_cvVec3f_delete(vector* vector) +CVAPI(void) vector_Vec3f_delete(vector* vector) { delete vector; } #pragma endregion #pragma region cv::Vec4i -CVAPI(vector*) vector_cvVec4i_new1() +CVAPI(vector*) vector_Vec4i_new1() { return new vector; } -CVAPI(vector*) vector_cvVec4i_new2(size_t size) +CVAPI(vector*) vector_Vec4i_new2(size_t size) { return new vector(size); } -CVAPI(vector*) vector_cvVec4i_new3(cv::Vec4i* data, size_t data_length) +CVAPI(vector*) vector_Vec4i_new3(cv::Vec4i* data, size_t data_length) { vector* vec = new vector(data_length); for(size_t i=0; i*) vector_cvVec4i_new3(cv::Vec4i* data, size_t data_lengt } return vec; } -CVAPI(size_t) vector_cvVec4i_getSize(vector* vector) +CVAPI(size_t) vector_Vec4i_getSize(vector* vector) { return vector->size(); } -CVAPI(cv::Vec4i*) vector_cvVec4i_getPointer(vector* vector) +CVAPI(cv::Vec4i*) vector_Vec4i_getPointer(vector* vector) { return &(vector->at(0)); } -CVAPI(void) vector_cvVec4i_delete(vector* vector) +CVAPI(void) vector_Vec4i_delete(vector* vector) { delete vector; } @@ -198,15 +198,15 @@ CVAPI(void) vector_cvPoint_delete(vector* vector) #pragma endregion #pragma region cv::Rect -CVAPI(vector*) vector_cvRect_new1() +CVAPI(vector*) vector_Rect_new1() { return new vector; } -CVAPI(vector*) vector_cvRect_new2(size_t size) +CVAPI(vector*) vector_Rect_new2(size_t size) { return new vector(size); } -CVAPI(vector*) vector_cvRect_new3(CvRect* data, size_t data_length) +CVAPI(vector*) vector_Rect_new3(CvRect* data, size_t data_length) { vector* vec = new vector(data_length); for(size_t i=0; i*) vector_cvRect_new3(CvRect* data, size_t data_length) } return vec; } -CVAPI(size_t) vector_cvRect_getSize(vector* vector) +CVAPI(size_t) vector_Rect_getSize(vector* vector) { return vector->size(); } -CVAPI(cv::Rect*) vector_cvRect_getPointer(vector* vector) +CVAPI(cv::Rect*) vector_Rect_getPointer(vector* vector) { return &(vector->at(0)); } -CVAPI(void) vector_cvRect_delete(vector* vector) +CVAPI(void) vector_Rect_delete(vector* vector) { //vector->~vector(); delete vector; @@ -232,15 +232,15 @@ CVAPI(void) vector_cvRect_delete(vector* vector) #pragma endregion #pragma region cv::KeyPoint -CVAPI(vector*) vector_cvKeyPoint_new1() +CVAPI(vector*) vector_KeyPoint_new1() { return new vector; } -CVAPI(vector*) vector_cvKeyPoint_new2(size_t size) +CVAPI(vector*) vector_KeyPoint_new2(size_t size) { return new vector(size); } -CVAPI(vector*) vector_cvKeyPoint_new3(cv::KeyPoint* data, size_t data_length) +CVAPI(vector*) vector_KeyPoint_new3(cv::KeyPoint* data, size_t data_length) { vector* vec = new vector(data_length); for(size_t i=0; i*) vector_cvKeyPoint_new3(cv::KeyPoint* data, size_t d } return vec; } -CVAPI(size_t) vector_cvKeyPoint_getSize(vector* vector) +CVAPI(size_t) vector_KeyPoint_getSize(vector* vector) { return vector->size(); } -CVAPI(cv::KeyPoint*) vector_cvKeyPoint_getPointer(vector* vector) +CVAPI(cv::KeyPoint*) vector_KeyPoint_getPointer(vector* vector) { return &(vector->at(0)); } -CVAPI(void) vector_cvKeyPoint_delete(vector* vector) +CVAPI(void) vector_KeyPoint_delete(vector* vector) { //vector->~vector(); delete vector; From fc12369e720bf6cdf9d0f86bff5987e0703b37f1 Mon Sep 17 00:00:00 2001 From: shimat Date: Sat, 8 Feb 2014 00:46:51 +0900 Subject: [PATCH 18/29] Added imgproc methods --- src/OpenCvSharp/Src/DisposableCvObject.cs | 2 +- src/OpenCvSharpExtern/imgproc.h | 22 ++++------------------ 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/src/OpenCvSharp/Src/DisposableCvObject.cs b/src/OpenCvSharp/Src/DisposableCvObject.cs index bad97da04..b74eefef9 100644 --- a/src/OpenCvSharp/Src/DisposableCvObject.cs +++ b/src/OpenCvSharp/Src/DisposableCvObject.cs @@ -152,7 +152,7 @@ public IntPtr CvPtr /// /// /// IntPtr.Zero if obj==null, obj.CvPtr otherwise - protected static IntPtr GetCvPtr(DisposableCvObject obj) + public static IntPtr GetCvPtr(DisposableCvObject obj) { return (obj == null) ? IntPtr.Zero : obj.CvPtr; } diff --git a/src/OpenCvSharpExtern/imgproc.h b/src/OpenCvSharpExtern/imgproc.h index 262d933c9..6e6de2bd2 100644 --- a/src/OpenCvSharpExtern/imgproc.h +++ b/src/OpenCvSharpExtern/imgproc.h @@ -60,91 +60,78 @@ CVAPI(void) imgproc_blur(cv::_InputArray *src, cv::_OutputArray *dst, CvSize ksi { cv::blur(*src, *dst, ksize, anchor, borderType); } -//! applies non-separable 2D linear filter to the image + CVAPI(void) imgproc_filter2D(cv::_InputArray *src, cv::_OutputArray *dst, int ddepth, cv::_InputArray *kernel, CvPoint anchor, double delta, int borderType) { + cv::filter2D(*src, *dst, ddepth, *kernel, anchor, delta, borderType); } -//! applies separable 2D linear filter to the image CVAPI(void) imgproc_sepFilter2D(cv::_InputArray *src, cv::_OutputArray *dst, int ddepth, cv::_InputArray *kernelX, cv::_InputArray kernelY, CvPoint anchor, double delta, int borderType) { } -//! applies generalized Sobel operator to the image CVAPI(void) imgproc_Sobel(cv::_InputArray *src, cv::_OutputArray *dst, int ddepth, int dx, int dy, int ksize, double scale, double delta, int borderType) { } -//! applies the vertical or horizontal Scharr operator to the image CVAPI(void) imgproc_Scharr(cv::_InputArray *src, cv::_OutputArray *dst, int ddepth, int dx, int dy, double scale, double delta, int borderType) { } -//! applies Laplacian operator to the image CVAPI(void) imgproc_Laplacian(cv::_InputArray *src, cv::_OutputArray *dst, int ddepth, int ksize, double scale, double delta, int borderType) { } -//! applies Canny edge detector and produces the edge map. CVAPI(void) imgproc_Canny(cv::_InputArray *src, cv::_OutputArray *edges, double threshold1, double threshold2, int apertureSize, bool L2gradient) { } -//! computes minimum eigen value of 2x2 derivative covariation matrix at each pixel - the cornerness criteria CVAPI(void) imgproc_cornerMinEigenVal(cv::_InputArray *src, cv::_OutputArray *dst, int blockSize, int ksize, int borderType) { } -//! computes Harris cornerness criteria at each image pixel CVAPI(void) imgproc_cornerHarris(cv::_InputArray *src, cv::_OutputArray *dst, int blockSize, int ksize, double k, int borderType) { } -// low-level function for computing eigenvalues and eigenvectors of 2x2 matrices CVAPI(void) imgproc_eigen2x2(const float* a, float* e, int n); -//! computes both eigenvalues and the eigenvectors of 2x2 derivative covariation matrix at each pixel. The output is stored as 6-channel matrix. CVAPI(void) imgproc_cornerEigenValsAndVecs(cv::_InputArray *src, cv::_OutputArray *dst, int blockSize, int ksize, int borderType) { } -//! computes another complex cornerness criteria at each pixel CVAPI(void) imgproc_preCornerDetect(cv::_InputArray *src, cv::_OutputArray *dst, int ksize, int borderType) { } -//! adjusts the corner locations with sub-pixel accuracy to maximize the certain cornerness criteria CVAPI(void) imgproc_cornerSubPix(cv::_InputArray *src, cv::_OutputArray *corners, CvSize winSize, CvSize zeroZone, CvTermCriteria criteria) { } -//! finds the strong enough corners where the cornerMinEigenVal() or cornerHarris() report the local maxima CVAPI(void) imgproc_goodFeaturesToTrack(cv::_InputArray *src, cv::_OutputArray *corners, int maxCorners, double qualityLevel, double minDistance, cv::_InputArray *mask, int blockSize, bool useHarrisDetector, double k) { } -//! finds lines in the black-n-white image using the standard or pyramid Hough transform -CVAPI(void) imgproc_HoughLines(cv::_InputArray *src, cv::_OutputArray *lines, +CVAPI(void) imgproc_HoughLines(cv::_InputArray *src, std::vector *lines, double rho, double theta, int threshold, double srn, double stn) { cv::HoughLines(*src, *lines, rho, theta, threshold, srn, stn); } -//! finds line segments in the black-n-white image using probabilistic Hough transform CVAPI(void) imgproc_HoughLinesP(cv::_InputArray *src, std::vector *lines, double rho, double theta, int threshold, double minLineLength, double maxLineGap) @@ -152,8 +139,7 @@ CVAPI(void) imgproc_HoughLinesP(cv::_InputArray *src, std::vector *li cv::HoughLinesP(*src, *lines, rho, theta, threshold, minLineLength, maxLineGap); } -//! finds circles in the grayscale image using 2+1 gradient Hough transform -CVAPI(void) imgproc_HoughCircles(cv::_InputArray *src, cv::_OutputArray *circles, +CVAPI(void) imgproc_HoughCircles(cv::_InputArray *src, std::vector *circles, int method, double dp, double minDist, double param1, double param2, int minRadius, int maxRadius) { From 4c593afdd1e0e08f5b6b176cd54b05c573ee7944 Mon Sep 17 00:00:00 2001 From: shimat Date: Sat, 8 Feb 2014 08:12:58 +0900 Subject: [PATCH 19/29] Fixed CvBlobs.UpdateTracks --- src/OpenCvSharp.Blob/CvBlobs.cs | 363 ++++++++++++++----------- src/OpenCvSharpExtern/imgproc.h | 6 +- src/OpenCvSharpExtern/include_opencv.h | 2 + src/OpenCvSharpExtern/std_vector.h | 91 ++++--- 4 files changed, 262 insertions(+), 200 deletions(-) diff --git a/src/OpenCvSharp.Blob/CvBlobs.cs b/src/OpenCvSharp.Blob/CvBlobs.cs index 7643ffb50..f9850a456 100644 --- a/src/OpenCvSharp.Blob/CvBlobs.cs +++ b/src/OpenCvSharp.Blob/CvBlobs.cs @@ -38,6 +38,7 @@ public class CvBlobs : Dictionary public CvBlobs() { } + /// /// Constructor (init and cvLabel) /// @@ -55,7 +56,9 @@ public CvBlobs(IplImage img) } #region Methods + #region BlobMeanColor + /// /// Calculates mean color of a blob in an image. (cvBlobMeanColor) /// @@ -74,13 +77,13 @@ public CvScalar BlobMeanColor(CvBlob targetBlob, IplImage originalImage) if (Labels == null) throw new ArgumentException("blobs.Labels == null"); - int step = originalImage.WidthStep; + int step = originalImage.WidthStep; CvRect roi = originalImage.ROI; int width = roi.Width; int height = roi.Height; int offset = roi.X + (roi.Y * step); - int mb = 0; + int mb = 0; int mg = 0; int mr = 0; unsafe @@ -93,8 +96,8 @@ public CvScalar BlobMeanColor(CvBlob targetBlob, IplImage originalImage) if (Labels[r, c] == targetBlob.Label) { mb += imgData[3 * c + 0]; - mg += imgData[3 * c + 1]; - mr += imgData[3 * c + 2]; + mg += imgData[3 * c + 1]; + mr += imgData[3 * c + 2]; } } imgData += step; @@ -103,8 +106,11 @@ public CvScalar BlobMeanColor(CvBlob targetBlob, IplImage originalImage) int pixels = targetBlob.Area; return new CvColor((byte)(mr / pixels), (byte)(mg / pixels), (byte)(mb / pixels)); } + #endregion + #region FilterByArea + /// /// Filter blobs by area. /// Those blobs whose areas are not in range will be erased from the input list of blobs. (cvFilterByArea) @@ -113,7 +119,7 @@ public CvScalar BlobMeanColor(CvBlob targetBlob, IplImage originalImage) /// Maximun area. public void FilterByArea(int minArea, int maxArea) { - int[] keys = new int[Count]; + int[] keys = new int[Count]; Keys.CopyTo(keys, 0); foreach (int key in keys) @@ -125,8 +131,11 @@ public void FilterByArea(int minArea, int maxArea) } } } + #endregion + #region FilterByLabel + /// /// Filter blobs by label. /// Delete all blobs except those with label l. @@ -145,8 +154,11 @@ public void FilterByLabel(int label) } } } + #endregion + #region FilterLabels + /// /// Draw a binary image with the blobs that have been given. (cvFilterLabels) /// @@ -192,8 +204,11 @@ public void FilterLabels(IplImage imgOut) } } } + #endregion + #region GreaterBlob + /// /// Find greater blob. (cvGreaterBlob) /// @@ -202,6 +217,7 @@ public CvBlob GreaterBlob() { return LargestBlob(); } + /// /// Find the largest blob. (cvGreaterBlob) /// @@ -214,19 +230,22 @@ public CvBlob LargestBlob() var list = new List>(this); // é™é †ã‚½ãƒ¼ãƒˆ list.Sort((kv1, kv2) => - { - CvBlob b1 = kv1.Value; - CvBlob b2 = kv2.Value; - if (b1 == null) - return -1; - if (b2 == null) - return 1; - return b2.Area - b1.Area; - }); + { + CvBlob b1 = kv1.Value; + CvBlob b2 = kv2.Value; + if (b1 == null) + return -1; + if (b2 == null) + return 1; + return b2.Area - b1.Area; + }); return list[0].Value; } + #endregion + #region GetLabel + /// /// Label the connected parts of a binary image. (cvLabel) /// @@ -237,8 +256,11 @@ public int GetLabel(int x, int y) { return Labels[y, x]; } + #endregion + #region Label + /// /// Label the connected parts of a binary image. (cvLabel) /// @@ -252,8 +274,11 @@ public int Label(IplImage img) Labels = new LabelData(img.Height, img.Width, img.ROI); return Labeller.Perform(img, this); } + #endregion + #region RenderBlobs + /// /// Draws or prints information about blobs. (cvRenderBlobs) /// @@ -263,6 +288,7 @@ public void RenderBlobs(IplImage imgSource, IplImage imgDest) { CvBlobLib.RenderBlobs(this, imgSource, imgDest); } + /// /// Draws or prints information about blobs. (cvRenderBlobs) /// @@ -273,6 +299,7 @@ public void RenderBlobs(IplImage imgSource, IplImage imgDest, RenderBlobsMode mo { CvBlobLib.RenderBlobs(this, imgSource, imgDest, mode); } + /// /// Draws or prints information about blobs. (cvRenderBlobs) /// @@ -284,8 +311,11 @@ public void RenderBlobs(IplImage imgSource, IplImage imgDest, RenderBlobsMode mo { CvBlobLib.RenderBlobs(this, imgSource, imgDest, mode, alpha); } + #endregion + #region UpdateTracks + /// /// Updates list of tracks based on current blobs. /// @@ -303,6 +333,7 @@ public void UpdateTracks(CvTracks tracks, double thDistance, int thInactive) { UpdateTracks(tracks, thDistance, thInactive, 0); } + /// /// Updates list of tracks based on current blobs. /// @@ -323,161 +354,160 @@ public void UpdateTracks(CvTracks tracks, double thDistance, int thInactive, int throw new ArgumentNullException("tracks"); int nBlobs = this.Count; - int nTracks = tracks.Count; + int nTracks = tracks.Count; if (nBlobs == 0) return; - // Proximity matrix: - // Last row/column is for ID/label. - // Last-1 "/" is for accumulation. + // Proximity matrix: + // Last row/column is for ID/label. + // Last-1 "/" is for accumulation. ProximityMatrix close = new ProximityMatrix(nBlobs, nTracks); - // Initialization: - int i = 0; - foreach (CvBlob blob in Values) - { - close.AB[i] = 0; - close.IB[i] = blob.Label; - i++; - } - - int maxTrackID = 0; - int j = 0; - foreach (CvTrack track in tracks.Values) - { - close.AT[j] = 0; - close.AT[j] = track.Id; - if (track.Id > maxTrackID) - maxTrackID = track.Id; - j++; - } - - // Proximity matrix calculation and "used blob" list inicialization: - for (i = 0; i < nBlobs; i++) - { - for (j = 0; j < nTracks; j++) - { - CvBlob b = this[close.IB[i]]; - CvTrack t = tracks[close.IT[j]]; - close[i, j] = (int)DistantBlobTrack(b, t); - if (close[i, j] < thDistance) - { - close.AB[i]++; - close.AT[j]++; - } - } - } - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Detect inactive tracks - for (j = 0; j < nTracks; j++) - { - int c = close[nBlobs, j]; - if (c == 0) - { - //cout << "Inactive track: " << j << endl; - - // Inactive track. - CvTrack track = tracks[j]; - track.Inactive++; - track.Label = 0; - } - } - - // Detect new tracks - for (i = 0; i < nBlobs; i++) - { - int c = close.AB[i]; - if (c == 0) - { - //cout << "Blob (new track): " << maxTrackID+1 << endl; - //cout << *B(i) << endl; - - // New track. - maxTrackID++; - CvBlob blob = this[i]; - CvTrack track = new CvTrack - { - Id = maxTrackID, - Label = blob.Label, - MinX = blob.MinX, - MinY = blob.MinY, - MaxX = blob.MaxX, - MaxY = blob.MaxY, - Centroid = blob.Centroid, - LifeTime = 0, - Active = 0, - Inactive = 0, - }; - tracks[maxTrackID] = track; - } - } - - // Clustering - for (j = 0; j < nTracks; j++) - { - int c = close.AT[j]; - if (c != 0) - { - List tt = new List(); - tt.Add(tracks[j]); - List bb = new List(); - - GetClusterForTrack(j, close, nBlobs, nTracks, this, tracks, bb, tt); - - // Select track - CvTrack track = null; - int area = 0; - foreach (CvTrack t in tt) - { - int a = (t.MaxX - t.MinX)*(t.MaxY - t.MinY); - if (a > area) - { - area = a; - track = t; - } - } - - // Select blob - CvBlob blob = null; - area = 0; - foreach (CvBlob b in Values) - { - if (b.Area > area) - { - area = b.Area; - blob = b; - } - } - - if(blob == null || track == null) + // Initialization: + int i = 0; + foreach (CvBlob blob in Values) + { + close.AB[i] = 0; + close.IB[i] = blob.Label; + i++; + } + + int maxTrackID = 0; + int j = 0; + foreach (CvTrack track in tracks.Values) + { + close.AT[j] = 0; + close.AT[j] = track.Id; + if (track.Id > maxTrackID) + maxTrackID = track.Id; + j++; + } + + // Proximity matrix calculation and "used blob" list inicialization: + for (i = 0; i < nBlobs; i++) + { + for (j = 0; j < nTracks; j++) + { + CvBlob b = this[close.IB[i]]; + CvTrack t = tracks[close.IT[j]]; + close[i, j] = (DistantBlobTrack(b, t) < thDistance) ? 1 : 0; + if (close[i, j] < thDistance) + { + close.AB[i]++; + close.AT[j]++; + } + } + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Detect inactive tracks + for (j = 0; j < nTracks; j++) + { + int c = close[nBlobs, j]; + if (c == 0) + { + //cout << "Inactive track: " << j << endl; + + // Inactive track. + CvTrack track = tracks[j]; + track.Inactive++; + track.Label = 0; + } + } + + // Detect new tracks + for (i = 0; i < nBlobs; i++) + { + int c = close.AB[i]; + if (c == 0) + { + //cout << "Blob (new track): " << maxTrackID+1 << endl; + //cout << *B(i) << endl; + + // New track. + maxTrackID++; + CvBlob blob = this[i]; + CvTrack track = new CvTrack + { + Id = maxTrackID, + Label = blob.Label, + MinX = blob.MinX, + MinY = blob.MinY, + MaxX = blob.MaxX, + MaxY = blob.MaxY, + Centroid = blob.Centroid, + LifeTime = 0, + Active = 0, + Inactive = 0, + }; + tracks[maxTrackID] = track; + } + } + + // Clustering + for (j = 0; j < nTracks; j++) + { + int c = close.AT[j]; + if (c != 0) + { + List tt = new List {tracks[j]}; + List bb = new List(); + + GetClusterForTrack(j, close, nBlobs, nTracks, this, tracks, bb, tt); + + // Select track + CvTrack track = null; + int area = 0; + foreach (CvTrack t in tt) + { + int a = (t.MaxX - t.MinX) * (t.MaxY - t.MinY); + if (a > area) + { + area = a; + track = t; + } + } + + // Select blob + CvBlob blob = null; + area = 0; + foreach (CvBlob b in Values) + { + if (b.Area > area) + { + area = b.Area; + blob = b; + } + } + + if (blob == null || track == null) throw new NotSupportedException(); - // Update track - track.Label = blob.Label; - track.Centroid = blob.Centroid; - track.MinX = blob.MinX; - track.MinY = blob.MinY; - track.MaxX = blob.MaxX; - track.MaxY = blob.MaxY; - if (track.Inactive != 0) - track.Active = 0; - track.Inactive = 0; - - // Others to inactive - foreach (CvTrack t in tt) - { - if (t != track) - { - //cout << "Inactive: track=" << t->id << endl; - t.Inactive++; - t.Label = 0; - } - } - } - } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Update track + track.Label = blob.Label; + track.Centroid = blob.Centroid; + track.MinX = blob.MinX; + track.MinY = blob.MinY; + track.MaxX = blob.MaxX; + track.MaxY = blob.MaxY; + if (track.Inactive != 0) + track.Active = 0; + track.Inactive = 0; + + // Others to inactive + foreach (CvTrack t in tt) + { + if (t != track) + { + //cout << "Inactive: track=" << t->id << endl; + t.Inactive++; + t.Label = 0; + } + } + } + } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// int[] trackKeys = new int[tracks.Count]; tracks.Keys.CopyTo(trackKeys, 0); @@ -498,7 +528,7 @@ public void UpdateTracks(CvTracks tracks, double thDistance, int thInactive, int } } - double DistantBlobTrack(CvBlob b, CvTrack t) + private double DistantBlobTrack(CvBlob b, CvTrack t) { double d1; if (b.Centroid.X < t.MinX) @@ -562,8 +592,8 @@ double DistantBlobTrack(CvBlob b, CvTrack t) } private static void GetClusterForTrack(int trackPos, ProximityMatrix close, - int nBlobs, int nTracks, CvBlobs blobs, - CvTracks tracks, List bb, List tt) + int nBlobs, int nTracks, CvBlobs blobs, + CvTracks tracks, List bb, List tt) { for (int i = 0; i < nBlobs; i++) { @@ -586,8 +616,8 @@ private static void GetClusterForTrack(int trackPos, ProximityMatrix close, } private static void GetClusterForBlob(int blobPos, ProximityMatrix close, - int nBlobs, int nTracks, CvBlobs blobs, CvTracks tracks, - List bb, List tt) + int nBlobs, int nTracks, CvBlobs blobs, CvTracks tracks, + List bb, List tt) { for (int j = 0; j < nTracks; j++) { @@ -610,6 +640,7 @@ private static void GetClusterForBlob(int blobPos, ProximityMatrix close, } #endregion + #endregion } } diff --git a/src/OpenCvSharpExtern/imgproc.h b/src/OpenCvSharpExtern/imgproc.h index 6e6de2bd2..c177d6635 100644 --- a/src/OpenCvSharpExtern/imgproc.h +++ b/src/OpenCvSharpExtern/imgproc.h @@ -119,10 +119,12 @@ CVAPI(void) imgproc_cornerSubPix(cv::_InputArray *src, cv::_OutputArray *corners { } -CVAPI(void) imgproc_goodFeaturesToTrack(cv::_InputArray *src, cv::_OutputArray *corners, +CVAPI(void) imgproc_goodFeaturesToTrack(cv::_InputArray *src, std::vector *corners, int maxCorners, double qualityLevel, double minDistance, - cv::_InputArray *mask, int blockSize, bool useHarrisDetector, double k) + cv::_InputArray *mask, int blockSize, int useHarrisDetector, double k) { + cv::InputArray maskVal = (mask == NULL) ? cv::noArray() : *mask; + cv::goodFeaturesToTrack(*src, *corners, maxCorners, qualityLevel, minDistance, maskVal, blockSize, useHarrisDetector != 0, k); } CVAPI(void) imgproc_HoughLines(cv::_InputArray *src, std::vector *lines, diff --git a/src/OpenCvSharpExtern/include_opencv.h b/src/OpenCvSharpExtern/include_opencv.h index e5163efca..d49e76369 100644 --- a/src/OpenCvSharpExtern/include_opencv.h +++ b/src/OpenCvSharpExtern/include_opencv.h @@ -2,5 +2,7 @@ #define _INCLUDE_OPENCV_H_ #include +typedef unsigned int uint; +typedef unsigned short ushort; #endif diff --git a/src/OpenCvSharpExtern/std_vector.h b/src/OpenCvSharpExtern/std_vector.h index e98d1a313..342327094 100644 --- a/src/OpenCvSharpExtern/std_vector.h +++ b/src/OpenCvSharpExtern/std_vector.h @@ -6,12 +6,7 @@ #ifndef _CPP_WVECTOR_H_ #define _CPP_WVECTOR_H_ -#include - -#ifdef _MSC_VER -#pragma warning(disable: 4251) -#endif -#include +#include "include_opencv.h" using namespace std; @@ -20,11 +15,11 @@ CVAPI(vector*) vector_uchar_new1() { return new vector; } -CVAPI(vector*) vector_uchar_new2(size_t size) +CVAPI(vector*) vector_uchar_new2(uint size) { return new vector(size); } -CVAPI(vector*) vector_uchar_new3(uchar* data, size_t data_length) +CVAPI(vector*) vector_uchar_new3(uchar* data, uint data_length) { return new vector(data, data + data_length); } @@ -47,11 +42,11 @@ CVAPI(vector*) vector_float_new1() { return new vector; } -CVAPI(vector*) vector_float_new2(size_t size) +CVAPI(vector*) vector_float_new2(uint size) { return new vector(size); } -CVAPI(vector*) vector_float_new3(float* data, size_t data_length) +CVAPI(vector*) vector_float_new3(float* data, uint data_length) { return new vector(data, data + data_length); } @@ -74,14 +69,14 @@ CVAPI(vector*) vector_Vec2f_new1() { return new vector; } -CVAPI(vector*) vector_Vec2f_new2(size_t size) +CVAPI(vector*) vector_Vec2f_new2(uint size) { return new vector(size); } -CVAPI(vector*) vector_Vec2f_new3(cv::Vec2f* data, size_t data_length) +CVAPI(vector*) vector_Vec2f_new3(cv::Vec2f* data, uint data_length) { vector* vec = new vector(data_length); - for(size_t i=0; ipush_back(data[i]); } @@ -138,14 +133,14 @@ CVAPI(vector*) vector_Vec4i_new1() { return new vector; } -CVAPI(vector*) vector_Vec4i_new2(size_t size) +CVAPI(vector*) vector_Vec4i_new2(uint size) { return new vector(size); } -CVAPI(vector*) vector_Vec4i_new3(cv::Vec4i* data, size_t data_length) +CVAPI(vector*) vector_Vec4i_new3(cv::Vec4i* data, uint data_length) { vector* vec = new vector(data_length); - for(size_t i=0; ipush_back(data[i]); } @@ -165,33 +160,65 @@ CVAPI(void) vector_Vec4i_delete(vector* vector) } #pragma endregion -#pragma region cv::Point -CVAPI(vector*) vector_cvPoint_new1() +#pragma region cv::Point2i +CVAPI(vector*) vector_Point2i_new1() { return new vector; } -CVAPI(vector*) vector_cvPoint_new2(size_t size) +CVAPI(vector*) vector_Point2i_new2(uint size) { return new vector(size); } -CVAPI(vector*) vector_cvPoint_new3(CvPoint* data, size_t data_length) +CVAPI(vector*) vector_Point2i_new3(CvPoint* data, uint data_length) { vector* vec = new vector(data_length); - for(size_t i=0; ipush_back(data[i]); + } + return vec; +} +CVAPI(size_t) vector_Point2i_getSize(vector* vector) +{ + return vector->size(); +} +CVAPI(cv::Point*) vector_Point2i_getPointer(vector* vector) +{ + return &(vector->at(0)); +} +CVAPI(void) vector_Point2i_delete(vector* vector) +{ + delete vector; +} +#pragma endregion + +#pragma region cv::Point2f +CVAPI(vector*) vector_Point2f_new1() +{ + return new vector; +} +CVAPI(vector*) vector_Point2f_new2(uint size) +{ + return new vector(size); +} +CVAPI(vector*) vector_Point2f_new3(CvPoint2D32f* data, uint data_length) +{ + vector* vec = new vector(data_length); + for (uint i = 0; ipush_back(data[i]); } return vec; } -CVAPI(size_t) vector_cvPoint_getSize(vector* vector) +CVAPI(size_t) vector_cvPoint_getSize(vector* vector) { return vector->size(); } -CVAPI(cv::Point*) vector_cvPoint_getPointer(vector* vector) +CVAPI(cv::Point2f*) vector_cvPoint_getPointer(vector* vector) { return &(vector->at(0)); } -CVAPI(void) vector_cvPoint_delete(vector* vector) +CVAPI(void) vector_cvPoint_delete(vector* vector) { delete vector; } @@ -202,28 +229,28 @@ CVAPI(vector*) vector_Rect_new1() { return new vector; } -CVAPI(vector*) vector_Rect_new2(size_t size) +CVAPI(vector*) vector_Rect_new2(uint size) { return new vector(size); } -CVAPI(vector*) vector_Rect_new3(CvRect* data, size_t data_length) +CVAPI(vector*) vector_Rect_new3(CvRect* data, size data_length) { vector* vec = new vector(data_length); - for(size_t i=0; ipush_back(data[i]); } return vec; } -CVAPI(size_t) vector_Rect_getSize(vector* vector) +CVAPI(size) vector_Rect_getSize(vector* vector) { return vector->size(); } -CVAPI(cv::Rect*) vector_Rect_getPointer(vector* vector) +CVAPI(cv::Rect*) vector_Rect_getPointer(vector *xvector) { return &(vector->at(0)); } -CVAPI(void) vector_Rect_delete(vector* vector) +CVAPI(void) vector_Rect_delete(vector *vector) { //vector->~vector(); delete vector; @@ -236,11 +263,11 @@ CVAPI(vector*) vector_KeyPoint_new1() { return new vector; } -CVAPI(vector*) vector_KeyPoint_new2(size_t size) +CVAPI(vector*) vector_KeyPoint_new2(size size) { return new vector(size); } -CVAPI(vector*) vector_KeyPoint_new3(cv::KeyPoint* data, size_t data_length) +CVAPI(vector*) vector_KeyPoint_new3(cv::KeyPoint *data, size data_length) { vector* vec = new vector(data_length); for(size_t i=0; i Date: Sat, 8 Feb 2014 08:55:45 +0900 Subject: [PATCH 20/29] Changed directory structure --- src/OpenCvSharp.Gpu/HOGDescriptor.cs | 4 +- .../OpenCvSharpExtern.vcxproj | 4 +- .../OpenCvSharpExtern.vcxproj.filters | 12 +- src/OpenCvSharpExtern/WHOGDescriptor.cpp | 6 - src/OpenCvSharpExtern/WHOGDescriptor.h | 264 ------------------ src/OpenCvSharpExtern/core_Mat.h | 8 + src/OpenCvSharpExtern/include_opencv.h | 22 +- src/OpenCvSharpExtern/objdetect.cpp | 6 + src/OpenCvSharpExtern/objdetect.h | 242 ++++++++++++++++ src/OpenCvSharpExtern/std_vector.h | 76 ++--- 10 files changed, 324 insertions(+), 320 deletions(-) delete mode 100644 src/OpenCvSharpExtern/WHOGDescriptor.cpp delete mode 100644 src/OpenCvSharpExtern/WHOGDescriptor.h create mode 100644 src/OpenCvSharpExtern/objdetect.cpp create mode 100644 src/OpenCvSharpExtern/objdetect.h diff --git a/src/OpenCvSharp.Gpu/HOGDescriptor.cs b/src/OpenCvSharp.Gpu/HOGDescriptor.cs index 55fd51ec8..a1d614114 100644 --- a/src/OpenCvSharp.Gpu/HOGDescriptor.cs +++ b/src/OpenCvSharp.Gpu/HOGDescriptor.cs @@ -7,7 +7,7 @@ using System.Collections.Generic; using System.Text; using OpenCvSharp; -using OpenCvSharp.CPlusPlus; +using OpenCvSharp.CPlusPlus.Prototype; namespace OpenCvSharp.Gpu { @@ -1338,7 +1338,7 @@ public virtual CvPoint[] Detect(GpuMat img, double hitThreshold, CvSize winStrid if (img == null) throw new ArgumentNullException("img"); - using (StdVectorPoint flVec = new StdVectorPoint()) + using (StdVectorPoint2i flVec = new StdVectorPoint2i()) { GpuInvoke.HOGDescriptor_detect(ptr, img.CvPtr, flVec.CvPtr, hitThreshold, winStride, padding); // std::vector*ã‹ã‚‰CvPoint[]ã«ç§»ã—替ãˆã¦è¿”ã™ diff --git a/src/OpenCvSharpExtern/OpenCvSharpExtern.vcxproj b/src/OpenCvSharpExtern/OpenCvSharpExtern.vcxproj index 9a75571b4..2769992a0 100644 --- a/src/OpenCvSharpExtern/OpenCvSharpExtern.vcxproj +++ b/src/OpenCvSharpExtern/OpenCvSharpExtern.vcxproj @@ -217,6 +217,7 @@ + @@ -244,7 +245,6 @@ - @@ -259,6 +259,7 @@ + @@ -283,7 +284,6 @@ - diff --git a/src/OpenCvSharpExtern/OpenCvSharpExtern.vcxproj.filters b/src/OpenCvSharpExtern/OpenCvSharpExtern.vcxproj.filters index a1316789e..40e83945d 100644 --- a/src/OpenCvSharpExtern/OpenCvSharpExtern.vcxproj.filters +++ b/src/OpenCvSharpExtern/OpenCvSharpExtern.vcxproj.filters @@ -82,9 +82,6 @@ Sources - - Sources - Sources @@ -118,6 +115,9 @@ Sources\cpp + + Sources\cpp + @@ -189,9 +189,6 @@ Headers - - Headers - Headers @@ -225,6 +222,9 @@ Headers\cpp + + Headers\cpp + diff --git a/src/OpenCvSharpExtern/WHOGDescriptor.cpp b/src/OpenCvSharpExtern/WHOGDescriptor.cpp deleted file mode 100644 index 868922309..000000000 --- a/src/OpenCvSharpExtern/WHOGDescriptor.cpp +++ /dev/null @@ -1,6 +0,0 @@ -/* - * (C) 2008-2014 shimat - * This code is licenced under the LGPL. - */ - -#include "WHOGDescriptor.h" \ No newline at end of file diff --git a/src/OpenCvSharpExtern/WHOGDescriptor.h b/src/OpenCvSharpExtern/WHOGDescriptor.h deleted file mode 100644 index 3645c0f62..000000000 --- a/src/OpenCvSharpExtern/WHOGDescriptor.h +++ /dev/null @@ -1,264 +0,0 @@ -/* - * (C) 2008-2014 shimat - * This code is licenced under the LGPL. - */ - -#ifndef _CPP_WHOGDESCRIPTOR_H_ -#define _CPP_WHOGDESCRIPTOR_H_ - -#ifdef _MSC_VER -#pragma warning(disable: 4251) -//#pragma warning(disable: 4996) -#endif -#include - - -#ifdef _WIN32 -#include -#include -int p(const char* msg) -{ - return MessageBoxA(NULL, msg, "MessageBox", MB_OK); -} -template -int p(T obj) -{ - std::stringstream ss; - ss << obj; - return p(ss.str().c_str()); -} -#endif - - -#pragma region Methods -CVAPI(int) HOGDescriptor_sizeof() -{ - return sizeof(cv::HOGDescriptor); -} -CVAPI(cv::HOGDescriptor*) HOGDescriptor_new1() -{ - return new cv::HOGDescriptor(); -} -CVAPI(cv::HOGDescriptor*) HOGDescriptor_new2( CvSize winSize, CvSize blockSize, CvSize blockStride, CvSize cellSize, - int nbins, int derivAperture, double winSigma, int histogramNormType, double L2HysThreshold, bool gammaCorrection, int nlevels) -{ - return new cv::HOGDescriptor(winSize, blockSize, blockStride, cellSize, nbins, derivAperture, winSigma, histogramNormType, L2HysThreshold, gammaCorrection, nlevels); -} -CVAPI(cv::HOGDescriptor*) HOGDescriptor_new3(const char* filename) -{ - std::string filename_str(filename); - return new cv::HOGDescriptor(filename_str); -} -CVAPI(void) HOGDescriptor_delete(cv::HOGDescriptor* obj) -{ - delete obj; -} - -CVAPI(size_t) HOGDescriptor_getDescriptorSize(cv::HOGDescriptor* obj) -{ - return obj->getDescriptorSize(); -} -CVAPI(bool) HOGDescriptor_checkDetectorSize(cv::HOGDescriptor* obj) -{ - return obj->checkDetectorSize(); -} -CVAPI(double) HOGDescriptor_getWinSigma(cv::HOGDescriptor* obj) -{ - return obj->getWinSigma(); -} - -CVAPI(std::vector*) HOGDescriptor_getDefaultPeopleDetector() -{ - static std::vector vec = cv::HOGDescriptor::getDefaultPeopleDetector(); - return &vec; -} - -CVAPI(void) HOGDescriptor_setSVMDetector(cv::HOGDescriptor* obj, std::vector* svmdetector) -{ - //std::vector vec = obj->getDefaultPeopleDetector(); - //p(vec[0]); - //p(vec.size()); - obj->setSVMDetector(*svmdetector); - //hog.setSVMDetector(); - - //obj->setSVMDetector(cv::HOGDescriptor::getDefaultPeopleDetector()); - - /* - FILE* fp = fopen("C:\\hoge.txt", "w"); - fprintf(fp, "svmdetector size: %d\n", svmdetector->size()); - fprintf(fp, "svmdetector[0]: %f\n", svmdetector->at(0)); - - fprintf(fp, "svmdetector before: %d\n", obj->svmDetector.size()); - fprintf(fp, "getDescriptorSize before: %d\n", obj->getDescriptorSize()); - //obj->svmDetector = *svmdetector; - fprintf(fp, "svmdetector after: %d\n", obj->svmDetector.size()); - fprintf(fp, "getDescriptorSize after: %d\n", obj->getDescriptorSize()); - - size_t detectorSize = obj->svmDetector.size(), descriptorSize = obj->getDescriptorSize(); - bool result1 = obj->checkDetectorSize(); - bool result2 = detectorSize == 0 || - detectorSize == descriptorSize || - detectorSize == descriptorSize + 1; - fprintf(fp, "detectorSize : %d\n", detectorSize); - fprintf(fp, "descriptorSize : %d\n", descriptorSize); - fprintf(fp, "checkDetectorSize : %d\n", result1 ? 1 : 0); - fprintf(fp, "myresult : %d\n", result2 ? 1 : 0); - fclose(fp); - //*/ - - //obj->setSVMDetector(*svmdetector); - -} -CVAPI(bool) HOGDescriptor_load(cv::HOGDescriptor* obj, const char* filename, const char* objname) -{ - cv::String filename_str(filename); - cv::String objname_str; - if(objname != NULL) - objname_str = cv::String(objname); - return obj->load(filename_str, objname_str); -} -CVAPI(void) HOGDescriptor_save(cv::HOGDescriptor* obj, const char* filename, const char* objname) -{ - cv::String filename_str(filename); - cv::String objname_str; - if(objname != NULL) - objname_str = cv::String(objname); - obj->save(filename_str, objname_str); -} -CVAPI(void) HOGDescriptor_compute(cv::HOGDescriptor* obj, cv::Mat* img, std::vector* descriptors, - CvSize winStride, CvSize padding, CvPoint* locations, int locations_length) -{ - std::vector locations_vec; - if(locations != NULL) - { - locations_vec = std::vector(locations_length); - for(int i=0; icompute(*img, *descriptors, winStride, padding, locations_vec); -} - -CVAPI(void) HOGDescriptor_detect(cv::HOGDescriptor* obj, cv::Mat* img, std::vector* foundLocations, - double hitThreshold, CvSize winStride, CvSize padding, CvPoint* searchLocations, int searchLocationsLength) -{ - std::vector slVec; - if(searchLocations != NULL) - { - slVec = std::vector(searchLocationsLength); - for(int i=0; idetect(*img, *foundLocations, hitThreshold, winStride, padding, slVec); -} - -CVAPI(void) HOGDescriptor_detectMultiScale(cv::HOGDescriptor* obj, cv::Mat* img, std::vector* foundLocations, - double hitThreshold, CvSize winStride, CvSize padding, double scale, int groupThreshold) -{ - obj->detectMultiScale(*img, *foundLocations, hitThreshold, winStride, padding, scale, groupThreshold); -} - -CVAPI(void) HOGDescriptor_computeGradient(cv::HOGDescriptor* obj, cv::Mat* img, cv::Mat* grad, cv::Mat* angleOfs, CvSize paddingTL, CvSize paddingBR) -{ - obj->computeGradient(*img, *grad, *angleOfs, paddingTL, paddingBR); -} -#pragma endregion - -#pragma region Fields -CVAPI(CvSize) HOGDescriptor_winSize_get(cv::HOGDescriptor* obj) -{ - return obj->winSize; -} -CVAPI(CvSize) HOGDescriptor_blockSize_get(cv::HOGDescriptor* obj) -{ - return obj->blockSize; -} -CVAPI(CvSize) HOGDescriptor_blockStride_get(cv::HOGDescriptor* obj) -{ - return obj->blockStride; -} -CVAPI(CvSize) HOGDescriptor_cellSize_get(cv::HOGDescriptor* obj) -{ - return obj->winSize; -} -CVAPI(int) HOGDescriptor_nbins_get(cv::HOGDescriptor* obj) -{ - return obj->nbins; -} -CVAPI(int) HOGDescriptor_derivAperture_get(cv::HOGDescriptor* obj) -{ - return obj->derivAperture; -} -CVAPI(double) HOGDescriptor_winSigma_get(cv::HOGDescriptor* obj) -{ - return obj->winSigma; -} -CVAPI(int) HOGDescriptor_histogramNormType_get(cv::HOGDescriptor* obj) -{ - return obj->histogramNormType; -} -CVAPI(double) HOGDescriptor_L2HysThreshold_get(cv::HOGDescriptor* obj) -{ - return obj->L2HysThreshold; -} -CVAPI(int) HOGDescriptor_gammaCorrection_get(cv::HOGDescriptor* obj) -{ - return obj->gammaCorrection ? 1 : 0; -} -CVAPI(int) HOGDescriptor_nlevels_get(cv::HOGDescriptor* obj) -{ - return obj->nlevels; -} - -CVAPI(void) HOGDescriptor_winSize_set(cv::HOGDescriptor* obj, CvSize value) -{ - obj->winSize = value; -} -CVAPI(void) HOGDescriptor_blockSize_set(cv::HOGDescriptor* obj, CvSize value) -{ - obj->blockSize = value; -} -CVAPI(void) HOGDescriptor_blockStride_set(cv::HOGDescriptor* obj, CvSize value) -{ - obj->blockStride = value; -} -CVAPI(void) HOGDescriptor_cellSize_set(cv::HOGDescriptor* obj, CvSize value) -{ - obj->cellSize = value; -} -CVAPI(void) HOGDescriptor_nbins_set(cv::HOGDescriptor* obj, int value) -{ - obj->nbins = value; -} -CVAPI(void) HOGDescriptor_derivAperture_set(cv::HOGDescriptor* obj, int value) -{ - obj->derivAperture = value; -} -CVAPI(void) HOGDescriptor_winSigma_set(cv::HOGDescriptor* obj, double value) -{ - obj->winSigma = value; -} -CVAPI(void) HOGDescriptor_histogramNormType_set(cv::HOGDescriptor* obj, int value) -{ - obj->histogramNormType = value; -} -CVAPI(void) HOGDescriptor_L2HysThreshold_set(cv::HOGDescriptor* obj, double value) -{ - obj->L2HysThreshold = value; -} -CVAPI(void) HOGDescriptor_gammaCorrection_set(cv::HOGDescriptor* obj, int value) -{ - obj->gammaCorrection = (value != 0); -} -CVAPI(void) HOGDescriptor_nlevels_set(cv::HOGDescriptor* obj, int value) -{ - obj->nlevels = value; -} -#pragma endregion - -#endif \ No newline at end of file diff --git a/src/OpenCvSharpExtern/core_Mat.h b/src/OpenCvSharpExtern/core_Mat.h index 4d9705fc9..333ade7ea 100644 --- a/src/OpenCvSharpExtern/core_Mat.h +++ b/src/OpenCvSharpExtern/core_Mat.h @@ -47,6 +47,14 @@ CVAPI(cv::Mat*) core_Mat_new8(int ndims, const int* sizes, int type, void* data, { return new cv::Mat(ndims, sizes, type, data, steps); } +CVAPI(cv::Mat*) core_Mat_new_FromIplImage(IplImage *img, int copyData) +{ + return new cv::Mat(img, copyData != 0); +} +CVAPI(cv::Mat*) core_Mat_new_FromCvMat(CvMat *mat, int copyData) +{ + return new cv::Mat(mat, copyData != 0); +} CVAPI(void) core_Mat_release(cv::Mat *self) diff --git a/src/OpenCvSharpExtern/include_opencv.h b/src/OpenCvSharpExtern/include_opencv.h index d49e76369..68844acf2 100644 --- a/src/OpenCvSharpExtern/include_opencv.h +++ b/src/OpenCvSharpExtern/include_opencv.h @@ -2,7 +2,25 @@ #define _INCLUDE_OPENCV_H_ #include -typedef unsigned int uint; -typedef unsigned short ushort; +typedef unsigned int uint32; +typedef unsigned short uint16; + +#if 0 +#ifdef _WIN32 +#include +#include +int p(const char* msg) +{ + return MessageBoxA(NULL, msg, "MessageBox", MB_OK); +} +template +int p(T obj) +{ + std::stringstream ss; + ss << obj; + return p(ss.str().c_str()); +} +#endif +#endif #endif diff --git a/src/OpenCvSharpExtern/objdetect.cpp b/src/OpenCvSharpExtern/objdetect.cpp new file mode 100644 index 000000000..7d29d026b --- /dev/null +++ b/src/OpenCvSharpExtern/objdetect.cpp @@ -0,0 +1,6 @@ +/* +* (C) 2008-2014 shimat +* This code is licenced under the LGPL. +*/ + +#include "objdetect.h" \ No newline at end of file diff --git a/src/OpenCvSharpExtern/objdetect.h b/src/OpenCvSharpExtern/objdetect.h new file mode 100644 index 000000000..bded9939f --- /dev/null +++ b/src/OpenCvSharpExtern/objdetect.h @@ -0,0 +1,242 @@ +/* +* (C) 2008-2014 shimat +* This code is licenced under the LGPL. +*/ + +#ifndef _CPP_OBJDETECT_H_ +#define _CPP_OBJDETECT_H_ + +#include "include_opencv.h" + +#pragma region Methods +CVAPI(int) objdetect_HOGDescriptor_sizeof() +{ + return sizeof(cv::HOGDescriptor); +} +CVAPI(cv::HOGDescriptor*) objdetect_HOGDescriptor_new1() +{ + return new cv::HOGDescriptor(); +} +CVAPI(cv::HOGDescriptor*) objdetect_HOGDescriptor_new2(CvSize winSize, CvSize blockSize, CvSize blockStride, CvSize cellSize, + int nbins, int derivAperture, double winSigma, int histogramNormType, double L2HysThreshold, bool gammaCorrection, int nlevels) +{ + return new cv::HOGDescriptor(winSize, blockSize, blockStride, cellSize, nbins, derivAperture, winSigma, histogramNormType, L2HysThreshold, gammaCorrection, nlevels); +} +CVAPI(cv::HOGDescriptor*) objdetect_HOGDescriptor_new3(const char* filename) +{ + std::string filename_str(filename); + return new cv::HOGDescriptor(filename_str); +} +CVAPI(void) objdetect_HOGDescriptor_delete(cv::HOGDescriptor* obj) +{ + delete obj; +} + +CVAPI(size_t) objdetect_HOGDescriptor_getDescriptorSize(cv::HOGDescriptor* obj) +{ + return obj->getDescriptorSize(); +} +CVAPI(bool) objdetect_HOGDescriptor_checkDetectorSize(cv::HOGDescriptor* obj) +{ + return obj->checkDetectorSize(); +} +CVAPI(double) objdetect_HOGDescriptor_getWinSigma(cv::HOGDescriptor* obj) +{ + return obj->getWinSigma(); +} + +CVAPI(std::vector*) objdetect_HOGDescriptor_getDefaultPeopleDetector() +{ + static std::vector vec = cv::HOGDescriptor::getDefaultPeopleDetector(); + return &vec; +} + +CVAPI(void) objdetect_HOGDescriptor_setSVMDetector(cv::HOGDescriptor* obj, std::vector* svmdetector) +{ + //std::vector vec = obj->getDefaultPeopleDetector(); + //p(vec[0]); + //p(vec.size()); + obj->setSVMDetector(*svmdetector); + //hog.setSVMDetector(); + + //obj->setSVMDetector(cv::HOGDescriptor::getDefaultPeopleDetector()); + + /* + FILE* fp = fopen("C:\\hoge.txt", "w"); + fprintf(fp, "svmdetector size: %d\n", svmdetector->size()); + fprintf(fp, "svmdetector[0]: %f\n", svmdetector->at(0)); + + fprintf(fp, "svmdetector before: %d\n", obj->svmDetector.size()); + fprintf(fp, "getDescriptorSize before: %d\n", obj->getDescriptorSize()); + //obj->svmDetector = *svmdetector; + fprintf(fp, "svmdetector after: %d\n", obj->svmDetector.size()); + fprintf(fp, "getDescriptorSize after: %d\n", obj->getDescriptorSize()); + + size_t detectorSize = obj->svmDetector.size(), descriptorSize = obj->getDescriptorSize(); + bool result1 = obj->checkDetectorSize(); + bool result2 = detectorSize == 0 || + detectorSize == descriptorSize || + detectorSize == descriptorSize + 1; + fprintf(fp, "detectorSize : %d\n", detectorSize); + fprintf(fp, "descriptorSize : %d\n", descriptorSize); + fprintf(fp, "checkDetectorSize : %d\n", result1 ? 1 : 0); + fprintf(fp, "myresult : %d\n", result2 ? 1 : 0); + fclose(fp); + //*/ + + //obj->setSVMDetector(*svmdetector); + +} +CVAPI(bool) objdetect_HOGDescriptor_load(cv::HOGDescriptor* obj, const char* filename, const char* objname) +{ + cv::String filename_str(filename); + cv::String objname_str; + if (objname != NULL) + objname_str = cv::String(objname); + return obj->load(filename_str, objname_str); +} +CVAPI(void) objdetect_HOGDescriptor_save(cv::HOGDescriptor* obj, const char* filename, const char* objname) +{ + cv::String filename_str(filename); + cv::String objname_str; + if (objname != NULL) + objname_str = cv::String(objname); + obj->save(filename_str, objname_str); +} +CVAPI(void) objdetect_HOGDescriptor_compute(cv::HOGDescriptor* obj, cv::Mat* img, std::vector* descriptors, + CvSize winStride, CvSize padding, CvPoint* locations, int locations_length) +{ + std::vector locations_vec; + if (locations != NULL) + { + locations_vec = std::vector(locations_length); + for (int i = 0; icompute(*img, *descriptors, winStride, padding, locations_vec); +} + +CVAPI(void) objdetect_HOGDescriptor_detect(cv::HOGDescriptor* obj, cv::Mat* img, std::vector* foundLocations, + double hitThreshold, CvSize winStride, CvSize padding, CvPoint* searchLocations, int searchLocationsLength) +{ + std::vector slVec; + if (searchLocations != NULL) + { + slVec = std::vector(searchLocationsLength); + for (int i = 0; idetect(*img, *foundLocations, hitThreshold, winStride, padding, slVec); +} + +CVAPI(void) objdetect_HOGDescriptor_detectMultiScale(cv::HOGDescriptor* obj, cv::Mat* img, std::vector* foundLocations, + double hitThreshold, CvSize winStride, CvSize padding, double scale, int groupThreshold) +{ + obj->detectMultiScale(*img, *foundLocations, hitThreshold, winStride, padding, scale, groupThreshold); +} + +CVAPI(void) objdetect_HOGDescriptor_computeGradient(cv::HOGDescriptor* obj, cv::Mat* img, cv::Mat* grad, cv::Mat* angleOfs, CvSize paddingTL, CvSize paddingBR) +{ + obj->computeGradient(*img, *grad, *angleOfs, paddingTL, paddingBR); +} +#pragma endregion + +#pragma region Fields +CVAPI(CvSize) objdetect_HOGDescriptor_winSize_get(cv::HOGDescriptor* obj) +{ + return obj->winSize; +} +CVAPI(CvSize) objdetect_HOGDescriptor_blockSize_get(cv::HOGDescriptor* obj) +{ + return obj->blockSize; +} +CVAPI(CvSize) objdetect_HOGDescriptor_blockStride_get(cv::HOGDescriptor* obj) +{ + return obj->blockStride; +} +CVAPI(CvSize) objdetect_HOGDescriptor_cellSize_get(cv::HOGDescriptor* obj) +{ + return obj->winSize; +} +CVAPI(int) objdetect_HOGDescriptor_nbins_get(cv::HOGDescriptor* obj) +{ + return obj->nbins; +} +CVAPI(int) objdetect_HOGDescriptor_derivAperture_get(cv::HOGDescriptor* obj) +{ + return obj->derivAperture; +} +CVAPI(double) objdetect_HOGDescriptor_winSigma_get(cv::HOGDescriptor* obj) +{ + return obj->winSigma; +} +CVAPI(int) objdetect_HOGDescriptor_histogramNormType_get(cv::HOGDescriptor* obj) +{ + return obj->histogramNormType; +} +CVAPI(double) objdetect_HOGDescriptor_L2HysThreshold_get(cv::HOGDescriptor* obj) +{ + return obj->L2HysThreshold; +} +CVAPI(int) objdetect_HOGDescriptor_gammaCorrection_get(cv::HOGDescriptor* obj) +{ + return obj->gammaCorrection ? 1 : 0; +} +CVAPI(int) objdetect_HOGDescriptor_nlevels_get(cv::HOGDescriptor* obj) +{ + return obj->nlevels; +} + +CVAPI(void) objdetect_HOGDescriptor_winSize_set(cv::HOGDescriptor* obj, CvSize value) +{ + obj->winSize = value; +} +CVAPI(void) objdetect_HOGDescriptor_blockSize_set(cv::HOGDescriptor* obj, CvSize value) +{ + obj->blockSize = value; +} +CVAPI(void) objdetect_HOGDescriptor_blockStride_set(cv::HOGDescriptor* obj, CvSize value) +{ + obj->blockStride = value; +} +CVAPI(void) objdetect_HOGDescriptor_cellSize_set(cv::HOGDescriptor* obj, CvSize value) +{ + obj->cellSize = value; +} +CVAPI(void) objdetect_HOGDescriptor_nbins_set(cv::HOGDescriptor* obj, int value) +{ + obj->nbins = value; +} +CVAPI(void) objdetect_HOGDescriptor_derivAperture_set(cv::HOGDescriptor* obj, int value) +{ + obj->derivAperture = value; +} +CVAPI(void) objdetect_HOGDescriptor_winSigma_set(cv::HOGDescriptor* obj, double value) +{ + obj->winSigma = value; +} +CVAPI(void) objdetect_HOGDescriptor_histogramNormType_set(cv::HOGDescriptor* obj, int value) +{ + obj->histogramNormType = value; +} +CVAPI(void) objdetect_HOGDescriptor_L2HysThreshold_set(cv::HOGDescriptor* obj, double value) +{ + obj->L2HysThreshold = value; +} +CVAPI(void) objdetect_HOGDescriptor_gammaCorrection_set(cv::HOGDescriptor* obj, int value) +{ + obj->gammaCorrection = (value != 0); +} +CVAPI(void) objdetect_HOGDescriptor_nlevels_set(cv::HOGDescriptor* obj, int value) +{ + obj->nlevels = value; +} +#pragma endregion + +#endif \ No newline at end of file diff --git a/src/OpenCvSharpExtern/std_vector.h b/src/OpenCvSharpExtern/std_vector.h index 342327094..aca981e5f 100644 --- a/src/OpenCvSharpExtern/std_vector.h +++ b/src/OpenCvSharpExtern/std_vector.h @@ -15,13 +15,13 @@ CVAPI(vector*) vector_uchar_new1() { return new vector; } -CVAPI(vector*) vector_uchar_new2(uint size) +CVAPI(vector*) vector_uchar_new2(size_t size) { return new vector(size); } -CVAPI(vector*) vector_uchar_new3(uchar* data, uint data_length) +CVAPI(vector*) vector_uchar_new3(uchar* data, size_t dataLength) { - return new vector(data, data + data_length); + return new vector(data, data + dataLength); } CVAPI(size_t) vector_uchar_getSize(vector* vector) { @@ -42,13 +42,13 @@ CVAPI(vector*) vector_float_new1() { return new vector; } -CVAPI(vector*) vector_float_new2(uint size) +CVAPI(vector*) vector_float_new2(size_t size) { return new vector(size); } -CVAPI(vector*) vector_float_new3(float* data, uint data_length) +CVAPI(vector*) vector_float_new3(float* data, size_t dataLength) { - return new vector(data, data + data_length); + return new vector(data, data + dataLength); } CVAPI(size_t) vector_float_getSize(vector* vector) { @@ -69,14 +69,14 @@ CVAPI(vector*) vector_Vec2f_new1() { return new vector; } -CVAPI(vector*) vector_Vec2f_new2(uint size) +CVAPI(vector*) vector_Vec2f_new2(size_t size) { return new vector(size); } -CVAPI(vector*) vector_Vec2f_new3(cv::Vec2f* data, uint data_length) +CVAPI(vector*) vector_Vec2f_new3(cv::Vec2f* data, size_t dataLength) { - vector* vec = new vector(data_length); - for (uint i = 0; i* vec = new vector(dataLength); + for (size_t i = 0; ipush_back(data[i]); } @@ -105,10 +105,10 @@ CVAPI(vector*) vector_Vec3f_new2(size_t size) { return new vector(size); } -CVAPI(vector*) vector_Vec3f_new3(cv::Vec3f* data, size_t data_length) +CVAPI(vector*) vector_Vec3f_new3(cv::Vec3f* data, size_t dataLength) { - vector* vec = new vector(data_length); - for(size_t i=0; i* vec = new vector(dataLength); + for (size_t i = 0; ipush_back(data[i]); } @@ -133,14 +133,14 @@ CVAPI(vector*) vector_Vec4i_new1() { return new vector; } -CVAPI(vector*) vector_Vec4i_new2(uint size) +CVAPI(vector*) vector_Vec4i_new2(size_t size) { return new vector(size); } -CVAPI(vector*) vector_Vec4i_new3(cv::Vec4i* data, uint data_length) +CVAPI(vector*) vector_Vec4i_new3(cv::Vec4i* data, size_t dataLength) { - vector* vec = new vector(data_length); - for (uint i = 0; i* vec = new vector(dataLength); + for (size_t i = 0; ipush_back(data[i]); } @@ -165,14 +165,14 @@ CVAPI(vector*) vector_Point2i_new1() { return new vector; } -CVAPI(vector*) vector_Point2i_new2(uint size) +CVAPI(vector*) vector_Point2i_new2(size_t size) { return new vector(size); } -CVAPI(vector*) vector_Point2i_new3(CvPoint* data, uint data_length) +CVAPI(vector*) vector_Point2i_new3(CvPoint* data, size_t dataLength) { - vector* vec = new vector(data_length); - for (uint i = 0; i* vec = new vector(dataLength); + for (size_t i = 0; ipush_back(data[i]); } @@ -197,28 +197,28 @@ CVAPI(vector*) vector_Point2f_new1() { return new vector; } -CVAPI(vector*) vector_Point2f_new2(uint size) +CVAPI(vector*) vector_Point2f_new2(size_t size) { return new vector(size); } -CVAPI(vector*) vector_Point2f_new3(CvPoint2D32f* data, uint data_length) +CVAPI(vector*) vector_Point2f_new3(CvPoint2D32f* data, size_t dataLength) { - vector* vec = new vector(data_length); - for (uint i = 0; i* vec = new vector(dataLength); + for (size_t i = 0; ipush_back(data[i]); } return vec; } -CVAPI(size_t) vector_cvPoint_getSize(vector* vector) +CVAPI(size_t) vector_Point2f_getSize(vector* vector) { return vector->size(); } -CVAPI(cv::Point2f*) vector_cvPoint_getPointer(vector* vector) +CVAPI(cv::Point2f*) vector_Point2f_getPointer(vector* vector) { return &(vector->at(0)); } -CVAPI(void) vector_cvPoint_delete(vector* vector) +CVAPI(void) vector_Point2f_delete(vector* vector) { delete vector; } @@ -229,24 +229,24 @@ CVAPI(vector*) vector_Rect_new1() { return new vector; } -CVAPI(vector*) vector_Rect_new2(uint size) +CVAPI(vector*) vector_Rect_new2(size_t size) { return new vector(size); } -CVAPI(vector*) vector_Rect_new3(CvRect* data, size data_length) +CVAPI(vector*) vector_Rect_new3(CvRect* data, size_t dataLength) { - vector* vec = new vector(data_length); - for (size i = 0; i* vec = new vector(dataLength); + for (size_t i = 0; ipush_back(data[i]); } return vec; } -CVAPI(size) vector_Rect_getSize(vector* vector) +CVAPI(size_t) vector_Rect_getSize(vector* vector) { return vector->size(); } -CVAPI(cv::Rect*) vector_Rect_getPointer(vector *xvector) +CVAPI(cv::Rect*) vector_Rect_getPointer(vector *vector) { return &(vector->at(0)); } @@ -263,14 +263,14 @@ CVAPI(vector*) vector_KeyPoint_new1() { return new vector; } -CVAPI(vector*) vector_KeyPoint_new2(size size) +CVAPI(vector*) vector_KeyPoint_new2(size_t size) { return new vector(size); } -CVAPI(vector*) vector_KeyPoint_new3(cv::KeyPoint *data, size data_length) +CVAPI(vector*) vector_KeyPoint_new3(cv::KeyPoint *data, size_t dataLength) { - vector* vec = new vector(data_length); - for(size_t i=0; i* vec = new vector(dataLength); + for (size_t i = 0; ipush_back(data[i]); } From 549acb0f50b26cf387e6abcb48ef259d8df61868 Mon Sep 17 00:00:00 2001 From: shimat Date: Sat, 8 Feb 2014 20:42:11 +0900 Subject: [PATCH 21/29] Added many features --- nuget/OpenCvSharp-x64.nuspec | 1 + nuget/OpenCvSharp-x86.nuspec | 3 +- nuget/tools-x64/install.ps1 | 1 + src/OpenCvSharp.Gpu/HOGDescriptor.cs | 76 +---- src/OpenCvSharp/Src/Utilities/Util.cs | 16 + .../OpenCvSharpExtern.vcxproj | 10 +- .../OpenCvSharpExtern.vcxproj.filters | 30 +- src/OpenCvSharpExtern/WCore.h | 67 ----- src/OpenCvSharpExtern/WCv.cpp | 6 - src/OpenCvSharpExtern/WCv.h | 162 ---------- src/OpenCvSharpExtern/WHighgui.cpp | 6 - src/OpenCvSharpExtern/WHighgui.h | 56 ---- src/OpenCvSharpExtern/WMat.cpp | 6 - src/OpenCvSharpExtern/WMat.h | 279 ------------------ src/OpenCvSharpExtern/calib3d.cpp | 6 + src/OpenCvSharpExtern/calib3d.h | 19 ++ src/OpenCvSharpExtern/core.cpp | 6 + src/OpenCvSharpExtern/core.h | 165 +++++++++++ src/OpenCvSharpExtern/imgproc.h | 169 ++++++++++- src/OpenCvSharpExtern/include_opencv.h | 9 + src/OpenCvSharpExtern/std_vector.h | 32 ++ 21 files changed, 439 insertions(+), 686 deletions(-) delete mode 100644 src/OpenCvSharpExtern/WCv.cpp delete mode 100644 src/OpenCvSharpExtern/WCv.h delete mode 100644 src/OpenCvSharpExtern/WHighgui.cpp delete mode 100644 src/OpenCvSharpExtern/WHighgui.h delete mode 100644 src/OpenCvSharpExtern/WMat.cpp delete mode 100644 src/OpenCvSharpExtern/WMat.h create mode 100644 src/OpenCvSharpExtern/calib3d.cpp create mode 100644 src/OpenCvSharpExtern/calib3d.h create mode 100644 src/OpenCvSharpExtern/core.cpp create mode 100644 src/OpenCvSharpExtern/core.h diff --git a/nuget/OpenCvSharp-x64.nuspec b/nuget/OpenCvSharp-x64.nuspec index fde69d9bd..cc4bc713e 100644 --- a/nuget/OpenCvSharp-x64.nuspec +++ b/nuget/OpenCvSharp-x64.nuspec @@ -38,6 +38,7 @@ + diff --git a/nuget/OpenCvSharp-x86.nuspec b/nuget/OpenCvSharp-x86.nuspec index 0297319df..5ecd2d1c9 100644 --- a/nuget/OpenCvSharp-x86.nuspec +++ b/nuget/OpenCvSharp-x86.nuspec @@ -6,7 +6,7 @@ OpenCvSharp x86 shimat http://www.gnu.org/licenses/lgpl-3.0.en.html - https://github.com/shimat/opencvsharp + http://code.google.com/p/opencvsharp/ http://opencvsharp.googlecode.com/files/Lenna.ico false OpenCV wrapper for .NET Framework @@ -38,6 +38,7 @@ + diff --git a/nuget/tools-x64/install.ps1 b/nuget/tools-x64/install.ps1 index 6a128118a..34f140885 100644 --- a/nuget/tools-x64/install.ps1 +++ b/nuget/tools-x64/install.ps1 @@ -39,6 +39,7 @@ $copyFiles = @( "opencv_ml248.dll"; "opencv_nonfree248.dll"; "opencv_objdetect248.dll"; + "opencv_ocl248.dll"; "opencv_photo248.dll"; "opencv_stitching248.dll"; "opencv_superres248.dll"; diff --git a/src/OpenCvSharp.Gpu/HOGDescriptor.cs b/src/OpenCvSharp.Gpu/HOGDescriptor.cs index a1d614114..e496c409b 100644 --- a/src/OpenCvSharp.Gpu/HOGDescriptor.cs +++ b/src/OpenCvSharp.Gpu/HOGDescriptor.cs @@ -1298,9 +1298,9 @@ public double GetWinSigma() /// /// /// - public virtual CvPoint[] Detect(GpuMat img) + public virtual Point[] Detect(GpuMat img) { - return Detect(img, 0, new CvSize(0, 0), new CvSize(0, 0)); + return Detect(img, 0, new Size(0, 0), new Size(0, 0)); } /// /// @@ -1308,9 +1308,9 @@ public virtual CvPoint[] Detect(GpuMat img) /// /// /// - public virtual CvPoint[] Detect(GpuMat img, double hitThreshold) + public virtual Point[] Detect(GpuMat img, double hitThreshold) { - return Detect(img, hitThreshold, new CvSize(0, 0), new CvSize(0, 0)); + return Detect(img, hitThreshold, new Size(0, 0), new Size(0, 0)); } /// /// @@ -1319,9 +1319,9 @@ public virtual CvPoint[] Detect(GpuMat img, double hitThreshold) /// /// /// - public virtual CvPoint[] Detect(GpuMat img, double hitThreshold, CvSize winStride) + public virtual Point[] Detect(GpuMat img, double hitThreshold, Size winStride) { - return Detect(img, hitThreshold, winStride, new CvSize(0, 0)); + return Detect(img, hitThreshold, winStride, new Size(0, 0)); } /// /// @@ -1331,7 +1331,7 @@ public virtual CvPoint[] Detect(GpuMat img, double hitThreshold, CvSize winStrid /// /// /// - public virtual CvPoint[] Detect(GpuMat img, double hitThreshold, CvSize winStride, CvSize padding) + public virtual Point[] Detect(GpuMat img, double hitThreshold, Size winStride, Size padding) { if (disposed) throw new ObjectDisposedException("HOGDescriptor"); @@ -1351,77 +1351,25 @@ public virtual CvPoint[] Detect(GpuMat img, double hitThreshold, CvSize winStrid /// /// /// - /// - public virtual CvRect[] DetectMultiScale(Mat img) - { - return DetectMultiScale(img, 0, new CvSize(0, 0), new CvSize(0, 0), 1.05, 2); - } - /// - /// - /// - /// - /// - /// - public virtual CvRect[] DetectMultiScale(Mat img, double hitThreshold) - { - return DetectMultiScale(img, hitThreshold, new CvSize(0, 0), new CvSize(0, 0), 1.05, 2); - } - /// - /// - /// - /// - /// - /// - /// - public virtual CvRect[] DetectMultiScale(Mat img, double hitThreshold, CvSize winStride) - { - return DetectMultiScale(img, hitThreshold, winStride, new CvSize(0, 0), 1.05, 2); - } - /// - /// - /// - /// - /// - /// - /// - /// - public virtual CvRect[] DetectMultiScale(Mat img, double hitThreshold, CvSize winStride, CvSize padding) - { - return DetectMultiScale(img, hitThreshold, winStride, padding, 1.05, 2); - } - /// - /// - /// - /// - /// - /// - /// - /// - /// - public virtual CvRect[] DetectMultiScale(Mat img, double hitThreshold, CvSize winStride, CvSize padding, double scale) - { - return DetectMultiScale(img, hitThreshold, winStride, padding, scale, 2); - } - /// - /// - /// - /// /// /// /// /// /// /// - public virtual CvRect[] DetectMultiScale(Mat img, double hitThreshold, CvSize winStride, CvSize padding, double scale, int groupThreshold) + public virtual Rect[] DetectMultiScale(Mat img, double hitThreshold = 0, + Size? winStride = null, Size? padding = null, double scale = 1.05, int groupThreshold = 2) { if (disposed) throw new ObjectDisposedException("HOGDescriptor"); if (img == null) throw new ArgumentNullException("img"); + Size winStride0 = winStride.GetValueOrDefault(new Size()); + Size padding0 = padding.GetValueOrDefault(new Size()); using (StdVectorRect flVec = new StdVectorRect()) { - GpuInvoke.HOGDescriptor_detectMultiScale(ptr, img.CvPtr, flVec.CvPtr, hitThreshold, winStride, padding, scale, groupThreshold); + GpuInvoke.HOGDescriptor_detectMultiScale(ptr, img.CvPtr, flVec.CvPtr, hitThreshold, winStride0, padding0, scale, groupThreshold); // std::vector*ã‹ã‚‰CvRect[]ã«ç§»ã—替ãˆã¦è¿”ã™ return flVec.ToArray(); } diff --git a/src/OpenCvSharp/Src/Utilities/Util.cs b/src/OpenCvSharp/Src/Utilities/Util.cs index 697f77a7a..71563c8cc 100644 --- a/src/OpenCvSharp/Src/Utilities/Util.cs +++ b/src/OpenCvSharp/Src/Utilities/Util.cs @@ -288,5 +288,21 @@ public static int SizeOf(Type t) } } #endregion + + /// + /// IEnumerable<T>.ToArray of LINQ + /// + /// + /// + /// + public static T[] ToArray(IEnumerable enumerable) + { + if (enumerable == null) + return null; + T[] array = enumerable as T[]; + if (array != null) + return array; + return new List(enumerable).ToArray(); + } } } diff --git a/src/OpenCvSharpExtern/OpenCvSharpExtern.vcxproj b/src/OpenCvSharpExtern/OpenCvSharpExtern.vcxproj index 2769992a0..e9a5beff3 100644 --- a/src/OpenCvSharpExtern/OpenCvSharpExtern.vcxproj +++ b/src/OpenCvSharpExtern/OpenCvSharpExtern.vcxproj @@ -211,6 +211,8 @@ + + @@ -239,19 +241,18 @@ - - - + + @@ -276,15 +277,12 @@ - - - diff --git a/src/OpenCvSharpExtern/OpenCvSharpExtern.vcxproj.filters b/src/OpenCvSharpExtern/OpenCvSharpExtern.vcxproj.filters index 40e83945d..515bf8ab1 100644 --- a/src/OpenCvSharpExtern/OpenCvSharpExtern.vcxproj.filters +++ b/src/OpenCvSharpExtern/OpenCvSharpExtern.vcxproj.filters @@ -64,9 +64,6 @@ Sources - - Sources - Sources @@ -79,12 +76,6 @@ Sources - - Sources - - - Sources - Sources @@ -118,6 +109,12 @@ Sources\cpp + + Sources\cpp + + + Sources\cpp + @@ -168,9 +165,6 @@ Headers - - Headers - Headers @@ -183,12 +177,6 @@ Headers - - Headers - - - Headers - Headers @@ -225,6 +213,12 @@ Headers\cpp + + Headers\cpp + + + Headers\cpp + diff --git a/src/OpenCvSharpExtern/WCore.h b/src/OpenCvSharpExtern/WCore.h index ff98a3bc2..c54644d34 100644 --- a/src/OpenCvSharpExtern/WCore.h +++ b/src/OpenCvSharpExtern/WCore.h @@ -11,73 +11,6 @@ #endif #include -#pragma region Miscellaneous - -CVAPI(void) cv_setNumThreads(int nthreads) -{ - cv::setNumThreads(nthreads); -} -CVAPI(int) cv_getNumThreads() -{ - return cv::getNumThreads(); -} -CVAPI(int) cv_getThreadNum() -{ - return cv::getThreadNum(); -} - -CVAPI(const char*) cv_getBuildInformation() -{ - const std::string& str = cv::getBuildInformation(); - return str.c_str(); -} - -CVAPI(int64) cv_getTickCount() -{ - return cv::getTickCount(); -} -CVAPI(double) cv_getTickFrequency() -{ - return cv::getTickFrequency(); -} -CVAPI(int64) cv_getCPUTickCount() -{ - return cv::getCPUTickCount(); -} - -CVAPI(bool) cv_checkHardwareSupport(int feature) -{ - return cv::checkHardwareSupport(feature); -} - -CVAPI(int) cv_getNumberOfCPUs() -{ - return cv::getNumberOfCPUs(); -} - -CVAPI(void*) cv_fastMalloc(size_t bufSize) -{ - return cv::fastMalloc(bufSize); -} -CVAPI(void) cv_fastFree(void* ptr) -{ - return cv::fastFree(ptr); -} - -CVAPI(void) cv_cvarrToMat(CvArr* arr, bool copyData, bool allowND, int coiMode, cv::Mat* outValue) -{ - *outValue = cv::cvarrToMat(arr, copyData, allowND, coiMode); -} -CVAPI(void) cv_extractImageCOI(const CvArr* arr, cv::Mat* coiimg, int coi) -{ - cv::extractImageCOI(arr, *coiimg, coi); -} -CVAPI(void) cv_insertImageCOI(cv::Mat* coiimg, CvArr* arr, int coi) -{ - cv::insertImageCOI(*coiimg, arr, coi); -} -#pragma endregion - #pragma region Array Operations CVAPI(void) cv_abs1(cv::Mat* src, cv::Mat* dst) { diff --git a/src/OpenCvSharpExtern/WCv.cpp b/src/OpenCvSharpExtern/WCv.cpp deleted file mode 100644 index ef84a9a4f..000000000 --- a/src/OpenCvSharpExtern/WCv.cpp +++ /dev/null @@ -1,6 +0,0 @@ -/* - * (C) 2008-2014 shimat - * This code is licenced under the LGPL. - */ - -#include "WCv.h" diff --git a/src/OpenCvSharpExtern/WCv.h b/src/OpenCvSharpExtern/WCv.h deleted file mode 100644 index 7f453d7f5..000000000 --- a/src/OpenCvSharpExtern/WCv.h +++ /dev/null @@ -1,162 +0,0 @@ -/* - * (C) 2008-2014 shimat - * This code is licenced under the LGPL. - */ - -#ifndef _CPP_WCV_H_ -#define _CPP_WCV_H_ - -#ifdef _MSC_VER -#pragma warning(disable: 4251) -#endif -#include - -CVAPI(void) cv_cvtColor( cv::Mat* src, cv::Mat* dst, int code, int dstCn ) -{ - cv::cvtColor(*src, *dst, code, dstCn); -} - - -CVAPI(void) cv_copyMakeBorder( cv::Mat* src, cv::Mat* dst, int top, int bottom, int left, int right, int borderType, CvScalar value ) -{ - -} - -CVAPI(void) cv_medianBlur( cv::Mat* src, cv::Mat* dst, int kCvSize ) -{ -} - -CVAPI(void) cv_GaussianBlur( cv::Mat* src, cv::Mat* dst, CvSize kCvSize, double sigma1, double sigma2, int borderType ) -{ -} - -CVAPI(void) cv_bilateralFilter( cv::Mat* src, cv::Mat* dst, int d, double sigmaColor, double sigmaSpace, int borderType ) -{ -} - -CVAPI(void) cv_boxFilter( cv::Mat* src, cv::Mat* dst, int ddepth, CvSize ksize, CvPoint anchor, bool normalize, int borderType ) -{ -} - -CVAPI(void) cv_blur( cv::Mat* src, cv::Mat* dst, CvSize ksize, CvPoint anchor, int borderType ) -{ - cv::blur(*src, *dst, ksize, anchor, borderType); -} - -CVAPI(void) cv_filter2D( cv::Mat* src, cv::Mat* dst, int ddepth, cv::Mat* kernel, CvPoint anchor, double delta, int borderType ) -{ -} - -CVAPI(void) cv_sepFilter2D( cv::Mat* src, cv::Mat* dst, int ddepth, cv::Mat* kernelX, cv::Mat* kernelY, CvPoint anchor, double delta, int borderType ) -{ -} - -CVAPI(void) cv_Sobel( cv::Mat* src, cv::Mat* dst, int ddepth, int dx, int dy, int ksize, double scale, double delta, int borderType ) -{ -} - -CVAPI(void) cv_Scharr( cv::Mat* src, cv::Mat* dst, int ddepth, int dx, int dy, double scale, double delta, int borderType ) -{ -} - -CVAPI(void) cv_Laplacian( cv::Mat* src, cv::Mat* dst, int ddepth, int ksize, double scale, double delta, int borderType ) -{ -} - -CVAPI(void) cv_Canny( cv::Mat* image, cv::Mat* edges, double threshold1, double threshold2, int apertureSize, bool L2gradient ) -{ - cv::Canny(*image, *edges, threshold1, threshold2, apertureSize, L2gradient); -} - -CVAPI(void) cv_cornerMinEigenVal( cv::Mat* src, cv::Mat* dst, int blockSize, int kaize, int borderType ) -{ -} - -CVAPI(void) cv_cornerHarris( cv::Mat* src, cv::Mat* dst, int blockSize, int ksize, double k, int borderType ) -{ - cv::cornerHarris(*src, *dst, blockSize, ksize, k, borderType); -} - -CVAPI(void) cv_cornerEigenValsAndVecs( cv::Mat* src, cv::Mat* dst, int blockSize, int ksize, int borderType ) -{ - cv::cornerEigenValsAndVecs(*src, *dst, blockSize, ksize, borderType); -} - -CVAPI(void) cv_preCornerDetect( cv::Mat* src, cv::Mat* dst, int ksize, int borderType ) -{ - cv::preCornerDetect(*src, *dst, ksize, borderType); -} - -CVAPI(void) cv_cornerSubPix( cv::Mat* image, std::vector* corners, CvSize winSize, CvSize zeroZone, CvTermCriteria criteria ) -{ - cv::cornerSubPix(*image, *corners, winSize, zeroZone, criteria); -} - -CVAPI(void) cv_goodFeaturesToTrack( cv::Mat* image, std::vector* corners, int maxCorners, double qualityLevel, double minDistance, cv::Mat* mask, int blocksize, bool useHarrisDetector, double k ) -{ - cv::goodFeaturesToTrack(*image, *corners, maxCorners, qualityLevel, minDistance, *mask, blocksize, useHarrisDetector, k); -} - -CVAPI(void) cv_HoughLines( cv::Mat* image, std::vector* lines, double rho, double theta, int threshold, double srn, double stn ) -{ - cv::HoughLines(*image, *lines, rho, theta, threshold, srn, stn); -} - -CVAPI(void) cv_HoughLinesP( cv::Mat* image, std::vector* lines, double rho, double theta, int threshold, double minLineLength, double maxLineGap ) -{ - cv::HoughLinesP(*image, *lines, rho, theta, threshold, minLineLength, maxLineGap); -} - -CVAPI(void) cv_HoughCircles( cv::Mat* image, std::vector* circles, int method, double dp, double minDist, double param1, double param2, int minRadius, int maxRadius ) -{ - cv::HoughCircles(*image, *circles, method, dp, minDist, param1, param2, minRadius, maxRadius); -} - -CVAPI(void) cv_erode( cv::Mat* src, cv::Mat* dst, cv::Mat* kernel, CvPoint anchor, int iterations, int borderType, CvScalar borderValue ) -{ - cv::erode(*src, *dst, *kernel, anchor, iterations, borderType, borderValue); //cv::morphologyDefaultBorderValue(); -} - -CVAPI(void) cv_dilate( cv::Mat* src, cv::Mat* dst, cv::Mat* kernel, CvPoint anchor, int iterations, int borderType, CvScalar borderValue ) -{ - cv::dilate(*src, *dst, *kernel, anchor, iterations, borderType, borderValue); -} - -CVAPI(void) cv_morphologyEx( cv::Mat* src, cv::Mat* dst, int op, cv::Mat* kernel, CvPoint anchor, int iterations, int borderType, CvScalar borderValue ) -{ - cv::morphologyEx(*src, *dst, op, *kernel, anchor, iterations, borderType, borderValue); -} - -CVAPI(void) cv_resize( cv::Mat* src, cv::Mat* dst, CvSize dsize, double fx, double fy, int interpolation ) -{ - cv::resize(*src, *dst, dsize, fx, fy, interpolation); -} - -CVAPI(void) cv_warpAffine( cv::Mat* src, cv::Mat* dst, cv::Mat* M, CvSize dsize, int flags, int borderMode, CvScalar borderValue) -{ - cv::warpAffine(*src, *dst, *M, dsize, flags, borderMode, borderValue); -} - -CVAPI(void) cv_warpPerspective( cv::Mat* src, cv::Mat* dst, cv::Mat* M, CvSize dsize, int flags, int borderMode, CvScalar borderValue) -{ - cv::warpPerspective(*src, *dst, *M, dsize, flags, borderMode, borderValue); -} - -CVAPI(void) cv_remap( cv::Mat* src, cv::Mat* dst, cv::Mat* map1, cv::Mat* map2, int interpolation, int borderMode, CvScalar borderValue) -{ - cv::remap(*src, *dst, *map1, *map2, interpolation, borderMode, borderValue); -} - -CVAPI(void) cv_convertMaps( cv::Mat* map1, cv::Mat* map2, cv::Mat* dstmap1, cv::Mat* dstmap2, int dstmap1type, bool nninterpolation ) -{ - cv::convertMaps(*map1, *map2, *dstmap1, *dstmap2, dstmap1type, nninterpolation); -} - - - -CVAPI(void) cv_solvePnP( cv::Mat* objectPoints, cv::Mat* imagePoints, cv::Mat* cameraMatrix, cv::Mat* distCoeffs, cv::Mat* rvec, cv::Mat* tvec, bool useExtrinsicGuess ) -{ - cv::solvePnP(*objectPoints, *imagePoints, *cameraMatrix, *distCoeffs, *rvec, *tvec, useExtrinsicGuess); -} - -#endif \ No newline at end of file diff --git a/src/OpenCvSharpExtern/WHighgui.cpp b/src/OpenCvSharpExtern/WHighgui.cpp deleted file mode 100644 index 865a23f67..000000000 --- a/src/OpenCvSharpExtern/WHighgui.cpp +++ /dev/null @@ -1,6 +0,0 @@ -/* - * (C) 2008-2014 shimat - * This code is licenced under the LGPL. - */ - -#include "WHighgui.h" \ No newline at end of file diff --git a/src/OpenCvSharpExtern/WHighgui.h b/src/OpenCvSharpExtern/WHighgui.h deleted file mode 100644 index 533f19fca..000000000 --- a/src/OpenCvSharpExtern/WHighgui.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * (C) 2008-2014 shimat - * This code is licenced under the LGPL. - */ - -#ifndef _CPP_WHIGHGUI_H_ -#define _CPP_WHIGHGUI_H_ - -#ifdef _MSC_VER -#pragma warning(disable: 4251) -#pragma warning(disable: 4996) -#endif -#include - -CVAPI(void) cv_namedWindow( const char* winname, int flags ) -{ - std::string winname_str(winname); - cv::namedWindow(winname_str, flags); -} -CVAPI(void) cv_imshow( const char* winname, cv::Mat* mat ) -{ - std::string winname_str(winname); - cv::imshow(winname_str, *mat); -} -CVAPI(void) cv_imread( const char* filename, int flags, cv::Mat* outValue ) -{ - std::string filename_str(filename); - cv::Mat mat = cv::imread(filename_str, flags); - mat.addref(); - *outValue = mat; -} -CVAPI(bool) cv_imwrite( const char* filename, cv::Mat* img, const int* params, int params_length) -{ - std::string filename_str(filename); - std::vector params_v(params, params + params_length); - cv::Mat& imgRef = *img; - return cv::imwrite(filename_str, imgRef, params_v); -} -CVAPI(void) cv_imdecode( cv::Mat* buf, int flags, cv::Mat* outValue ) -{ - cv::Mat& bufRef = *buf; - *outValue = cv::imdecode(bufRef, flags); -} -CVAPI(bool) cv_imencode( const char* ext, cv::Mat* img, std::vector* buf, const int* params, int params_length) -{ - std::string ext_str(ext); - std::vector params_v(params, params + params_length); - cv::Mat& imgRef = *img; - return cv::imencode(ext_str, imgRef, *buf, params_v); -} -CVAPI(int) cv_waitKey(int delay) -{ - return cv::waitKey(delay); -} - -#endif \ No newline at end of file diff --git a/src/OpenCvSharpExtern/WMat.cpp b/src/OpenCvSharpExtern/WMat.cpp deleted file mode 100644 index aa33c039c..000000000 --- a/src/OpenCvSharpExtern/WMat.cpp +++ /dev/null @@ -1,6 +0,0 @@ -/* - * (C) 2008-2014 shimat - * This code is licenced under the LGPL. - */ - -#include "WMat.h" diff --git a/src/OpenCvSharpExtern/WMat.h b/src/OpenCvSharpExtern/WMat.h deleted file mode 100644 index 1cdca5452..000000000 --- a/src/OpenCvSharpExtern/WMat.h +++ /dev/null @@ -1,279 +0,0 @@ -/* - * (C) 2008-2014 shimat - * This code is licenced under the LGPL. - */ - -#ifndef _CPP_WMAT_H_ -#define _CPP_WMAT_H_ - -#ifdef _MSC_VER -#pragma warning(disable: 4251) -#endif -#include - - -#pragma region Init and Disposal -CVAPI(int) Mat_sizeof() -{ - return sizeof(cv::Mat); -} -CVAPI(void) Mat_delete(cv::Mat* obj) -{ - delete obj; -} -CVAPI(cv::Mat*) Mat_new1() -{ - return new cv::Mat(); -} -CVAPI(cv::Mat*) Mat_new2(int rows, int cols, int type) -{ - return new cv::Mat(rows, cols, type); -} -CVAPI(cv::Mat*) Mat_new3(int rows, int cols, int type, CvScalar s) -{ - return new cv::Mat(rows, cols, type, s); -} -CVAPI(cv::Mat*) Mat_new4(int rows, int cols, int type, void* data, size_t step) -{ - return new cv::Mat(rows, cols, type, data, step); -} -CVAPI(cv::Mat*) Mat_new5(const cv::Mat* m, CvSlice rowRange, CvSlice colRange) -{ - return new cv::Mat(*m, (cv::Range)rowRange, (cv::Range)colRange); -} -CVAPI(cv::Mat*) Mat_new6(const cv::Mat* m, CvRect roi) -{ - return new cv::Mat(*m, (cv::Rect)roi); -} -CVAPI(cv::Mat*) Mat_new7(const CvMat* m, bool copyData) -{ - return new cv::Mat(m, copyData); -} -CVAPI(cv::Mat*) Mat_new8(const IplImage* img, bool copyData) -{ - return new cv::Mat(img, copyData); -} -CVAPI(cv::Mat*) Mat_new9(uchar* vec, int vecSize, int depthType, int elemSize, bool copyData) -{ - cv::Mat* mat = new cv::Mat(); - if( !copyData ) - { - mat->rows = vecSize; - mat->cols = 1; - mat->step = elemSize; - mat->data = mat->datastart = vec; - mat->dataend = mat->datastart + mat->rows*mat->step; - } - else - { - cv::Mat(vecSize, 1, depthType, vec).copyTo(*mat); - } - return mat; -} -#pragma endregion - -#pragma region Fields -CVAPI(int) Mat_flags(const cv::Mat* obj) -{ - return obj->flags; -} -CVAPI(int) Mat_rows(const cv::Mat* obj) -{ - return obj->rows; -} -CVAPI(int) Mat_cols(const cv::Mat* obj) -{ - return obj->cols; -} -CVAPI(size_t) Mat_step(const cv::Mat* obj) -{ - return obj->step; -} -CVAPI(uchar*) Mat_data(const cv::Mat* obj) -{ - return obj->data; -} -CVAPI(int*) Mat_refcount(const cv::Mat* obj) -{ - return obj->refcount; -} -CVAPI(uchar*) Mat_datastart(const cv::Mat* obj) -{ - return obj->datastart; -} -CVAPI(uchar*) Mat_dataend(const cv::Mat* obj) -{ - return obj->dataend; -} -#pragma endregion - -#pragma region Operators -CVAPI(void) Mat_opUnaryMinus(cv::Mat* src, cv::Mat* dst) -{ - cv::Mat m = *src; - *dst = -m; -} -CVAPI(void) Mat_opBinaryPlus1(cv::Mat* src1, cv::Mat* src2, cv::Mat* dst) -{ - *dst = (*src1) + (*src2); -} -CVAPI(void) Mat_opBinaryPlus2(cv::Mat* src1, cv::Scalar src2, cv::Mat* dst) -{ - *dst = (*src1) + src2; -} -CVAPI(void) Mat_opBinaryMinus1(cv::Mat* src1, cv::Mat* src2, cv::Mat* dst) -{ - *dst = (*src1) - (*src2); -} -CVAPI(void) Mat_opBinaryMinus2(cv::Mat* src1, cv::Scalar src2, cv::Mat* dst) -{ - *dst = (*src1) - src2; -} -CVAPI(void) Mat_opBinaryMultiply(cv::Mat* src1, cv::Mat* src2, cv::Mat* dst) -{ - *dst = (*src1) * (*src2); -} -CVAPI(void) Mat_opBinaryDivide(cv::Mat* src1, cv::Mat* src2, cv::Mat* dst) -{ - *dst = (*src1) / (*src2); -} - -CVAPI(void) Mat_opRange1(cv::Mat* src, CvRect roi, cv::Mat* dst) -{ - *dst = (*src)(roi); -} -CVAPI(void) Mat_opRange2(cv::Mat* src, CvSlice rowRange, CvSlice colRange, cv::Mat* dst) -{ - *dst = (*src)(rowRange, colRange); -} - -CVAPI(void) Mat_opCvMat(cv::Mat* obj, CvMat* value) -{ - CvMat mat = (CvMat)(*obj); - *value = mat; -} -CVAPI(void) Mat_opIplImage(cv::Mat* obj, IplImage* value) -{ - IplImage ipl = (IplImage)(*obj); - *value = ipl; -} -#pragma endregion - -#pragma region Methods -CVAPI(void) Mat_row(cv::Mat* obj, int y, cv::Mat* outValue) -{ - *outValue = obj->row(y); -} -CVAPI(void) Mat_col(cv::Mat* obj, int x, cv::Mat* outValue) -{ - *outValue = obj->col(x); -} -CVAPI(void) Mat_rowRange(cv::Mat* obj, int startrow, int endrow, cv::Mat* outValue) -{ - *outValue = obj->rowRange(startrow, endrow); -} -CVAPI(void) Mat_colRange(cv::Mat* obj, int startcol, int endcol, cv::Mat* outValue) -{ - *outValue = obj->colRange(startcol, endcol); -} -CVAPI(void) Mat_diag1(cv::Mat* obj, int d, cv::Mat* outValue) -{ - *outValue = obj->diag(d); -} -CVAPI(void) Mat_diag2(cv::Mat* d, cv::Mat* outValue) -{ - *outValue = cv::Mat::diag(*d); -} -CVAPI(void) Mat_clone(cv::Mat* obj, cv::Mat* outValue) -{ - *outValue = obj->clone(); -} -CVAPI(void) Mat_copyTo1(cv::Mat* obj, cv::Mat* m) -{ - obj->copyTo(*m); -} -CVAPI(void) Mat_copyTo2(cv::Mat* obj, cv::Mat* m, cv::Mat* mask) -{ - obj->copyTo(*m, *mask); -} -CVAPI(void) Mat_convertTo(cv::Mat* obj, cv::Mat* m, int rtype, double alpha, double beta) -{ - obj->convertTo(*m, rtype, alpha, beta); -} -CVAPI(void) Mat_assignTo(cv::Mat* obj, cv::Mat* m, int type) -{ - obj->assignTo(*m, type); -} -CVAPI(void) Mat_setTo(cv::Mat* obj, cv::Mat* value, cv::Mat* mask, cv::Mat* dst) -{ - if(mask == NULL) - *dst = obj->setTo(*value); - else - *dst = obj->setTo(*value, *mask); -} -CVAPI(void) Mat_reshape(cv::Mat* obj, int cn, int rows, cv::Mat* outValue) -{ - obj->reshape(cn, rows); -} -CVAPI(void) Mat_cross(cv::Mat* obj, cv::Mat* m, cv::Mat* outValue) -{ - *outValue = obj->cross(*m); -} -CVAPI(double) Mat_dot(cv::Mat* obj, cv::Mat* m) -{ - return obj->dot(*m); -} - -CVAPI(void) Mat_zeros(int rows, int cols, int type, cv::Mat* outValue) -{ - *outValue = cv::Mat::zeros(rows, cols, type); -} -CVAPI(void) Mat_ones(int rows, int cols, int type, cv::Mat* outValue) -{ - *outValue = cv::Mat::ones(rows, cols, type); -} -CVAPI(void) Mat_eye(int rows, int cols, int type, cv::Mat* outValue) -{ - *outValue = cv::Mat::eye(rows, cols, type); -} - -CVAPI(void) Mat_create(cv::Mat* obj, int rows, int cols, int type) -{ - obj->create(rows, cols, type); -} -CVAPI(void) Mat_locateROI(cv::Mat* obj, CvSize* wholeSize, CvPoint* ofs) -{ - cv::Size _wholeSize; - cv::Point _ofs; - obj->locateROI(_wholeSize, _ofs); - *wholeSize = (CvSize)_wholeSize; - *ofs = (CvPoint)_ofs; -} -CVAPI(void) Mat_adjustROI(cv::Mat* obj, int dtop, int dbottom, int dleft, int dright, cv::Mat* dst) -{ - *dst = obj->adjustROI(dtop, dbottom, dleft, dright); -} - - -CVAPI(void) Mat_t(cv::Mat* src, cv::Mat* dst) -{ - *dst = src->t(); -} - -CVAPI(void) Mat_inv(cv::Mat* src, int method, cv::Mat* dst) -{ - *dst = src->inv(method); -} - -/* - MatExpr_ >, Mat> - // per-element matrix multiplication by means of matrix expressions - mul(const Mat& m, double scale=1) const; - MatExpr_ >, Mat> - mul(const MatExpr_ >, Mat>& m, double scale=1) const; - MatExpr_ >, Mat> - mul(const MatExpr_ >, Mat>& m, double scale=1) const; - */ -#pragma endregion - -#endif \ No newline at end of file diff --git a/src/OpenCvSharpExtern/calib3d.cpp b/src/OpenCvSharpExtern/calib3d.cpp new file mode 100644 index 000000000..aa744be83 --- /dev/null +++ b/src/OpenCvSharpExtern/calib3d.cpp @@ -0,0 +1,6 @@ +/* +* (C) 2008-2014 shimat +* This code is licenced under the LGPL. +*/ + +#include "calib3d.h" \ No newline at end of file diff --git a/src/OpenCvSharpExtern/calib3d.h b/src/OpenCvSharpExtern/calib3d.h new file mode 100644 index 000000000..966f978fb --- /dev/null +++ b/src/OpenCvSharpExtern/calib3d.h @@ -0,0 +1,19 @@ +/* +* (C) 2008-2014 shimat +* This code is licenced under the LGPL. +*/ + +#ifndef _CPP_CORE_CALIB3D_H_ +#define _CPP_CORE_CALIB3D_H_ + +#include "include_opencv.h" + + +CVAPI(void) imgproc_solvePnP(cv::_InputArray* objectPoints, cv::_InputArray* imagePoints, cv::_InputArray* cameraMatrix, cv::_InputArray* distCoeffs, + cv::_OutputArray* rvec, cv::_OutputArray* tvec, int useExtrinsicGuess) +{ + cv::InputArray distCoeffsVal = (distCoeffs != NULL) ? *distCoeffs : cv::noArray(); + cv::solvePnP(*objectPoints, *imagePoints, *cameraMatrix, distCoeffsVal, *rvec, *tvec, useExtrinsicGuess != 0); +} + +#endif \ No newline at end of file diff --git a/src/OpenCvSharpExtern/core.cpp b/src/OpenCvSharpExtern/core.cpp new file mode 100644 index 000000000..227e0599b --- /dev/null +++ b/src/OpenCvSharpExtern/core.cpp @@ -0,0 +1,6 @@ +/* +* (C) 2008-2014 shimat +* This code is licenced under the LGPL. +*/ + +#include "core.h" \ No newline at end of file diff --git a/src/OpenCvSharpExtern/core.h b/src/OpenCvSharpExtern/core.h new file mode 100644 index 000000000..40b705220 --- /dev/null +++ b/src/OpenCvSharpExtern/core.h @@ -0,0 +1,165 @@ +/* +* (C) 2008-2014 shimat +* This code is licenced under the LGPL. +*/ + +#ifndef _CPP_CORE_H_ +#define _CPP_CORE_H_ + +#include "include_opencv.h" + +#pragma region Miscellaneous + +CVAPI(void) core_setNumThreads(int nthreads) +{ + cv::setNumThreads(nthreads); +} +CVAPI(int) core_getNumThreads() +{ + return cv::getNumThreads(); +} +CVAPI(int) core_getThreadNum() +{ + return cv::getThreadNum(); +} + +CVAPI(void) core_getBuildInformation(char* buf, uint32 maxLength) +{ + const std::string& str = cv::getBuildInformation(); + const char* srcPtr = str.c_str(); + uint32 length = std::max(str.length() + 1, maxLength); + memcpy(buf, srcPtr, length); +} + +CVAPI(int64) core_getTickCount() +{ + return cv::getTickCount(); +} +CVAPI(double) core_getTickFrequency() +{ + return cv::getTickFrequency(); +} +CVAPI(int64) core_getCPUTickCount() +{ + return cv::getCPUTickCount(); +} + +CVAPI(int) core_checkHardwareSupport(int feature) +{ + return cv::checkHardwareSupport(feature) ? 1 : 0; +} + +CVAPI(int) core_getNumberOfCPUs() +{ + return cv::getNumberOfCPUs(); +} + +CVAPI(void*) core_fastMalloc(size_t bufSize) +{ + return cv::fastMalloc(bufSize); +} +CVAPI(void) core_fastFree(void* ptr) +{ + return cv::fastFree(ptr); +} + +CVAPI(void) core_setUseOptimized(int onoff) +{ + cv::setUseOptimized(onoff != 0); +} +CVAPI(int) core_useOptimized() +{ + return cv::useOptimized() ? 1 : 0; +} + +CVAPI(cv::Mat*) core_cvarrToMat(CvArr* arr, int copyData, int allowND, int coiMode) +{ + cv::Mat ret = cv::cvarrToMat(arr, copyData != 0, allowND != 0, coiMode); + return new cv::Mat(ret); +} +CVAPI(void) core_extractImageCOI(CvArr *arr, cv::_OutputArray *coiimg, int coi) +{ + cv::extractImageCOI(arr, *coiimg, coi); +} +CVAPI(void) core_insertImageCOI(cv::_InputArray *coiimg, CvArr* arr, int coi) +{ + cv::insertImageCOI(*coiimg, arr, coi); +} +#pragma endregion + +#pragma region Drawing + +CVAPI(void) core_line(cv::Mat *img, CvPoint pt1, CvPoint pt2, CvScalar color, + int thickness, int lineType, int shift) +{ + cv::line(*img, pt1, pt2, color, thickness, lineType, shift); +} + +CVAPI(void) core_rectangle1(cv::Mat *img, CvPoint pt1, CvPoint pt2, + CvScalar color, int thickness, int lineType, int shift) +{ + cv::rectangle(*img, pt1, pt2, color, thickness, shift); +} +CVAPI(void) core_rectangle2(cv::Mat *img, CvRect rect, + CvScalar color, int thickness, int lineType, int shift) +{ + cv::rectangle(*img, rect, color, thickness, shift); +} + +CVAPI(void) core_circle(cv::Mat *img, CvPoint center, int radius, + CvScalar color, int thickness, int lineType, int shift) +{ + cv::circle(*img, center, radius, color, thickness, lineType, shift); +} + +CVAPI(void) core_ellipse1(cv::Mat *img, CvPoint center, CvSize axes, + double angle, double startAngle, double endAngle, + CvScalar& color, int thickness, int lineType, int shift) +{ + cv::ellipse(*img, center, axes, angle, startAngle, endAngle, color, thickness, lineType, shift); +} +CVAPI(void) core_ellipse2(cv::Mat *img, CvBox2D box, CvScalar color, int thickness, int lineType) +{ + cv::ellipse(*img, box, color, thickness, lineType); +} + +CVAPI(void) core_fillConvexPoly(cv::Mat *img, cv::Point* pts, int npts, + CvScalar color, int lineType, int shift) +{ + cv::fillConvexPoly(*img, pts, npts, color, lineType, shift); +} + +CVAPI(void) core_fillPoly(cv::Mat *img, const cv::Point **pts, const int* npts, + int ncontours, CvScalar color, int lineType, int shift, CvPoint offset) +{ + cv::fillPoly(*img, pts, npts, ncontours, color, lineType, shift, offset); +} + +CVAPI(void) core_polylines(cv::Mat *img, const cv::Point **pts, const int* npts, + int ncontours, int isClosed, CvScalar color, + int thickness, int lineType, int shift) +{ + cv::polylines( + *img, pts, npts, ncontours, isClosed != 0, color, thickness, lineType, shift); +} + +CVAPI(int) core_clipLine1(CvSize imgSize, CvPoint *pt1, CvPoint *pt2) +{ + cv::Point pt1c = *pt1, pt2c = *pt2; + bool result = cv::clipLine(imgSize, pt1c, pt2c); + *pt1 = pt1c; + *pt2 = pt2c; + return result ? 1 : 0; +} +CVAPI(int) core_clipLine2(CvRect imgRect, CvPoint *pt1, CvPoint *pt2) +{ + cv::Point pt1c = *pt1, pt2c = *pt2; + bool result = cv::clipLine(imgRect, pt1c, pt2c); + *pt1 = pt1c; + *pt2 = pt2c; + return result ? 1 : 0; +} + +#pragma endregion + +#endif \ No newline at end of file diff --git a/src/OpenCvSharpExtern/imgproc.h b/src/OpenCvSharpExtern/imgproc.h index c177d6635..016bac990 100644 --- a/src/OpenCvSharpExtern/imgproc.h +++ b/src/OpenCvSharpExtern/imgproc.h @@ -8,7 +8,8 @@ #include "include_opencv.h" -CVAPI(cv::Mat*) imgproc_getGaborKernel(CvSize ksize, double sigma, double theta, double lambd, double gamma, double psi, int ktype) +CVAPI(cv::Mat*) imgproc_getGaborKernel(CvSize ksize, double sigma, double theta, + double lambd, double gamma, double psi, int ktype) { cv::Mat ret = cv::getGaborKernel(ksize, sigma, theta, lambd, gamma, ktype); return new cv::Mat(ret); @@ -25,7 +26,8 @@ CVAPI(void) imgproc_cvtColor(cv::_InputArray *src, cv::_OutputArray *dst, int co cv::cvtColor(*src, *dst, code, dstCn); } -CVAPI(void) imgproc_copyMakeBorder(cv::_InputArray *src, cv::_OutputArray *dst, int top, int bottom, int left, int right, int borderType, CvScalar value) +CVAPI(void) imgproc_copyMakeBorder(cv::_InputArray *src, cv::_OutputArray *dst, + int top, int bottom, int left, int right, int borderType, CvScalar value) { cv::copyMakeBorder(*src, *dst, top, bottom, left, right, borderType, value); } @@ -35,23 +37,26 @@ CVAPI(void) imgproc_medianBlur(cv::_InputArray *src, cv::_OutputArray *dst, int cv::medianBlur(*src, *dst, ksize); } -CVAPI(void) imgproc_GaussianBlur(cv::_InputArray *src, cv::_OutputArray *dst, CvSize ksize, double sigmaX, double sigmaY, int borderType) +CVAPI(void) imgproc_GaussianBlur(cv::_InputArray *src, cv::_OutputArray *dst, + CvSize ksize, double sigmaX, double sigmaY, int borderType) { cv::GaussianBlur(*src, *dst, ksize, sigmaX, sigmaY, borderType); } -CVAPI(void) imgproc_bilateralFilter(cv::_InputArray *src, cv::_OutputArray *dst, int d, double sigmaColor, double sigmaSpace, int borderType) +CVAPI(void) imgproc_bilateralFilter(cv::_InputArray *src, cv::_OutputArray *dst, + int d, double sigmaColor, double sigmaSpace, int borderType) { cv::bilateralFilter(*src, *dst, d, sigmaColor, sigmaSpace, borderType); } -CVAPI(void) imgproc_adaptiveBilateralFilter(cv::_InputArray *src, cv::_OutputArray *dst, CvSize ksize, double sigmaSpace, - double maxSigmaColor, CvPoint anchor, int borderType) +CVAPI(void) imgproc_adaptiveBilateralFilter(cv::_InputArray *src, cv::_OutputArray *dst, + CvSize ksize, double sigmaSpace, double maxSigmaColor, CvPoint anchor, int borderType) { cv::adaptiveBilateralFilter(*src, *dst, ksize, sigmaSpace, maxSigmaColor, anchor, borderType); } -CVAPI(void) imgproc_boxFilter(cv::_InputArray *src, cv::_OutputArray *dst, int ddepth, CvSize ksize, CvPoint anchor, int normalize, int borderType) +CVAPI(void) imgproc_boxFilter(cv::_InputArray *src, cv::_OutputArray *dst, int ddepth, + CvSize ksize, CvPoint anchor, int normalize, int borderType) { cv::boxFilter(*src, *dst, ddepth, ksize, anchor, normalize != 0, borderType); } @@ -68,63 +73,75 @@ CVAPI(void) imgproc_filter2D(cv::_InputArray *src, cv::_OutputArray *dst, int dd } CVAPI(void) imgproc_sepFilter2D(cv::_InputArray *src, cv::_OutputArray *dst, int ddepth, - cv::_InputArray *kernelX, cv::_InputArray kernelY, + cv::_InputArray *kernelX, cv::_InputArray *kernelY, CvPoint anchor, double delta, int borderType) { + cv::sepFilter2D(*src, *dst, ddepth, *kernelX, *kernelY, anchor, delta, borderType); } CVAPI(void) imgproc_Sobel(cv::_InputArray *src, cv::_OutputArray *dst, int ddepth, int dx, int dy, int ksize, double scale, double delta, int borderType) { + cv::Sobel(*src, *dst, ddepth, dx, dy, ksize, scale, delta, borderType); } CVAPI(void) imgproc_Scharr(cv::_InputArray *src, cv::_OutputArray *dst, int ddepth, int dx, int dy, double scale, double delta, int borderType) { + cv::Scharr(*src, *dst, ddepth, dx, dy, scale, delta, borderType); } CVAPI(void) imgproc_Laplacian(cv::_InputArray *src, cv::_OutputArray *dst, int ddepth, int ksize, double scale, double delta, int borderType) { + cv::Laplacian(*src, *dst, ddepth, ksize, scale, delta, borderType); } CVAPI(void) imgproc_Canny(cv::_InputArray *src, cv::_OutputArray *edges, - double threshold1, double threshold2, int apertureSize, bool L2gradient) + double threshold1, double threshold2, int apertureSize, int L2gradient) { + cv::Canny(*src, *edges, threshold1, threshold2, apertureSize, L2gradient != 0); } CVAPI(void) imgproc_cornerMinEigenVal(cv::_InputArray *src, cv::_OutputArray *dst, int blockSize, int ksize, int borderType) { + cv::cornerMinEigenVal(*src, *dst, blockSize, ksize, borderType); } -CVAPI(void) imgproc_cornerHarris(cv::_InputArray *src, cv::_OutputArray *dst, int blockSize, - int ksize, double k, int borderType) +CVAPI(void) imgproc_cornerHarris(cv::_InputArray *src, cv::_OutputArray *dst, + int blockSize, int ksize, double k, int borderType) { + cv::cornerHarris(*src, *dst, blockSize, ksize, k, borderType); } -CVAPI(void) imgproc_eigen2x2(const float* a, float* e, int n); +CVAPI(void) imgproc_eigen2x2(const float* a, float* e, int n) +{ + cv::eigen2x2(a, e, n); +} CVAPI(void) imgproc_cornerEigenValsAndVecs(cv::_InputArray *src, cv::_OutputArray *dst, int blockSize, int ksize, int borderType) { + cv::cornerEigenValsAndVecs(*src, *dst, blockSize, ksize, borderType); } CVAPI(void) imgproc_preCornerDetect(cv::_InputArray *src, cv::_OutputArray *dst, int ksize, int borderType) { + cv::preCornerDetect(*src, *dst, ksize, borderType); } -CVAPI(void) imgproc_cornerSubPix(cv::_InputArray *src, cv::_OutputArray *corners, +CVAPI(void) imgproc_cornerSubPix(cv::_InputArray *image, std::vector *corners, CvSize winSize, CvSize zeroZone, CvTermCriteria criteria) { + cv::cornerSubPix(*image, *corners, winSize, zeroZone, criteria); } CVAPI(void) imgproc_goodFeaturesToTrack(cv::_InputArray *src, std::vector *corners, int maxCorners, double qualityLevel, double minDistance, cv::_InputArray *mask, int blockSize, int useHarrisDetector, double k) { - cv::InputArray maskVal = (mask == NULL) ? cv::noArray() : *mask; - cv::goodFeaturesToTrack(*src, *corners, maxCorners, qualityLevel, minDistance, maskVal, blockSize, useHarrisDetector != 0, k); + cv::goodFeaturesToTrack(*src, *corners, maxCorners, qualityLevel, minDistance, entity(mask), blockSize, useHarrisDetector != 0, k); } CVAPI(void) imgproc_HoughLines(cv::_InputArray *src, std::vector *lines, @@ -148,4 +165,126 @@ CVAPI(void) imgproc_HoughCircles(cv::_InputArray *src, std::vector *c cv::HoughCircles(*src, *circles, method, dp, minDist, param1, param2, minRadius, maxRadius); } + +CVAPI(void) imgproc_erode(cv::_InputArray *src, cv::_OutputArray *dst, cv::_InputArray *kernel, + CvPoint anchor, int iterations, int borderType, CvScalar borderValue) +{ + cv::erode(*src, *dst, entity(kernel), anchor, iterations, borderType, borderValue); +} +CVAPI(void) imgproc_dilate(cv::_InputArray *src, cv::_OutputArray *dst, cv::_InputArray *kernel, + CvPoint anchor, int iterations, int borderType, CvScalar borderValue) +{ + cv::dilate(*src, *dst, entity(kernel), anchor, iterations, borderType, borderValue); +} +CVAPI(void) imgproc_morphologyEx(cv::_InputArray *src, cv::_OutputArray *dst, int op, cv::_InputArray *kernel, + CvPoint anchor, int iterations, int borderType, CvScalar borderValue) +{ + cv::morphologyEx(*src, *dst, op, entity(kernel), anchor, iterations, borderType, borderValue); +} + +CVAPI(void) imgproc_resize(cv::_InputArray* src, cv::_OutputArray* dst, CvSize dsize, double fx, double fy, int interpolation) +{ + cv::resize(*src, *dst, dsize, fx, fy, interpolation); +} + +CVAPI(void) imgproc_warpAffine(cv::_InputArray* src, cv::_OutputArray* dst, cv::_InputArray* M, CvSize dsize, + int flags, int borderMode, CvScalar borderValue) +{ + cv::warpAffine(*src, *dst, *M, dsize, flags, borderMode, borderValue); +} + +CVAPI(void) imgproc_warpPerspective(cv::_InputArray* src, cv::_OutputArray* dst, cv::_InputArray* M, CvSize dsize, + int flags, int borderMode, CvScalar borderValue) +{ + cv::warpPerspective(*src, *dst, *M, dsize, flags, borderMode, borderValue); +} + +CVAPI(void) imgproc_remap(cv::_InputArray* src, cv::_OutputArray* dst, cv::_InputArray* map1, cv::_InputArray* map2, + int interpolation, int borderMode, CvScalar borderValue) +{ + cv::remap(*src, *dst, *map1, *map2, interpolation, borderMode, borderValue); +} + +CVAPI(void) imgproc_convertMaps(cv::_InputArray* map1, cv::_InputArray* map2, cv::_OutputArray* dstmap1, cv::_OutputArray* dstmap2, + int dstmap1type, int nninterpolation) +{ + cv::convertMaps(*map1, *map2, *dstmap1, *dstmap2, dstmap1type, nninterpolation != 0); +} + +CVAPI(cv::Mat*) imgproc_getRotationMatrix2D(CvPoint2D32f center, double angle, double scale) +{ + cv::Mat ret = cv::getRotationMatrix2D(center, angle, scale); + return new cv::Mat(ret); + +} +CVAPI(void) imgproc_invertAffineTransform(cv::_InputArray* M, cv::_OutputArray *iM) +{ + cv::invertAffineTransform(*M, *iM); +} + +CVAPI(cv::Mat*) imgproc_getPerspectiveTransform1(cv::Point2f *src, cv::Point2f *dst) +{ + cv::Mat ret = cv::getPerspectiveTransform(src, dst); + return new cv::Mat(ret); +} +CVAPI(cv::Mat*) imgproc_getPerspectiveTransform2(cv::_InputArray *src, cv::_InputArray *dst) +{ + cv::Mat ret = cv::getPerspectiveTransform(*src, *dst); + return new cv::Mat(ret); +} + +CVAPI(cv::Mat*) imgproc_getAffineTransform1(cv::Point2f *src, cv::Point2f *dst) +{ + cv::Mat ret = cv::getAffineTransform(src, dst); + return new cv::Mat(ret); +} +CVAPI(cv::Mat*) imgproc_getAffineTransform2(cv::_InputArray *src, cv::_InputArray *dst) +{ + cv::Mat ret = cv::getAffineTransform(*src, *dst); + return new cv::Mat(ret); +} + +CVAPI(void) imgproc_getRectSubPix(cv::_InputArray *image, CvSize patchSize, CvPoint2D32f center, cv::_OutputArray *patch, int patchType) +{ + cv::getRectSubPix(*image, patchSize, center, *patch, patchType); +} + +CVAPI(void) imgproc_integral1(cv::_InputArray *src, cv::_OutputArray *sum, int sdepth) +{ + cv::integral(*src, *sum, sdepth); +} +CVAPI(void) imgproc_integral2(cv::_InputArray *src, cv::_OutputArray *sum, cv::_OutputArray *sqsum, int sdepth) +{ + cv::integral(*src, *sum, *sqsum, sdepth); +} +CVAPI(void) imgproc_integral3(cv::_InputArray *src, cv::_OutputArray *sum, cv::_OutputArray *sqsum, cv::_OutputArray *tilted, int sdepth) +{ + cv::integral(*src, *sum, *sqsum, *tilted, sdepth); +} + +CVAPI(void) imgproc_accumulate(cv::_InputArray *src, cv::_OutputArray *dst, cv::_InputArray *mask) +{ + cv::accumulate(*src, *dst, entity(mask)); +} +CVAPI(void) imgproc_accumulateSquare(cv::_InputArray* src, cv::_OutputArray *dst, cv::_InputArray *mask) +{ + cv::accumulateSquare(*src, *dst, entity(mask)); +} +CVAPI(void) imgproc_accumulateProduct(cv::_InputArray *src1, cv::_InputArray *src2, cv::_OutputArray *dst, cv::_InputArray *mask) +{ + cv::accumulateProduct(*src1, *src2, *dst, entity(mask)); +} +CVAPI(void) imgproc_accumulateWeighted(cv::_InputArray *src, cv::_OutputArray *dst, double alpha, cv::_InputArray *mask) +{ + cv::accumulateWeighted(*src, *dst, alpha, entity(mask)); +} + +CVAPI(double) imgproc_PSNR(cv::_InputArray *src1, cv::_InputArray *src2) +{ + return cv::PSNR(*src1, *src2); +} + + + + #endif \ No newline at end of file diff --git a/src/OpenCvSharpExtern/include_opencv.h b/src/OpenCvSharpExtern/include_opencv.h index 68844acf2..ebcb1d94b 100644 --- a/src/OpenCvSharpExtern/include_opencv.h +++ b/src/OpenCvSharpExtern/include_opencv.h @@ -23,4 +23,13 @@ int p(T obj) #endif #endif +static inline cv::InputArray entity(cv::_InputArray *obj) +{ + return (obj != NULL) ? *obj : cv::noArray(); +} +static inline cv::OutputArray entity(cv::_OutputArray *obj) +{ + return (obj != NULL) ? *obj : cv::noArray(); +} + #endif diff --git a/src/OpenCvSharpExtern/std_vector.h b/src/OpenCvSharpExtern/std_vector.h index aca981e5f..76376d79a 100644 --- a/src/OpenCvSharpExtern/std_vector.h +++ b/src/OpenCvSharpExtern/std_vector.h @@ -224,6 +224,38 @@ CVAPI(void) vector_Point2f_delete(vector* vector) } #pragma endregion +#pragma region cv::Point3f +CVAPI(vector*) vector_Point3f_new1() +{ + return new vector; +} +CVAPI(vector*) vector_Point3f_new2(size_t size) +{ + return new vector(size); +} +CVAPI(vector*) vector_Point3f_new3(CvPoint3D32f* data, size_t dataLength) +{ + vector* vec = new vector(dataLength); + for (size_t i = 0; ipush_back(data[i]); + } + return vec; +} +CVAPI(size_t) vector_Point3f_getSize(vector* vector) +{ + return vector->size(); +} +CVAPI(cv::Point3f*) vector_Point3f_getPointer(vector* vector) +{ + return &(vector->at(0)); +} +CVAPI(void) vector_Point3f_delete(vector* vector) +{ + delete vector; +} +#pragma endregion + #pragma region cv::Rect CVAPI(vector*) vector_Rect_new1() { From 4cf9632a45f2efe0fdb5cc77b0d43fee42f64aad Mon Sep 17 00:00:00 2001 From: shimat Date: Sun, 9 Feb 2014 01:27:43 +0900 Subject: [PATCH 22/29] Prototype becomes RC --- src/OpenCvSharp.Gpu/HOGDescriptor.cs | 2 +- .../OpenCvSharpExtern.vcxproj | 34 +++-- .../OpenCvSharpExtern.vcxproj.filters | 102 +++++++------- src/OpenCvSharpExtern/WAlgorithm.cpp | 6 - src/OpenCvSharpExtern/WAlgorithm.h | 97 ------------- src/OpenCvSharpExtern/WCore.cpp | 6 - src/OpenCvSharpExtern/WCore.h | 75 ---------- .../WCvAdaptiveSkinDetector.cpp | 1 - .../WCvAdaptiveSkinDetector.h | 28 ---- src/OpenCvSharpExtern/WCvCamShiftTracker.cpp | 2 - src/OpenCvSharpExtern/WCvCamShiftTracker.h | 114 ---------------- src/OpenCvSharpExtern/WCvaux.cpp | 1 - src/OpenCvSharpExtern/WCvaux.h | 21 --- src/OpenCvSharpExtern/WStereoSGBM.cpp | 2 - src/OpenCvSharpExtern/WStereoSGBM.h | 128 ------------------ src/OpenCvSharpExtern/calib3d.h | 120 +++++++++++++++- src/OpenCvSharpExtern/contrib.cpp | 6 + src/OpenCvSharpExtern/contrib.h | 24 ++++ src/OpenCvSharpExtern/core.h | 31 +++++ src/OpenCvSharpExtern/core_Algorithm.cpp | 6 + src/OpenCvSharpExtern/core_Algorithm.h | 91 +++++++++++++ src/OpenCvSharpExtern/core_Mat.h | 7 + src/OpenCvSharpExtern/core_MatExpr.h | 6 + src/OpenCvSharpExtern/core_Ptr.cpp | 6 + src/OpenCvSharpExtern/core_Ptr.h | 16 +++ src/OpenCvSharpExtern/features2d.cpp | 1 + src/OpenCvSharpExtern/features2d.h | 60 ++++++++ .../{WFlann.cpp => flann.cpp} | 2 +- src/OpenCvSharpExtern/{WFlann.h => flann.h} | 51 +++---- src/OpenCvSharpExtern/include_opencv.h | 9 ++ src/OpenCvSharpExtern/legacy.cpp | 6 + src/OpenCvSharpExtern/legacy.h | 110 +++++++++++++++ .../{WVideo.cpp => nonfree.cpp} | 2 +- .../{WNonfree.h => nonfree.h} | 6 +- src/OpenCvSharpExtern/std_vector.h | 41 ++++++ .../{WNonfree.cpp => video.cpp} | 2 +- src/OpenCvSharpExtern/{WVideo.h => video.h} | 40 +++--- 37 files changed, 648 insertions(+), 614 deletions(-) delete mode 100644 src/OpenCvSharpExtern/WAlgorithm.cpp delete mode 100644 src/OpenCvSharpExtern/WAlgorithm.h delete mode 100644 src/OpenCvSharpExtern/WCore.cpp delete mode 100644 src/OpenCvSharpExtern/WCore.h delete mode 100644 src/OpenCvSharpExtern/WCvAdaptiveSkinDetector.cpp delete mode 100644 src/OpenCvSharpExtern/WCvAdaptiveSkinDetector.h delete mode 100644 src/OpenCvSharpExtern/WCvCamShiftTracker.cpp delete mode 100644 src/OpenCvSharpExtern/WCvCamShiftTracker.h delete mode 100644 src/OpenCvSharpExtern/WCvaux.cpp delete mode 100644 src/OpenCvSharpExtern/WCvaux.h delete mode 100644 src/OpenCvSharpExtern/WStereoSGBM.cpp delete mode 100644 src/OpenCvSharpExtern/WStereoSGBM.h create mode 100644 src/OpenCvSharpExtern/contrib.cpp create mode 100644 src/OpenCvSharpExtern/contrib.h create mode 100644 src/OpenCvSharpExtern/core_Algorithm.cpp create mode 100644 src/OpenCvSharpExtern/core_Algorithm.h create mode 100644 src/OpenCvSharpExtern/core_Ptr.cpp create mode 100644 src/OpenCvSharpExtern/core_Ptr.h create mode 100644 src/OpenCvSharpExtern/features2d.cpp create mode 100644 src/OpenCvSharpExtern/features2d.h rename src/OpenCvSharpExtern/{WFlann.cpp => flann.cpp} (79%) rename src/OpenCvSharpExtern/{WFlann.h => flann.h} (84%) create mode 100644 src/OpenCvSharpExtern/legacy.cpp create mode 100644 src/OpenCvSharpExtern/legacy.h rename src/OpenCvSharpExtern/{WVideo.cpp => nonfree.cpp} (78%) rename src/OpenCvSharpExtern/{WNonfree.h => nonfree.h} (70%) rename src/OpenCvSharpExtern/{WNonfree.cpp => video.cpp} (77%) rename src/OpenCvSharpExtern/{WVideo.h => video.h} (71%) diff --git a/src/OpenCvSharp.Gpu/HOGDescriptor.cs b/src/OpenCvSharp.Gpu/HOGDescriptor.cs index e496c409b..575b4af02 100644 --- a/src/OpenCvSharp.Gpu/HOGDescriptor.cs +++ b/src/OpenCvSharp.Gpu/HOGDescriptor.cs @@ -7,7 +7,7 @@ using System.Collections.Generic; using System.Text; using OpenCvSharp; -using OpenCvSharp.CPlusPlus.Prototype; +using OpenCvSharp.CPlusPlus; namespace OpenCvSharp.Gpu { diff --git a/src/OpenCvSharpExtern/OpenCvSharpExtern.vcxproj b/src/OpenCvSharpExtern/OpenCvSharpExtern.vcxproj index e9a5beff3..a69df569e 100644 --- a/src/OpenCvSharpExtern/OpenCvSharpExtern.vcxproj +++ b/src/OpenCvSharpExtern/OpenCvSharpExtern.vcxproj @@ -213,15 +213,16 @@ + + - - + @@ -241,14 +242,12 @@ - + - - - - - - + + + + @@ -257,12 +256,13 @@ + - - + + @@ -277,14 +277,12 @@ - + - - - - - - + + + + diff --git a/src/OpenCvSharpExtern/OpenCvSharpExtern.vcxproj.filters b/src/OpenCvSharpExtern/OpenCvSharpExtern.vcxproj.filters index 515bf8ab1..d5fdd9c6c 100644 --- a/src/OpenCvSharpExtern/OpenCvSharpExtern.vcxproj.filters +++ b/src/OpenCvSharpExtern/OpenCvSharpExtern.vcxproj.filters @@ -58,33 +58,6 @@ Sources\cvblob - - Sources - - - Sources - - - Sources - - - Sources - - - Sources - - - Sources - - - Sources - - - Sources - - - Sources - Sources\cpp @@ -115,6 +88,30 @@ Sources\cpp + + Sources\cpp + + + Sources\cpp + + + Sources\cpp + + + Sources\cpp + + + Sources\cpp + + + Sources\cpp + + + Sources\cpp + + + Sources\cpp + @@ -159,33 +156,6 @@ Headers\ml - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - Headers\cpp @@ -219,6 +189,30 @@ Headers\cpp + + Headers\cpp + + + Headers\cpp + + + Headers\cpp + + + Headers\cpp + + + Headers\cpp + + + Headers\cpp + + + Headers\cpp + + + Headers\cpp + diff --git a/src/OpenCvSharpExtern/WAlgorithm.cpp b/src/OpenCvSharpExtern/WAlgorithm.cpp deleted file mode 100644 index 0d2f7387a..000000000 --- a/src/OpenCvSharpExtern/WAlgorithm.cpp +++ /dev/null @@ -1,6 +0,0 @@ -/* - * (C) 2008-2014 shimat - * This code is licenced under the LGPL. - */ - -#include "WAlgorithm.h" \ No newline at end of file diff --git a/src/OpenCvSharpExtern/WAlgorithm.h b/src/OpenCvSharpExtern/WAlgorithm.h deleted file mode 100644 index 01d3d3048..000000000 --- a/src/OpenCvSharpExtern/WAlgorithm.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - * (C) 2008-2014 shimat - * This code is licenced under the LGPL. - */ - -#ifndef _CPP_CORE_WALGORITHM_H_ -#define _CPP_CORE_WALGORITHM_H_ - -#ifdef _MSC_VER -#pragma warning(disable: 4251) -#endif -#include -#include -#include -#include - -CVAPI(cv::Algorithm*) cv_Algorithm_new() -{ - return new cv::Algorithm(); -} -CVAPI(void) cv_Algorithm_delete(cv::Algorithm* obj) -{ - delete obj; -} -CVAPI(void) cv_Algorithm_name(cv::Algorithm* obj, char* buf) -{ - strcpy(buf, obj->name().c_str()); -} -CVAPI(int) cv_Algorithm_sizeof() -{ - return sizeof(cv::Algorithm); -} - -CVAPI(int) cv_Algorithm_getInt(cv::Algorithm* obj, const char* name) -{ - return obj->getInt(name); -} -CVAPI(double) cv_Algorithm_getDouble(cv::Algorithm* obj, const char* name) -{ - return obj->getDouble(name); -} -CVAPI(bool) cv_Algorithm_getBool(cv::Algorithm* obj, const char* name) -{ - return obj->getBool(name); -} -CVAPI(void) cv_Algorithm_getString(cv::Algorithm* obj, const char* name, char* buf) -{ - std::string str = obj->getString(name); - strcpy(buf, str.c_str()); -} -CVAPI(void) cv_Algorithm_getMat(cv::Algorithm* obj, const char* name, cv::Mat* outMat) -{ - cv::Mat mat = obj->getMat(name); - outMat = new cv::Mat(mat); -} -CVAPI(void) cv_Algorithm_getMatVector(cv::Algorithm* obj, const char* name, std::vector* outVec) -{ - std::vector vec = obj->getMatVector(name); - outVec = new std::vector(vec.size()); - std::copy(vec.begin(), vec.end(), std::back_inserter(*outVec)); -} -CVAPI(cv::Algorithm*) cv_Algorithm_getAlgorithm(cv::Algorithm* obj, const char* name) -{ - return obj->getAlgorithm(name); -} - -CVAPI(void) cv_Algorithm_setInt(cv::Algorithm* obj, const char* name, int value) -{ - obj->set(name, value); -} -CVAPI(void) cv_Algorithm_setDouble(cv::Algorithm* obj, const char* name, double value) -{ - obj->set(name, value); -} -CVAPI(void) cv_Algorithm_setBool(cv::Algorithm* obj, const char* name, bool value) -{ - obj->set(name, value); -} -CVAPI(void) cv_Algorithm_setString(cv::Algorithm* obj, const char* name, const char* value) -{ - std::string str(value); - obj->set(name, str); -} -CVAPI(void) cv_Algorithm_setMat(cv::Algorithm* obj, const char* name, const cv::Mat* value) -{ - obj->set(name, *value); -} -CVAPI(void) cv_Algorithm_setMatVector(cv::Algorithm* obj, const char* name, const std::vector* value) -{ - obj->set(name, *value); -} -CVAPI(void) cv_Algorithm_setAlgorithm(cv::Algorithm* obj, const char* name, const cv::Algorithm* value) -{ - obj->set(name, value); -} - -#endif \ No newline at end of file diff --git a/src/OpenCvSharpExtern/WCore.cpp b/src/OpenCvSharpExtern/WCore.cpp deleted file mode 100644 index b31407795..000000000 --- a/src/OpenCvSharpExtern/WCore.cpp +++ /dev/null @@ -1,6 +0,0 @@ -/* - * (C) 2008-2014 shimat - * This code is licenced under the LGPL. - */ - -#include "WCore.h" diff --git a/src/OpenCvSharpExtern/WCore.h b/src/OpenCvSharpExtern/WCore.h deleted file mode 100644 index c54644d34..000000000 --- a/src/OpenCvSharpExtern/WCore.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * (C) 2008-2014 shimat - * This code is licenced under the LGPL. - */ - -#ifndef _CPP_WCORE_H_ -#define _CPP_WCORE_H_ - -#ifdef _MSC_VER -#pragma warning(disable: 4251) -#endif -#include - -#pragma region Array Operations -CVAPI(void) cv_abs1(cv::Mat* src, cv::Mat* dst) -{ - *dst = cv::abs(*src); -} -CVAPI(void) cv_add1(cv::Mat* a, cv::Mat* b, cv::Mat* c, cv::Mat* mask) -{ - if(mask == NULL) - cv::add(*a, *b, *c); - else - cv::add(*a, *b, *c, *mask); -} -CVAPI(void) cv_add2(cv::Mat* a, CvScalar s, cv::Mat* c, cv::Mat* mask) -{ - if(mask == NULL) - cv::add(*a, cv::InputArray(s), *c); - else - cv::add(*a, cv::InputArray(s), *c, *mask); -} -CVAPI(void) cv_subtract1(cv::Mat* a, cv::Mat* b, cv::Mat* c, cv::Mat* mask) -{ - if(mask == NULL) - cv::subtract(*a, *b, *c); - else - cv::subtract(*a, *b, *c, *mask); -} -CVAPI(void) cv_subtract2(cv::Mat* a, CvScalar s, cv::Mat* c, cv::Mat* mask) -{ - if(mask == NULL) - cv::subtract(*a, cv::InputArray(s), *c); - else - cv::subtract(*a, cv::InputArray(s), *c, *mask); -} -CVAPI(void) cv_subtract3(CvScalar s, cv::Mat* a, cv::Mat* c, cv::Mat* mask) -{ - if(mask == NULL) - cv::subtract(cv::InputArray(s), *a, *c); - else - cv::subtract(cv::InputArray(s), *a, *c, *mask); -} - -CVAPI(void) cv_multiply(cv::Mat* a, cv::Mat* b, cv::Mat* c, double scale) -{ - cv::multiply(*a, *b, *c, scale); -} -CVAPI(void) cv_divide1(cv::Mat* a, cv::Mat* b, cv::Mat* c, double scale) -{ - cv::divide(*a, *b, *c, scale); -} -CVAPI(void) cv_divide2(double scale, cv::Mat* b, cv::Mat* c) -{ - cv::divide(scale, *b, *c); -} - - -CVAPI(void) cv_convertScaleAbs(cv::Mat* src, cv::Mat* dst, double alpha, double beta) -{ - cv::convertScaleAbs(*src, *dst, alpha, beta); -} -#pragma endregion - -#endif \ No newline at end of file diff --git a/src/OpenCvSharpExtern/WCvAdaptiveSkinDetector.cpp b/src/OpenCvSharpExtern/WCvAdaptiveSkinDetector.cpp deleted file mode 100644 index 8fa3c85fe..000000000 --- a/src/OpenCvSharpExtern/WCvAdaptiveSkinDetector.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "WCvAdaptiveSkinDetector.h" diff --git a/src/OpenCvSharpExtern/WCvAdaptiveSkinDetector.h b/src/OpenCvSharpExtern/WCvAdaptiveSkinDetector.h deleted file mode 100644 index a68fe05bc..000000000 --- a/src/OpenCvSharpExtern/WCvAdaptiveSkinDetector.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * (C) 2008-2014 shimat - * This code is licenced under the LGPL. - */ - -#ifndef _CPP_WHOGDESCRIPTOR_H_ -#define _CPP_WHOGDESCRIPTOR_H_ - -#ifdef _MSC_VER -#pragma warning(disable: 4251) -#pragma warning(disable: 4996) -#endif -#include - -CVAPI(CvAdaptiveSkinDetector*) CvAdaptiveSkinDetector_new(int samplingDivider, int morphingMethod) -{ - return new CvAdaptiveSkinDetector(samplingDivider, morphingMethod); -} -CVAPI(void) CvAdaptiveSkinDetector_delete(CvAdaptiveSkinDetector* obj) -{ - delete obj; -} -CVAPI(void) CvAdaptiveSkinDetector_process(CvAdaptiveSkinDetector* obj, IplImage *inputBGRImage, IplImage *outputHueMask) -{ - obj->process(inputBGRImage, outputHueMask); -} - -#endif \ No newline at end of file diff --git a/src/OpenCvSharpExtern/WCvCamShiftTracker.cpp b/src/OpenCvSharpExtern/WCvCamShiftTracker.cpp deleted file mode 100644 index 94251ecd1..000000000 --- a/src/OpenCvSharpExtern/WCvCamShiftTracker.cpp +++ /dev/null @@ -1,2 +0,0 @@ -#include "WCvCamShiftTracker.h" - diff --git a/src/OpenCvSharpExtern/WCvCamShiftTracker.h b/src/OpenCvSharpExtern/WCvCamShiftTracker.h deleted file mode 100644 index 8b3cadc68..000000000 --- a/src/OpenCvSharpExtern/WCvCamShiftTracker.h +++ /dev/null @@ -1,114 +0,0 @@ -#pragma once - -#ifndef _CPP_WCVCAMSHIFTTRACKER_H_ -#define _CPP_WCVCAMSHIFTTRACKER_H_ - -#ifdef _MSC_VER -#pragma warning(disable: 4251) -#pragma warning(disable: 4996) -#endif -#include - -CVAPI(int) CvCamShiftTracker_sizeof() -{ - return sizeof(CvCamShiftTracker); -} -CVAPI(CvCamShiftTracker*) CvCamShiftTracker_new() -{ - return new CvCamShiftTracker(); -} -CVAPI(void) CvCamShiftTracker_delete(CvCamShiftTracker* obj) -{ - delete obj; -} - -/**** Characteristics of the object that are calculated by track_object method *****/ -CVAPI(float) CvCamShiftTracker_get_orientation(CvCamShiftTracker* obj) -{ - return obj->get_orientation(); -} -CVAPI(float) CvCamShiftTracker_get_length(CvCamShiftTracker* obj) -{ - return obj->get_length(); -} -CVAPI(float) CvCamShiftTracker_get_width(CvCamShiftTracker* obj) -{ - return obj->get_width(); -} -CVAPI(CvPoint2D32f) CvCamShiftTracker_get_center(CvCamShiftTracker* obj) -{ - return obj->get_center(); -} -CVAPI(CvRect) CvCamShiftTracker_get_window(CvCamShiftTracker* obj) -{ - return obj->get_window(); -} - -CVAPI(int) CvCamShiftTracker_get_threshold(CvCamShiftTracker* obj) -{ - return obj->get_threshold(); -} -CVAPI(int) CvCamShiftTracker_get_hist_dims(CvCamShiftTracker* obj, int* dims) -{ - return obj->get_hist_dims(dims); -} -CVAPI(int) CvCamShiftTracker_get_min_ch_val(CvCamShiftTracker* obj, int channel) -{ - return obj->get_min_ch_val(channel); -} -CVAPI(int) CvCamShiftTracker_get_max_ch_val(CvCamShiftTracker* obj, int channel) -{ - return obj->get_max_ch_val(channel); -} - -CVAPI(bool) CvCamShiftTracker_set_window(CvCamShiftTracker* obj, CvRect window) -{ - return obj->set_window(window); -} -CVAPI(bool) CvCamShiftTracker_set_threshold(CvCamShiftTracker* obj, int threshold) -{ - return obj->set_threshold(threshold); -} -CVAPI(bool) CvCamShiftTracker_set_hist_bin_range(CvCamShiftTracker* obj, int dim, int min_val, int max_val) -{ - return obj->set_hist_bin_range(dim, min_val, max_val); -} -CVAPI(bool) CvCamShiftTracker_set_hist_dims(CvCamShiftTracker* obj, int c_dims, int* dims) -{ - return obj->set_hist_dims(c_dims, dims); -} -CVAPI(bool) CvCamShiftTracker_set_min_ch_val(CvCamShiftTracker* obj, int channel, int val) -{ - return obj->set_min_ch_val(channel, val); -} -CVAPI(bool) CvCamShiftTracker_set_max_ch_val(CvCamShiftTracker* obj, int channel, int val) -{ - return obj->set_max_ch_val(channel, val); -} - -/************************ The processing methods *********************************/ -CVAPI(bool) CvCamShiftTracker_track_object(CvCamShiftTracker* obj, IplImage* cur_frame) -{ - return obj->track_object(cur_frame); -} -CVAPI(bool) CvCamShiftTracker_update_histogram(CvCamShiftTracker* obj, IplImage* cur_frame) -{ - return obj->update_histogram(cur_frame); -} -CVAPI(void) CvCamShiftTracker_reset_histogram(CvCamShiftTracker* obj) -{ - return obj->reset_histogram(); -} - -/************************ Retrieving internal data *******************************/ -CVAPI(IplImage*) CvCamShiftTracker_get_back_project(CvCamShiftTracker* obj) -{ - return obj->get_back_project(); -} - -CVAPI(float) CvCamShiftTracker_query(CvCamShiftTracker* obj, int* bin) -{ - return obj->query(bin); -} - -#endif \ No newline at end of file diff --git a/src/OpenCvSharpExtern/WCvaux.cpp b/src/OpenCvSharpExtern/WCvaux.cpp deleted file mode 100644 index 34796f27a..000000000 --- a/src/OpenCvSharpExtern/WCvaux.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "WCvaux.h" diff --git a/src/OpenCvSharpExtern/WCvaux.h b/src/OpenCvSharpExtern/WCvaux.h deleted file mode 100644 index b7a671129..000000000 --- a/src/OpenCvSharpExtern/WCvaux.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * (C) 2008-2014 shimat - * This code is licenced under the LGPL. - */ - -#ifndef _CPP_WCVAUX_H_ -#define _CPP_WCVAUX_H_ - -#ifdef _MSC_VER -#pragma warning(disable: 4251) -#pragma warning(disable: 4996) -#endif -#include - - -CVAPI(void) cv_FAST( cv::Mat* image, std::vector* keypoints, int threshold, bool nonmax_supression ) -{ - cv::FAST(*image, *keypoints, threshold, nonmax_supression); -} - -#endif \ No newline at end of file diff --git a/src/OpenCvSharpExtern/WStereoSGBM.cpp b/src/OpenCvSharpExtern/WStereoSGBM.cpp deleted file mode 100644 index 578c8c830..000000000 --- a/src/OpenCvSharpExtern/WStereoSGBM.cpp +++ /dev/null @@ -1,2 +0,0 @@ -#include "WStereoSGBM.h" - diff --git a/src/OpenCvSharpExtern/WStereoSGBM.h b/src/OpenCvSharpExtern/WStereoSGBM.h deleted file mode 100644 index 9ad31c229..000000000 --- a/src/OpenCvSharpExtern/WStereoSGBM.h +++ /dev/null @@ -1,128 +0,0 @@ -/* - * (C) 2008-2014 shimat - * This code is licenced under the LGPL. - */ - -#ifndef _CPP_WSTEREOSGBM_H_ -#define _CPP_WSTEREOSGBM_H_ - -#ifdef _MSC_VER -#pragma warning(disable: 4251) -#endif -#include - -CVAPI(int) StereoSGBM_sizeof() -{ - return sizeof(cv::StereoSGBM); -} - - -CVAPI(void) StereoSGBM_delete(cv::StereoSGBM* obj) -{ - delete obj; -} -CVAPI(cv::StereoSGBM*) StereoSGBM_new1() -{ - return new cv::StereoSGBM(); -} -CVAPI(cv::StereoSGBM*) StereoSGBM_new2(int minDisparity, int numDisparities, int SADWindowSize, int P1, int P2, int disp12MaxDiff, int preFilterCap, int uniquenessRatio, int speckleWindowSize, int speckleRange, bool fullDP) -{ - return new cv::StereoSGBM(minDisparity, numDisparities, SADWindowSize, P1, P2, disp12MaxDiff, preFilterCap, uniquenessRatio, speckleWindowSize, speckleRange, fullDP); -} - -CVAPI(void) StereoSGBM_exec(cv::StereoSGBM* obj, cv::Mat* left, cv::Mat* right, cv::Mat* disp) -{ - (*obj)(*left, *right, *disp); -} - - -CVAPI(int) StereoSGBM_minDisparity_get(const cv::StereoSGBM* obj) -{ - return obj->minDisparity; -} -CVAPI(void) StereoSGBM_minDisparity_set(cv::StereoSGBM* obj, int value) -{ - obj->minDisparity = value; -} -CVAPI(int) StereoSGBM_numberOfDisparities_get(const cv::StereoSGBM* obj) -{ - return obj->numberOfDisparities; -} -CVAPI(void) StereoSGBM_numberOfDisparities_set(cv::StereoSGBM* obj, int value) -{ - obj->numberOfDisparities = value; -} -CVAPI(int) StereoSGBM_SADWindowSize_get(const cv::StereoSGBM* obj) -{ - return obj->SADWindowSize; -} -CVAPI(void) StereoSGBM_SADWindowSize_set(cv::StereoSGBM* obj, int value) -{ - obj->SADWindowSize = value; -} -CVAPI(int) StereoSGBM_preFilterCap_get(const cv::StereoSGBM* obj) -{ - return obj->preFilterCap; -} -CVAPI(void) StereoSGBM_preFilterCap_set(cv::StereoSGBM* obj, int value) -{ - obj->preFilterCap = value; -} -CVAPI(int) StereoSGBM_uniquenessRatio_get(const cv::StereoSGBM* obj) -{ - return obj->uniquenessRatio; -} -CVAPI(void) StereoSGBM_uniquenessRatio_set(cv::StereoSGBM* obj, int value) -{ - obj->uniquenessRatio = value; -} -CVAPI(int) StereoSGBM_P1_get(const cv::StereoSGBM* obj) -{ - return obj->P1; -} -CVAPI(void) StereoSGBM_P1_set(cv::StereoSGBM* obj, int value) -{ - obj->P1 = value; -} -CVAPI(int) StereoSGBM_P2_get(const cv::StereoSGBM* obj) -{ - return obj->P2; -} -CVAPI(void) StereoSGBM_P2_set(cv::StereoSGBM* obj, int value) -{ - obj->P2 = value; -} -CVAPI(int) StereoSGBM_speckleWindowSize_get(const cv::StereoSGBM* obj) -{ - return obj->speckleWindowSize; -} -CVAPI(void) StereoSGBM_speckleWindowSize_set(cv::StereoSGBM* obj, int value) -{ - obj->speckleWindowSize = value; -} -CVAPI(int) StereoSGBM_speckleRange_get(const cv::StereoSGBM* obj) -{ - return obj->speckleRange; -} -CVAPI(void) StereoSGBM_speckleRange_set(cv::StereoSGBM* obj, int value) -{ - obj->speckleRange = value; -} -CVAPI(int) StereoSGBM_disp12MaxDiff_get(const cv::StereoSGBM* obj) -{ - return obj->disp12MaxDiff; -} -CVAPI(void) StereoSGBM_disp12MaxDiff_set(cv::StereoSGBM* obj, int value) -{ - obj->disp12MaxDiff = value; -} -CVAPI(int) StereoSGBM_fullDP_get(const cv::StereoSGBM* obj) -{ - return obj->fullDP ? 1 : 0; -} -CVAPI(void) StereoSGBM_fullDP_set(cv::StereoSGBM* obj, int value) -{ - obj->fullDP = (value != 0); -} - -#endif \ No newline at end of file diff --git a/src/OpenCvSharpExtern/calib3d.h b/src/OpenCvSharpExtern/calib3d.h index 966f978fb..93af01d27 100644 --- a/src/OpenCvSharpExtern/calib3d.h +++ b/src/OpenCvSharpExtern/calib3d.h @@ -12,8 +12,124 @@ CVAPI(void) imgproc_solvePnP(cv::_InputArray* objectPoints, cv::_InputArray* imagePoints, cv::_InputArray* cameraMatrix, cv::_InputArray* distCoeffs, cv::_OutputArray* rvec, cv::_OutputArray* tvec, int useExtrinsicGuess) { - cv::InputArray distCoeffsVal = (distCoeffs != NULL) ? *distCoeffs : cv::noArray(); - cv::solvePnP(*objectPoints, *imagePoints, *cameraMatrix, distCoeffsVal, *rvec, *tvec, useExtrinsicGuess != 0); + cv::solvePnP(*objectPoints, *imagePoints, *cameraMatrix, entity(distCoeffs), *rvec, *tvec, useExtrinsicGuess != 0); } + +#pragma region StereoSGBM +CVAPI(size_t) calib3d_StereoSGBM_sizeof() +{ + return sizeof(cv::StereoSGBM); +} + + +CVAPI(void) calib3d_StereoSGBM_delete(cv::StereoSGBM* obj) +{ + delete obj; +} +CVAPI(cv::StereoSGBM*) calib3d_StereoSGBM_new1() +{ + return new cv::StereoSGBM(); +} +CVAPI(cv::StereoSGBM*) calib3d_StereoSGBM_new2(int minDisparity, int numDisparities, int SADWindowSize, int P1, int P2, int disp12MaxDiff, int preFilterCap, int uniquenessRatio, int speckleWindowSize, int speckleRange, bool fullDP) +{ + return new cv::StereoSGBM(minDisparity, numDisparities, SADWindowSize, P1, P2, disp12MaxDiff, preFilterCap, uniquenessRatio, speckleWindowSize, speckleRange, fullDP); +} + +CVAPI(void) calib3d_StereoSGBM_exec(cv::StereoSGBM* obj, cv::_InputArray* left, cv::_InputArray* right, cv::_OutputArray* disp) +{ + (*obj)(*left, *right, *disp); +} + + +CVAPI(int) calib3d_StereoSGBM_minDisparity_get(const cv::StereoSGBM* obj) +{ + return obj->minDisparity; +} +CVAPI(void) calib3d_StereoSGBM_minDisparity_set(cv::StereoSGBM* obj, int value) +{ + obj->minDisparity = value; +} +CVAPI(int) calib3d_StereoSGBM_numberOfDisparities_get(const cv::StereoSGBM* obj) +{ + return obj->numberOfDisparities; +} +CVAPI(void) calib3d_StereoSGBM_numberOfDisparities_set(cv::StereoSGBM* obj, int value) +{ + obj->numberOfDisparities = value; +} +CVAPI(int) calib3d_StereoSGBM_SADWindowSize_get(const cv::StereoSGBM* obj) +{ + return obj->SADWindowSize; +} +CVAPI(void) calib3d_StereoSGBM_SADWindowSize_set(cv::StereoSGBM* obj, int value) +{ + obj->SADWindowSize = value; +} +CVAPI(int) calib3d_StereoSGBM_preFilterCap_get(const cv::StereoSGBM* obj) +{ + return obj->preFilterCap; +} +CVAPI(void) calib3d_StereoSGBM_preFilterCap_set(cv::StereoSGBM* obj, int value) +{ + obj->preFilterCap = value; +} +CVAPI(int) calib3d_StereoSGBM_uniquenessRatio_get(const cv::StereoSGBM* obj) +{ + return obj->uniquenessRatio; +} +CVAPI(void) calib3d_StereoSGBM_uniquenessRatio_set(cv::StereoSGBM* obj, int value) +{ + obj->uniquenessRatio = value; +} +CVAPI(int) calib3d_StereoSGBM_P1_get(const cv::StereoSGBM* obj) +{ + return obj->P1; +} +CVAPI(void) calib3d_StereoSGBM_P1_set(cv::StereoSGBM* obj, int value) +{ + obj->P1 = value; +} +CVAPI(int) calib3d_StereoSGBM_P2_get(const cv::StereoSGBM* obj) +{ + return obj->P2; +} +CVAPI(void) calib3d_StereoSGBM_P2_set(cv::StereoSGBM* obj, int value) +{ + obj->P2 = value; +} +CVAPI(int) calib3d_StereoSGBM_speckleWindowSize_get(const cv::StereoSGBM* obj) +{ + return obj->speckleWindowSize; +} +CVAPI(void) calib3d_StereoSGBM_speckleWindowSize_set(cv::StereoSGBM* obj, int value) +{ + obj->speckleWindowSize = value; +} +CVAPI(int) calib3d_StereoSGBM_speckleRange_get(const cv::StereoSGBM* obj) +{ + return obj->speckleRange; +} +CVAPI(void) calib3d_StereoSGBM_speckleRange_set(cv::StereoSGBM* obj, int value) +{ + obj->speckleRange = value; +} +CVAPI(int) calib3d_StereoSGBM_disp12MaxDiff_get(const cv::StereoSGBM* obj) +{ + return obj->disp12MaxDiff; +} +CVAPI(void) calib3d_StereoSGBM_disp12MaxDiff_set(cv::StereoSGBM* obj, int value) +{ + obj->disp12MaxDiff = value; +} +CVAPI(int) calib3d_StereoSGBM_fullDP_get(const cv::StereoSGBM* obj) +{ + return obj->fullDP ? 1 : 0; +} +CVAPI(void) calib3d_StereoSGBM_fullDP_set(cv::StereoSGBM* obj, int value) +{ + obj->fullDP = (value != 0); +} +#pragma endregion + #endif \ No newline at end of file diff --git a/src/OpenCvSharpExtern/contrib.cpp b/src/OpenCvSharpExtern/contrib.cpp new file mode 100644 index 000000000..4bdfd00f9 --- /dev/null +++ b/src/OpenCvSharpExtern/contrib.cpp @@ -0,0 +1,6 @@ +/* +* (C) 2008-2014 shimat +* This code is licenced under the LGPL. +*/ + +#include "contrib.h" \ No newline at end of file diff --git a/src/OpenCvSharpExtern/contrib.h b/src/OpenCvSharpExtern/contrib.h new file mode 100644 index 000000000..b726f1293 --- /dev/null +++ b/src/OpenCvSharpExtern/contrib.h @@ -0,0 +1,24 @@ +/* + * (C) 2008-2014 shimat + * This code is licenced under the LGPL. + */ + +#ifndef _CPP_CONTRIB_H_ +#define _CPP_CONTRIB_H_ + +#include "include_opencv.h" + +CVAPI(CvAdaptiveSkinDetector*) contrib_CvAdaptiveSkinDetector_new(int samplingDivider, int morphingMethod) +{ + return new CvAdaptiveSkinDetector(samplingDivider, morphingMethod); +} +CVAPI(void) contrib_CvAdaptiveSkinDetector_delete(CvAdaptiveSkinDetector* obj) +{ + delete obj; +} +CVAPI(void) contrib_CvAdaptiveSkinDetector_process(CvAdaptiveSkinDetector* obj, IplImage *inputBGRImage, IplImage *outputHueMask) +{ + obj->process(inputBGRImage, outputHueMask); +} + +#endif \ No newline at end of file diff --git a/src/OpenCvSharpExtern/core.h b/src/OpenCvSharpExtern/core.h index 40b705220..0ec11ebb7 100644 --- a/src/OpenCvSharpExtern/core.h +++ b/src/OpenCvSharpExtern/core.h @@ -87,6 +87,36 @@ CVAPI(void) core_insertImageCOI(cv::_InputArray *coiimg, CvArr* arr, int coi) } #pragma endregion +#pragma region Array Operations + +CVAPI(void) cv_add(cv::_InputArray *src1, cv::_InputArray *src2, cv::_OutputArray* dst, cv::_InputArray *mask, int dtype) +{ + cv::add(*src1, *src2, *dst, entity(mask), dtype); +} +CVAPI(void) cv_subtract(cv::_InputArray *src1, cv::_InputArray *src2, cv::_OutputArray* dst, cv::_InputArray *mask, int dtype) +{ + cv::subtract(*src1, *src2, *dst, entity(mask), dtype); +} +CVAPI(void) cv_multiply(cv::_InputArray *src1, cv::_InputArray *src2, cv::_OutputArray* dst, double scale, int dtype) +{ + cv::multiply(*src1, *src2, *dst, scale, dtype); +} +CVAPI(void) cv_divide1(double scale, cv::_InputArray *src2, cv::_OutputArray* dst, int dtype) +{ + cv::divide(scale, *src2, *dst, dtype); +} +CVAPI(void) cv_divide2(cv::_InputArray *src1, cv::_InputArray *src2, cv::_OutputArray *dst, double scale, int dtype) +{ + cv::divide(*src1, *src2, *dst); +} + + +CVAPI(void) cv_convertScaleAbs(cv::_InputArray *src, cv::_OutputArray *dst, double alpha, double beta) +{ + cv::convertScaleAbs(*src, *dst, alpha, beta); +} +#pragma endregion + #pragma region Drawing CVAPI(void) core_line(cv::Mat *img, CvPoint pt1, CvPoint pt2, CvScalar color, @@ -162,4 +192,5 @@ CVAPI(int) core_clipLine2(CvRect imgRect, CvPoint *pt1, CvPoint *pt2) #pragma endregion + #endif \ No newline at end of file diff --git a/src/OpenCvSharpExtern/core_Algorithm.cpp b/src/OpenCvSharpExtern/core_Algorithm.cpp new file mode 100644 index 000000000..fd99eede8 --- /dev/null +++ b/src/OpenCvSharpExtern/core_Algorithm.cpp @@ -0,0 +1,6 @@ +/* +* (C) 2008-2014 shimat +* This code is licenced under the LGPL. +*/ + +#include "core_Algorithm.h" \ No newline at end of file diff --git a/src/OpenCvSharpExtern/core_Algorithm.h b/src/OpenCvSharpExtern/core_Algorithm.h new file mode 100644 index 000000000..1231916b9 --- /dev/null +++ b/src/OpenCvSharpExtern/core_Algorithm.h @@ -0,0 +1,91 @@ +/* + * (C) 2008-2014 shimat + * This code is licenced under the LGPL. + */ + +#ifndef _CPP_CORE_ALGORITHM_H_ +#define _CPP_CORE_ALGORITHM_H_ + +#include "include_opencv.h" + +CVAPI(cv::Algorithm*) core_Algorithm_new() +{ + return new cv::Algorithm(); +} +CVAPI(void) core_Algorithm_delete(cv::Algorithm* obj) +{ + delete obj; +} +CVAPI(void) core_Algorithm_name(cv::Algorithm* obj, char* buf) +{ + strcpy(buf, obj->name().c_str()); +} +CVAPI(int) core_Algorithm_sizeof() +{ + return sizeof(cv::Algorithm); +} + +CVAPI(int) core_Algorithm_getInt(cv::Algorithm* obj, const char* name) +{ + return obj->getInt(name); +} +CVAPI(double) core_Algorithm_getDouble(cv::Algorithm* obj, const char* name) +{ + return obj->getDouble(name); +} +CVAPI(bool) core_Algorithm_getBool(cv::Algorithm* obj, const char* name) +{ + return obj->getBool(name); +} +CVAPI(void) core_Algorithm_getString(cv::Algorithm* obj, const char* name, char* buf) +{ + std::string str = obj->getString(name); + strcpy(buf, str.c_str()); +} +CVAPI(void) core_Algorithm_getMat(cv::Algorithm* obj, const char* name, cv::Mat* outMat) +{ + cv::Mat mat = obj->getMat(name); + outMat = new cv::Mat(mat); +} +CVAPI(void) core_Algorithm_getMatVector(cv::Algorithm* obj, const char* name, std::vector* outVec) +{ + std::vector vec = obj->getMatVector(name); + outVec = new std::vector(vec.size()); + std::copy(vec.begin(), vec.end(), std::back_inserter(*outVec)); +} +CVAPI(cv::Algorithm*) core_Algorithm_getAlgorithm(cv::Algorithm* obj, const char* name) +{ + return obj->getAlgorithm(name); +} + +CVAPI(void) core_Algorithm_setInt(cv::Algorithm* obj, const char* name, int value) +{ + obj->set(name, value); +} +CVAPI(void) core_Algorithm_setDouble(cv::Algorithm* obj, const char* name, double value) +{ + obj->set(name, value); +} +CVAPI(void) core_Algorithm_setBool(cv::Algorithm* obj, const char* name, bool value) +{ + obj->set(name, value); +} +CVAPI(void) core_Algorithm_setString(cv::Algorithm* obj, const char* name, const char* value) +{ + std::string str(value); + obj->set(name, str); +} +CVAPI(void) core_Algorithm_setMat(cv::Algorithm* obj, const char* name, const cv::Mat* value) +{ + obj->set(name, *value); +} +CVAPI(void) core_Algorithm_setMatVector(cv::Algorithm* obj, const char* name, const std::vector* value) +{ + obj->set(name, *value); +} +CVAPI(void) core_Algorithm_setAlgorithm(cv::Algorithm* obj, const char* name, const cv::Algorithm* value) +{ + obj->set(name, value); +} + +#endif \ No newline at end of file diff --git a/src/OpenCvSharpExtern/core_Mat.h b/src/OpenCvSharpExtern/core_Mat.h index 333ade7ea..99594ed00 100644 --- a/src/OpenCvSharpExtern/core_Mat.h +++ b/src/OpenCvSharpExtern/core_Mat.h @@ -613,4 +613,11 @@ CVAPI(cv::MatExpr*) core_operatorNot_Mat(cv::Mat *a) #pragma endregion + +CVAPI(cv::MatExpr*) core_abs_Mat(cv::Mat *m) +{ + cv::MatExpr ret = cv::abs(*m); + return new cv::MatExpr(ret); +} + #endif \ No newline at end of file diff --git a/src/OpenCvSharpExtern/core_MatExpr.h b/src/OpenCvSharpExtern/core_MatExpr.h index 434fc5008..8a70773ee 100644 --- a/src/OpenCvSharpExtern/core_MatExpr.h +++ b/src/OpenCvSharpExtern/core_MatExpr.h @@ -216,4 +216,10 @@ CVAPI(cv::MatExpr*) core_operatorDivide_MatExprMatExpr(cv::MatExpr *e1, cv::MatE } #pragma endregion +CVAPI(cv::MatExpr*) core_abs_MatExpr(cv::MatExpr *e) +{ + cv::MatExpr ret = cv::abs(*e); + return new cv::MatExpr(ret); +} + #endif \ No newline at end of file diff --git a/src/OpenCvSharpExtern/core_Ptr.cpp b/src/OpenCvSharpExtern/core_Ptr.cpp new file mode 100644 index 000000000..b6a1bc311 --- /dev/null +++ b/src/OpenCvSharpExtern/core_Ptr.cpp @@ -0,0 +1,6 @@ +/* +* (C) 2008-2014 shimat +* This code is licenced under the LGPL. +*/ + +#include "core_Ptr.h" \ No newline at end of file diff --git a/src/OpenCvSharpExtern/core_Ptr.h b/src/OpenCvSharpExtern/core_Ptr.h new file mode 100644 index 000000000..5271e99da --- /dev/null +++ b/src/OpenCvSharpExtern/core_Ptr.h @@ -0,0 +1,16 @@ +/* +* (C) 2008-2014 shimat +* This code is licenced under the LGPL. +*/ + +#ifndef _CPP_CORE_PTR_H_ +#define _CPP_CORE_PTR_H_ + +#include "include_opencv.h" + +CVAPI(void) core_Ptr_FeatureDetector_delete(cv::Ptr* obj) +{ + delete obj; +} + +#endif \ No newline at end of file diff --git a/src/OpenCvSharpExtern/features2d.cpp b/src/OpenCvSharpExtern/features2d.cpp new file mode 100644 index 000000000..54b1523ba --- /dev/null +++ b/src/OpenCvSharpExtern/features2d.cpp @@ -0,0 +1 @@ +#include "features2d.h" diff --git a/src/OpenCvSharpExtern/features2d.h b/src/OpenCvSharpExtern/features2d.h new file mode 100644 index 000000000..7e9f358ca --- /dev/null +++ b/src/OpenCvSharpExtern/features2d.h @@ -0,0 +1,60 @@ +/* + * (C) 2008-2014 shimat + * This code is licenced under the LGPL. + */ + +#ifndef _CPP_FEATURES2D_H_ +#define _CPP_FEATURES2D_H_ + +#include "include_opencv.h" + +#pragma region FeatureDetector + +CVAPI(void) features2d_FeatureDetector_detect1(cv::FeatureDetector *detector, cv::Mat *image, std::vector *keypoints, cv::Mat *mask) +{ + detector->detect(*image, *keypoints, entity(mask)); +} + +CVAPI(void) features2d_FeatureDetector_detect2(cv::FeatureDetector *detector, cv::Mat **images, int imageLength, std::vector> *keypoints, cv::Mat **mask) +{ + std::vector imageVec(imageLength); + std::vector maskVec; + { + for (int i = 0; i < imageLength; i++) + imageVec.push_back(*images[i]); + } + if (mask != NULL) + { + maskVec.reserve(imageLength); + for (int i = 0; i < imageLength; i++) + maskVec.push_back(*mask[i]); + } + + detector->detect(imageVec, *keypoints, maskVec); +} + +CVAPI(int) features2d_FeatureDetector_empty(cv::FeatureDetector *detector) +{ + return detector->empty(); +} + +CVAPI(cv::Ptr*) features2d_FeatureDetector_create(const char *detectorType) +{ + cv::Ptr ret = cv::FeatureDetector::create(detectorType); + return new cv::Ptr(ret); +} + +#pragma endregion + +CVAPI(void) features2d_FAST(cv::_InputArray *image, std::vector *keypoints, int threshold, int nonmaxSupression) +{ + cv::FAST(*image, *keypoints, threshold, nonmaxSupression != 0); +} + +CVAPI(void) features2d_FASTX(cv::_InputArray *image, std::vector *keypoints, int threshold, int nonmaxSupression, int type) +{ + cv::FASTX(*image, *keypoints, threshold, nonmaxSupression != 0, type); +} + + +#endif \ No newline at end of file diff --git a/src/OpenCvSharpExtern/WFlann.cpp b/src/OpenCvSharpExtern/flann.cpp similarity index 79% rename from src/OpenCvSharpExtern/WFlann.cpp rename to src/OpenCvSharpExtern/flann.cpp index 337c8d2ef..0e123a964 100644 --- a/src/OpenCvSharpExtern/WFlann.cpp +++ b/src/OpenCvSharpExtern/flann.cpp @@ -3,4 +3,4 @@ * This code is licenced under the LGPL. */ -#include "WFlann.h" \ No newline at end of file +#include "flann.h" \ No newline at end of file diff --git a/src/OpenCvSharpExtern/WFlann.h b/src/OpenCvSharpExtern/flann.h similarity index 84% rename from src/OpenCvSharpExtern/WFlann.h rename to src/OpenCvSharpExtern/flann.h index 2baecb1ea..f8f8714ba 100644 --- a/src/OpenCvSharpExtern/WFlann.h +++ b/src/OpenCvSharpExtern/flann.h @@ -3,26 +3,17 @@ * This code is licenced under the LGPL. */ -#ifndef _WFLANN_H_ -#define _WFLANN_H_ - -#ifdef _MSC_VER -#pragma warning(disable: 4251) -#endif -#include -#include - -using namespace cv; -using namespace cvflann; -using namespace cv::flann; +#ifndef _CPP_FLANN_H_ +#define _CPP_FLANN_H_ +#include "include_opencv.h" // cv::flann::Index CVAPI(int) flann_Index_sizeof() { return sizeof(cv::flann::Index); } -CVAPI(cv::flann::Index*) flann_Index_construct(Mat* features, cv::flann::IndexParams* params) +CVAPI(cv::flann::Index*) flann_Index_construct(cv::Mat *features, cv::flann::IndexParams* params) { return new cv::flann::Index(*features, *params); } @@ -32,51 +23,51 @@ CVAPI(void) flann_Index_destruct(cv::flann::Index* obj) } CVAPI(void) flann_Index_knnSearch1(cv::flann::Index* obj, float* queries, int queries_length, int* indices, float* dists, int knn, cv::flann::SearchParams* params) { - vector queries_vec(queries_length); - vector indices_vec(knn); - vector dists_vec(knn); + std::vector queries_vec(queries_length); + std::vector indices_vec(knn); + std::vector dists_vec(knn); memcpy(&queries_vec[0], queries, sizeof(float) * queries_length); obj->knnSearch(queries_vec, indices_vec, dists_vec, knn, *params); memcpy(indices, &indices_vec[0], sizeof(int) * knn); memcpy(dists, &dists_vec[0], sizeof(float) * knn); } -CVAPI(void) flann_Index_knnSearch2(cv::flann::Index* obj, Mat* queries, Mat* indices, Mat* dists, int knn, cv::flann::SearchParams* params) +CVAPI(void) flann_Index_knnSearch2(cv::flann::Index* obj, cv::Mat* queries, cv::Mat* indices, cv::Mat* dists, int knn, cv::flann::SearchParams* params) { obj->knnSearch(*queries, *indices, *dists, knn, *params); } -CVAPI(void) flann_Index_knnSearch3(cv::flann::Index* obj, Mat* queries, int* indices, float* dists, int knn, cv::flann::SearchParams* params) +CVAPI(void) flann_Index_knnSearch3(cv::flann::Index* obj, cv::Mat* queries, int* indices, float* dists, int knn, cv::flann::SearchParams* params) { - Mat indices_mat(1, knn, CV_32SC1); - Mat dists_mat(1, knn, CV_32FC1); + cv::Mat indices_mat(1, knn, CV_32SC1); + cv::Mat dists_mat(1, knn, CV_32FC1); obj->knnSearch(*queries, indices_mat, dists_mat, knn, *params); memcpy(indices, indices_mat.ptr(0), sizeof(int) * knn); memcpy(dists, dists_mat.ptr(0), sizeof(float) * knn); } CVAPI(void) flann_Index_radiusSearch1(cv::flann::Index* obj, float* queries, int queries_length, int* indices, int indices_length, float* dists, int dists_length, float radius, int maxResults, cv::flann::SearchParams* params) { - vector queries_vec(queries_length); - vector indices_vec(indices_length); - vector dists_vec(dists_length); + std::vector queries_vec(queries_length); + std::vector indices_vec(indices_length); + std::vector dists_vec(dists_length); memcpy(&queries_vec[0], queries, sizeof(float) * queries_length); obj->radiusSearch(queries_vec, indices_vec, dists_vec, radius, maxResults, *params); memcpy(indices, &indices_vec[0], sizeof(int) * indices_length); memcpy(dists, &dists_vec[0], sizeof(float) * dists_length); } -CVAPI(void) flann_Index_radiusSearch2(cv::flann::Index* obj, Mat* queries, Mat* indices, Mat* dists, float radius, int maxResults, cv::flann::SearchParams* params) +CVAPI(void) flann_Index_radiusSearch2(cv::flann::Index* obj, cv::Mat* queries, cv::Mat* indices, cv::Mat* dists, float radius, int maxResults, cv::flann::SearchParams* params) { obj->radiusSearch(*queries, *indices, *dists, radius, maxResults, *params); } -CVAPI(void) flann_Index_radiusSearch3(cv::flann::Index* obj, Mat* queries, int* indices, int indices_length, float* dists, int dists_length, float radius, int maxResults, cv::flann::SearchParams* params) +CVAPI(void) flann_Index_radiusSearch3(cv::flann::Index* obj, cv::Mat* queries, int* indices, int indices_length, float* dists, int dists_length, float radius, int maxResults, cv::flann::SearchParams* params) { - Mat indices_mat(1, indices_length, CV_32SC1); - Mat dists_mat(1, dists_length, CV_32FC1); + cv::Mat indices_mat(1, indices_length, CV_32SC1); + cv::Mat dists_mat(1, dists_length, CV_32FC1); obj->radiusSearch(*queries, indices_mat, dists_mat, radius, maxResults, *params); memcpy(indices, indices_mat.ptr(0), sizeof(int) * indices_length); memcpy(dists, dists_mat.ptr(0), sizeof(float) * dists_length); } CVAPI(void) flann_Index_save(cv::flann::Index* obj, const char* filename) { - string _filename(filename); + std::string _filename(filename); obj->save(_filename); } /* @@ -188,7 +179,7 @@ CVAPI(int) flann_KMeansIndexParams_sizeof() { return sizeof(cv::flann::KMeansIndexParams); } -CVAPI(cv::flann::KMeansIndexParams*) flann_KMeansIndexParams_construct(int branching, int iterations, flann_centers_init_t centers_init, float cb_index) +CVAPI(cv::flann::KMeansIndexParams*) flann_KMeansIndexParams_construct(int branching, int iterations, cvflann::flann_centers_init_t centers_init, float cb_index) { return new cv::flann::KMeansIndexParams(branching, iterations, centers_init, cb_index); } @@ -220,7 +211,7 @@ CVAPI(int) flann_CompositeIndexParams_sizeof() { return sizeof(cv::flann::CompositeIndexParams); } -CVAPI(cv::flann::CompositeIndexParams*) flann_CompositeIndexParams_construct(int trees, int branching, int iterations, flann_centers_init_t centers_init, float cb_index) +CVAPI(cv::flann::CompositeIndexParams*) flann_CompositeIndexParams_construct(int trees, int branching, int iterations, cvflann::flann_centers_init_t centers_init, float cb_index) { return new cv::flann::CompositeIndexParams(trees, branching, iterations, centers_init, cb_index); } diff --git a/src/OpenCvSharpExtern/include_opencv.h b/src/OpenCvSharpExtern/include_opencv.h index ebcb1d94b..a3d4d958e 100644 --- a/src/OpenCvSharpExtern/include_opencv.h +++ b/src/OpenCvSharpExtern/include_opencv.h @@ -2,9 +2,14 @@ #define _INCLUDE_OPENCV_H_ #include +#include typedef unsigned int uint32; typedef unsigned short uint16; +#include +#include +#include + #if 0 #ifdef _WIN32 #include @@ -31,5 +36,9 @@ static inline cv::OutputArray entity(cv::_OutputArray *obj) { return (obj != NULL) ? *obj : cv::noArray(); } +static inline cv::Mat entity(cv::Mat *obj) +{ + return (obj != NULL) ? *obj : cv::Mat(); +} #endif diff --git a/src/OpenCvSharpExtern/legacy.cpp b/src/OpenCvSharpExtern/legacy.cpp new file mode 100644 index 000000000..ab9f0cd8d --- /dev/null +++ b/src/OpenCvSharpExtern/legacy.cpp @@ -0,0 +1,6 @@ +/* +* (C) 2008-2014 shimat +* This code is licenced under the LGPL. +*/ + +#include "legacy.h" \ No newline at end of file diff --git a/src/OpenCvSharpExtern/legacy.h b/src/OpenCvSharpExtern/legacy.h new file mode 100644 index 000000000..3d60b8aad --- /dev/null +++ b/src/OpenCvSharpExtern/legacy.h @@ -0,0 +1,110 @@ +#pragma once + +#ifndef _CPP_LEGACY_H_ +#define _CPP_LEGACY_H_ + +#include "include_opencv.h" + +CVAPI(size_t) legacy_CvCamShiftTracker_sizeof() +{ + return sizeof(CvCamShiftTracker); +} +CVAPI(CvCamShiftTracker*) legacy_CvCamShiftTracker_new() +{ + return new CvCamShiftTracker(); +} +CVAPI(void) legacy_CvCamShiftTracker_delete(CvCamShiftTracker* obj) +{ + delete obj; +} + +/**** Characteristics of the object that are calculated by track_object method *****/ +CVAPI(float) legacy_CvCamShiftTracker_get_orientation(CvCamShiftTracker* obj) +{ + return obj->get_orientation(); +} +CVAPI(float) legacy_CvCamShiftTracker_get_length(CvCamShiftTracker* obj) +{ + return obj->get_length(); +} +CVAPI(float) legacy_CvCamShiftTracker_get_width(CvCamShiftTracker* obj) +{ + return obj->get_width(); +} +CVAPI(CvPoint2D32f) legacy_CvCamShiftTracker_get_center(CvCamShiftTracker* obj) +{ + return obj->get_center(); +} +CVAPI(CvRect) legacy_CvCamShiftTracker_get_window(CvCamShiftTracker* obj) +{ + return obj->get_window(); +} + +CVAPI(int) legacy_CvCamShiftTracker_get_threshold(CvCamShiftTracker* obj) +{ + return obj->get_threshold(); +} +CVAPI(int) legacy_CvCamShiftTracker_get_hist_dims(CvCamShiftTracker* obj, int* dims) +{ + return obj->get_hist_dims(dims); +} +CVAPI(int) legacy_CvCamShiftTracker_get_min_ch_val(CvCamShiftTracker* obj, int channel) +{ + return obj->get_min_ch_val(channel); +} +CVAPI(int) legacy_CvCamShiftTracker_get_max_ch_val(CvCamShiftTracker* obj, int channel) +{ + return obj->get_max_ch_val(channel); +} + +CVAPI(int) legacy_CvCamShiftTracker_set_window(CvCamShiftTracker* obj, CvRect window) +{ + return obj->set_window(window); +} +CVAPI(int) legacy_CvCamShiftTracker_set_threshold(CvCamShiftTracker* obj, int threshold) +{ + return obj->set_threshold(threshold); +} +CVAPI(int) legacy_CvCamShiftTracker_set_hist_bin_range(CvCamShiftTracker* obj, int dim, int min_val, int max_val) +{ + return obj->set_hist_bin_range(dim, min_val, max_val); +} +CVAPI(int) legacy_CvCamShiftTracker_set_hist_dims(CvCamShiftTracker* obj, int c_dims, int* dims) +{ + return obj->set_hist_dims(c_dims, dims); +} +CVAPI(int) legacy_CvCamShiftTracker_set_min_ch_val(CvCamShiftTracker* obj, int channel, int val) +{ + return obj->set_min_ch_val(channel, val); +} +CVAPI(int) legacy_CvCamShiftTracker_set_max_ch_val(CvCamShiftTracker* obj, int channel, int val) +{ + return obj->set_max_ch_val(channel, val); +} + +/************************ The processing methods *********************************/ +CVAPI(bool) legacy_CvCamShiftTracker_track_object(CvCamShiftTracker* obj, IplImage* cur_frame) +{ + return obj->track_object(cur_frame); +} +CVAPI(bool) legacy_CvCamShiftTracker_update_histogram(CvCamShiftTracker* obj, IplImage* cur_frame) +{ + return obj->update_histogram(cur_frame); +} +CVAPI(void) legacy_CvCamShiftTracker_reset_histogram(CvCamShiftTracker* obj) +{ + return obj->reset_histogram(); +} + +/************************ Retrieving internal data *******************************/ +CVAPI(IplImage*) legacy_CvCamShiftTracker_get_back_project(CvCamShiftTracker* obj) +{ + return obj->get_back_project(); +} + +CVAPI(float) legacy_CvCamShiftTracker_query(CvCamShiftTracker* obj, int* bin) +{ + return obj->query(bin); +} + +#endif \ No newline at end of file diff --git a/src/OpenCvSharpExtern/WVideo.cpp b/src/OpenCvSharpExtern/nonfree.cpp similarity index 78% rename from src/OpenCvSharpExtern/WVideo.cpp rename to src/OpenCvSharpExtern/nonfree.cpp index e5b9e8f6f..f3f43146e 100644 --- a/src/OpenCvSharpExtern/WVideo.cpp +++ b/src/OpenCvSharpExtern/nonfree.cpp @@ -3,4 +3,4 @@ * This code is licenced under the LGPL. */ -#include "WVideo.h" +#include "nonfree.h" \ No newline at end of file diff --git a/src/OpenCvSharpExtern/WNonfree.h b/src/OpenCvSharpExtern/nonfree.h similarity index 70% rename from src/OpenCvSharpExtern/WNonfree.h rename to src/OpenCvSharpExtern/nonfree.h index 7c17e16fb..08a15f6d1 100644 --- a/src/OpenCvSharpExtern/WNonfree.h +++ b/src/OpenCvSharpExtern/nonfree.h @@ -3,15 +3,15 @@ * This code is licenced under the LGPL. */ -#ifndef _WNONFREE_H_ -#define _WNONFREE_H_ +#ifndef _CPP_NONFREE_H_ +#define _CPP_NONFREE_H_ #ifdef _MSC_VER #pragma warning(disable: 4251) #endif #include -CVAPI(int) cv_initModule_nonfree() +CVAPI(int) nonfree_initModule_nonfree() { return cv::initModule_nonfree(); } diff --git a/src/OpenCvSharpExtern/std_vector.h b/src/OpenCvSharpExtern/std_vector.h index 76376d79a..3c162db89 100644 --- a/src/OpenCvSharpExtern/std_vector.h +++ b/src/OpenCvSharpExtern/std_vector.h @@ -323,4 +323,45 @@ CVAPI(void) vector_KeyPoint_delete(vector* vector) } #pragma endregion +#pragma region vector +CVAPI(vector>*) vector_vector_KeyPoint_new1() +{ + return new vector>; +} +CVAPI(vector>*) vector_vector_KeyPoint_new2(size_t size) +{ + return new vector>(size); +} +CVAPI(size_t) vector_vector_KeyPoint_getSize1(vector>* vec) +{ + return vec->size(); +} +CVAPI(void) vector_vector_KeyPoint_getSize2(vector>* vec, size_t *sizes) +{ + for (size_t i = 0; i < vec->size(); i++) + { + sizes[i] = vec->at(i).size(); + } +} +CVAPI(vector*) vector_vector_KeyPoint_getPointer(vector>* vec) +{ + return &(vec->at(0)); +} +CVAPI(void) vector_vector_KeyPoint_copy(vector> *vec, cv::KeyPoint **dst) +{ + for (size_t i = 0; i < vec->size(); i++) + { + vector &elem = vec->at(i); + for (size_t j = 0; j < elem.size(); j++) + { + dst[i][j] = elem[j]; + } + } +} +CVAPI(void) vector_vector_KeyPoint_delete(vector>* vec) +{ + delete vec; +} +#pragma endregion + #endif \ No newline at end of file diff --git a/src/OpenCvSharpExtern/WNonfree.cpp b/src/OpenCvSharpExtern/video.cpp similarity index 77% rename from src/OpenCvSharpExtern/WNonfree.cpp rename to src/OpenCvSharpExtern/video.cpp index 1e3d27b04..94e0bf3d4 100644 --- a/src/OpenCvSharpExtern/WNonfree.cpp +++ b/src/OpenCvSharpExtern/video.cpp @@ -3,4 +3,4 @@ * This code is licenced under the LGPL. */ -#include "WNonFree.h" \ No newline at end of file +#include "video.h" diff --git a/src/OpenCvSharpExtern/WVideo.h b/src/OpenCvSharpExtern/video.h similarity index 71% rename from src/OpenCvSharpExtern/WVideo.h rename to src/OpenCvSharpExtern/video.h index ea6447a51..707a7e0b0 100644 --- a/src/OpenCvSharpExtern/WVideo.h +++ b/src/OpenCvSharpExtern/video.h @@ -3,48 +3,44 @@ * This code is licenced under the LGPL. */ +#ifndef _CPP_VIDEO_H_ +#define _CPP_VIDEO_H_ -#ifndef _CPP_WCV_H_ -#define _CPP_WCV_H_ - -#ifdef _MSC_VER -#pragma warning(disable: 4251) -#endif -#include +#include "include_opencv.h" // BackgroundSubtractor -CVAPI(int) BackgroundSubtractor_sizeof() +CVAPI(size_t) video_BackgroundSubtractor_sizeof() { return sizeof(cv::BackgroundSubtractor); } -CVAPI(void) BackgroundSubtractor_getBackgroundImage(cv::BackgroundSubtractor* obj, cv::_OutputArray* backgroundImage) +CVAPI(void) video_BackgroundSubtractor_getBackgroundImage(cv::BackgroundSubtractor* obj, cv::_OutputArray* backgroundImage) { obj->getBackgroundImage(*backgroundImage); } // BackgroundSubtractorMOG -CVAPI(int) BackgroundSubtractorMOG_sizeof() +CVAPI(size_t) video_BackgroundSubtractorMOG_sizeof() { return sizeof(cv::BackgroundSubtractorMOG); } -CVAPI(cv::BackgroundSubtractorMOG*) BackgroundSubtractorMOG_new1() +CVAPI(cv::BackgroundSubtractorMOG*) video_BackgroundSubtractorMOG_new1() { return new cv::BackgroundSubtractorMOG(); } -CVAPI(cv::BackgroundSubtractorMOG*) BackgroundSubtractorMOG_new2(int history, int nmixtures, double backgroundRatio, double noiseSigma) +CVAPI(cv::BackgroundSubtractorMOG*) video_BackgroundSubtractorMOG_new2(int history, int nmixtures, double backgroundRatio, double noiseSigma) { return new cv::BackgroundSubtractorMOG(history, nmixtures, backgroundRatio, noiseSigma); } -CVAPI(void) BackgroundSubtractorMOG_delete(cv::BackgroundSubtractorMOG* obj) +CVAPI(void) video_BackgroundSubtractorMOG_delete(cv::BackgroundSubtractorMOG* obj) { delete obj; } -CVAPI(void) BackgroundSubtractorMOG_operator(cv::BackgroundSubtractorMOG* obj, cv::Mat* image, cv::Mat* fgmask, double learningRate) +CVAPI(void) video_BackgroundSubtractorMOG_operator(cv::BackgroundSubtractorMOG* obj, cv::_InputArray *image, cv::_OutputArray *fgmask, double learningRate) { (*obj)(*image, *fgmask, learningRate); } -CVAPI(void) BackgroundSubtractorMOG_initialize(cv::BackgroundSubtractorMOG* obj, CvSize frameSize, int frameType) +CVAPI(void) video_BackgroundSubtractorMOG_initialize(cv::BackgroundSubtractorMOG* obj, CvSize frameSize, int frameType) { obj->initialize(frameSize, frameType); } @@ -93,31 +89,31 @@ CVAPI(double*) BackgroundSubtractorMOG_noiseSigma(cv::BackgroundSubtractorMOG* o // BackgroundSubtractorMOG2 -CVAPI(int) BackgroundSubtractorMOG2_sizeof() +CVAPI(size_t) video_BackgroundSubtractorMOG2_sizeof() { return sizeof(cv::BackgroundSubtractorMOG2); } -CVAPI(cv::BackgroundSubtractorMOG2*) BackgroundSubtractorMOG2_new1() +CVAPI(cv::BackgroundSubtractorMOG2*) video_BackgroundSubtractorMOG2_new1() { return new cv::BackgroundSubtractorMOG2(); } -CVAPI(cv::BackgroundSubtractorMOG2*) BackgroundSubtractorMOG2_new2(int history, float varThreshold, int bShadowDetection) +CVAPI(cv::BackgroundSubtractorMOG2*) video_BackgroundSubtractorMOG2_new2(int history, float varThreshold, int bShadowDetection) { return new cv::BackgroundSubtractorMOG2(history, varThreshold, bShadowDetection!=0); } -CVAPI(void) BackgroundSubtractorMOG2_delete(cv::BackgroundSubtractorMOG2* obj) +CVAPI(void) video_BackgroundSubtractorMOG2_delete(cv::BackgroundSubtractorMOG2* obj) { delete obj; } -CVAPI(void) BackgroundSubtractorMOG2_operator(cv::BackgroundSubtractorMOG2* obj, cv::_InputArray* image, cv::_OutputArray* fgmask, double learningRate) +CVAPI(void) video_BackgroundSubtractorMOG2_operator(cv::BackgroundSubtractorMOG2* obj, cv::_InputArray* image, cv::_OutputArray* fgmask, double learningRate) { (*obj)(*image, *fgmask, learningRate); } -CVAPI(void) BackgroundSubtractorMOG2_getBackgroundImage(cv::BackgroundSubtractorMOG2* obj, cv::_OutputArray* backgroundImage) +CVAPI(void) video_BackgroundSubtractorMOG2_getBackgroundImage(cv::BackgroundSubtractorMOG2* obj, cv::_OutputArray* backgroundImage) { obj->getBackgroundImage(*backgroundImage); } -CVAPI(void) BackgroundSubtractorMOG2_initialize(cv::BackgroundSubtractorMOG2* obj, CvSize frameSize, int frameType) +CVAPI(void) video_BackgroundSubtractorMOG2_initialize(cv::BackgroundSubtractorMOG2* obj, CvSize frameSize, int frameType) { obj->initialize(frameSize, frameType); } From fe4448492e9ff59e85a024f11e2861053ce55d26 Mon Sep 17 00:00:00 2001 From: shimat Date: Sun, 9 Feb 2014 02:21:45 +0900 Subject: [PATCH 23/29] added FeatureDetector --- src/OpenCvSharp/Src/Utilities/ArrayAddress.cs | 23 ++++++++++++++----- src/OpenCvSharpExtern/core_Ptr.h | 9 ++++++-- src/OpenCvSharpExtern/include_opencv.h | 2 ++ 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/OpenCvSharp/Src/Utilities/ArrayAddress.cs b/src/OpenCvSharp/Src/Utilities/ArrayAddress.cs index 9e2345b10..a91e098c9 100644 --- a/src/OpenCvSharp/Src/Utilities/ArrayAddress.cs +++ b/src/OpenCvSharp/Src/Utilities/ArrayAddress.cs @@ -24,6 +24,7 @@ public class ArrayAddress1 : DisposableObject { private Array array; private GCHandle gch; + private bool disposed; #if LANG_JP /// @@ -73,11 +74,15 @@ public ArrayAddress1(T[,] array) #endif protected override void Dispose(bool disposing) { - if (gch.IsAllocated) + if (!disposed) { - gch.Free(); + if (gch.IsAllocated) + { + gch.Free(); + } + disposed = true; + base.Dispose(disposing); } - base.Dispose(); } #if LANG_JP @@ -126,6 +131,7 @@ public static implicit operator IntPtr(ArrayAddress1 self) #endif public class ArrayAddress2 : DisposableObject { + private bool disposed; private T[][] array; private readonly GCHandle[] gch; private readonly IntPtr[] ptr; @@ -174,12 +180,17 @@ public ArrayAddress2(T[][] array) #endif protected override void Dispose(bool disposing) { - foreach (GCHandle h in gch) + if (!disposed) { - if (h.IsAllocated) + foreach (GCHandle h in gch) { - h.Free(); + if (h.IsAllocated) + { + h.Free(); + } } + disposed = true; + base.Dispose(disposing); } } diff --git a/src/OpenCvSharpExtern/core_Ptr.h b/src/OpenCvSharpExtern/core_Ptr.h index 5271e99da..e31c08f59 100644 --- a/src/OpenCvSharpExtern/core_Ptr.h +++ b/src/OpenCvSharpExtern/core_Ptr.h @@ -8,9 +8,14 @@ #include "include_opencv.h" -CVAPI(void) core_Ptr_FeatureDetector_delete(cv::Ptr* obj) +CVAPI(cv::FeatureDetector*) core_Ptr_FeatureDetector_obj(cv::Ptr* ptr) { - delete obj; + return ptr->obj; +} + +CVAPI(void) core_Ptr_FeatureDetector_delete(cv::Ptr* ptr) +{ + delete ptr; } #endif \ No newline at end of file diff --git a/src/OpenCvSharpExtern/include_opencv.h b/src/OpenCvSharpExtern/include_opencv.h index a3d4d958e..fbd8a91a3 100644 --- a/src/OpenCvSharpExtern/include_opencv.h +++ b/src/OpenCvSharpExtern/include_opencv.h @@ -9,6 +9,8 @@ typedef unsigned short uint16; #include #include #include +#include +#include #if 0 #ifdef _WIN32 From 551ac746c692ee186e35b7eef454b3672078b638 Mon Sep 17 00:00:00 2001 From: shimat Date: Sun, 9 Feb 2014 03:16:57 +0900 Subject: [PATCH 24/29] Added C++ sample (incomplete) --- src/OpenCvSharpExtern/highgui.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/OpenCvSharpExtern/highgui.h b/src/OpenCvSharpExtern/highgui.h index 4642ff43a..75282c734 100644 --- a/src/OpenCvSharpExtern/highgui.h +++ b/src/OpenCvSharpExtern/highgui.h @@ -45,4 +45,13 @@ CVAPI(int) highgui_waitKey(int delay) return cv::waitKey(delay); } +CVAPI(void) highgui_destroyWindow(const char *winName) +{ + cv::destroyWindow(winName); +} +CVAPI(void) highgui_destroyAllWindows() +{ + cv::destroyAllWindows(); +} + #endif \ No newline at end of file From e6b4ee9b836c8642b38f38ff92680cca3661975b Mon Sep 17 00:00:00 2001 From: shimat Date: Sun, 9 Feb 2014 14:15:25 +0900 Subject: [PATCH 25/29] Added samples for CPlusPlus --- nuget/OpenCvSharp-x86.nuspec | 2 +- src/OpenCvSharpExtern/core_Mat.h | 10 +--------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/nuget/OpenCvSharp-x86.nuspec b/nuget/OpenCvSharp-x86.nuspec index 5ecd2d1c9..faa218adb 100644 --- a/nuget/OpenCvSharp-x86.nuspec +++ b/nuget/OpenCvSharp-x86.nuspec @@ -2,7 +2,7 @@ OpenCvSharp-x86 - 2.4.8.20140203 + 2.4.8.20140208 OpenCvSharp x86 shimat http://www.gnu.org/licenses/lgpl-3.0.en.html diff --git a/src/OpenCvSharpExtern/core_Mat.h b/src/OpenCvSharpExtern/core_Mat.h index 99594ed00..defc47121 100644 --- a/src/OpenCvSharpExtern/core_Mat.h +++ b/src/OpenCvSharpExtern/core_Mat.h @@ -139,15 +139,7 @@ CVAPI(int) core_Mat_dims(cv::Mat *self) return self->dims; } -CVAPI(void) core_Mat_convertTo1(cv::Mat *self, cv::Mat *m, int rtype) -{ - self->convertTo(*m, rtype); -} -CVAPI(void) core_Mat_convertTo2(cv::Mat *self, cv::Mat *m, int rtype, double alpha) -{ - self->convertTo(*m, rtype, alpha); -} -CVAPI(void) core_Mat_convertTo3(cv::Mat *self, cv::Mat *m, int rtype, double alpha, double beta) +CVAPI(void) core_Mat_convertTo(cv::Mat *self, cv::Mat *m, int rtype, double alpha, double beta) { self->convertTo(*m, rtype, alpha, beta); } From 11faefa7f97a2545ac795ec4206035fa151a9668 Mon Sep 17 00:00:00 2001 From: shimat Date: Sun, 9 Feb 2014 21:57:13 +0900 Subject: [PATCH 26/29] Changed Nuget of samples From e5bf86fe8bdf516162b1020a0cf67f00b900b0b9 Mon Sep 17 00:00:00 2001 From: shimat Date: Sun, 16 Feb 2014 01:47:50 +0900 Subject: [PATCH 27/29] Added MDS sample --- src/OpenCvSharp.SandboxCpp.cpp | 42 ------------- src/OpenCvSharpExtern/core.h | 81 ++++++++++++++++++++++--- src/OpenCvSharpExtern/core_InputArray.h | 6 ++ src/OpenCvSharpExtern/core_Mat.h | 6 ++ 4 files changed, 84 insertions(+), 51 deletions(-) delete mode 100644 src/OpenCvSharp.SandboxCpp.cpp diff --git a/src/OpenCvSharp.SandboxCpp.cpp b/src/OpenCvSharp.SandboxCpp.cpp deleted file mode 100644 index 435908a18..000000000 --- a/src/OpenCvSharp.SandboxCpp.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include "stdafx.h" - -using namespace System; - -struct U8C3 -{ - uchar b, g, r; -}; - -// For researching native OpenCV behaviour -int main(array ^args) -{ - cv::Mat mat1 = cv::imread("C:\\Lenna.png", CV_LOAD_IMAGE_COLOR); - cv::Mat mat2 = cv::imread("C:\\Lenna.png", CV_LOAD_IMAGE_COLOR); - - for (auto it = mat1.begin(); it != mat1.end(); it++) - { - U8C3 elem = *it; - std::swap(elem.b, elem.r); - *it = elem; - } - - cv::Mat eql = (mat1 == mat2); - cv::Mat channels[3]; - cv::split(eql, channels); - - //std::cout << "b: " << cv::countNonZero(channels[0]) << std::endl; - //std::cout << "g: " << cv::countNonZero(channels[1]) << std::endl; - //std::cout << "r: " << cv::countNonZero(channels[2]) << std::endl; - std::cout << "sum: " << cv::sum(eql) << std::endl; - std::cout << "total: " << eql.total() * 255 << std::endl; - std::cout << "equals: " << (cv::sum(eql)[0] == (eql.total() * 255)) << std::endl; - - cv::Scalar sc; - std::cout << "abs: " << cv::trace(mat1 - mat2) << std::endl; - - //cv::imshow("window", abs); - //cv::waitKey(); - - getchar(); - return 0; -} diff --git a/src/OpenCvSharpExtern/core.h b/src/OpenCvSharpExtern/core.h index 0ec11ebb7..82a86a21f 100644 --- a/src/OpenCvSharpExtern/core.h +++ b/src/OpenCvSharpExtern/core.h @@ -89,32 +89,29 @@ CVAPI(void) core_insertImageCOI(cv::_InputArray *coiimg, CvArr* arr, int coi) #pragma region Array Operations -CVAPI(void) cv_add(cv::_InputArray *src1, cv::_InputArray *src2, cv::_OutputArray* dst, cv::_InputArray *mask, int dtype) +CVAPI(void) core_add(cv::_InputArray *src1, cv::_InputArray *src2, cv::_OutputArray* dst, cv::_InputArray *mask, int dtype) { cv::add(*src1, *src2, *dst, entity(mask), dtype); } -CVAPI(void) cv_subtract(cv::_InputArray *src1, cv::_InputArray *src2, cv::_OutputArray* dst, cv::_InputArray *mask, int dtype) +CVAPI(void) core_subtract(cv::_InputArray *src1, cv::_InputArray *src2, cv::_OutputArray* dst, cv::_InputArray *mask, int dtype) { cv::subtract(*src1, *src2, *dst, entity(mask), dtype); } -CVAPI(void) cv_multiply(cv::_InputArray *src1, cv::_InputArray *src2, cv::_OutputArray* dst, double scale, int dtype) +CVAPI(void) core_multiply(cv::_InputArray *src1, cv::_InputArray *src2, cv::_OutputArray* dst, double scale, int dtype) { cv::multiply(*src1, *src2, *dst, scale, dtype); } -CVAPI(void) cv_divide1(double scale, cv::_InputArray *src2, cv::_OutputArray* dst, int dtype) +CVAPI(void) core_divide1(double scale, cv::_InputArray *src2, cv::_OutputArray* dst, int dtype) { cv::divide(scale, *src2, *dst, dtype); } -CVAPI(void) cv_divide2(cv::_InputArray *src1, cv::_InputArray *src2, cv::_OutputArray *dst, double scale, int dtype) +CVAPI(void) core_divide2(cv::_InputArray *src1, cv::_InputArray *src2, cv::_OutputArray *dst, double scale, int dtype) { cv::divide(*src1, *src2, *dst); } -CVAPI(void) cv_convertScaleAbs(cv::_InputArray *src, cv::_OutputArray *dst, double alpha, double beta) -{ - cv::convertScaleAbs(*src, *dst, alpha, beta); -} + #pragma endregion #pragma region Drawing @@ -190,7 +187,73 @@ CVAPI(int) core_clipLine2(CvRect imgRect, CvPoint *pt1, CvPoint *pt2) return result ? 1 : 0; } +//! renders text string in the image +CVAPI(void) core_putText(cv::Mat *img, const char *text, CvPoint org, + int fontFace, double fontScale, CvScalar color, + int thickness, int lineType, int bottomLeftOrigin) +{ + cv::putText(*img, text, org, fontFace, fontScale, color, thickness, lineType, bottomLeftOrigin != 0); +} + +//! returns bounding box of the text string +CVAPI(CvSize) core_getTextSize(const char *text, int fontFace, + double fontScale, int thickness, int* baseLine) +{ + return cv::getTextSize(text, fontFace, fontScale, thickness, baseLine); +} + + #pragma endregion +CVAPI(void) core_convertScaleAbs(cv::_InputArray *src, cv::_OutputArray *dst, double alpha, double beta) +{ + cv::convertScaleAbs(*src, *dst, alpha, beta); +} + +CVAPI(void) core_normalize(cv::_InputArray *src, cv::_OutputArray *dst, double alpha, double beta, + int normType, int dtype, cv::_InputArray *mask) +{ + cv::InputArray maskVal = entity(mask); + cv::normalize(*src, *dst, alpha, beta, normType, dtype, maskVal); +} + +CVAPI(void) core_minMaxLoc1(cv::_InputArray *src, double* minVal, double* maxVal) +{ + cv::minMaxLoc(*src, minVal, maxVal); +} +CVAPI(void) core_minMaxLoc2(cv::_InputArray *src, double* minVal, double* maxVal, + CvPoint* minLoc, CvPoint* maxLoc, cv::_InputArray* mask) +{ + cv::InputArray maskVal = entity(mask); + cv::Point minLoc0, maxLoc0; + cv::minMaxLoc(*src, minVal, maxVal, &minLoc0, &maxLoc0, maskVal); + *minLoc = minLoc0; + *maxLoc = maxLoc0; +} +CVAPI(void) core_minMaxIdx1(cv::_InputArray *src, double* minVal, double* maxVal) +{ + cv::minMaxIdx(*src, minVal, maxVal); +} +CVAPI(void) core_minMaxIdx2(cv::_InputArray *src, double* minVal, double* maxVal, + int* minIdx, int* maxIdx, cv::_InputArray *mask) +{ + cv::InputArray maskVal = entity(mask); + cv::minMaxIdx(*src, minVal, maxVal, minIdx, maxIdx, maskVal); +} + +CVAPI(int) core_eigen1(cv::_InputArray *src, cv::_OutputArray *eigenvalues, int lowindex, int highindex) +{ + return cv::eigen(*src, *eigenvalues, lowindex, highindex) ? 1 : 0; +} +CVAPI(int) core_eigen2(cv::_InputArray *src, cv::_OutputArray *eigenvalues, + cv::_OutputArray *eigenvectors, int lowindex, int highindex) +{ + return cv::eigen(*src, *eigenvalues, *eigenvectors, lowindex, highindex) ? 1 : 0; +} +CVAPI(int) core_eigen3(cv::_InputArray *src, bool computeEigenvectors, + cv::_OutputArray *eigenvalues, cv::_OutputArray *eigenvectors) +{ + return cv::eigen(*src, computeEigenvectors, *eigenvalues, *eigenvectors) ? 1 : 0; +} #endif \ No newline at end of file diff --git a/src/OpenCvSharpExtern/core_InputArray.h b/src/OpenCvSharpExtern/core_InputArray.h index 3573243df..818c678d4 100644 --- a/src/OpenCvSharpExtern/core_InputArray.h +++ b/src/OpenCvSharpExtern/core_InputArray.h @@ -14,6 +14,12 @@ CVAPI(cv::_InputArray*) core_InputArray_new_byMat(cv::Mat *mat) return new cv::_InputArray(ia); } +CVAPI(cv::_InputArray*) core_InputArray_new_byMatExpr(cv::MatExpr *expr) +{ + cv::_InputArray ia(*expr); + return new cv::_InputArray(ia); +} + CVAPI(void) core_InputArray_delete(cv::_InputArray *ia) { delete ia; diff --git a/src/OpenCvSharpExtern/core_Mat.h b/src/OpenCvSharpExtern/core_Mat.h index defc47121..d64fe161e 100644 --- a/src/OpenCvSharpExtern/core_Mat.h +++ b/src/OpenCvSharpExtern/core_Mat.h @@ -480,6 +480,12 @@ CVAPI(void) core_Mat_CvMat(cv::Mat *self, CvMat *outMat) memcpy(outMat, &inMat, sizeof(CvMat)); } +CVAPI(cv::MatExpr*) core_operatorUnaryMinus_Mat(cv::Mat *mat) +{ + cv::MatExpr expr = -(*mat); + return new cv::MatExpr(expr); +} + CVAPI(cv::MatExpr*) core_operatorAdd_MatMat(cv::Mat *a, cv::Mat *b) { cv::MatExpr expr = (*a) + (*b); From c9d9562680e1f2bff9e2dd643fbcee8ae77efef1 Mon Sep 17 00:00:00 2001 From: shimat Date: Wed, 19 Feb 2014 22:36:02 +0900 Subject: [PATCH 28/29] Minor update From 4672835ffcad81a77ed190a045294af4ca7afa65 Mon Sep 17 00:00:00 2001 From: shimat Date: Wed, 19 Feb 2014 22:44:01 +0900 Subject: [PATCH 29/29] Added DLLs