//thread for retriving 4sec-data from buffer private static void retriving() { int count = 0; while (!STOP_RETRIVING) { if (buffer.getSize() >= (Buffer.SLIDING_WINDOW_SIZE / Buffer.SRATE) && buffer.isNewDataReady()) //one second data in the buffer { float[][] a = buffer.getData((Buffer.SLIDING_WINDOW_SIZE / Buffer.SRATE)); //debug /*string ooo = ""; * for (int i = 0; i < a[0].GetLength (0); i++) { * ooo = ooo+a[0][i].ToString()+" "; * } * System.IO.File.AppendAllText (@"C:\Users\UCSD\Desktop\YT\raw.txt", ooo);*/ //print (a[14][0] + " , " + a[15][0]); double[][] b = new double[a.GetLength(0)][]; for (int i = 0; i < a.GetLength(0); i++) { b[i] = new double[a[i].GetLength(0)]; for (int j = 0; j < b[i].Length; j++) { b[i][j] = (double)a[i][j]; } } //print ("Get data: " + ++count); ++count; if (count <= fe.TRAINING_openEye_TIME) { int[] q = { 0 }; fe.setData(b, q); print("Training open eyes..." + count); } else if (count <= (fe.TRAINING_closeEye_TIME + fe.TRAINING_openEye_TIME) && count > fe.TRAINING_openEye_TIME) { //print ("----------Open eye training complete---------"); print("Training close eyes..." + count); int[] q = { 1 }; fe.setData(b, q); } else { //print ("----------Close eye training complete---------"); int[] oo = fe.getPrediction(b); float drowsinessPercent = 0; print("Prediction: "); //Console.Write ("Prediction: "); for (int qq = 0; qq < oo.Length; qq++) { print("oo[qq]"); //Console.Write (oo[qq]); if (oo[qq] == 1) { drowsinessPercent++; } } print(", " + (drowsinessPercent / oo.Length * 100f) + "%"); //Console.Write (", " + (drowsinessPercent / oo.Length * 100f) + "%"); //Console.WriteLine (); } Thread.Sleep(1000); } else { //print ("Buffer is not ready"); Thread.Sleep(500); } } print("Stop from thread retriving()"); }