From f0ebe87de05c15592f2bb02856f2639cb3424caf Mon Sep 17 00:00:00 2001 From: shimat Date: Fri, 23 May 2014 12:17:45 +0900 Subject: [PATCH] Updated NuGet packages in samples --- nuget/OpenCvSharp-AnyCPU.nuspec | 92 +++---- nuget/icon/Girl.jpg | Bin 5524 -> 15453 bytes nuget/tools-x86/install.ps1 | 60 +++-- src/OpenCvSharp.sln | 1 - src/OpenCvSharp/Src/PInvoke/NativeMethods.cs | 23 +- .../Src/PInvoke/WindowsLibraryLoader.cs | 224 ++++++++++-------- 6 files changed, 241 insertions(+), 159 deletions(-) diff --git a/nuget/OpenCvSharp-AnyCPU.nuspec b/nuget/OpenCvSharp-AnyCPU.nuspec index f8e74ae4e..8a094a695 100644 --- a/nuget/OpenCvSharp-AnyCPU.nuspec +++ b/nuget/OpenCvSharp-AnyCPU.nuspec @@ -22,52 +22,52 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nuget/icon/Girl.jpg b/nuget/icon/Girl.jpg index eabccb6c626502e1d222ffc76107d0e5df8136c6..d0a0219b95bac66f2fdd7d728211ffb32dc47cec 100644 GIT binary patch delta 14980 zcmV-~I(x;GE8Tb!|JeWF01!$>Nk#wx0RaGD0AP_4k^{&9$g!u%0e{z(5#eEtuA>JP z%MN#_P;A^0^v@@b)ywKkKG*Yocj5dQ$dJiZ6~O&(^i;hQZUYk2o1 z%u>q_+FNMCi1I?H_WEYL=UNk~&W}c&MHnh=KkNGFek5Nhn^Xzgc6b%k`0C^AJ`9dO zn}Lo`wSJO(TK@oo0_pnDn^o{Wy>See_YV4fq|Y0vjDH>r4CPeyZ-G#~SWr-ZDClwY~A9#ouVVk`T?i zINa)0KSg&%vOKG^-6ejg`>JPT~76UOMCa^{rbCC3LMi7$a3hjy`$D+>XTm04k;6*#6O} zOvCTAffxclZ=pX*`s%4FYCqTX&w|6to}{MFU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Qu@ZytOy zy3?WYcZPM33CF5NWww)4wP*y$F`bzJHUS3%r+<7?^gRmK!#1HU*KCcEVp&m#mbfl<2toqxNCT0agI|^3@Kdk& zCG3B*j+r0Cj{wDeC&SyBO5VY6er-BOo;aZv`>^xI=2Zh~lABI=`K#slZ^TL&jb(zw zLx0)S>1|VewX?t8R(+J?TlUkuyu7>o&yTdDH|d z<(?>QuENF^T<=4Ga#57>agH!iU(7Wz6;^LjN>2RmtM1O4l;J7QnJ2iv1Aiuu;RUv< zaiQDC44T!oy`{&V&v2zYyqqkIS0wUD2d#VU=ZvmwukPV6+0DC0Nl}a;Jc3HG^3^t? zXZ@8QpEOZkp9%i+KBw(9_0-m!V(V(Uf97Iq)y3k8Qu4}{*+N))i___pOta-IL9zt rs@wkn=||t6v7e5$2)+wLADFDM-8!z}oDHaP`kE-Bx#hX=vfTgKPCGFA diff --git a/nuget/tools-x86/install.ps1 b/nuget/tools-x86/install.ps1 index 62c0a92e3..2a4492e70 100644 --- a/nuget/tools-x86/install.ps1 +++ b/nuget/tools-x86/install.ps1 @@ -1,7 +1,5 @@ param($installPath, $toolsPath, $package, $project) -$platform = "x86" - # 指定したディレクトリを「新しい場合はコピー」にする function MarkDirectoryAsCopy($item) { @@ -26,7 +24,7 @@ $platforms = @( "x86"; "x64"; ) -$copyFiles = @( +$copyFilesX86 = @( "msvcp110.dll"; "msvcr110.dll"; "OpenCvSharpExtern.dll"; @@ -35,6 +33,29 @@ $copyFiles = @( "opencv_core248.dll"; "opencv_features2d248.dll"; "opencv_ffmpeg248.dll"; + "opencv_gpu248.dll"; + "opencv_flann248.dll"; + "opencv_highgui248.dll"; + "opencv_imgproc248.dll"; + "opencv_legacy248.dll"; + "opencv_ml248.dll"; + "opencv_nonfree248.dll"; + "opencv_ocl248.dll"; + "opencv_objdetect248.dll"; + "opencv_photo248.dll"; + "opencv_stitching248.dll"; + "opencv_superres248.dll"; + "opencv_video248.dll"; + "opencv_videostab248.dll"; +) +$copyFilesX64 = @( + "msvcp110.dll"; + "msvcr110.dll"; + "OpenCvSharpExtern.dll"; + "opencv_calib3d248.dll"; + "opencv_contrib248.dll"; + "opencv_core248.dll"; + "opencv_features2d248.dll"; "opencv_ffmpeg248_64.dll"; "opencv_gpu248.dll"; "opencv_flann248.dll"; @@ -52,34 +73,43 @@ $copyFiles = @( "opencv_videostab248.dll"; ) -foreach ( $platform in $platforms ) +# x86 +foreach ($file in $copyFilesX86) { - foreach ( $file in $copyFiles ) - { - $path = [System::IO::Path]::Combine($platform, $file) - MarkFileAsCopy($project.ProjectItems.Item($path)) - } + $dllDir = $project.ProjectItems.Item("dll") + $platFormDir = $dllDir.ProjectItems.Item("x86") + MarkFileAsCopy($platFormDir.ProjectItems.Item($file)) +} +# x64 +foreach ($file in $copyFilesX64) +{ + $dllDir = $project.ProjectItems.Item("dll") + $platFormDir = $dllDir.ProjectItems.Item("x64") + MarkFileAsCopy($platFormDir.ProjectItems.Item($file)) } function HasPlatform($manager, $platformName) { - $platforms = [Array] $manager.PlatformNames - $index = [System.Array]::IndexOf($platforms, $platformName) + $myPlatforms = [Array] $manager.PlatformNames + $index = [System.Array]::IndexOf($myPlatforms, $platformName) $index -ge 0 } $manager = $project.ConfigurationManager $configs = [Array] $manager.PlatformNames -$hasPlatform = HasPlatform $manager $platform -if(-not $hasPlatform) + +foreach ($p in $platforms) { - [void]$manager.AddPlatform($platform, "Any CPU", $true) + $hasPlatform = HasPlatform $manager $p + if(-not $hasPlatform) + { + [void]$manager.AddPlatform($p, "Any CPU", $true) + } } - #foreach ($config in $configs) #{ # [System.Windows.Forms.MessageBox]::Show(HasPlatform) diff --git a/src/OpenCvSharp.sln b/src/OpenCvSharp.sln index 2d6a14a13..315a7d4e9 100644 --- a/src/OpenCvSharp.sln +++ b/src/OpenCvSharp.sln @@ -251,7 +251,6 @@ Global {8E7279F8-F801-4672-B42F-1ED2C68B16A4}.Release JP|x86.ActiveCfg = Release|Win32 {8E7279F8-F801-4672-B42F-1ED2C68B16A4}.Release JP|x86.Build.0 = Release|Win32 {8E7279F8-F801-4672-B42F-1ED2C68B16A4}.Release|Any CPU.ActiveCfg = Release|Win32 - {8E7279F8-F801-4672-B42F-1ED2C68B16A4}.Release|Any CPU.Build.0 = Release|Win32 {8E7279F8-F801-4672-B42F-1ED2C68B16A4}.Release|Mixed Platforms.ActiveCfg = Release|x64 {8E7279F8-F801-4672-B42F-1ED2C68B16A4}.Release|Mixed Platforms.Build.0 = Release|x64 {8E7279F8-F801-4672-B42F-1ED2C68B16A4}.Release|Win32.ActiveCfg = Release|Win32 diff --git a/src/OpenCvSharp/Src/PInvoke/NativeMethods.cs b/src/OpenCvSharp/Src/PInvoke/NativeMethods.cs index bead80790..50f841545 100644 --- a/src/OpenCvSharp/Src/PInvoke/NativeMethods.cs +++ b/src/OpenCvSharp/Src/PInvoke/NativeMethods.cs @@ -95,7 +95,7 @@ static NativeMethods() /// public static void LoadLibraries() { - if (IsMono()) + if (IsUnix()) return; // core: @@ -123,6 +123,27 @@ public static void LoadLibraries() WindowsLibraryLoader.Instance.LoadLibrary(DllLegacy); } + /// + /// Returns whether the OS is Windows or not + /// + /// + private static bool IsWindows() + { + return !IsUnix(); + } + + /// + /// Returns whether the OS is *nix or not + /// + /// + private static bool IsUnix() + { + var p = Environment.OSVersion.Platform; + return (p == PlatformID.Unix || + p == PlatformID.MacOSX || + (int)p == 128); + } + /// /// Returns whether the runtime is Mono or not /// diff --git a/src/OpenCvSharp/Src/PInvoke/WindowsLibraryLoader.cs b/src/OpenCvSharp/Src/PInvoke/WindowsLibraryLoader.cs index 8d8315b46..7680d4cff 100644 --- a/src/OpenCvSharp/Src/PInvoke/WindowsLibraryLoader.cs +++ b/src/OpenCvSharp/Src/PInvoke/WindowsLibraryLoader.cs @@ -15,34 +15,9 @@ namespace OpenCvSharp /// /// Handles loading embedded dlls into memory, based on http://stackoverflow.com/questions/666799/embedding-unmanaged-dll-into-a-managed-c-sharp-dll. /// - /// This code is from https://github.com/charlesw/tesseract - public class WindowsLibraryLoader + /// This code is based on https://github.com/charlesw/tesseract + public sealed class WindowsLibraryLoader { - private class ProcessArchitectureInfo - { - public ProcessArchitectureInfo() - { - Warnings = new List(); - } - - public string Architecture { get; set; } - public List Warnings { get; set; } - - public bool HasWarnings - { - get { return Warnings.Count > 0; } - } - - public string WarningText() - { -#if Net20 - return String.Join("\r\n", Warnings.ToArray()); -#else - return String.Join("\r\n", Warnings); -#endif - } - } - #region Singleton pattern private static readonly WindowsLibraryLoader instance = new WindowsLibraryLoader(); @@ -50,28 +25,21 @@ public string WarningText() public static WindowsLibraryLoader Instance { get { return instance; } } #endregion - - private readonly object syncLock = new object(); - + /// /// The default base directory name to copy the assemblies too. /// private const string ProcessorArchitecture = "PROCESSOR_ARCHITECTURE"; private const string DllFileExtension = ".dll"; + private const string DllDirectory = "dll"; -#if Net40 || Net45 - private HashSet loadedAssemblies = new HashSet(); -#else private readonly List loadedAssemblies = new List(); -#endif - // Map processor - private readonly Dictionary processorArchitecturePlatforms; - // Used as a sanity check for the returned processor architecture to double check the returned value. - private readonly Dictionary processorArchitectureAddressWidthPlatforms; - private WindowsLibraryLoader() - { - processorArchitecturePlatforms = new Dictionary(StringComparer.OrdinalIgnoreCase) + /// + /// Map processor + /// + private readonly Dictionary processorArchitecturePlatforms = + new Dictionary(StringComparer.OrdinalIgnoreCase) { {"x86", "x86"}, {"AMD64", "x64"}, @@ -79,15 +47,32 @@ private WindowsLibraryLoader() {"ARM", "WinCE"} }; - processorArchitectureAddressWidthPlatforms = new Dictionary(StringComparer.OrdinalIgnoreCase) + /// + /// Used as a sanity check for the returned processor architecture to double check the returned value. + /// + private readonly Dictionary processorArchitectureAddressWidthPlatforms = + new Dictionary(StringComparer.OrdinalIgnoreCase) { {"x86", 4}, {"AMD64", 8}, {"IA64", 8}, {"ARM", 4} }; + + private readonly object syncLock = new object(); + + /// + /// constructor + /// + private WindowsLibraryLoader() + { } + /// + /// + /// + /// + /// public bool IsLibraryLoaded(string dllName) { lock (syncLock) @@ -96,67 +81,80 @@ public bool IsLibraryLoaded(string dllName) } } + /// + /// + /// + /// public bool IsCurrentPlatformSupported() { return Environment.OSVersion.Platform == PlatformID.Win32NT || Environment.OSVersion.Platform == PlatformID.Win32Windows; } + /// + /// + /// + /// public void LoadLibrary(string dllName) { - if (IsCurrentPlatformSupported()) + if (!IsCurrentPlatformSupported()) { - try + return; + } + + try + { + lock (syncLock) { - lock (syncLock) + if (loadedAssemblies.Contains(dllName)) { - if (!loadedAssemblies.Contains(dllName)) - { - var processArch = GetProcessArchitecture(); - IntPtr dllHandle; - string baseDirectory; - - // Try loading from executing assembly domain - var executingAssembly = Assembly.GetExecutingAssembly(); - baseDirectory = Path.GetDirectoryName(executingAssembly.Location); - dllHandle = LoadLibraryInternal(dllName, baseDirectory, processArch); - if (dllHandle != IntPtr.Zero) return; - - // Fallback to current app domain - baseDirectory = Path.GetFullPath(AppDomain.CurrentDomain.BaseDirectory); - dllHandle = LoadLibraryInternal(dllName, baseDirectory, processArch); - if (dllHandle != IntPtr.Zero) return; - - // Finally try the working directory - baseDirectory = Path.GetFullPath(Environment.CurrentDirectory); - dllHandle = LoadLibraryInternal(dllName, baseDirectory, processArch); - if (dllHandle != IntPtr.Zero) return; - - // ASP.NET hack, requires an active context + return; + } + + var processArch = GetProcessArchitecture(); + IntPtr dllHandle; + string baseDirectory; + + // Try loading from executing assembly domain + var executingAssembly = Assembly.GetExecutingAssembly(); + baseDirectory = Path.GetDirectoryName(executingAssembly.Location); + dllHandle = LoadLibraryInternal(dllName, baseDirectory, processArch); + if (dllHandle != IntPtr.Zero) return; + + // Fallback to current app domain + baseDirectory = Path.GetFullPath(AppDomain.CurrentDomain.BaseDirectory); + dllHandle = LoadLibraryInternal(dllName, baseDirectory, processArch); + if (dllHandle != IntPtr.Zero) return; + + // Finally try the working directory + baseDirectory = Path.GetFullPath(Environment.CurrentDirectory); + dllHandle = LoadLibraryInternal(dllName, baseDirectory, processArch); + if (dllHandle != IntPtr.Zero) return; + + // ASP.NET hack, requires an active context #if !ClientProfile - if (HttpContext.Current != null) - { - var server = HttpContext.Current.Server; - baseDirectory = Path.GetFullPath(server.MapPath("bin")); - dllHandle = LoadLibraryInternal(dllName, baseDirectory, processArch); - if (dllHandle != IntPtr.Zero) return; - } + if (HttpContext.Current != null) + { + var server = HttpContext.Current.Server; + baseDirectory = Path.GetFullPath(server.MapPath("bin")); + dllHandle = LoadLibraryInternal(dllName, baseDirectory, processArch); + if (dllHandle != IntPtr.Zero) return; + } #endif - StringBuilder errorMessage = new StringBuilder(); - errorMessage.AppendFormat("Failed to find dll \"{0}\", for processor architecture {1}.", dllName, processArch.Architecture); - if (processArch.HasWarnings) - { - // include process detection warnings - errorMessage.AppendFormat("\r\nWarnings: \r\n{0}", processArch.WarningText()); - } - throw new LoadLibraryException(errorMessage.ToString()); - } + StringBuilder errorMessage = new StringBuilder(); + errorMessage.AppendFormat("Failed to find dll \"{0}\", for processor architecture {1}.", dllName, + processArch.Architecture); + if (processArch.HasWarnings) + { + // include process detection warnings + errorMessage.AppendFormat("\r\nWarnings: \r\n{0}", processArch.WarningText()); } + throw new LoadLibraryException(errorMessage.ToString()); } - catch (LoadLibraryException e) - { - Trace.TraceError(e.Message); - } + } + catch (LoadLibraryException e) + { + Trace.TraceError(e.Message); } } @@ -176,10 +174,10 @@ private ProcessArchitectureInfo GetProcessArchitecture() } else { - processInfo.Architecture = "x86"; - processInfo.Warnings.Add("Failed to detect processor architecture, falling back to x86."); - } + processInfo.AddWarning("Failed to detect processor architecture, falling back to x86."); + processInfo.Architecture = (IntPtr.Size == 8) ? "x64" : "x86"; + } var addressWidth = processorArchitectureAddressWidthPlatforms[processInfo.Architecture]; if (addressWidth != IntPtr.Size) @@ -188,12 +186,12 @@ private ProcessArchitectureInfo GetProcessArchitecture() { // fall back to x86 if detected x64 but has an address width of 32 bits. processInfo.Architecture = "x86"; - processInfo.Warnings.Add(String.Format("Expected the detected processing architecture of {0} to have an address width of {1} Bytes but was {2} Bytes, falling back to x86.", processInfo.Architecture, addressWidth, IntPtr.Size)); + processInfo.AddWarning("Expected the detected processing architecture of {0} to have an address width of {1} Bytes but was {2} Bytes, falling back to x86.", processInfo.Architecture, addressWidth, IntPtr.Size); } else { // no fallback possible - processInfo.Warnings.Add(String.Format("Expected the detected processing architecture of {0} to have an address width of {1} Bytes but was {2} Bytes.", processInfo.Architecture, addressWidth, IntPtr.Size)); + processInfo.AddWarning("Expected the detected processing architecture of {0} to have an address width of {1} Bytes but was {2} Bytes.", processInfo.Architecture, addressWidth, IntPtr.Size); } } @@ -205,7 +203,8 @@ private IntPtr LoadLibraryInternal(string dllName, string baseDirectory, Process { IntPtr libraryHandle = IntPtr.Zero; var platformName = GetPlatformName(processArchInfo.Architecture); - var expectedDllDirectory = Path.Combine(baseDirectory, platformName); + var expectedDllDirectory = Path.Combine( + Path.Combine(baseDirectory, DllDirectory), platformName); var fileName = FixUpDllFileName(Path.Combine(expectedDllDirectory, dllName)); if (File.Exists(fileName)) @@ -229,13 +228,17 @@ private IntPtr LoadLibraryInternal(string dllName, string baseDirectory, Process } else { - Trace.TraceError(String.Format("Failed to load native library \"{0}\".\r\nCheck windows event log.", fileName)); + Trace.TraceError( + "Failed to load native library \"{0}\".\r\nCheck windows event log.", + fileName); } } catch (Exception e) { var lastError = Marshal.GetLastWin32Error(); - Trace.TraceError(String.Format("Failed to load native library \"{0}\".\r\nLast Error:{1}\r\nCheck inner exception and\\or windows event log.\r\nInner Exception: {2}", fileName, lastError, e.ToString())); + Trace.TraceError( + "Failed to load native library \"{0}\".\r\nLast Error:{1}\r\nCheck inner exception and\\or windows event log.\r\nInner Exception: {2}", + fileName, lastError, e); } } else @@ -291,6 +294,35 @@ private string GetPlatformName(string processorArchitecture) return null; } + /// + /// + /// + private class ProcessArchitectureInfo + { + public ProcessArchitectureInfo() + { + Warnings = new List(); + } + + public string Architecture { get; set; } + private List Warnings { get; set; } + + public bool HasWarnings + { + get { return Warnings.Count > 0; } + } + + public void AddWarning(string format, params object[] args) + { + Warnings.Add(String.Format(format, args)); + } + + public string WarningText() + { + return String.Join("\r\n", Warnings.ToArray()); + } + } + [DllImport("kernel32", EntryPoint = "LoadLibrary", CallingConvention = CallingConvention.Winapi, SetLastError = true, CharSet = CharSet.Auto, BestFitMapping = false, ThrowOnUnmappableChar = true)] private static extern IntPtr Win32LoadLibrary(string dllPath);