private void returns() { DataStructure.clear(); referenceRead(referencePath); SetContentView(Resource.Layout.TakePicture); bool norm = autoScaling.Checked; captureButton = FindViewById <ImageButton>(Resource.Id.picButton); captureButton.SetImageResource(Resource.Drawable.cameraBtnImage); captureButton.Click += TakeAPicture; importImgButton = FindViewById <Button>(Resource.Id.picImport); importImgButton.Visibility = Android.Views.ViewStates.Visible; importImgButton.Click += importImage; importDataButton = FindViewById <Button>(Resource.Id.dataImport); importDataButton.Visibility = Android.Views.ViewStates.Visible; importDataButton.Click += importDataFrag; autoScaling = FindViewById <CheckBox>(Resource.Id.StuCheckBox); autoScaling.Visibility = Android.Views.ViewStates.Visible; autoScaling.Click += autoScale; autoScaling.Checked = norm; }
private void Finished(Object sender, EventArgs e) { //This is where we will tie in the PCA core ///Its undecided if we want to create a new class that is just the PCA core output to file output, probably best way to do it DataStructure.Data = DataSet; DataStructure.Labels = Labels; DataStructure.Process(); DataWriter dataWriter = new DataWriter(); //Create the reference file here //In new class pls //User Prompt string path = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath; string filePath; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.SetTitle("Please select desired reference file name(including .txt)"); EditText input = new EditText(this); input.InputType = Android.Text.InputTypes.ClassText; builder.SetView(input); //only the postive button should do anything builder.SetPositiveButton("OK", (see, ess) => { //get file path //get file path string name = "RefernceFile.txt";//Default value if (input.Text != "") { name = input.Text; } filePath = System.IO.Path.Combine(path, name); dataWriter.Filepath = filePath; //Dimension size dataWriter.Dimensionsize = areaUpperLimit; dataWriter.NumberOfPics = Labels.Count; dataWriter.writeDimension(); //Labels dataWriter.Labels = Labels; dataWriter.writeLabels(); //using the final data from PCA forms the vectors. dataWriter.FinalData = DataStructure.FinalDataRealigned; dataWriter.writeFinalDataRealigned(); //Grab the vectors dataWriter.Vectors = DataStructure.FeatureVectors; dataWriter.writeVectors(); //Clear the data structure afterwords DataStructure.clear(); ///Temporarily commented out for testing of student mode SetContentView(Resource.Layout.Main); Intent intent = new Intent(this, typeof(MainActivity)); StartActivity(intent); }); //this should just cancel builder.SetNegativeButton("Cancel", (afk, kfa) => { }); //show dialog Dialog diaglog = builder.Create(); diaglog.Show(); }
private void exportDataSets(EditText input) { #region nonnormalized //This is where we will tie in the PCA core ///Its undecided if we want to create a new class that is just the PCA core output to file output, probably best way to do it DataStructure.Data = DataSet; DataStructure.Labels = Labels; DataStructure.Process(); DataWriter dataWriter = new DataWriter(); //User Prompt string path = AppSettings.dirData.Path; string filePath; //get file path //get file path string name = "RefernceFile.txt"; //Default value if (input.Text != "") { name = "Reference_areas" + areaUpperLimit.ToString() + "_" + input.Text + ".csv"; } filePath = System.IO.Path.Combine(path, name); dataWriter.Filepath = filePath; //Dimension size dataWriter.Dimensionsize = areaUpperLimit; dataWriter.NumberOfPics = Labels.Count; dataWriter.writeDimension(); //Labels dataWriter.Labels = Labels; dataWriter.writeLabels(); //using the final data from PCA forms the vectors. dataWriter.FinalData = DataStructure.FinalDataRealigned; dataWriter.writeFinalDataRealigned(); //Grab the vectors dataWriter.Vectors = DataStructure.FeatureVectors; dataWriter.writeVectors(); //Clear the data structure afterwords DataStructure.clear(); #endregion #region normalized DataStructure.Data = normalizedSet(DataSet); DataStructure.Process(); dataWriter.FinalData = DataStructure.FinalDataRealigned; dataWriter.writeFinalDataRealigned(); //Grab the vectors dataWriter.Vectors = DataStructure.FeatureVectors; dataWriter.writeVectors(); #endregion // Export a raw file which can then be added to later name = "DataSet_areas" + areaUpperLimit.ToString() + "_" + input.Text + ".csv"; filePath = System.IO.Path.Combine(path, name); if (System.IO.File.Exists(path)) { System.IO.File.Create(path); } for (int i = 0; i < Labels.Count; i++) { System.IO.File.AppendAllText(filePath, Labels[i] + "\n"); } foreach (List <double> item in DataSet) { for (int i = 0; i < item.Count - 1; i++) { System.IO.File.AppendAllText(filePath, item[i].ToString() + ","); } System.IO.File.AppendAllText(filePath, item[item.Count - 1].ToString() + "\n"); } SetContentView(Resource.Layout.Main); Intent intent = new Intent(this, typeof(MainActivity)); StartActivity(intent); }