Skip to content

Commit

Permalink
Merge pull request #1203 from shimat/window_param_order
Browse files Browse the repository at this point in the history
Change Window constructor
  • Loading branch information
shimat authored Feb 6, 2021
2 parents 1c6a50c + 581358b commit 83464ed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 30 deletions.
36 changes: 7 additions & 29 deletions src/OpenCvSharp/Modules/highgui/Window.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,26 +46,9 @@ public class Window : DisposableObject
/// </summary>
#endif
public Window()
: this(DefaultName(), WindowFlags.AutoSize, null)
: this(DefaultName(), null, WindowFlags.AutoSize)
{
}

#if LANG_JP
/// <summary>
/// 適当なウィンドウ名で、始めから表示しておく画像を指定して初期化
/// </summary>
/// <param name="image">ウィンドウに表示する画像</param>
#else
/// <summary>
/// Creates a window with a random name and a specified image
/// </summary>
/// <param name="image"></param>
#endif
public Window(Mat image)
: this(DefaultName(), WindowFlags.AutoSize, image)
{

}

#if LANG_JP
/// <summary>
Expand All @@ -79,32 +62,27 @@ public Window(Mat image)
/// Creates a window
/// </summary>
/// <param name="name">Name of the window which is used as window identifier and appears in the window caption. </param>
/// <param name="image">Image to be shown.</param>
/// <param name="flags">Flags of the window. Currently the only supported flag is WindowMode.AutoSize.
/// If it is set, window size is automatically adjusted to fit the displayed image (see cvShowImage), while user can not change the window size manually. </param>
/// <param name="image">Image to be shown.</param>
#endif
public Window(string name, WindowFlags flags = WindowFlags.AutoSize, Mat? image = null)
public Window(string name, Mat? image = null, WindowFlags flags = WindowFlags.AutoSize)
{
if (string.IsNullOrEmpty(name))
{
throw new ArgumentException("Null or empty window name.", nameof(name));
}


this.name = name;
NativeMethods.HandleException(
NativeMethods.highgui_namedWindow(name, (int) flags));

if (image != null)
{
ShowImage(image);
}


trackbars = new Dictionary<string, CvTrackbar>();

if (!Windows.ContainsKey(name))
{
Windows.Add(name, this);
}

callbackHandle = null;
}

Expand Down Expand Up @@ -570,7 +548,7 @@ public static void ShowImages(params Mat[] images)
var windows = new List<Window>();
foreach (var img in images)
{
windows.Add(new Window(img));
windows.Add(new Window { Image = img });
}

WaitKey();
Expand Down
1 change: 0 additions & 1 deletion test/OpenCvSharp.Tests/OpenCvSharp.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
<ItemGroup>
<ProjectReference Include="..\..\src\OpenCvSharp.WpfExtensions\OpenCvSharp.WpfExtensions.csproj" />
<ProjectReference Include="..\..\src\OpenCvSharp\OpenCvSharp.csproj" />
<ProjectReference Include="..\..\src\OpenCvSharp.Blob\OpenCvSharp.Blob.csproj" />
<ProjectReference Include="..\..\src\OpenCvSharp.Extensions\OpenCvSharp.Extensions.csproj" />
</ItemGroup>

Expand Down

0 comments on commit 83464ed

Please sign in to comment.