Skip to content

Commit 774353d

Browse files
committed
clarify and clean up spew
1 parent ec8384e commit 774353d

File tree

5 files changed

+60
-16
lines changed

5 files changed

+60
-16
lines changed

RockCollect/Stages/ImageThreshold.cs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ public override bool SaveOutput()
137137
// shadow blob
138138
string shadowBlobPath = Path.Combine(GetDirectory(Dir.Output), "shadowBlobs.ppm");
139139
int numShadows = 0;
140+
141+
Console.WriteLine("running rock detector on tile to make shadow blob image");
142+
140143
if(0 == RockDetector.shadows_from_files(shadowPath, shadowBlobPath, ref numShadows)) //BUGBUG: pre-splitting ids...wont match
141144
{
142145
throw new Exception("Failed to generate shadow blob image");
@@ -190,6 +193,10 @@ public Dictionary<float, int> SweepShadowBlobsForGamma(float stepSize, string sh
190193
GammaThresholdOverride = RockDetector.DISABLE_GAMMA_THRESH_OVERRIDE
191194
};
192195

196+
Console.WriteLine(string.Format("running rock detector on tile {0} times with gamma {1} to {2} " +
197+
"to compute shadow blob pixels by gamma",
198+
steps, MIN_GAMMA, MAX_GAMMA));
199+
193200
for (int idxStep = 0; idxStep < steps; idxStep++)
194201
{
195202
settings.Gamma = MIN_GAMMA + idxStep * stepSize;
@@ -223,10 +230,15 @@ public Dictionary<float, int> SweepShadowPixelsForGamma(float stepSize, string s
223230

224231
float range = MAX_GAMMA - MIN_GAMMA;
225232
int steps = (int)Math.Ceiling(range / stepSize);
233+
234+
Console.WriteLine(string.Format("running rock detector on tile {0} times with gamma {1} to {2} " +
235+
"to compute shadow pixels by gamma",
236+
steps, MIN_GAMMA, MAX_GAMMA));
237+
226238
for (int idxStep = 1; idxStep < steps; idxStep++) //gamma 0 is too many pixels
227239
{
228240
float gamma = MIN_GAMMA + idxStep * stepSize;
229-
var tmpImage = CreateShadowImage(TilePath, shadowPath, gamma, 0, out int thresholdInGamma);
241+
var tmpImage = CreateShadowImage(TilePath, shadowPath, gamma, 0, out int thresholdInGamma, true);
230242
int shadowPixels = 0;
231243
for (int idxPixel = 0; idxPixel < tmpImage.Width * tmpImage.Height; idxPixel++)
232244
{
@@ -321,6 +333,8 @@ private Image CreateGammaImage(string tilePath, string gammaPath)
321333
File.Delete(gammaPath);
322334
}
323335

336+
Console.WriteLine("running rock detector on tile to make gamma image");
337+
324338
if( 0 == RockDetector.gamma_from_files(tilePath, Gamma, gammaPath))
325339
{
326340
throw new Exception("failed to make gamma image");
@@ -341,7 +355,7 @@ private Image CreateGammaImage(string tilePath, string gammaPath)
341355
return gammaImage;
342356
}
343357

344-
private Image CreateShadowImage(string tilePath, string shadowPath, float gamma, int thresholdOverride, out int thresholdInGamma)
358+
private Image CreateShadowImage(string tilePath, string shadowPath, float gamma, int thresholdOverride, out int thresholdInGamma, bool quiet = false)
345359
{
346360
if (!File.Exists(tilePath))
347361
{
@@ -353,6 +367,11 @@ private Image CreateShadowImage(string tilePath, string shadowPath, float gamma,
353367
File.Delete(shadowPath);
354368
}
355369

370+
if (!quiet)
371+
{
372+
Console.WriteLine("running rock detector on tile to make shadow image");
373+
}
374+
356375
thresholdInGamma = 0;
357376
if (0 == RockDetector.threshold_from_files(tilePath, gamma, thresholdOverride, shadowPath, ref thresholdInGamma))
358377
{

RockCollect/Stages/RefineShadows.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,9 @@ bool UpdateDetections(out RockDetector.DetectionResults results)
133133
return false;
134134

135135
results = new RockDetector.DetectionResults("Shadows", TileImage.Width, TileImage.Height);
136-
136+
137+
Console.WriteLine("running rock detector on tile to refine shadows");
138+
137139
int numOutRocks = 0;
138140
RockDetector.INSETTINGS inSettings = RockDetector.CreateInSettings(settings);
139141
byte[] detectImage = new byte[TileImage.Width * TileImage.Height];

RockCollect/Stages/ReviewRocks.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ private bool UpdateDetections(out RockDetector.DetectionResults results, out Bit
364364

365365
results = new RockDetector.DetectionResults("Yours", TileImage.Width, TileImage.Height);
366366

367+
Console.WriteLine("running rock detector on tile to review rock detections");
367368

368369
int numOutRocks = 0;
369370
RockDetector.INSETTINGS inSettings = RockDetector.CreateInSettings(settings);
@@ -500,6 +501,9 @@ public override bool SaveOutput()
500501
InputToOutput("TILES_VERTICAL");
501502
InputToOutput("COMPARISON_ROCKLIST");
502503

504+
Console.WriteLine(string.Format("saving detection settings for tile to \"{0}\" and \"{1}\"",
505+
outJSONPath, outParamsPath));
506+
503507
if (!WriteOutputJSON())
504508
return false;
505509

@@ -509,6 +513,9 @@ public override bool SaveOutput()
509513
return false;
510514
}
511515

516+
Console.WriteLine(string.Format("running rock detector on tile, saving rock list to \"{0}\"",
517+
outRocksListPath));
518+
512519
if(0 == RockDetector.detect_from_files(TilePath, outParamsPath, outRocksListPath))
513520
{
514521
return false;

RockCollect/Stages/TileSelect.cs

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -220,14 +220,18 @@ public int CountTunedTiles()
220220

221221
internal void SaveRocklist(string fileName)
222222
{
223+
Console.WriteLine(string.Format("running rock detector on all runnable tiles, " +
224+
"saving resulting rocklist to \"{0}\"", fileName));
225+
223226
int numTiles = TilesVertical * TilesHorizontal;
224227
var inSettings = new RockDetector.INSETTINGS[numTiles];
225228
var loaded = new bool[numTiles];
226229

227230
var tsd = TileShapeData;
228231
var writeJSONOpts = new JsonSerializerOptions { WriteIndented = true };
229232

230-
Console.WriteLine("loading settings for already-tuned tiles from " + GetDirectory(Dir.FinalOutput));
233+
Console.WriteLine(string.Format("loading settings for already-tuned tiles from \"{0}\"",
234+
GetDirectory(Dir.FinalOutput)));
231235
int numLoaded = 0;
232236
for (int y = 0; y < TilesVertical; y++)
233237
{
@@ -294,6 +298,7 @@ internal void SaveRocklist(string fileName)
294298
}
295299
}
296300

301+
int nc = 0, nf = 0;
297302
for (int y = 0; y < TilesVertical; y++)
298303
{
299304
for (int x = 0; x < TilesHorizontal; x++)
@@ -313,8 +318,8 @@ internal void SaveRocklist(string fileName)
313318
int maxRadius = Math.Max(x, y);
314319
maxRadius = Math.Max(maxRadius, TilesHorizontal - x - 1);
315320
maxRadius = Math.Max(maxRadius, TilesVertical - y - 1);
316-
Console.WriteLine(string.Format("searching for tuned neighbor of tile at col {0}, row {1}, " +
317-
"max radius {2}{3}", x, y, maxRadius, grpMsg));
321+
// Console.WriteLine(string.Format("searching for tuned neighbor of tile at col {0}, row {1}, " +
322+
// "max radius {2}{3}", x, y, maxRadius, grpMsg));
318323
int ni = -1;
319324
for (int radius = 1; radius <= maxRadius && ni < 0; radius++)
320325
{
@@ -346,8 +351,8 @@ internal void SaveRocklist(string fileName)
346351
if (ni >= 0)
347352
{
348353
GetTileAddress(ni, out int nx, out int ny);
349-
Console.WriteLine(string.Format("copying settings for tuned tile at col {0}, row {1} " +
350-
"for tile at col {2}, row {3}{4}", nx, ny, x, y, grpMsg));
354+
// Console.WriteLine(string.Format("copying settings for tuned tile at col {0}, row {1} " +
355+
// "for tile at col {2}, row {3}{4}", nx, ny, x, y, grpMsg));
351356
inSettings[idx] = inSettings[ni];
352357
string srcName = ReviewRocks.GetTileOutputName(ni, TilesHorizontal) + ".json";
353358
string srcJSON = Path.Combine(GetDirectory(Dir.FinalOutput), srcName);
@@ -362,29 +367,39 @@ internal void SaveRocklist(string fileName)
362367
string dstName = ReviewRocks.GetTileOutputName(idx, TilesHorizontal) + ".json";
363368
string dstJSON = Path.Combine(dir, dstName);
364369
File.WriteAllText(dstJSON, JsonSerializer.Serialize(data, data.GetType(), writeJSONOpts));
370+
nc++;
365371
}
366372
else
367373
{
368374
//MaxShadowArea = 0 will cause RockDetector.detect_per_tile_settings() to ignore the tile
369375
Console.WriteLine(string.Format("failed to find tuned tile from which to copy settings " +
370376
"for tile at col {0}, row {1}{2}", x, y, grpMsg));
377+
nf++;
371378
}
372379
}
373380
}
374381
}
375382

376-
//MaxShadowArea = 0 will cause RockDetector.detect_per_tile_settings() to ignore the tile
377-
if (tsd != null) {
378-
for (int y = 0; y < TilesVertical; y++)
383+
Console.WriteLine(string.Format("copied settings for {0} un-tuned tiles from nearest tuned neighbor{1}",
384+
nc, tsd != null ? " in same shape file group" : ""));
385+
Console.WriteLine(string.Format("failed to copy settings for {0} un-tuned tiles from any tuned neighbor{1}",
386+
nf, tsd != null ? " in same shape file group" : ""));
387+
388+
int nr = 0;
389+
for (int y = 0; y < TilesVertical; y++)
390+
{
391+
for (int x = 0; x < TilesHorizontal; x++)
379392
{
380-
for (int x = 0; x < TilesHorizontal; x++)
381-
{
382-
int idx = GetTileIndex(x, y);
383-
if (tsd[idx] == null || !tsd[idx].run) inSettings[idx].MaxShadowArea = 0;
384-
}
393+
int idx = GetTileIndex(x, y);
394+
//MaxShadowArea = 0 will cause RockDetector.detect_per_tile_settings() to ignore the tile
395+
if (tsd != null && (tsd[idx] == null || !tsd[idx].run)) inSettings[idx].MaxShadowArea = 0;
396+
else if (inSettings[idx].MaxShadowArea > 0) nr++;
385397
}
386398
}
387399

400+
Console.WriteLine(string.Format("running rock detector on {0} runnable of {1} total tiles, " +
401+
"saving resulting rocklist to \"{2}\"", nr, numTiles, fileName));
402+
388403
RockDetector.detect_per_tile_settings(ImagePath, fileName, numTiles, inSettings);
389404
//TODO: warn
390405
}

RockCollect/Workflow.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ public void NextStage()
7272
{
7373
Directory.CreateDirectory(CurImageDirectory);
7474
}
75+
Console.WriteLine("saving per-tile settings and results at \"{0}\"", CurImageDirectory);
7576
}
7677

7778
Stage nextStage = null;

0 commit comments

Comments
 (0)