public static double CompareActivities(ActivityRecord record, ActivityWindow window, DynamicTimeWarpingCalculationType dtwType, DynamicTimeWarpingPathTypes pathType = DynamicTimeWarpingPathTypes.Standart, bool toUseSakoeChibaBand = false, double bandWidthInProcentage = 0.1) { double similarity = 0.0f; double[,] DTW = new double[record.Frames.Count, window.Frames.Count]; for (int i = 1; i < window.Frames.Count; i++) { DTW[0, i] = double.PositiveInfinity; } for (int i = 1; i < record.Frames.Count; i++) { DTW[i, 0] = double.PositiveInfinity; } DTW[0, 0] = 0; var windowPresentedByImportedSkeletons = new List<ImportedSkeleton>(); foreach (var skeleton in window.Frames) { windowPresentedByImportedSkeletons.Add(new ImportedSkeleton(skeleton)); } int bandWidth = (int)(windowPresentedByImportedSkeletons.Count * bandWidthInProcentage); if (toUseSakoeChibaBand) { for (int i = 1; i < record.Frames.Count; i++) { for (int j = 1; j < windowPresentedByImportedSkeletons.Count; j++) { int currentCellOnMiddleDiagonal = (int)((j * windowPresentedByImportedSkeletons.Count) / record.Frames.Count); if (j > currentCellOnMiddleDiagonal - bandWidth && j < currentCellOnMiddleDiagonal + bandWidth) // Checking if the current cell is in the range { similarity = SkeletonComparer.CompareWithSMIJ(record.Frames[i], windowPresentedByImportedSkeletons[j], record.MostInformativeJoints); FillDTWTableCell(pathType, DTW, i, j, similarity); } } } } else //Start a DTW search without using Sakoe-Chiba band { for (int i = 1; i < record.Frames.Count; i++) { for (int j = 1; j < windowPresentedByImportedSkeletons.Count; j++) { similarity = SkeletonComparer.CompareWithSMIJ(record.Frames[i], windowPresentedByImportedSkeletons[j], record.MostInformativeJoints); FillDTWTableCell(pathType, DTW, i, j, similarity); } } } return DTW[record.Frames.Count - 1, window.Frames.Count - 1] / record.MostInformativeJoints.Count; }
/// <summary> /// Log out the currently logged in user and display the login form. /// </summary> public void Logout(ActivityWindow activityWindow) { this.account = null; activityWindow.Close(); this.DisplayLoginForm(); }