Exemplo n.º 1
0
        public override void Work()
        {
            ICommResult ires = _in[0] as ICommResult;

            int tcount = ires.Length;
            int bcount = ires[0].Length;

            int[][] res = new int[y][];

            for (int i = 0; i < y; i++)
            {
                ICommResult r = _in[i] as ICommResult;

                if (r.Length != tcount || r[0].Length != bcount)
                {
                    throw new PluginException(Catalog.GetString("Incompatible data on input."));
                }

                res[i] = r.FindResultsSimple();
            }

            bool[] match = new bool[tcount];

            for (int i = 0; i < tcount; i++)
            {
                match[i] = true;
            }

            IResult[] resarray = new IResult[tcount];

            for (int i = 0; i < tcount; i++)
            {
                double[] tmp = new double[bcount];
                int[]    cnt = new int[bcount];
                int      j;

                for (j = 0; j < bcount; j++)
                {
                    tmp[j] = 0;
                    cnt[j] = 0;
                }

                for (j = 0; j < y; j++)
                {
                    if ((_in[j] as ICommResult).Match[i])
                    {
                        cnt[res[j][i]]++;
                    }
                }

                for (j = 0; j < bcount; j++)
                {
                    if (cnt[j] >= x)
                    {
                        tmp[j] = cnt[j];
                        break;
                    }
                }

                // no match
                if (j == bcount)
                {
                    match[i] = false;
                }

                resarray[i] = new IResult(tmp);
            }

            _out    = new CommSocket(1);
            _out[0] = new ICommResult(resarray, y, ires.OriginalBaseImages, ires.OriginalTestImages, ires.BaseCategories,
                                      ires.TestCategories, match);


            _workdone = true;
        }
Exemplo n.º 2
0
        public override void Work()
        {
            ICommResult r = _in[0] as ICommResult;

            itest = new Gdk.Pixbuf[r.Length];
            ibase = new Gdk.Pixbuf[r.OriginalBaseImages.Length];

            double scale;

            for (int i = 0; i < itest.Length; i++)
            {
                IImage img = r.OriginalTestImages[i];

                if (img.W > img.H)
                {
                    scale = img.W / 32.0;
                }
                else
                {
                    scale = img.H / 32.0;
                }

                Gdk.Pixbuf tmp = img.CreatePixbuf();
                itest[i] = tmp.ScaleSimple(Scale(img.W, scale), Scale(img.H, scale), Gdk.InterpType.Bilinear);
            }

            for (int i = 0; i < ibase.Length; i++)
            {
                IImage img = r.OriginalBaseImages[i];

                if (img.W > img.H)
                {
                    scale = img.W / 32.0;
                }
                else
                {
                    scale = img.H / 32.0;
                }

                Gdk.Pixbuf tmp = img.CreatePixbuf();
                ibase[i] = tmp.ScaleSimple(Scale(img.W, scale), Scale(img.H, scale), Gdk.InterpType.Bilinear);
            }

            res = new IResult[r.Length];
            for (int i = 0; i < r.Length; i++)
            {
                res[i] = r[i];
            }

            match = r.FindResultsSimple();

            for (int i = 0; i < r.Length; i++)
            {
                if (!r.Match[i])
                {
                    match[i] = -1;
                }
            }

            _workdone = true;
        }
Exemplo n.º 3
0
        public override void Work()
        {
            ICommResult r = _in[0] as ICommResult;

            int[] res    = r.FindResultsSimple();
            int   numcat = FindNumCategories(r.TestCategories);

            cat = new Category[numcat + 1];
            for (int i = 0; i < numcat + 1; i++)
            {
                cat[i] = new Category();
            }

            total   = r.Length;
            matched = 0;

            for (int i = 0; i < r.Length; i++)
            {
                int tc = r.TestCategory(i);
                int bc = r.BaseCategory(res[i]);

                cat[tc].total++;

                if (cat[tc].image == null)
                {
                    double scale;
                    IImage img = null;

                    for (int j = 0; j < r.OriginalBaseImages.Length; j++)
                    {
                        if (r.BaseCategory(j) == tc)
                        {
                            img = r.OriginalBaseImages[j];
                            if (first)
                            {
                                break;
                            }
                        }
                    }

                    if (img == null)
                    {
                        cat[tc].image = new Gdk.Pixbuf(Assembly.GetEntryAssembly(), "no-base.png");
                    }
                    else
                    {
                        if (img.W > img.H)
                        {
                            scale = img.W / 48.0;
                        }
                        else
                        {
                            scale = img.H / 48.0;
                        }

                        Gdk.Pixbuf tmp = img.CreatePixbuf();
                        cat[tc].image = tmp.ScaleSimple(Scale(img.W, scale), Scale(img.H, scale),
                                                        Gdk.InterpType.Bilinear);
                    }
                }

                if (tc == bc && r.Match[i])
                {
                    cat[tc].matched++;
                    matched++;
                }
            }

            _workdone = true;
        }
Exemplo n.º 4
0
        public override void Work()
        {
            ICommResult r = _in[0] as ICommResult;

            itest  = new Gdk.Pixbuf[r.Length];
            thumbs = new Gdk.Pixbuf[r.Length];
            ibase  = new Gdk.Pixbuf[r.OriginalBaseImages.Length];

            double scale;

            for (int i = 0; i < itest.Length; i++)
            {
                IImage _img = r.OriginalTestImages[i];
                IImage img  = new IImage(_img.BPP, _img.W, _img.H, _img.Data, invert);

                if (invert)
                {
                    img.Invert();
                }

                if (img.W > img.H)
                {
                    scale = img.W / 256.0;
                }
                else
                {
                    scale = img.H / 256.0;
                }

                Gdk.Pixbuf tmp = img.CreatePixbuf();
                itest[i] = tmp.ScaleSimple(Scale(img.W, scale), Scale(img.H, scale), Gdk.InterpType.Bilinear);

                if (img.W > img.H)
                {
                    scale = img.W / 64.0;
                }
                else
                {
                    scale = img.H / 64.0;
                }

                thumbs[i] = itest[i].ScaleSimple(Scale(img.W, scale), Scale(img.H, scale), Gdk.InterpType.Bilinear);
            }

            for (int i = 0; i < ibase.Length; i++)
            {
                IImage _img = r.OriginalBaseImages[i];
                IImage img  = new IImage(_img.BPP, _img.W, _img.H, _img.Data, invert);

                if (invert)
                {
                    img.Invert();
                }

                if (img.W > img.H)
                {
                    scale = img.W / 256.0;
                }
                else
                {
                    scale = img.H / 256.0;
                }

                Gdk.Pixbuf tmp = img.CreatePixbuf();
                ibase[i] = tmp.ScaleSimple(Scale(img.W, scale), Scale(img.H, scale), Gdk.InterpType.Bilinear);
            }

            res = r.FindResultsSimple();

            cat1 = r.BaseCategories;
            cat2 = r.TestCategories;

            match = r.Match;

            _workdone = true;
        }