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

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

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

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

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

                // FIXME add configuration
                int[][] res = r.FindResults();

                for (int t = 0; t < tcount; t++)
                {
                    points[t][res[t][0]] += 1;

                    if (res[t].Length > 1)
                    {
                        points[t][res[t][1]] += 0.5;
                    }

                    if (res[t].Length > 2)
                    {
                        points[t][res[t][2]] += 0.25;
                    }
                }
            }

            IResult[] resarray = new IResult[tcount];

            for (int i = 0; i < tcount; i++)
            {
                resarray[i] = new IResult(points[i]);
            }

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

            _workdone = true;
        }
Esempio n. 2
0
        public override void Work()
        {
            tasks.Clear();

            bool MultiThreading = Eithne.Config.Get("engine/blockthreads", false);

            ICommImage socket1 = _in[0] as ICommImage;
            ICommImage socket2 = _in[1] as ICommImage;

            IImage[] img1 = socket1.Images;
            IImage[] img2 = socket2.Images;

            _out = new CommSocket(1);

            IResult[] res = new IResult[img2.Length];

            totalImages = img1.Length * img2.Length;

            if (MultiThreading)
            {
                TaskInfo ti1 = new TaskInfo(res, img1, img2, delta, 0, img2.Length / 2);
                TaskInfo ti2 = new TaskInfo(res, img1, img2, delta, img2.Length / 2, img2.Length);

                tasks.Add(ti1);
                tasks.Add(ti2);

                Thread t1 = new Thread(ti1.TaskWork);
                Thread t2 = new Thread(ti2.TaskWork);

                t1.Start();
                t2.Start();

                t1.Join();
                t2.Join();
            }
            else
            {
                TaskInfo t = new TaskInfo(res, img1, img2, delta, 0, img2.Length);
                tasks.Add(t);
                t.TaskWork();
            }

            _out[0] = new ICommResult(res, 0, socket1.OriginalImages, socket2.OriginalImages,
                                      socket1.Categories, socket2.Categories);

            tasks.Clear();

            _workdone = true;
        }
Esempio n. 3
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;
        }
Esempio n. 4
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;
        }
Esempio n. 5
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;
        }
Esempio n. 6
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;
        }