Skip to content

Commit

Permalink
Merge pull request #45 from lizaalert/dev_desktopApp
Browse files Browse the repository at this point in the history
Dev desktop app 0.3.0
  • Loading branch information
gosha20777 authored Sep 25, 2019
2 parents 660b85c + 83f2f33 commit 32c79cf
Show file tree
Hide file tree
Showing 7 changed files with 145 additions and 7 deletions.
2 changes: 1 addition & 1 deletion DataUtils/LaddGenerator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ static void Main(string[] args)
if (dstAnnotation.Objects == null || dstAnnotation.Objects.Count <= 0)
{
dstAnnotation.Objects = new List<Object>();
//throw new Exception("no objects in the image!");
throw new Exception("no objects in the image!");
}
foreach (var obj in dstAnnotation.Objects)
{
Expand Down
2 changes: 1 addition & 1 deletion RescuerLaApp/Models/Docker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ public async Task Remove(string imageName = "gosha20777/test", string tag = "1")
}
}

var images = await _client.Images.ListImagesAsync(new ImagesListParameters(){MatchName = imageName});
var images = await _client.Images.ListImagesAsync(new ImagesListParameters(){MatchName = $"{imageName}:{tag}"});
foreach (var image in images)
{
await _client.Images.DeleteImageAsync(image.ID, new ImageDeleteParameters {Force = true});
Expand Down
2 changes: 1 addition & 1 deletion RescuerLaApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ internal static class Program
{
private static void Main(string[] args)
{
Console.WriteLine("Lacmus desktop application. Version 0.2.9 alpha. \nCopyright (c) 2019 Georgy Perevozghikov <[email protected]>\nGithub page: https://github.com/lizaalert/lacmus/.\nProvided by Yandex Cloud: https://cloud.yandex.com/.");
Console.WriteLine("Lacmus desktop application. Version 0.3.0 alpha. \nCopyright (c) 2019 Georgy Perevozghikov <[email protected]>\nGithub page: https://github.com/lizaalert/lacmus/.\nProvided by Yandex Cloud: https://cloud.yandex.com/.");
Console.WriteLine("This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.");
Console.WriteLine("This is free software, and you are welcome to redistribute it\nunder certain conditions; type `show c' for details.");
Console.WriteLine("------------------------------------");
Expand Down
1 change: 1 addition & 0 deletions RescuerLaApp/RescuerLaApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<PackageReference Include="Avalonia.ReactiveUI" Version="0.8.2" />
<PackageReference Include="Avalonia.Skia.Linux.Natives" Version="1.68.0.2" />
<PackageReference Include="Docker.DotNet" Version="3.125.2" />
<PackageReference Include="MessageBox.Avalonia" Version="0.8.3" />
<PackageReference Include="NewtonSoft.Json" Version="12.0.2" />
<PackageReference Include="ReactiveUI.Fody" Version="9.16.3" />
</ItemGroup>
Expand Down
136 changes: 136 additions & 0 deletions RescuerLaApp/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@
using System.Linq;
using System.Reactive;
using System.Reactive.Linq;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Media.Imaging;
using Docker.DotNet;
using MessageBox.Avalonia.DTO;
using MessageBox.Avalonia.Enums;
using MessageBox.Avalonia.Models;
using ReactiveUI;
using ReactiveUI.Fody.Helpers;
using Newtonsoft.Json;
Expand Down Expand Up @@ -61,6 +67,10 @@ public MainWindowViewModel()
UpdateModelCommand = ReactiveCommand.Create(UpdateModel, canExecute);
ShowPerestriansCommand = ReactiveCommand.Create(ShowPedestrians, canExecute);
ImportAllCommand = ReactiveCommand.Create(ImportAll, canExecute);
SaveAllImagesWithObjectsCommand = ReactiveCommand.Create(SaveAllImagesWithObjects, canExecute);
HelpCommand = ReactiveCommand.Create(Help);
AboutCommand = ReactiveCommand.Create(About);
ExitCommand = ReactiveCommand.Create(Exit, canExecute);
}

public void UpdateFramesRepo()
Expand Down Expand Up @@ -118,6 +128,13 @@ public void UpdateFramesRepo()
public ReactiveCommand<Unit, Unit> UpdateModelCommand { get; }

public ReactiveCommand<Unit, Unit> ShowPerestriansCommand { get; }

public ReactiveCommand<Unit, Unit> SaveAllImagesWithObjectsCommand { get; }
public ReactiveCommand<Unit, Unit> HelpCommand { get; }
public ReactiveCommand<Unit, Unit> AboutCommand { get; }
public ReactiveCommand<Unit, Unit> ExitCommand { get; }



#endregion

Expand Down Expand Up @@ -368,6 +385,49 @@ private async void SaveAll()
};
}
}

private async void SaveAllImagesWithObjects()
{
try
{
if (Frames == null || Frames.Count < 1)
{
Status = new AppStatusInfo() {Status = Enums.Status.Ready};
return;
}
Status = new AppStatusInfo() {Status = Enums.Status.Working};

var openDig = new OpenFolderDialog()
{
Title = "Choose a directory to save images with objects"
};
var dirName = await openDig.ShowAsync(new Window());


if (string.IsNullOrEmpty(dirName) || !Directory.Exists(dirName))
{
Status = new AppStatusInfo() {Status = Enums.Status.Ready};
return;
}

foreach (var frame in Frames)
{
if (frame.Rectangles == null || frame.Rectangles.Count <= 0)
continue;
File.Copy(frame.Patch, Path.Combine(dirName, Path.GetFileName(frame.Patch)));
}
Console.WriteLine($"Saved to {dirName}");
Status = new AppStatusInfo() {Status = Enums.Status.Ready, StringStatus = $"Success | saved to {dirName}"};
}
catch (Exception ex)
{
Status = new AppStatusInfo()
{
Status = Enums.Status.Error,
StringStatus = $"Error | {ex.Message.Replace('\n', ' ')}"
};
}
}

private async void ImportAll()
{
Expand Down Expand Up @@ -478,6 +538,82 @@ private void FrameLoadingProgressUpdate()
}
}

public void Help()
{
OpenUrl("https://github.com/lizaalert/lacmus/wiki");
}

public async void About()
{
var message =
"Copyright (c) 2019 Georgy Perevozghikov <[email protected]>\nGithub page: https://github.com/lizaalert/lacmus/. Press `Github` button for more details.\nProvided by Yandex Cloud: https://cloud.yandex.com/." +
"\nThis program comes with ABSOLUTELY NO WARRANTY." +
"\nThis is free software, and you are welcome to redistribute it under GNU GPLv3 conditions.\nPress `License` button to learn more about the license";

var msgBoxCustomParams = new MessageBoxCustomParams
{
ButtonDefinitions = new []
{
new ButtonDefinition{Name = "Ok", Type = ButtonType.Colored},
new ButtonDefinition{Name = "License"},
new ButtonDefinition{Name = "Github"}
},
ContentTitle = "About",
ContentHeader = "Lacmus desktop application. Version 0.3.0 alpha.",
ContentMessage = message,
Icon = Icon.Avalonia,
Style = Style.None,
ShowInCenter = true
};
var msgbox = MessageBox.Avalonia.MessageBoxWindow.CreateCustomWindow(msgBoxCustomParams);
var result = await msgbox.Show();
switch (result.ToLower())
{
case "ok": return;
case "license": OpenUrl("https://github.com/lizaalert/lacmus/blob/master/LICENSE"); break;
case "github": OpenUrl("https://github.com/lizaalert/lacmus"); break;
}
}

public async void Exit()
{
var message = "Do you really want to exit?";

var msgbox = new MessageBox.Avalonia.MessageBoxWindow(new MessageBoxParams
{
Button = ButtonEnum.YesNo,
ContentTitle = "Exit",
ContentMessage = message,
Icon = Icon.Info,
Style = Style.None,
ShowInCenter = true
});
var result = await msgbox.Show();
if(result.ToLower() == "yes")
Application.Current.MainWindow.Close();
}

private void OpenUrl(string url)
{
try
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
System.Diagnostics.Process.Start(url);
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ||
RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
System.Diagnostics.Process.Start("x-www-browser", url);
}
}
catch (Exception e)
{
Console.WriteLine(e);
}

}

private void UpdateUi()
{
/*TODO: Вынести сюда все функции обновления UI*/
Expand Down
7 changes: 4 additions & 3 deletions RescuerLaApp/Views/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@
<MenuItem Name="mFileOpen" Header="Open directory..." Command="{Binding OpenFileCommand}"/>
<MenuItem Name="mFileExportAll" Header="Import all from XML..." Command="{Binding ImportAllCommand}"/>
<MenuItem Name="mFileSave" Header="Save all" Command="{Binding SaveAllCommand}"/>
<MenuItem Name="mFileSaveAllImagesWithObjects" Header="Save only images with pedestrians" Command="{Binding SaveAllImagesWithObjectsCommand}"/>
<Separator></Separator>
<MenuItem Name="mFileExit" Header="Exit"/>
<MenuItem Name="mFileExit" Header="Exit" Command="{Binding ExitCommand}"/>
</MenuItem>
<MenuItem Name="mModel" Header="Model">
<MenuItem Name="mModelLoad" Header="Load model..." Command="{Binding LoadModelCommand}"/>
Expand All @@ -41,9 +42,9 @@
<MenuItem Name="mImagePrev" Header="Prev" Command="{Binding PrevImageCommand}"/>
</MenuItem>
<MenuItem Name="mHelp" Header="Help">
<MenuItem Name="mHelpOpen" Header="Open user guide"/>
<MenuItem Name="mHelpOpen" Header="Open user guide" Command="{Binding HelpCommand}"/>
<Separator></Separator>
<MenuItem Name="mHelpAbout" Header="About"/>
<MenuItem Name="mHelpAbout" Header="About" Command="{Binding AboutCommand}"/>
</MenuItem>
</Menu>
<ToolTip>
Expand Down
2 changes: 1 addition & 1 deletion RetinaNet/config.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[anchor_parameters]
sizes = 16 32 64 128
sizes = 16 32 64 128 256
strides = 8 16 32 64 128
ratios = 0.5 1 2 3
scales = 1 1.2 1.6

0 comments on commit 32c79cf

Please sign in to comment.