001package org.openimaj.demos.sandbox.tldcpp.detector; 002 003import java.util.ArrayList; 004import java.util.List; 005 006import org.openimaj.math.geometry.shape.Rectangle; 007 008/** 009 * This state class holds the results of {@link DetectorCascade#detect(org.openimaj.image.FImage)} and 010 * is used primarily to save having to do this work again, this can probably be protected or gone entirley 011 * @author Sina Samangooei (ss@ecs.soton.ac.uk) 012 * 013 */ 014public class DetectionResult { 015 016 /** 017 * Whether the contained results are valid 018 */ 019 public boolean containsValidData; 020// public List<Rectangle> fgList; 021 /** 022 * The probability of each window as set by the {@link EnsembleClassifier} 023 */ 024 public float [] posteriors; /* Contains the posteriors for each slding window. Is of size numWindows. Allocated by tldInitClassifier. */ 025 /** 026 * The windows which we are confident (by the 3 classifiers) might contain the object 027 */ 028 public List<Integer> confidentIndices; 029 /** 030 * This is a numberOfTrees * numberOfWindows list containing the feature for each tree for each window 031 */ 032 public int [] featureVectors; 033 /** 034 * This is a numberOfWindows list containing the variance of each window 035 */ 036 public float [] variances; 037 /** 038 * The number of clusters which confident windows were grouped into based on their overlaps 039 */ 040 public int numClusters; 041 /** 042 * The current window estimated by the detector (afte clustering) 043 */ 044 public Rectangle detectorBB; 045 /** 046 * The number of windows skipped thanks to variance check 047 */ 048 public int varCount; 049 /** 050 * The number of windows skipped thanks to ensemble classifier 051 */ 052 public int ensCount; 053 /** 054 * The number of windows skipped thanks to normalised correlation. 055 */ 056 public int nnClassCount; 057 058 DetectionResult() { 059 containsValidData = false; 060 confidentIndices = new ArrayList<Integer>(); 061 numClusters = 0; 062 detectorBB = null; 063 064 variances = null; 065 posteriors = null; 066 featureVectors = null; 067 } 068 069 070 void init(int numWindows, int numTrees) { 071 variances = new float[numWindows]; 072 posteriors = new float[numWindows]; 073 featureVectors = new int[numWindows*numTrees]; 074 confidentIndices = new ArrayList<Integer>(); 075 076 } 077 078 void reset() { 079 containsValidData = false; 080 if(confidentIndices != null) confidentIndices.clear(); 081 numClusters = 0; 082 detectorBB = null; 083 varCount = 0; 084 ensCount = 0; 085 nnClassCount = 0; 086 } 087 088 void release() { 089 variances = null; 090 posteriors = null; 091 featureVectors = null; 092 confidentIndices = null; 093 detectorBB = null; 094 containsValidData = false; 095 } 096 097 098}