Reality Capture Terasque: Progress Files No Longer Writable/Readable Through CLI

After upgrading our farm to RC Tarasque, progress files are causing errors in Reality Capture:

Error Parsing or Executing Commandline Batch

The Process cannon access the file because it is being used by another process. Please try again later.

Details:
My automation pipeline creates a temp progressfile that reads while RC writes to it. The automation pipeline opens the file but ensures it’s not locked from other processes. This worked just fine in RC Blaze but I now encounter this error in Terasque.

Thank you for reporting this, it’s possibly connected to a new command -stdConsole which mirrors the RC console in the windows command line console

edit: I’m not sure if it would be possible for you to use this new command instead to gather the data you need?

It would be nice to not have to change the pipeline and logging system I have. I’ll look into the new command.

Hi Wallace,

This new command you mentioned (-stdConsole) doesn’t seem to be documented. 

I need to measure the progress the same way -writeProgress does, but RC doesn’t allow me to read from that file it writes. That really seems like a bug because it defeats the purpose of the command.

What are the alternatives?

Hi Quantum Theory,

there is a description about this command on our site: - Enable console redirection to the application standard output. When used, you will see the application console content mirrored also in the standard Windows console. This also enables further redirections for CLI purposes.

It will do something like this:

What file do you use for writeProgress command? I used txt and I am able to open it and read it.

 

I write progress to .tmp files in the user’s local/temp folder along side the realitycapture.log file. No level of file permissions allows me to read it or share it with RC for some reason. This worked fine until Terasque.

I tried -stdConsole and yes, it writes fine, but I need to ingest that data and check for status completions. The logging appears only after RC exits if I attempt to redirect the standardoutput. After looking into it, it appears there is a limitation with c# processes and flushing the buffer, so this is a bit of a downer.

Instead I parse the realitycapture.log file now and wait for conditions. Not ideal but that’s what works. I would still classify this as a bug since I can read the log file as it’s written, but not progress files.

 

Hi, is it possible to send us your script?

It’s part of my code, not a batch file, but i’ll post some of the code here.

The line where it tries to open the progress file in WaitForProgressComplete() is commented to show when RC stops. The fileaccess and fileshare options are set properly so that my application does not lock the file. I assume Reality Capture is locking the file.

Log.Event("Image Alignment");
string progressFile = Path.GetTempFileName();
string args = "";
args += " -writeProgress " + "\"" + progressFile + "\"" + " 5";
args += " -align";
Process p = new Process();
p.StartInfo.Arguments = "-delegateTo " + GUID +" " + args;
p.StartInfo.FileName = u.Path_RealityCapture;
p.Start();
WaitForProgressComplete(progressFile, true);


public void WaitForProgressComplete(string file, bool verboseOutput=false)
{
Log.Info("Reading Progress File");
//wait for the file to show up
while (File.Exists(file) == false)
{
if (isRunning == false)
break;
}
if (isRunning)
{
//This is where Reality Capture stops and notifies me it can't open the progress file in Terasque.
//However, it worked just fine in previous versions.
using (var fs = new FileStream(file, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite))//, FileShare.ReadWrite)) //, FileShare.Delete))
{
using (var reader = new StreamReader(fs))
{
while (true)
{
var line = reader.ReadLine();

if (!String.IsNullOrWhiteSpace(line))
{
if (verboseOutput)
Console.WriteLine("Line read: " + line);
if (line.Contains("completed"))
break;
if (isRunning == false)
{
Console.Write("Ending progress file reading");
break;
}
}
else if (isRunning==false)
{
break;
}
}
}
}
//});
}

Console.WriteLine("Done Watching Progress File");
}

Thank your for reporting the issues regarding the progress file, and the delay when using the stdConsole command.
It was recently reported to us that there may be an issue with the progress file, when operating RealityCapture through Command Line, and we are testing it to see what exactly is the issue. Your report on this problem will help us a lot, and I want to apologize, that I don’t have any straightforward answer at the moment. Once we have tested this out, and found the best workflow to define this issue, we will file it us a bug so our developers can fix it.

If you believe it may help, you can download an older version of RealityCapture here:
https://support.capturingreality.com/hc/en-us/articles/360020519640-Version-1-1-1-15122-Blaze-Release

Thanks Ondrej. I’ll await the response!

Also, I’ve been trying to parse in the output from -stdConsole lately and I think Reality Capture may have an issue related to that.

In C#, to parse the console output, the StandardOutput needs to be set to redirect to the process’s StandardOutput stream. Setup properly, however, the console output is not made until Reality Capture exits. When I choose not to redirect the standardoutput, the log data appears just fine but I’m not able to parse it in code.

Some info that might lead to a resolution:

https://stackoverflow.com/questions/22080431/redirectstandardoutput-doesnt-fire-until-console-process-finishes

“A redirected program writes its output into an internal buffer. If it doesn’t write enough text to fill the buffer to capacity, and doesn’t itself force the buffer to flush, then you won’t see anything until the buffer has to be flushed, at program exit. Nothing you can do about that if you don’t have the source code for the program”

Hello, 

381284867620, 374823146340, 375240618100

I see this issue was raised 8 months ago, has it been resolved?

Thank you

Hi Kiran, this should be solved in the next release.