public static double CompareActivities(ActivityRecord record, ActivityWindow window) { double result = 0; var mostInformativeJoints = record.MostInformativeJoints; List<ImportedSkeleton> windowPresentedByImportedSkeleton = new List<ImportedSkeleton>(); while(window.Frames.Count != 0) { windowPresentedByImportedSkeleton.Add(window.Frames.Dequeue()); } for (int i = 1; i < record.Frames.Count; i++) { for (int j = 0; j < windowPresentedByImportedSkeleton.Count; j++) { int index = (j / record.Frames.Count) * windowPresentedByImportedSkeleton.Count; if (index >= windowPresentedByImportedSkeleton.Count) index--; result += SkeletonComparer.CompareWithSMIJ(record.Frames[i], windowPresentedByImportedSkeleton[index], mostInformativeJoints); } } return result; }
public static double CompareActivities(ActivityRecord record, ActivityWindow window) { double result = double.PositiveInfinity; //Initialize the matrix //Calculate the matrix //for(... //Return the path //result = ... return result; }
public static double CompareActivities(ActivityRecord record, ActivityWindow window) { double result = double.PositiveInfinity; //Initialize the matrix //Calculate the matrix //for(... //Return the path //result = ... return(result); }
public double DTW(ActivityRecord record, ActivityWindow window, DynamicTimeWarpingCalculationType calcType = DynamicTimeWarpingCalculationType.Standart, DynamicTimeWarpingPathTypes stepPattern = DynamicTimeWarpingPathTypes.Standart, bool toUseSakoeChiba = true, double bandWidth = 0.1) { return (double)DynamicTimeWarping.CompareActivities(record, window, calcType, stepPattern, toUseSakoeChiba, bandWidth); }
public double DTW(ActivityRecord record, ActivityWindow window, DynamicTimeWarpingCalculationType calcType = DynamicTimeWarpingCalculationType.Standart, DynamicTimeWarpingPathTypes stepPattern = DynamicTimeWarpingPathTypes.Standart, bool toUseSakoeChiba = true, double bandWidth = 0.1) { return((double)DynamicTimeWarping.CompareActivities(record, window, calcType, stepPattern, toUseSakoeChiba, bandWidth)); }
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); for (int i = 1; i < record.Frames.Count; i++) { for (int j = 1; j < windowPresentedByImportedSkeletons.Count; j++) { if (toUseSakoeChibaBand) { 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 { if (dtwType == DynamicTimeWarpingCalculationType.Standart) { similarity = SkeletonComparer.CompareWithSMIJ(record.Frames[i], windowPresentedByImportedSkeletons[j], record.MostInformativeJoints); } else if (dtwType == DynamicTimeWarpingCalculationType.Derivative) { if (i != record.Frames.Count) { ImportedSkeleton mainSkeletonDerivatives = CalculateSkeletonDerivative(record.Frames, i, record.MostInformativeJoints); ImportedSkeleton secondarySkeletonDerivatives = CalculateSkeletonDerivative(windowPresentedByImportedSkeletons, i, record.MostInformativeJoints); similarity = SkeletonComparer.CompareWithSMIJ(mainSkeletonDerivatives, secondarySkeletonDerivatives, record.MostInformativeJoints); } } } } else //Start a DTW search without using Sakoe-Chiba band { if (dtwType == DynamicTimeWarpingCalculationType.Derivative) { if (i != record.Frames.Count) { ImportedSkeleton mainSkeletonDerivatives = CalculateSkeletonDerivative(record.Frames, i, record.MostInformativeJoints); ImportedSkeleton secondarySkeletonDerivatives = CalculateSkeletonDerivative(windowPresentedByImportedSkeletons, i, record.MostInformativeJoints); similarity = SkeletonComparer.CompareWithSMIJ(mainSkeletonDerivatives, secondarySkeletonDerivatives, record.MostInformativeJoints); } } else if (dtwType == DynamicTimeWarpingCalculationType.Standart) { 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; }
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); for (int i = 1; i < record.Frames.Count; i++) { for (int j = 1; j < windowPresentedByImportedSkeletons.Count; j++) { if (toUseSakoeChibaBand) { 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 { if (dtwType == DynamicTimeWarpingCalculationType.Standart) { similarity = SkeletonComparer.CompareWithSMIJ(record.Frames[i], windowPresentedByImportedSkeletons[j], record.MostInformativeJoints); } else if (dtwType == DynamicTimeWarpingCalculationType.Derivative) { if (i != record.Frames.Count) { ImportedSkeleton mainSkeletonDerivatives = CalculateSkeletonDerivative(record.Frames, i, record.MostInformativeJoints); ImportedSkeleton secondarySkeletonDerivatives = CalculateSkeletonDerivative(windowPresentedByImportedSkeletons, i, record.MostInformativeJoints); similarity = SkeletonComparer.CompareWithSMIJ(mainSkeletonDerivatives, secondarySkeletonDerivatives, record.MostInformativeJoints); } } } } else //Start a DTW search without using Sakoe-Chiba band { if (dtwType == DynamicTimeWarpingCalculationType.Derivative) { if (i != record.Frames.Count) { ImportedSkeleton mainSkeletonDerivatives = CalculateSkeletonDerivative(record.Frames, i, record.MostInformativeJoints); ImportedSkeleton secondarySkeletonDerivatives = CalculateSkeletonDerivative(windowPresentedByImportedSkeletons, i, record.MostInformativeJoints); similarity = SkeletonComparer.CompareWithSMIJ(mainSkeletonDerivatives, secondarySkeletonDerivatives, record.MostInformativeJoints); } } else if (dtwType == DynamicTimeWarpingCalculationType.Standart) { 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); }