1、保存点云
string CurrentDir = Application.StartupPath;
string FileName = CurrentDir + "\\ScanPoint.asc";
FileStream of = File.Open(FileName, FileMode.Create);
StreamWriter sw = new StreamWriter(of);
sw.WriteLine("scan");
sw.WriteLine("scan");
sw.WriteLine("cloud_start");
int ptCount = hv_Pnt_x.TupleLength();
int nStep = 5;
for (int j = 0; j < ptCount; j += nStep)
{
string line = hv_Pnt_x[j].D + " " + hv_Pnt_y[j].D + " " + hv_Pnt_z[j].D;
sw.WriteLine(line);
}
sw.WriteLine("cloud_end");
int LastPtNum = ptCount - 1;
sw.WriteLine("startPoint");
string SptStr = hv_Pnt_x[0].D + " " + hv_Pnt_y[0].D + " " + hv_Pnt_z[0].D;
sw.WriteLine(SptStr);
sw.WriteLine("startPoint_end");
sw.WriteLine("endPoint");
string EptStr = hv_Pnt_x[LastPtNum].D.ToString() + " " + hv_Pnt_y[LastPtNum].D.ToString() + " " + hv_Pnt_z[LastPtNum].D.ToString();
sw.WriteLine(EptStr);
sw.WriteLine("endPoint_end");
sw.Close();
of.Close();
2、读取数据
string CurrentDir = Application.StartupPath;
string FileName = CurrentDir + "\\CameraParameter.txt";
FileStream of = File.Open(FileName, FileMode.Open);
StreamReader sr = new StreamReader(of);
string str1 = sr.ReadLine();
string str2 = sr.ReadLine();
string str3 = sr.ReadLine();
sr.Close();
of.Close();
this.hScrollBar_Gain.Value = Convert.ToInt32(str1);
this.hScrollBar_Exposure.Value = Convert.ToInt32(str2);
this.hScrollBar_ThresholdValue.Value = Convert.ToInt32(str3);
this.textBox_Gain.Text = this.hScrollBar_Gain.Value.ToString();
this.textBox_Exposure.Text = this.hScrollBar_Exposure.Value.ToString();
this.textBox_ThresholdValue.Text = this.hScrollBar_ThresholdValue.Value.ToString();