7 public class BestInfo
: IInfo
9 public override string Name
11 get { return Catalog.GetString("Best-of"); }
14 public override string ShortName
16 get { return "Best"; }
19 public override string Author
21 get { return "Bartosz Taudul"; }
24 public override string Description
26 get { return Catalog.GetString("This plugin selects best of results."); }
30 public class BestFactory
: IFactory
32 IInfo _info
= new BestInfo();
40 get { return IType.ResProc; }
43 public void Initialize()
47 public Plugin
.Base
Create()
49 return new BestPlugin();
53 public class BestPlugin
: Plugin
.ResProc
59 _info
= new BestInfo();
62 public override XmlNode Config
64 get { return GetConfig(); }
65 set { LoadConfig(value); }
68 private void UpdateValue(int n
)
71 _block
.SlotsChanged();
74 public override void Setup()
76 new BestSetup(num
, UpdateValue
);
79 public override void Work()
81 ICommResult ires
= _in
[0] as ICommResult
;
83 int tcount
= ires
.Length
;
84 int bcount
= ires
[0].Length
;
86 double[][] points
= new double[tcount
][];
87 for(int i
=0; i
<tcount
; i
++)
89 points
[i
] = new double[bcount
];
90 for(int j
=0; j
<bcount
; j
++)
94 for(int i
=0; i
<num
; i
++)
96 ICommResult r
= _in
[i
] as ICommResult
;
98 if(r
.Length
!= tcount
|| r
[0].Length
!= bcount
)
99 throw new PluginException(Catalog
.GetString("Incompatible data on input."));
101 // FIXME add configuration
102 int[][] res
= r
.FindResults();
104 for(int t
=0; t
<tcount
; t
++)
106 points
[t
][res
[t
][0]] += 1;
108 if(res
[t
].Length
> 1)
109 points
[t
][res
[t
][1]] += 0.5;
111 if(res
[t
].Length
> 2)
112 points
[t
][res
[t
][2]] += 0.25;
116 IResult
[] resarray
= new IResult
[tcount
];
118 for(int i
=0; i
<tcount
; i
++)
119 resarray
[i
] = new IResult(points
[i
]);
121 _out
= new CommSocket(1);
122 _out
[0] = new ICommResult(resarray
, num
, ires
.OriginalBaseImages
, ires
.OriginalTestImages
, ires
.BaseCategories
,
123 ires
.TestCategories
, ires
.Match
);
128 private XmlNode
GetConfig()
130 XmlNode root
= _xmldoc
.CreateNode(XmlNodeType
.Element
, "config", "");
132 root
.InnerText
= num
.ToString();
137 private void LoadConfig(XmlNode root
)
139 UpdateValue(Int32
.Parse(root
.InnerText
));
142 public override int NumIn { get { return num; }
}
143 public override int NumOut { get { return 1; }
}
145 public override string DescIn(int n
)
147 return String
.Format(Catalog
.GetString("{0}. input signal."), n
+1);
150 public override string DescOut(int n
)
152 return Catalog
.GetString("Best results.");
155 private static string[] matchin
= new string[] { "result" }
;
156 private static string[] matchout
= new string[] { "result/processed" }
;
158 public override string[] MatchIn { get { return matchin; }
}
159 public override string[] MatchOut { get { return matchout; }
}