Skip to content

Commit 14a3c4b

Browse files
committed
add support for LAZ Intensity, create output folder if doesnt exists, byte packing tests (not enabled yet), #BUILD
1 parent 27b04ec commit 14a3c4b

File tree

10 files changed

+201
-39
lines changed

10 files changed

+201
-39
lines changed

App.config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@
9191
<setting name="lastExportFolder" serializeAs="String">
9292
<value />
9393
</setting>
94+
<setting name="importIntensity" serializeAs="String">
95+
<value>False</value>
96+
</setting>
97+
<setting name="importRGB" serializeAs="String">
98+
<value>True</value>
99+
</setting>
94100
</PointCloudConverter.Properties.Settings>
95101
</userSettings>
96102
</configuration>

MainWindow.xaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
<Label x:Name="label_Copy2" Content="Import format:&#xA;" HorizontalAlignment="Left" Margin="719,22,0,0" VerticalAlignment="Top" Foreground="{DynamicResource MainText}" Height="26"/>
2121

2222
<StackPanel HorizontalAlignment="Left" Height="238" Margin="20,198,0,0" VerticalAlignment="Top" Width="277">
23+
<StackPanel Orientation="Horizontal">
24+
<CheckBox x:Name="chkImportRGB" Content="Read RGB" HorizontalAlignment="Left" VerticalAlignment="Top" Foreground="{DynamicResource MainText}" IsChecked="True" ToolTip="Reads RGB color values" Checked="chkImportRGB_Checked" Unchecked="chkImportRGB_Unchecked"/>
25+
<CheckBox x:Name="chkImportIntensity" Content="Read Intensity" HorizontalAlignment="Left" VerticalAlignment="Top" Foreground="{DynamicResource MainText}" IsChecked="False" ToolTip="Reads Intensity as Color value" Checked="chkImportIntensity_Checked" Unchecked="chkImportIntensity_Unchecked"/>
26+
</StackPanel>
2327
<CheckBox x:Name="chkAutoOffset" Content="Auto-Offset" HorizontalAlignment="Left" VerticalAlignment="Top" Foreground="{DynamicResource MainText}" IsChecked="True" ToolTip="Auto-offsets cloud near 0,0,0 by using the first point as offset value"/>
2428
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Orientation="Horizontal"/>
2529
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Orientation="Horizontal"/>
@@ -75,7 +79,7 @@
7579
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Orientation="Horizontal"/>
7680
<CheckBox x:Name="chkPackColors" Content="Pack Colors" HorizontalAlignment="Left" VerticalAlignment="Top" Foreground="{DynamicResource MainText}" ToolTip="Packs color values, improves performance in viewer (but can cause lower precision positions and colors). Requires using special packed material&amp;shader in viewer"/>
7781
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Orientation="Horizontal">
78-
<CheckBox x:Name="chkUsePackMagic" Content="PackMagic:" HorizontalAlignment="Left" VerticalAlignment="Top" Foreground="{DynamicResource MainText}" ToolTip="Optional packing adjustment MagicInteger. Increase this value is you have large tiles and notice precision issues with packed data"/>
82+
<CheckBox x:Name="chkUsePackMagic" Content="PackMagic:" HorizontalAlignment="Left" VerticalAlignment="Top" Foreground="{DynamicResource MainText}" ToolTip="Optional packing adjustment MagicInteger. Increase this value is you have large tiles and notice precision or color issues with packed data"/>
7983
<TextBox x:Name="txtPackMagic" HorizontalAlignment="Left" Margin="0" TextWrapping="Wrap" VerticalAlignment="Top" Width="40" Text="64"/>
8084
</StackPanel>
8185
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Orientation="Horizontal"/>

MainWindow.xaml.cs

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace PointCloudConverter
1515
{
1616
public partial class MainWindow : Window
1717
{
18-
static string appname = "PointCloud Converter v1.75";
18+
static string appname = "PointCloud Converter v1.76";
1919
static readonly string rootFolder = AppDomain.CurrentDomain.BaseDirectory;
2020

2121
// allow console output from WPF application https://stackoverflow.com/a/7559336/5452781
@@ -30,6 +30,8 @@ public partial class MainWindow : Window
3030
Thread workerThread;
3131
static bool abort = false;
3232
public static MainWindow mainWindowStatic;
33+
bool isInitialiazing = true;
34+
3335

3436
public MainWindow()
3537
{
@@ -265,6 +267,8 @@ void StartProcess(bool doProcess = true)
265267
args.Add("-output=" + txtOutput.Text);
266268

267269
args.Add("-offset=" + (bool)chkAutoOffset.IsChecked);
270+
args.Add("-rgb=" + (bool)chkImportRGB.IsChecked);
271+
args.Add("-intensity=" + (bool)chkImportIntensity.IsChecked);
268272

269273
if (cmbExportFormat.SelectedItem.ToString().ToUpper().Contains("PCROOT")) args.Add("-gridsize=" + txtGridSize.Text);
270274

@@ -436,6 +440,9 @@ private void LoadSettings()
436440
txtInputFile.Text = Properties.Settings.Default.inputFile;
437441
txtOutput.Text = Properties.Settings.Default.outputFile;
438442

443+
chkImportRGB.IsChecked = Properties.Settings.Default.importRGB;
444+
chkImportIntensity.IsChecked = Properties.Settings.Default.importIntensity;
445+
439446
chkAutoOffset.IsChecked = Properties.Settings.Default.useAutoOffset;
440447
txtGridSize.Text = Properties.Settings.Default.gridSize.ToString();
441448
chkUseMinPointCount.IsChecked = Properties.Settings.Default.useMinPointCount;
@@ -455,6 +462,8 @@ private void LoadSettings()
455462
chkUseMaxFileCount.IsChecked = Properties.Settings.Default.useMaxFileCount;
456463
txtMaxFileCount.Text = Properties.Settings.Default.maxFileCount.ToString();
457464
chkRandomize.IsChecked = Properties.Settings.Default.randomize;
465+
466+
isInitialiazing = false;
458467
}
459468

460469
void SaveSettings()
@@ -509,5 +518,44 @@ private void cmbExportFormat_SelectionChanged(object sender, SelectionChangedEve
509518
// updatae file extension, if set
510519
txtOutput.Text = Path.ChangeExtension(txtOutput.Text, "." + cmbExportFormat.SelectedValue.ToString().ToLower());
511520
}
521+
522+
private void chkImportRGB_Checked(object sender, RoutedEventArgs e)
523+
{
524+
// not available at init
525+
if (isInitialiazing == true) return;
526+
527+
chkImportIntensity.IsChecked = false;
528+
Properties.Settings.Default.importRGB = true;
529+
Properties.Settings.Default.Save();
530+
}
531+
532+
private void chkImportIntensity_Checked(object sender, RoutedEventArgs e)
533+
{
534+
if (isInitialiazing == true) return;
535+
536+
chkImportRGB.IsChecked = false;
537+
Properties.Settings.Default.importIntensity = true;
538+
Properties.Settings.Default.Save();
539+
}
540+
541+
private void chkImportIntensity_Unchecked(object sender, RoutedEventArgs e)
542+
{
543+
if (isInitialiazing == true) return;
544+
Properties.Settings.Default.importIntensity = false;
545+
546+
chkImportRGB.IsChecked = true;
547+
Properties.Settings.Default.importRGB = true;
548+
Properties.Settings.Default.Save();
549+
}
550+
551+
private void chkImportRGB_Unchecked(object sender, RoutedEventArgs e)
552+
{
553+
if (isInitialiazing == true) return;
554+
Properties.Settings.Default.importRGB = false;
555+
556+
chkImportIntensity.IsChecked = true;
557+
Properties.Settings.Default.importIntensity = true;
558+
Properties.Settings.Default.Save();
559+
}
512560
} // class
513561
} // namespace

Properties/Settings.Designer.cs

Lines changed: 25 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Properties/Settings.settings

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,5 +83,11 @@
8383
<Setting Name="lastExportFolder" Type="System.String" Scope="User">
8484
<Value Profile="(Default)" />
8585
</Setting>
86+
<Setting Name="importIntensity" Type="System.Boolean" Scope="User">
87+
<Value Profile="(Default)">False</Value>
88+
</Setting>
89+
<Setting Name="importRGB" Type="System.Boolean" Scope="User">
90+
<Value Profile="(Default)">True</Value>
91+
</Setting>
8692
</Settings>
8793
</SettingsFile>

Readers/LAZ.cs

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,15 @@ public class LAZ : IReader
1717
{
1818
laszip_dll lazReader = new laszip_dll();
1919
bool compressed = false;
20+
bool importRGB = true;
21+
//bool importIntensity = false;
2022

2123
bool IReader.InitReader(ImportSettings importSettings, int fileIndex)
2224
{
2325
// TODO check errors
2426
var file = importSettings.inputFiles[fileIndex];
27+
importRGB = importSettings.importRGB;
28+
//importIntensity = importSettings.readIntensity;
2529
lazReader.laszip_open_reader(file, ref compressed);
2630
return true;
2731
}
@@ -54,19 +58,30 @@ Color IReader.GetRGB()
5458
// get point reference
5559
var p = lazReader.point;
5660

57-
// try to detect if colors are outside 0-255 range?
58-
if (p.rgb[0].ToString("X").Length > 2)
61+
if (importRGB == true)
5962
{
60-
c.r = Tools.LUT255[(byte)(p.rgb[0] / 256f)];
61-
c.g = Tools.LUT255[(byte)(p.rgb[1] / 256f)];
62-
c.b = Tools.LUT255[(byte)(p.rgb[2] / 256f)];
63+
// try to detect if colors are outside 0-255 range? TODO just check value?
64+
if (p.rgb[0].ToString("X").Length > 2)
65+
{
66+
c.r = Tools.LUT255[(byte)(p.rgb[0] / 256f)];
67+
c.g = Tools.LUT255[(byte)(p.rgb[1] / 256f)];
68+
c.b = Tools.LUT255[(byte)(p.rgb[2] / 256f)];
69+
}
70+
else // its 0-255
71+
{
72+
c.r = Tools.LUT255[(byte)(p.rgb[0])];
73+
c.g = Tools.LUT255[(byte)(p.rgb[1])];
74+
c.b = Tools.LUT255[(byte)(p.rgb[2])];
75+
}
6376
}
64-
else // its 0-255
77+
else // use intensity
6578
{
66-
c.r = Tools.LUT255[(byte)(p.rgb[0])];
67-
c.g = Tools.LUT255[(byte)(p.rgb[1])];
68-
c.b = Tools.LUT255[(byte)(p.rgb[2])];
79+
float i = Tools.LUT255[(byte)(p.intensity)];
80+
c.r = i;
81+
c.g = i;
82+
c.b = i;
6983
}
84+
7085
return c;
7186
}
7287

Structs/ImportSettings.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ public class ImportSettings
3030
// TODO these should be export settings..
3131

3232
public bool swapYZ = true;
33-
public readonly bool readRGB = true; // NOTE always on for now
33+
public bool importRGB = true; // this or intensity must be on
34+
public bool importIntensity = false;
3435
public bool useAutoOffset = true;
3536
public float offsetX = 0;
3637
public float offsetY = 0;
@@ -61,7 +62,8 @@ public override string ToString()
6162
t += "\n inputFiles=" + inputFiles;
6263
t += "\n outputFile=" + outputFile;
6364
t += "\n swapYZ=" + swapYZ;
64-
t += "\n readRGB=" + readRGB;
65+
t += "\n readRGB=" + importRGB;
66+
t += "\n readIntensity=" + importIntensity;
6567
t += "\n useAutoOffset=" + useAutoOffset;
6668
t += "\n offsetX=" + offsetX;
6769
t += "\n offsetY=" + offsetY;

Tools/ArgParser.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,32 @@ public static ImportSettings Parse(string[] args, string rootFolder)
493493
{
494494
importSettings.randomize = (param == "true");
495495
}
496+
break;
497+
498+
case "-rgb":
499+
Console.WriteLine("rgb = " + param);
500+
501+
if (param != "false" && param != "true")
502+
{
503+
errors.Add("Invalid rgb parameter: " + param);
504+
}
505+
else
506+
{
507+
importSettings.importRGB = (param == "true");
508+
}
509+
break;
510+
511+
case "-intensity":
512+
Console.WriteLine("intensity = " + param);
513+
514+
if (param != "false" && param != "true")
515+
{
516+
errors.Add("Invalid intensity parameter: " + param);
517+
}
518+
else
519+
{
520+
importSettings.importIntensity = (param == "true");
521+
}
496522
break;
497523

498524
case "?":
@@ -576,6 +602,12 @@ public static ImportSettings Parse(string[] args, string rootFolder)
576602
errors.Add("No export format defined (Example: -exportformat" + argValueSeparator + "UCPC)");
577603
}
578604

605+
// cannot have both rgb & intensity
606+
if (importSettings.importRGB == true && importSettings.importIntensity == true)
607+
{
608+
errors.Add("Cannot have both -rgb and -intensity enabled");
609+
}
610+
579611
//// check mismatching settings for v2 vs v3
580612
//if (importSettings.exportFormat == ExportFormat.UCPC)
581613
//{

Tools/Tools.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ public static void PrintHelpAndExit(char argSeparator, bool waitEnter = false)
174174
Console.WriteLine("-importformat" + argSeparator + "laz\tSupported import formats: LAZ, LAS)\tDefault is LAS/LAZ");
175175
Console.WriteLine("-exportformat" + argSeparator + "ucpc\tSupported export formats: UCPC (v2), PCROOT (v3))\tDefault is UCPC (v2)");
176176
Console.WriteLine("-output" + argSeparator + "yourfile.ucpc\t(Default is same folder as input file. For v3 you dont need to set file extension)");
177+
Console.WriteLine("-rgb" + argSeparator + "true or false\tReads RGB colors\tDefault is true");
178+
Console.WriteLine("-intensity" + argSeparator + "true or false\tReads Intensity as RGB color\tDefault is false");
177179
Console.WriteLine("-offset" + argSeparator + "true or false\tAuto-offsets cloud near 0,0,0 by using the first point as offset value\tDefault is true");
178180
Console.WriteLine("-gridsize" + argSeparator + "5\t\tGridsize in meters, splits cloud into tiles with this size. v3 only!\tDefault is 5, minimum is 0.1 (Note: values below 1 are not really tested)");
179181
Console.WriteLine("-minpoints" + argSeparator + "1000\t\tIf tile has less points than this value, its discarded. Good for removing straypoints. v3 only!\tDefault is 1000");

0 commit comments

Comments
 (0)