diff --git a/PointCloudWeb.Server/PointCloudWeb.Server/Services/PointCloudRegistrationServiceTeaerPp.cs b/PointCloudWeb.Server/PointCloudWeb.Server/Services/PointCloudRegistrationServiceTeaerPp.cs index 74555f3..100595c 100644 --- a/PointCloudWeb.Server/PointCloudWeb.Server/Services/PointCloudRegistrationServiceTeaerPp.cs +++ b/PointCloudWeb.Server/PointCloudWeb.Server/Services/PointCloudRegistrationServiceTeaerPp.cs @@ -1,5 +1,6 @@ using System; using System.Diagnostics; +using System.IO; using System.Linq; using PointCloudWeb.Server.Models; @@ -14,26 +15,84 @@ namespace PointCloudWeb.Server.Services var maxPoints = 5_000; + + // var p = new Process(); + // var info = new ProcessStartInfo + // { + // FileName = "cmd.exe", + // RedirectStandardInput = true, + // RedirectStandardOutput = true, + // UseShellExecute = false, + // Verb = "OPEN", + // CreateNoWindow = false, + // WindowStyle = ProcessWindowStyle.Normal + // }; + // p.StartInfo = info; + // p.Start(); + // + // using var sw = p.StandardInput; + // if (sw.BaseStream.CanWrite) + // { + // // sw.Write("wsl \n"); + // // sw.Write("echo \"Test\" \n"); + // // sw.Write("echo curl https://www.google.de \n"); + // // sw.Write("exit \n"); + // // sw.Write("exit \n"); + // + // //sw.Write("wsl curl https://www.google.de & exit \n"); + // + // sw.Write("wsl echo \"Test\" >> /mnt/c/Users/timwu/test.txt & exit \n"); + // + // } + // + // + // var outputN = p.StandardOutput.ReadToEnd(); + // Console.WriteLine(outputN[..Math.Min(outputN.Length, 100)]); + // + // p.WaitForExit(); + // + // Console.WriteLine($"RegistrationExitCode: {p.ExitCode}"); + source.WriteToPly(sourceFileName, maxPoints); target.WriteToPly(targetFileName, maxPoints); + // var teaserPp = new Process(); + // teaserPp.StartInfo.FileName = "C:\\Windows\\System32\\wsl.exe"; + // // teaserPp.StartInfo.FileName = "wsl"; + // teaserPp.StartInfo.Arguments = "curl https://www.google.de"; + // // teaserPp.StartInfo.Arguments = $"\"{sourceFileName}\" \"{targetFileName}\""; + // //teaserPp.StartInfo.Arguments = $" ls "; //{Globals.ToWslPath(Globals.TeaserPp)} ";// + + // //"\"/mnt/c/Users/timwu/source/repos/PointCloudWeb/PointCloudWeb.Server/Tools/TEASERpp/c4b9b7fc-0b97-4f52-ad1b-737aeca5ba97.ply\" " + + // //"\"/mnt/c/Users/timwu/source/repos/PointCloudWeb/PointCloudWeb.Server/Tools/TEASERpp/c620b175-ace8-42e5-bf29-55b6c99372bc.ply\" "; + // + // teaserPp.StartInfo.RedirectStandardOutput = true; + // teaserPp.Start(); + // + // + // var output = teaserPp.StandardOutput.ReadToEnd(); + // Console.WriteLine(output[..Math.Min(output.Length, 100)]); + // + // + // teaserPp.WaitForExit(); + // + // Console.WriteLine($"RegistrationExitCode: {teaserPp.ExitCode}"); + + var teaserPp = new Process(); - teaserPp.StartInfo.FileName = "C:\\Windows\\System32\\wsl.exe"; - // teaserPp.StartInfo.FileName = "wsl"; - teaserPp.StartInfo.Arguments = "curl https://www.google.de"; - // teaserPp.StartInfo.Arguments = $"\"{sourceFileName}\" \"{targetFileName}\""; - //teaserPp.StartInfo.Arguments = $" ls "; //{Globals.ToWslPath(Globals.TeaserPp)} ";// + - //"\"/mnt/c/Users/timwu/source/repos/PointCloudWeb/PointCloudWeb.Server/Tools/TEASERpp/c4b9b7fc-0b97-4f52-ad1b-737aeca5ba97.ply\" " + - //"\"/mnt/c/Users/timwu/source/repos/PointCloudWeb/PointCloudWeb.Server/Tools/TEASERpp/c620b175-ace8-42e5-bf29-55b6c99372bc.ply\" "; - - teaserPp.StartInfo.RedirectStandardOutput = true; + teaserPp.StartInfo.FileName = "wsl"; + teaserPp.StartInfo.Arguments = + $"{Globals.ToWslPath(Globals.TeaserPp)} " + + "\"/mnt/c/Users/timwu/source/repos/PointCloudWeb/PointCloudWeb.Server/Tools/TEASERpp/c4b9b7fc-0b97-4f52-ad1b-737aeca5ba97.ply\" " + + "\"/mnt/c/Users/timwu/source/repos/PointCloudWeb/PointCloudWeb.Server/Tools/TEASERpp/c620b175-ace8-42e5-bf29-55b6c99372bc.ply\" "; + + // teaserPp.StartInfo.RedirectStandardOutput = true; teaserPp.Start(); - var output = teaserPp.StandardOutput.ReadToEnd(); - Console.WriteLine(output[..Math.Min(output.Length, 100)]); - - + // var output = teaserPp.StandardOutput.ReadToEnd(); + // Console.WriteLine(output[..Math.Min(output.Length, 100)]); + + teaserPp.WaitForExit(); Console.WriteLine($"RegistrationExitCode: {teaserPp.ExitCode}"); diff --git a/PointCloudWeb.Server/Tools/TEASERpp/teaser_cpp_ply.cc b/PointCloudWeb.Server/Tools/TEASERpp/teaser_cpp_ply.cc index c72e7a5..b48b036 100644 --- a/PointCloudWeb.Server/Tools/TEASERpp/teaser_cpp_ply.cc +++ b/PointCloudWeb.Server/Tools/TEASERpp/teaser_cpp_ply.cc @@ -23,6 +23,10 @@ inline double getAngularError(Eigen::Matrix3d R_exp, Eigen::Matrix3d R_est) int main(int argc, char **argv) { + std::ofstream out("/mnt/c/Users/timwu/source/repos/PointCloudWeb/PointCloudWeb.Server/Tools/TEASERpp/build/out.txt"); + std::streambuf *coutbuf = std::cout.rdbuf(); //save old buf + std::cout.rdbuf(out.rdbuf()); //redirect std::cout to out.txt! + std::cout << "You have entered " << argc << " arguments:" << "\n"; @@ -91,4 +95,7 @@ int main(int argc, char **argv) << std::chrono::duration_cast(end - begin).count() / 1000000.0 << std::endl; + + //reset to standard output again, otherwise an error occurs + std::cout.rdbuf(coutbuf); }