Search in sources :

Example 11 with ScoreElement

use of org.vitrivr.cineast.core.data.score.ScoreElement in project cineast by vitrivr.

the class Lightfield method postprocessQuery.

/**
 * This method represents the last step that's executed when processing a query. A list of partial-results (DistanceElements) returned by the lookup stage is processed based on some internal method and finally converted to a list of ScoreElements. The filtered list of ScoreElements is returned by the feature module during retrieval.
 *
 * @param partialResults List of partial results returned by the lookup stage.
 * @param qc             A ReadableQueryConfig object that contains query-related configuration parameters.
 * @return List of final results. Is supposed to be de-duplicated and the number of items should not exceed the number of items per module.
 */
@Override
protected List<ScoreElement> postprocessQuery(List<SegmentDistanceElement> partialResults, ReadableQueryConfig qc) {
    /* Perform search for each extracted feature and adjust scores.  */
    HashMap<String, DistanceElement> map = new HashMap<>();
    for (DistanceElement result : partialResults) {
        map.merge(result.getId(), result, (v1, v2) -> {
            if (v1.getDistance() < v2.getDistance()) {
                return v1;
            } else {
                return v2;
            }
        });
    }
    /* Add results to list and return list of results. */
    final CorrespondenceFunction correspondence = qc.getCorrespondenceFunction().orElse(this.correspondence);
    return ScoreElement.filterMaximumScores(map.entrySet().stream().map((e) -> e.getValue().toScore(correspondence)));
}
Also used : StagedFeatureModule(org.vitrivr.cineast.core.features.abstracts.StagedFeatureModule) Image(java.awt.Image) BufferedImage(java.awt.image.BufferedImage) ReadableMesh(org.vitrivr.cineast.core.data.m3d.ReadableMesh) CorrespondenceFunction(org.vitrivr.cineast.core.data.CorrespondenceFunction) QueryConfig(org.vitrivr.cineast.core.config.QueryConfig) FloatVectorImpl(org.vitrivr.cineast.core.data.FloatVectorImpl) HashMap(java.util.HashMap) ScoreElement(org.vitrivr.cineast.core.data.score.ScoreElement) ReadableQueryConfig(org.vitrivr.cineast.core.config.ReadableQueryConfig) JOGLOffscreenRenderer(org.vitrivr.cineast.core.render.JOGLOffscreenRenderer) ArrayList(java.util.ArrayList) ImageUtil(com.twelvemonkeys.image.ImageUtil) List(java.util.List) SegmentContainer(org.vitrivr.cineast.core.data.segments.SegmentContainer) SegmentDistanceElement(org.vitrivr.cineast.core.data.distance.SegmentDistanceElement) LogHelper(org.vitrivr.cineast.core.util.LogHelper) DistanceElement(org.vitrivr.cineast.core.data.distance.DistanceElement) Renderer(org.vitrivr.cineast.core.render.Renderer) HashMap(java.util.HashMap) CorrespondenceFunction(org.vitrivr.cineast.core.data.CorrespondenceFunction) SegmentDistanceElement(org.vitrivr.cineast.core.data.distance.SegmentDistanceElement) DistanceElement(org.vitrivr.cineast.core.data.distance.DistanceElement)

Aggregations

ScoreElement (org.vitrivr.cineast.core.data.score.ScoreElement)11 ArrayList (java.util.ArrayList)9 ReadableQueryConfig (org.vitrivr.cineast.core.config.ReadableQueryConfig)7 CorrespondenceFunction (org.vitrivr.cineast.core.data.CorrespondenceFunction)7 HashMap (java.util.HashMap)6 DistanceElement (org.vitrivr.cineast.core.data.distance.DistanceElement)6 SegmentDistanceElement (org.vitrivr.cineast.core.data.distance.SegmentDistanceElement)6 List (java.util.List)5 QueryConfig (org.vitrivr.cineast.core.config.QueryConfig)5 SegmentContainer (org.vitrivr.cineast.core.data.segments.SegmentContainer)5 FloatVectorImpl (org.vitrivr.cineast.core.data.FloatVectorImpl)4 SegmentScoreElement (org.vitrivr.cineast.core.data.score.SegmentScoreElement)4 StagedFeatureModule (org.vitrivr.cineast.core.features.abstracts.StagedFeatureModule)4 Pair (org.vitrivr.cineast.core.data.Pair)3 HPCP (org.vitrivr.cineast.core.util.audio.HPCP)3 FFTUtil (org.vitrivr.cineast.core.util.dsp.fft.FFTUtil)3 STFT (org.vitrivr.cineast.core.util.dsp.fft.STFT)3 HanningWindow (org.vitrivr.cineast.core.util.dsp.fft.windows.HanningWindow)3 MathHelper (org.vitrivr.cineast.core.util.math.MathHelper)3 Map (java.util.Map)2