comparison align/TransformDTWAligner.cpp @ 781:b651dc5ff555

Add subsequence option all over the place
author Chris Cannam
date Thu, 16 Jul 2020 18:01:50 +0100
parents 8fa98f89eda8
children 700fc9e4852d
comparison
equal deleted inserted replaced
780:8fa98f89eda8 781:b651dc5ff555
54 TransformDTWAligner::m_dtwMutex; 54 TransformDTWAligner::m_dtwMutex;
55 55
56 TransformDTWAligner::TransformDTWAligner(Document *doc, 56 TransformDTWAligner::TransformDTWAligner(Document *doc,
57 ModelId reference, 57 ModelId reference,
58 ModelId toAlign, 58 ModelId toAlign,
59 bool subsequence,
59 Transform transform, 60 Transform transform,
60 DTWType dtwType) : 61 DTWType dtwType) :
61 m_document(doc), 62 m_document(doc),
62 m_reference(reference), 63 m_reference(reference),
63 m_toAlign(toAlign), 64 m_toAlign(toAlign),
64 m_transform(transform), 65 m_transform(transform),
65 m_dtwType(dtwType), 66 m_dtwType(dtwType),
67 m_subsequence(subsequence),
66 m_incomplete(true), 68 m_incomplete(true),
67 m_magnitudePreprocessor(identityMagnitudePreprocessor), 69 m_magnitudePreprocessor(identityMagnitudePreprocessor),
68 m_riseFallPreprocessor(identityRiseFallPreprocessor) 70 m_riseFallPreprocessor(identityRiseFallPreprocessor)
69 { 71 {
70 } 72 }
71 73
72 TransformDTWAligner::TransformDTWAligner(Document *doc, 74 TransformDTWAligner::TransformDTWAligner(Document *doc,
73 ModelId reference, 75 ModelId reference,
74 ModelId toAlign, 76 ModelId toAlign,
77 bool subsequence,
75 Transform transform, 78 Transform transform,
76 MagnitudePreprocessor outputPreprocessor) : 79 MagnitudePreprocessor outputPreprocessor) :
77 m_document(doc), 80 m_document(doc),
78 m_reference(reference), 81 m_reference(reference),
79 m_toAlign(toAlign), 82 m_toAlign(toAlign),
80 m_transform(transform), 83 m_transform(transform),
81 m_dtwType(Magnitude), 84 m_dtwType(Magnitude),
85 m_subsequence(subsequence),
82 m_incomplete(true), 86 m_incomplete(true),
83 m_magnitudePreprocessor(outputPreprocessor), 87 m_magnitudePreprocessor(outputPreprocessor),
84 m_riseFallPreprocessor(identityRiseFallPreprocessor) 88 m_riseFallPreprocessor(identityRiseFallPreprocessor)
85 { 89 {
86 } 90 }
87 91
88 TransformDTWAligner::TransformDTWAligner(Document *doc, 92 TransformDTWAligner::TransformDTWAligner(Document *doc,
89 ModelId reference, 93 ModelId reference,
90 ModelId toAlign, 94 ModelId toAlign,
95 bool subsequence,
91 Transform transform, 96 Transform transform,
92 RiseFallPreprocessor outputPreprocessor) : 97 RiseFallPreprocessor outputPreprocessor) :
93 m_document(doc), 98 m_document(doc),
94 m_reference(reference), 99 m_reference(reference),
95 m_toAlign(toAlign), 100 m_toAlign(toAlign),
96 m_transform(transform), 101 m_transform(transform),
97 m_dtwType(RiseFall), 102 m_dtwType(RiseFall),
103 m_subsequence(subsequence),
98 m_incomplete(true), 104 m_incomplete(true),
99 m_magnitudePreprocessor(identityMagnitudePreprocessor), 105 m_magnitudePreprocessor(identityMagnitudePreprocessor),
100 m_riseFallPreprocessor(outputPreprocessor) 106 m_riseFallPreprocessor(outputPreprocessor)
101 { 107 {
102 } 108 }
359 #ifdef DEBUG_TRANSFORM_DTW_ALIGNER 365 #ifdef DEBUG_TRANSFORM_DTW_ALIGNER
360 SVCERR << "TransformDTWAligner[" << this 366 SVCERR << "TransformDTWAligner[" << this
361 << "]: serialising DTW to avoid over-allocation" << endl; 367 << "]: serialising DTW to avoid over-allocation" << endl;
362 #endif 368 #endif
363 QMutexLocker locker(&m_dtwMutex); 369 QMutexLocker locker(&m_dtwMutex);
364 alignment = dtw.alignSequences(s1, s2); 370 if (m_subsequence) {
371 alignment = dtw.alignSubsequence(s1, s2);
372 } else {
373 alignment = dtw.alignSequences(s1, s2);
374 }
365 } 375 }
366 376
367 #ifdef DEBUG_TRANSFORM_DTW_ALIGNER 377 #ifdef DEBUG_TRANSFORM_DTW_ALIGNER
368 SVCERR << "TransformDTWAligner[" << this << "]: performAlignmentMagnitude: " 378 SVCERR << "TransformDTWAligner[" << this << "]: performAlignmentMagnitude: "
369 << "DTW produced " << alignment.size() << " points:" << endl; 379 << "DTW produced " << alignment.size() << " points:" << endl;
448 #ifdef DEBUG_TRANSFORM_DTW_ALIGNER 458 #ifdef DEBUG_TRANSFORM_DTW_ALIGNER
449 SVCERR << "TransformDTWAligner[" << this 459 SVCERR << "TransformDTWAligner[" << this
450 << "]: serialising DTW to avoid over-allocation" << endl; 460 << "]: serialising DTW to avoid over-allocation" << endl;
451 #endif 461 #endif
452 QMutexLocker locker(&m_dtwMutex); 462 QMutexLocker locker(&m_dtwMutex);
453 alignment = dtw.alignSequences(s1, s2); 463 if (m_subsequence) {
464 alignment = dtw.alignSubsequence(s1, s2);
465 } else {
466 alignment = dtw.alignSequences(s1, s2);
467 }
454 } 468 }
455 469
456 #ifdef DEBUG_TRANSFORM_DTW_ALIGNER 470 #ifdef DEBUG_TRANSFORM_DTW_ALIGNER
457 SVCERR << "TransformDTWAligner[" << this << "]: performAlignmentRiseFall: " 471 SVCERR << "TransformDTWAligner[" << this << "]: performAlignmentRiseFall: "
458 << "DTW produced " << alignment.size() << " points:" << endl; 472 << "DTW produced " << alignment.size() << " points:" << endl;