Beispiel #1
0
    public static void SaveGestureBatch(MasterControl mastercontrol, int gestureNumber)
    {
        BinaryFormatter formatter = new BinaryFormatter();
        //string path = Application.persistentDataPath + "/testcontrol.banana";
        string     path   = "C:/Users/Andrei/Documents/Unity Games/Hand Gesture Recognition/GestureAlbums/" + gestureNumber + "gestureBatch.banana";
        FileStream stream = new FileStream(path, FileMode.Create);

        GestureBatchData data = new GestureBatchData(mastercontrol);

        formatter.Serialize(stream, data);
        stream.Close();
    }
Beispiel #2
0
    public void LoadGestureBatch(int gestureNumber)
    {
        GestureBatchData data = GestureSaveSystem.LoadGestureBatch(gestureNumber);

        //deep copy of gestureBatch
        for (int i = 0; i < 500; i++)
        {
            for (int j = 0; j < 32; j++)             //<32 because the image is 32 pixles wide
            {
                for (int k = 0; k < 24; k++)         //<24 because the image is 24 pixels tall
                {
                    gestureBatch[i, j, k] = data.gestureBatch[i, j, k];
                }
            }
        }
    }
Beispiel #3
0
    public void LoadMEGAgestureBatch()
    {
        MEGAgestureBatch.Clear();

        for (int n = 0; n < 4; n++)          //assumes only 4 gestures are being used

        {
            List <int[, ]> imagecollection = new List <int[, ]>();

            GestureBatchData data = GestureSaveSystem.LoadGestureBatch(n);

            //deep copy of gestureBatch
            for (int i = 0; i < 500; i++)
            {
                int[,] gestureImage = new int[32, 24];
                for (int j = 0; j < 32; j++)                 //<32 because the image is 32 pixles wide
                {
                    for (int k = 0; k < 24; k++)             //<24 because the image is 24 pixels tall
                    {
                        gestureImage[j, k] = data.gestureBatch[i, j, k];
                    }
                }
                imagecollection.Add(gestureImage);
            }

            MEGAgestureBatch.Add(imagecollection);

            //for testing

            /*if(n == 1){
             *      reducedImage = new Texture2D (32, 24);
             *      for (int x = 0; x < 32; x++) {
             *              for (int y = 0; y < 24; y++) {
             *                      if (MEGAgestureBatch[0][304][x, y] == 1) {
             *                              reducedImage.SetPixel (x, y, Color.white);
             *                      } else {
             *                              reducedImage.SetPixel (x, y, Color.black);
             *                      }
             *              }
             *      }
             *      reducedImage.Apply();
             * Filtered.texture = reducedImage;
             * }*/
        }
    }
Beispiel #4
0
    public static GestureBatchData LoadGestureBatch(int gestureNumber)
    {
        //string path = Application.persistentDataPath + "/testcontrol.banana";
        string path = "C:/Users/Andrei/Documents/Unity Games/Hand Gesture Recognition/GestureAlbums/" + gestureNumber + "gestureBatch.banana";

        if (File.Exists(path))
        {
            BinaryFormatter formatter = new BinaryFormatter();
            FileStream      stream    = new FileStream(path, FileMode.Open);

            GestureBatchData data = formatter.Deserialize(stream) as GestureBatchData;
            stream.Close();

            return(data);
        }
        else
        {
            Debug.LogError("Save file not found in " + path);
            return(null);
        }
    }