Esempio n. 1
0
 public void addPicture(String name, UnityEngine.Matrix4x4 viewTransform, UnityEngine.Matrix4x4 projection)
 {
     System.Numerics.Matrix4x4 viewTransformS = new System.Numerics.Matrix4x4(viewTransform.m00, viewTransform.m01, viewTransform.m02, viewTransform.m03,
                                                                              viewTransform.m10, viewTransform.m11, viewTransform.m12, viewTransform.m13,
                                                                              viewTransform.m20, viewTransform.m21, viewTransform.m22, viewTransform.m23,
                                                                              viewTransform.m30, viewTransform.m31, viewTransform.m32, viewTransform.m33);
     System.Numerics.Matrix4x4 projectionS = new System.Numerics.Matrix4x4(projection.m00, projection.m01, projection.m02, projection.m03,
                                                                           projection.m10, projection.m11, projection.m12, projection.m13,
                                                                           projection.m20, projection.m21, projection.m22, projection.m23,
                                                                           projection.m30, projection.m31, projection.m32, projection.m33);
     nativeRefiner.addPicture(name, viewTransformS, projectionS);
 }
Esempio n. 2
0
        private async void Open_Image_Button_Click(object sender, RoutedEventArgs e)
        {
            var picker = new Windows.Storage.Pickers.FileOpenPicker();

            picker.ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail;
            picker.SuggestedStartLocation =
                Windows.Storage.Pickers.PickerLocationId.ComputerFolder;
            picker.FileTypeFilter.Add(".png");
            Windows.Storage.StorageFile file = await picker.PickSingleFileAsync();

            string matText = "";

            if (file != null)
            {
                // Application now has read/write access to the picked file
                try
                {
                    matText = System.IO.File.ReadAllText(file.Name + ".matr");
                }
                catch (Exception exc) {}
                char[]   delimiterChars = { ' ', ',', ':', '\t', '\n' };
                string[] values         = matText.Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries);
                float[]  fV             = new float[32];
                if (values.Length != 32)
                {
                    this.resultBox.Text = "no valid matrices (not right amount of values or no file) length of values is: " + values.Length.ToString();
                }
                else
                {
                    try
                    {
                        int i = 0;
                        foreach (String s in values)
                        {
                            fV[i] = float.Parse(s);
                            i++;
                        }
                    }
                    catch (Exception exc)
                    {
                        this.resultBox.Text = "no valid matrices (not numbers)/" + exc.ToString();
                    }
                }

                System.Numerics.Matrix4x4 View = new System.Numerics.Matrix4x4(fV[0], fV[1], fV[2], fV[3],
                                                                               fV[4], fV[5], fV[6], fV[7],
                                                                               fV[8], fV[9], fV[10], fV[11],
                                                                               fV[12], fV[13], fV[14], fV[15]);

                System.Numerics.Matrix4x4 Projection = new System.Numerics.Matrix4x4(fV[16], fV[17], fV[18], fV[19],
                                                                                     fV[20], fV[21], fV[22], fV[23],
                                                                                     fV[24], fV[25], fV[26], fV[27],
                                                                                     fV[28], fV[29], fV[30], fV[31]);
                // this.resultBox.Text = "View matrix is: " + View.ToString();
                //this.resultBox.Text = "Picked Image: " + file.Name + " path: " + file.Path;
                refiner.addPicture(file.Name, View, Projection);
                this.imageCountBox.Text = refiner.getNImages().ToString() + " images\n";// + View.ToString() + "\n" + Projection.ToString();
            }
            else
            {
                this.resultBox.Text = "Operation cancelled.";
            }
        }