Skip to content

Commit

Permalink
Merge branch 'BlobImprovement'
Browse files Browse the repository at this point in the history
  • Loading branch information
shimat committed Jun 19, 2014
2 parents 25b2758 + 4146b15 commit d139683
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 18 deletions.
5 changes: 3 additions & 2 deletions nuget/OpenCvSharp-AnyCPU.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>OpenCvSharp-AnyCPU</id>
<version>2.4.8.20140609</version>
<version>2.4.8.20140619</version>
<title>OpenCvSharp</title>
<authors>shimat</authors>
<licenseUrl>http://opensource.org/licenses/BSD-3-Clause</licenseUrl>
<projectUrl>https://github.com/shimat/opencvsharp</projectUrl>
<iconUrl>https://raw.githubusercontent.com/shimat/opencvsharp/master/nuget/icon/lenna-icon.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>OpenCV wrapper for .NET Framework</description>
<releaseNotes>- Added Mat methods for supporting method chaining
<releaseNotes>- Fixed bugs: Cv2.WarpPerspective and Cv2.FindChessboardCorners
- Added Mat methods for supporting method chaining
- Added conversion WriteableBitmap &lt;-&gt; Mat</releaseNotes>
<copyright>Copyright 2008-2014</copyright>
<tags>Image Processing OpenCV Wrapper FFI</tags>
Expand Down
35 changes: 21 additions & 14 deletions src/OpenCvSharp/Src/PInvoke/WindowsLibraryLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Web;

namespace OpenCvSharp
{
Expand All @@ -28,7 +27,7 @@ public sealed class WindowsLibraryLoader
public static WindowsLibraryLoader Instance { get { return instance; } }

#endregion

/// <summary>
/// The default base directory name to copy the assemblies too.
/// </summary>
Expand All @@ -53,7 +52,7 @@ public sealed class WindowsLibraryLoader
/// <summary>
/// Used as a sanity check for the returned processor architecture to double check the returned value.
/// </summary>
private readonly Dictionary<string, int> processorArchitectureAddressWidthPlatforms =
private readonly Dictionary<string, int> processorArchitectureAddressWidthPlatforms =
new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase)
{
{"x86", 4},
Expand All @@ -65,8 +64,8 @@ public sealed class WindowsLibraryLoader
/// <summary>
/// Additional user-defined DLL paths
/// </summary>
public List<string> AdditionalPaths { get; private set; }
public List<string> AdditionalPaths { get; private set; }

private readonly object syncLock = new object();

/// <summary>
Expand Down Expand Up @@ -114,7 +113,7 @@ public void LoadLibrary(string dllName, IEnumerable<string> additionalPaths = nu

if (additionalPaths == null)
additionalPaths = new string[0];

try
{
lock (syncLock)
Expand All @@ -131,8 +130,8 @@ public void LoadLibrary(string dllName, IEnumerable<string> additionalPaths = nu
// Try loading from user-defined paths
foreach (string path in additionalPaths)
{
baseDirectory = Path.GetDirectoryName(path);
dllHandle = LoadLibraryInternal(dllName, baseDirectory, processArch);
// baseDirectory = Path.GetFullPath(path);
dllHandle = LoadLibraryRaw(dllName, path);
if (dllHandle != IntPtr.Zero) return;
}

Expand Down Expand Up @@ -170,10 +169,10 @@ public void LoadLibrary(string dllName, IEnumerable<string> additionalPaths = nu
// include process detection warnings
errorMessage.AppendFormat("\r\nWarnings: \r\n{0}", processArch.WarningText());
}
throw new LoadLibraryException(errorMessage.ToString());
throw new Exception(errorMessage.ToString());
}
}
catch (LoadLibraryException e)
catch (Exception e)
{
Trace.TraceError(e.Message);
}
Expand Down Expand Up @@ -222,11 +221,19 @@ private ProcessArchitectureInfo GetProcessArchitecture()

private IntPtr LoadLibraryInternal(string dllName, string baseDirectory, ProcessArchitectureInfo processArchInfo)
{
IntPtr libraryHandle = IntPtr.Zero;
//IntPtr libraryHandle = IntPtr.Zero;
var platformName = GetPlatformName(processArchInfo.Architecture);
var expectedDllDirectory = Path.Combine(
Path.Combine(baseDirectory, DllDirectory), platformName);
var fileName = FixUpDllFileName(Path.Combine(expectedDllDirectory, dllName));
//var fileName = FixUpDllFileName(Path.Combine(expectedDllDirectory, dllName));

return LoadLibraryRaw(dllName, expectedDllDirectory);
}

private IntPtr LoadLibraryRaw(string dllName, string baseDirectory)
{
IntPtr libraryHandle = IntPtr.Zero;
var fileName = FixUpDllFileName(Path.Combine(baseDirectory, dllName));

if (File.Exists(fileName))
{
Expand All @@ -250,15 +257,15 @@ private IntPtr LoadLibraryInternal(string dllName, string baseDirectory, Process
else
{
Trace.TraceError(
"Failed to load native library \"{0}\".\r\nCheck windows event log.",
"Failed to load native library \"{0}\".\r\nCheck windows event log.",
fileName);
}
}
catch (Exception e)
{
var lastError = Marshal.GetLastWin32Error();
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}",
"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);
}
}
Expand Down
11 changes: 9 additions & 2 deletions src/OpenCvSharpExtern/imgproc.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,17 @@ CVAPI(void) imgproc_warpAffine(cv::_InputArray* src, cv::_OutputArray* dst, cv::
cv::warpAffine(*src, *dst, *M, dsize, flags, borderMode, borderValue);
}

CVAPI(void) imgproc_warpPerspective(cv::_InputArray* src, cv::_OutputArray* dst, cv::_InputArray* M, CvSize dsize,
CVAPI(void) imgproc_warpPerspective_MisInputArray(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);
cv::warpPerspective(*src, *dst, *m, dsize, flags, borderMode, borderValue);
}

CVAPI(void) imgproc_warpPerspective_MisArray(cv::_InputArray* src, cv::_OutputArray* dst, float* m, int mRow, int mCol, CvSize dsize,
int flags, int borderMode, CvScalar borderValue)
{
cv::Mat mmat(mRow, mCol, CV_32FC1, m);
cv::warpPerspective(*src, *dst, mmat, dsize, flags, borderMode, borderValue);
}

CVAPI(void) imgproc_remap(cv::_InputArray* src, cv::_OutputArray* dst, cv::_InputArray* map1, cv::_InputArray* map2,
Expand Down

0 comments on commit d139683

Please sign in to comment.