Skip to content

Commit

Permalink
Update GenericRecognizer.cs
Browse files Browse the repository at this point in the history
Issue #390 I changed the scope of the loop over decibel threshold values. This was to fix a bug in how events were subsequently merged.
  • Loading branch information
towsey authored and atruskie committed Nov 1, 2020
1 parent 772e18d commit 7150e80
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/AnalysisPrograms/Recognizers/GenericRecognizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ public override RecognizerResults Recognize(
message = $"Number of decibel thresholds = {decibelThresholds.Length}: " + decibelThresholds.Join(", ");
Log.Info(message);

var postprocessingConfig = configuration.PostProcessing;

// init object to store the combined results from all decibel thresholds.
var combinedResults = new RecognizerResults()
{
Expand All @@ -151,21 +153,19 @@ public override RecognizerResults Recognize(
{
// ############################### PROCESSING: DETECTION OF GENERIC EVENTS ###############################
var profileResults = RunProfiles(audioRecording, configuration, threshold, segmentStartOffset);

// ############################### POST-PROCESSING OF GENERIC EVENTS ###############################
var postprocessingConfig = configuration.PostProcessing;
profileResults.NewEvents = EventPostProcessing.PostProcessingOfSpectralEvents(profileResults.NewEvents, threshold.Value, postprocessingConfig, profileResults.Sonogram, segmentStartOffset);
Log.Debug($"Event count from all profiles at {threshold} dB threshold = {profileResults.NewEvents.Count}");

// combine the results i.e. add the events list of call events.
// add this profile results to combined results and remove enclosed events.
combinedResults.NewEvents.AddRange(profileResults.NewEvents);
combinedResults.Plots.AddRange(profileResults.Plots);
combinedResults.NewEvents = CompositeEvent.RemoveEnclosedEvents(combinedResults.NewEvents);

// effectively keeps only the *last* sonogram produced
combinedResults.Sonogram = profileResults.Sonogram;
combinedResults.Plots.AddRange(profileResults.Plots);
}

combinedResults.NewEvents = CompositeEvent.RemoveEnclosedEvents(combinedResults.NewEvents);
// ############################### POST-PROCESSING OF GENERIC EVENTS ###############################
combinedResults.NewEvents = EventPostProcessing.PostProcessingOfSpectralEvents(combinedResults.NewEvents, postprocessingConfig, combinedResults.Sonogram, segmentStartOffset);
return combinedResults;
}

Expand Down

0 comments on commit 7150e80

Please sign in to comment.