Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/origin/CPlusPlus-Improvement-ob…
Browse files Browse the repository at this point in the history
…jdetect'
  • Loading branch information
shimat committed Apr 5, 2014
2 parents ee5ff4d + dc00391 commit 93b37b6
Show file tree
Hide file tree
Showing 10 changed files with 462 additions and 261 deletions.
6 changes: 2 additions & 4 deletions nuget/OpenCvSharp-x64.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>OpenCvSharp-x64</id>
<version>2.4.8.20140331</version>
<version>2.4.8.20140405</version>
<title>OpenCvSharp x64</title>
<authors>shimat</authors>
<licenseUrl>http://www.gnu.org/licenses/lgpl-3.0.en.html</licenseUrl>
<projectUrl>https://github.com/shimat/opencvsharp</projectUrl>
<iconUrl>http://opencvsharp.googlecode.com/files/Lenna.ico</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>OpenCV wrapper for .NET Framework</description>
<releaseNotes>Added C++ highgui, features2d and calib3d methods.

BitmapConverter is moved to OpenCvSharp.Extensions.</releaseNotes>
<releaseNotes>Added C++ objdetect methods.</releaseNotes>
<copyright>Copyright 2008-2014</copyright>
<tags>Image Processing OpenCV Wrapper FFI</tags>
<frameworkAssemblies>
Expand Down
6 changes: 2 additions & 4 deletions nuget/OpenCvSharp-x86.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>OpenCvSharp-x86</id>
<version>2.4.8.20140331</version>
<version>2.4.8.20140405</version>
<title>OpenCvSharp x86</title>
<authors>shimat</authors>
<licenseUrl>http://www.gnu.org/licenses/lgpl-3.0.en.html</licenseUrl>
<projectUrl>https://github.com/shimat/opencvsharp</projectUrl>
<iconUrl>http://opencvsharp.googlecode.com/files/Lenna.ico</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>OpenCV wrapper for .NET Framework</description>
<releaseNotes>Added C++ highgui, features2d and calib3d methods.

BitmapConverter is moved to OpenCvSharp.Extensions.</releaseNotes>
<releaseNotes>Added C++ objdetect methods.</releaseNotes>
<copyright>Copyright 2008-2014</copyright>
<tags>Image Processing OpenCV Wrapper FFI</tags>
<frameworkAssemblies>
Expand Down
11 changes: 4 additions & 7 deletions src/OpenCvSharp.UserInterface/CvWindowEx.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using OpenCvSharp;

namespace OpenCvSharp.UserInterface
{
Expand Down Expand Up @@ -226,11 +223,11 @@ public void ShowImage(IplImage image)
#endif
public TrackbarWithLabel CreateTrackbar(string name, int value, int count, CvTrackbarCallback onChange)
{
TrackbarWithLabel t = new TrackbarWithLabel(name, value, count, 0);
var t = new TrackbarWithLabel(name, value, count, 0);
t.Dock = DockStyle.Top;
t.Trackbar.ValueChanged += delegate(object _o, EventArgs _e)
t.Trackbar.ValueChanged += (o, e) =>
{
int pos = ((TrackBar)_o).Value;
int pos = ((TrackBar)o).Value;
onChange(pos);
};
SetClientSize(new CvSize(ClientSize.Width, ClientSize.Height + t.Height));
Expand Down Expand Up @@ -320,7 +317,7 @@ static public void ShowImages(params IplImage[] images)
{
return;
}
List<CvWindowEx> windows = new List<CvWindowEx>();
var windows = new List<CvWindowEx>();
foreach (IplImage img in images)
{
windows.Add(new CvWindowEx(img));
Expand Down
1 change: 1 addition & 0 deletions src/OpenCvSharp/OpenCvSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@
<Compile Include="Src\Struct\CvFaceData.cs" />
<Compile Include="Src\Struct\CvLSVMFilterPosition.cs" />
<Compile Include="Src\Struct\CvObjectDetection.cs" />
<Compile Include="Src\Utilities\StringArrayAddress.cs" />
<Compile Include="Src\Utilities\ArrayAddress.cs" />
<Compile Include="Src\Class\CvConnectedComp.cs" />
<Compile Include="Src\Class\CvContourScanner.cs" />
Expand Down
88 changes: 19 additions & 69 deletions src/OpenCvSharp/Src/Utilities/ArrayAddress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,55 +6,38 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;

#pragma warning disable 1591
// ReSharper disable InconsistentNaming

namespace OpenCvSharp.Utilities
{
#if LANG_JP
/// <summary>
/// 1次元配列のアドレスを得るためのクラス
/// </summary>
#else
/// <summary>
///
/// </summary>
/// <typeparam name="T"></typeparam>
#endif
public class ArrayAddress1<T> : DisposableObject
{
private Array array;
private GCHandle gch;
protected Array array;
protected GCHandle gch;
private bool disposed;

#if LANG_JP
/// <summary>
/// 初期化
/// </summary>
/// <param name="array"></param>
#else

/// <summary>
///
/// </summary>
/// <param name="array"></param>
#endif
public ArrayAddress1(T[] array)
{
if (array == null)
throw new ArgumentNullException();
this.array = array;
this.gch = GCHandle.Alloc(array, GCHandleType.Pinned);
}
#if LANG_JP
/// <summary>
/// 初期化
/// </summary>
/// <param name="array"></param>
#else

/// <summary>
///
/// </summary>
/// <param name="array"></param>
#endif
public ArrayAddress1(T[,] array)
{
if (array == null)
Expand All @@ -63,15 +46,9 @@ public ArrayAddress1(T[,] array)
this.gch = GCHandle.Alloc(array, GCHandleType.Pinned);
}

#if LANG_JP
/// <summary>
/// リソースの解放
/// </summary>
#else
/// <summary>
///
/// </summary>
#endif
protected override void Dispose(bool disposing)
{
if (!disposed)
Expand All @@ -85,69 +62,48 @@ protected override void Dispose(bool disposing)
}
}

#if LANG_JP
/// <summary>
/// ポインタを得る
/// </summary>
/// <returns></returns>
#else
/// <summary>
///
/// </summary>
#endif
public IntPtr Pointer
{
get { return gch.AddrOfPinnedObject(); }
}
#if LANG_JP
/// <summary>
/// ポインタへの暗黙のキャスト
/// </summary>
/// <param name="self"></param>
/// <returns></returns>
#else

/// <summary>
///
/// </summary>
/// <param name="self"></param>
/// <returns></returns>
#endif
public static implicit operator IntPtr(ArrayAddress1<T> self)
{
return self.Pointer;
}
}


#if LANG_JP
/// <summary>
/// 2次元ジャグ配列のアドレスを得るためのクラス
/// </summary>
#else
/// <summary>
/// Class to get address of specified jagged array
/// </summary>
/// <typeparam name="T"></typeparam>
#endif
public class ArrayAddress2<T> : DisposableObject
where T : struct
{
private bool disposed;
private T[][] array;
private GCHandle[] gch;
private IntPtr[] ptr;
protected T[][] array;
protected GCHandle[] gch;
protected IntPtr[] ptr;

#if LANG_JP
/// <summary>
/// 初期化
///
/// </summary>
/// <param name="array">T[][]</param>
#else
public ArrayAddress2()
{
}
/// <summary>
///
/// </summary>
/// <param name="array"></param>
#endif
public ArrayAddress2(T[][] array)
{
Initialize(array);
Expand All @@ -161,7 +117,7 @@ public ArrayAddress2(IEnumerable<IEnumerable<T>> enumerable)
if (enumerable == null)
throw new ArgumentNullException("enumerable");

List<T[]> list = new List<T[]>();
var list = new List<T[]>();
foreach (IEnumerable<T> e in enumerable)
{
if(e == null)
Expand All @@ -172,11 +128,11 @@ public ArrayAddress2(IEnumerable<IEnumerable<T>> enumerable)
Initialize(list.ToArray());
}

private void Initialize(T[][] target)
protected void Initialize(T[][] target)
{
if (target == null)
throw new ArgumentNullException("target");
this.array = target;
array = target;

// T[][]をIntPtr[]に変換する
ptr = new IntPtr[array.Length];
Expand All @@ -194,15 +150,9 @@ private void Initialize(T[][] target)
}
}

#if LANG_JP
/// <summary>
/// リソースの解放
/// </summary>
#else
/// <summary>
///
/// </summary>
#endif
protected override void Dispose(bool disposing)
{
if (!disposed)
Expand Down Expand Up @@ -266,7 +216,7 @@ public int[] Dim2Lengths
{
get
{
List<int> lengths = new List<int>(array.Length);
var lengths = new List<int>(array.Length);
for (int i = 0; i < array.Length; i++)
{
lengths[i] = array[i].Length;
Expand Down
40 changes: 40 additions & 0 deletions src/OpenCvSharp/Src/Utilities/StringArrayAddress.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* (C) 2008-2014 shimat
* This code is licenced under the LGPL.
*/

using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;

namespace OpenCvSharp.Utilities
{
/// <summary>
/// Class to get address of string array
/// </summary>
public class StringArrayAddress : ArrayAddress2<byte>
{
/// <summary>
///
/// </summary>
/// <param name="stringArray"></param>
public StringArrayAddress(string[] stringArray)
{
var byteList = new List<byte[]>();
for (int i = 0; i < stringArray.Length; i++)
{
byteList.Add(Encoding.ASCII.GetBytes(stringArray[i]));
}
Initialize(byteList.ToArray());
}
/// <summary>
///
/// </summary>
/// <param name="enumerable"></param>
public StringArrayAddress(IEnumerable<string> enumerable)
: this(Util.ToArray(enumerable))
{
}
}
}
2 changes: 1 addition & 1 deletion src/OpenCvSharpExtern/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ CVAPI(void) core_circle(cv::Mat *img, CvPoint center, int radius,

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)
CvScalar color, int thickness, int lineType, int shift)
{
cv::ellipse(*img, center, axes, angle, startAngle, endAngle, color, thickness, lineType, shift);
}
Expand Down
Loading

0 comments on commit 93b37b6

Please sign in to comment.