Ejemplo n.º 1
0
        private void 合成ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // Image<Gray, Byte> tmp = new Image<Gray, byte>(size.Width, size.Height, mat.Step, mat.DataPointer)
            // Image<Bgr, byte> c = new Image<Bgr, byte>(picout.ToString());
            Image <Bgr, byte> a   = new Image <Bgr, byte>("D:\\c.jpg");
            Image <Bgr, byte> src = new Image <Bgr, byte>("D:\\c.jpg");
            //Image<Bgr, byte> c = new Image<Bgr, byte>("D:\\c.jpg");
            Stitcher stitcher = new Stitcher(false);
            Mat      outimg   = new Mat();

            try
            {
                // MessageBox.Show("d");
                imageBox2.Image = a.Mat;
                imageBox3.Image = src.Mat;
                stitcher.Stitch(new VectorOfMat(new Mat[] { a.Mat, src.Mat }), outimg);
                //MessageBox.Show("s");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            imageBox1.Image = outimg;
            picout          = outimg;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Stitch images together
        /// </summary>
        /// <param name="images">The list of images to stitch</param>
        /// <returns>A final stitched image</returns>
        public static Mat StichImages(List <Mat> images)
        {
            //Declare the Mat object that will store the final output
            Mat output = new Mat();

            //Declare a vector to store all images from the list
            VectorOfMat matVector = new VectorOfMat();

            //Push all images in the list into a vector
            foreach (Mat img in images)
            {
                matVector.Push(img);
            }

            //Declare a new stitcher
            Stitcher stitcher = new Stitcher();

            //Declare the type of detector that will be used to detect keypoints
            Brisk detector = new Brisk();

            //Here are some other detectors that you can try
            //ORBDetector detector = new ORBDetector();
            //KAZE detector = new KAZE();
            //AKAZE detector = new AKAZE();

            //Set the stitcher class to use the specified detector declared above
            stitcher.SetFeaturesFinder(detector);

            //Stitch the images together
            stitcher.Stitch(matVector, output);

            //Return the final stiched image
            return(output);
        }
Ejemplo n.º 3
0
        public static Bitmap ImgPj(List <string> strfile)
        {
            Bitmap bmp = null;
            Mat    outimg;

            try {
                List <Mat> listmat = new List <Mat>();
                for (int i = 0; i < strfile.Count; i++)
                {
                    string            str = strfile[i].ToString();
                    Image <Bgr, byte> a   = new Image <Bgr, byte>(str);
                    listmat.Add(a.Mat);
                }
                Stitcher stitcher = new Stitcher(false);
                outimg = new Mat();
                if (T_ConFigure.SfName.Trim().Length > 0)
                {
                    stitcher.Stitch(new VectorOfMat(listmat.ToArray()), outimg);
                }
            } catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                return(bmp);
            }
            return(outimg.Bitmap);
        }
Ejemplo n.º 4
0
        //Faz stich de dois frames de dois video separados
        private void stichFirstFrameToolStripMenuItem_Click(object sender, System.EventArgs e)
        {
            try
            {
                using (Stitcher stitcher = new Stitcher(true))
                {
                    using (VectorOfMat vm = new VectorOfMat())
                    {
                        vm.Push(sourceImages);
                        var stitchStatus = stitcher.Stitch(vm, result);

                        if (stitchStatus)
                        {
                            Bitmap bt = new Bitmap(result.Bitmap);
                            //por algum motivo a imagem fica rodada :(
                            bt.RotateFlip(RotateFlipType.RotateNoneFlipXY);
                            pictureBox1.Image = bt;
                            // pictureBox1.Image.Save(@"path", ImageFormat.Jpeg);
                        }
                        else
                        {
                            MessageBox.Show(this, String.Format("Stiching Error: {0}", stitchStatus));
                            pictureBox1.Image = null;
                        }
                    }
                }
            }
            catch
            {
            }
        }
Ejemplo n.º 5
0
            public void Attach(Transform transform, Equipment equipment)
            {
                if (!IsAttached)
                {
                    Equipment = equipment;

                    GameObject prefab;
                    if (Equipment.EquipmentData.EquipmentPrefab == null)
                    {
                        Debug.LogWarning("This Equipment prefab does not exist, a primitive will be used instead.");
                        prefab = GameObject.CreatePrimitive(PrimitiveType.Cube);
                    }
                    else
                    {
                        prefab = Equipment.EquipmentData.EquipmentPrefab;
                    }

                    _gameObject = Object.Instantiate(prefab, transform);

                    Stitcher.Stitch(_gameObject, transform.gameObject);

                    IsAttached = true;
                }
                else
                {
                    throw new UnityException("The attachment is already fulfill, please verify your logic.");
                }
            }
Ejemplo n.º 6
0
        private void button5_Click(object sender, EventArgs e)
        {
            string[] paths = Directory.GetFiles(Basepath);

            List <Mat> matlist = new List <Mat>();

            for (int i = 0; i < paths.Length; i++)
            {
                var tempmat = new Mat(paths[i], ImreadModes.Color);

                matlist.Add(tempmat);
            }


            using (VectorOfMat vmsrc = new VectorOfMat(matlist.ToArray()))
            {
                //Image<Bgr, byte> res = new Image<Bgr, byte>(28090, 27390);
                Mat      result   = new Mat();
                Stitcher stitcher = new Stitcher(false);


                Stitcher.Status stitchStatus = stitcher.Stitch(vmsrc, result);

                ImageViewer.Show(result);
                //result.Save(Basepath + "testresult.png");
            }
        }
Ejemplo n.º 7
0
        public Mat Stitch_vm(VectorOfMat vm)
        {
            Mat result = new Mat();

            stitcher.Stitch(vm, result);

            return(result);
        }
Ejemplo n.º 8
0
        private void selectImagesButton_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.CheckFileExists = true;
            dlg.Multiselect     = true;

            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                sourceImageDataGridView.Rows.Clear();

                Image <Bgr, byte>[] sourceImages = new Image <Bgr, byte> [dlg.FileNames.Length];

                for (int i = 0; i < sourceImages.Length; i++)
                {
                    sourceImages[i] = new Image <Bgr, byte>(dlg.FileNames[i]);

                    using (Image <Bgr, byte> thumbnail = sourceImages[i].Resize(200, 200, Emgu.CV.CvEnum.Inter.Cubic, true))
                    {
                        DataGridViewRow row = sourceImageDataGridView.Rows[sourceImageDataGridView.Rows.Add()];
                        row.Cells["FileNameColumn"].Value  = dlg.FileNames[i];
                        row.Cells["ThumbnailColumn"].Value = thumbnail.ToBitmap();
                        row.Height = 200;
                    }
                }
                try
                {
                    //only use GPU if you have build the native binary from code and enabled "NON_FREE"
                    using (Stitcher stitcher = new Stitcher(false))
                        using (AKAZEFeaturesFinder finder = new AKAZEFeaturesFinder())
                        {
                            stitcher.SetFeaturesFinder(finder);
                            using (VectorOfMat vm = new VectorOfMat())
                            {
                                Mat result = new Mat();
                                vm.Push(sourceImages);
                                Stitcher.Status stitchStatus = stitcher.Stitch(vm, result);
                                if (stitchStatus == Stitcher.Status.Ok)
                                {
                                    resultImageBox.Image = result;
                                }
                                else
                                {
                                    MessageBox.Show(this, String.Format("Stiching Error: {0}", stitchStatus));
                                    resultImageBox.Image = null;
                                }
                            }
                        }
                }
                finally
                {
                    foreach (Image <Bgr, Byte> img in sourceImages)
                    {
                        img.Dispose();
                    }
                }
            }
        }
Ejemplo n.º 9
0
 private void Wear(GameObject clothing)
 {
     if (clothing == null)
     {
         return;
     }
     //clothing = Instantiate(clothing);
     clothing = stitcher.Stitch(clothing, targetMesh);
 }
Ejemplo n.º 10
0
        private void selectImagesButton_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.CheckFileExists = true;
            dlg.Multiselect     = true;

            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                sourceImageDataGridView.Rows.Clear();

                Image <Bgr, Byte>[] sourceImages = new Image <Bgr, byte> [dlg.FileNames.Length];

                for (int i = 0; i < sourceImages.Length; i++)
                {
                    sourceImages[i] = new Image <Bgr, byte>(dlg.FileNames[i]);

                    using (Image <Bgr, byte> thumbnail = sourceImages[i].Resize(200, 200, Emgu.CV.CvEnum.Inter.Cubic, true))
                    {
                        DataGridViewRow row = sourceImageDataGridView.Rows[sourceImageDataGridView.Rows.Add()];
                        row.Cells["FileNameColumn"].Value  = dlg.FileNames[i];
                        row.Cells["ThumbnailColumn"].Value = thumbnail.ToBitmap();
                        row.Height = 200;
                    }
                }
                try
                {
                    //using (Stitcher stitcher = new Stitcher(true))
                    //CUDA bruteforce matcher seems to cause issue in this release, not using CUDA for matching for this reason
                    using (Stitcher stitcher = new Stitcher(false))
                    {
                        using (VectorOfMat vm = new VectorOfMat())
                        {
                            Mat result = new Mat();
                            vm.Push(sourceImages);
                            Stitcher.Status stitchStatus = stitcher.Stitch(vm, result);
                            if (stitchStatus == Stitcher.Status.Ok)
                            {
                                resultImageBox.Image = result;
                            }
                            else
                            {
                                MessageBox.Show(this, String.Format("Stiching Error: {0}", stitchStatus));
                                resultImageBox.Image = null;
                            }
                        }
                    }
                }
                finally
                {
                    foreach (Image <Bgr, Byte> img in sourceImages)
                    {
                        img.Dispose();
                    }
                }
            }
        }
Ejemplo n.º 11
0
 private void Wear(GameObject clothing)
 {
     if (clothing == null)
     {
         return;
     }
     clothing     = Instantiate(clothing);
     wornClothing = stitcher.Stitch(clothing, avatar);
 }
Ejemplo n.º 12
0
 private void Wear(GameObject part)
 {
     if (part == null)
     {
         return;
     }
     part = (GameObject)GameObject.Instantiate(part);
     stitcher.Stitch(part, core);
     GameObject.Destroy(part);
 }
Ejemplo n.º 13
0
    public CWearable ChangeEquip(CWearable wearable)
    {
        CWearable returnWear = null;

        if (wearable == null)
        {
            Debug.Log("Wearable is NullData");
            return(returnWear);
        }

        if (m_wearTarget == null)
        {
            Debug.LogError("Missing WearTarget");
            return(returnWear);
        }

        int nIdx = (int)wearable.PartsType;

        if (nIdx >= m_changeMeshes.Length)
        {
            Debug.LogError("Don't Use " + PartsType.WEAPON);
            return(returnWear);
        }

        if (m_changeMeshes[nIdx] != null)
        {
            GameObject.Destroy(m_changeMeshes[nIdx]);
        }

        m_changeMeshes[nIdx] = m_stitcher.Stitch(wearable.Prefab, m_wearTarget);
        returnWear           = m_Wearables[nIdx];
        m_Wearables[nIdx]    = wearable;

        switch (wearable.PartsType)
        {
        case PartsType.BODY:
            m_inventoryInfo.curBodyIdx = wearable.ItemIdx;
            break;

        case PartsType.ARM:
            m_inventoryInfo.curArmIdx = wearable.ItemIdx;
            break;

        case PartsType.LEG:
            m_inventoryInfo.curLegIdx = wearable.ItemIdx;
            break;

        case PartsType.HEAD:
            m_inventoryInfo.curHeadIdx = wearable.ItemIdx;
            break;
        }

        return(returnWear);
    }
Ejemplo n.º 14
0
 private GameObject Wear(GameObject clothing, GameObject wornClothing)
 {
     if (clothing == null)
     {
         return(null);
     }
     clothing     = (GameObject)GameObject.Instantiate(clothing);
     wornClothing = stitcher.Stitch(clothing, avatar);
     GameObject.Destroy(clothing);
     return(wornClothing);
 }
Ejemplo n.º 15
0
        ////////////////////////////////////////////////////////////////////////////////////////////

        private void btnOpenFile_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofdOpenfilesD = new OpenFileDialog();

            ofdOpenfilesD.CheckFileExists = true;
            ofdOpenfilesD.Multiselect     = true;

            if (ofdOpenfilesD.ShowDialog() != DialogResult.OK || ofdOpenfilesD.FileName == "")
            {
                MessageBox.Show("Can not read image");
            }
            else if (ofdOpenfilesD.ShowDialog() == DialogResult.OK)
            {
                dgvSourceImage.Rows.Clear();


                Image <Bgr, Byte>[] originalImagesU = new Image <Bgr, byte> [ofdOpenfilesD.FileNames.Length];

                for (int i = 0; i < originalImagesU.Length; i++)
                {
                    originalImagesU[i] = new Image <Bgr, byte>(ofdOpenfilesD.FileNames[i]);

                    using (Image <Bgr, byte> firstImage = originalImagesU[i].Resize(200, 200, Inter.Cubic, true))

                    {
                        DataGridViewRow row = dgvSourceImage.Rows[dgvSourceImage.Rows.Add()];
                        row.Cells["fileNameColumn"].Value      = ofdOpenfilesD.FileNames[i];
                        row.Cells["samplePictureColumn"].Value = firstImage.ToBitmap();
                        row.Height = 200;
                    }
                }
                try
                {
                    using (Stitcher stiching = new Stitcher(false))
                    {
                        using (VectorOfMat matVector = new VectorOfMat())
                        {
                            Mat finalImageN = new Mat();
                            matVector.Push(originalImagesU);
                            stiching.Stitch(matVector, finalImageN);
                            ibFinalImage.Image = finalImageN;
                        }
                    }
                }
                finally
                {
                    foreach (Image <Bgr, Byte> image in originalImagesU)
                    {
                        image.Dispose();
                    }
                }
            }
        }
Ejemplo n.º 16
0
        private void button1_Click(object sender, EventArgs e)
        {
            Stitcher stitcher = new Stitcher(false);

            Image <Bgr, byte>[] sourceImages = new Image <Bgr, byte> [3];
            sourceImages[0] = image1;
            sourceImages[1] = image2;
            sourceImages[2] = image3;
            Image <Bgr, byte> result = stitcher.Stitch(sourceImages);

            imageBox7.Image = result;
        }
Ejemplo n.º 17
0
        private void selectImagesButton_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.CheckFileExists = true;
            dlg.Multiselect     = true;

            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                sourceImageDataGridView.Rows.Clear();

                Image <Bgr, Byte>[] sourceImages = new Image <Bgr, byte> [dlg.FileNames.Length];

                for (int i = 0; i < sourceImages.Length; i++)
                {
                    sourceImages[i] = new Image <Bgr, byte>(dlg.FileNames[i]);

                    using (Image <Bgr, byte> thumbnail = sourceImages[i].Resize(200, 200, Emgu.CV.CvEnum.Inter.Cubic, true))
                    {
                        DataGridViewRow row = sourceImageDataGridView.Rows[sourceImageDataGridView.Rows.Add()];
                        row.Cells["FileNameColumn"].Value  = dlg.FileNames[i];
                        row.Cells["ThumbnailColumn"].Value = thumbnail.ToBitmap();
                        row.Height = 200;
                    }
                }
                try
                {
                    using (Stitcher stitcher = new Stitcher(true))
                    {
                        using (VectorOfMat vm = new VectorOfMat())
                        {
                            Mat result = new Mat();
                            vm.Push(sourceImages);
                            stitcher.Stitch(vm, result);
                            resultImageBox.Image = result;
                        }
                    }
                }
                finally
                {
                    foreach (Image <Bgr, Byte> img in sourceImages)
                    {
                        img.Dispose();
                    }
                }
            }
        }
Ejemplo n.º 18
0
        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Multiselect     = true;
            ofd.CheckFileExists = true;
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                //Clear data
                dataGridView1.Rows.Clear();
                //Store input images
                Image <Bgr, Byte>[] images = new Image <Bgr, Byte> [ofd.FileNames.Length];
                for (int i = 0; i < images.Length; i++)
                {
                    images[i] = new Image <Bgr, Byte>(ofd.FileNames[i]);
                    using (Image <Bgr, Byte> thumbnail = images[i].Resize(150, 150, Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC, true))
                    {
                        DataGridViewRow row = dataGridView1.Rows[dataGridView1.Rows.Add()];
                        row.Cells["Image"].Value = thumbnail.ToBitmap();
                        row.Height = 150;
                    }
                }
                //Try Image Stitching
                try
                {
                    //Core Part
                    using (Stitcher stitcher = new Stitcher(
                               // GPU boost enable or disable
                               // Must specify false because it will cause error if true
                               // The bug is from OpenCV
                               false))
                    {
                        Image <Bgr, Byte> result = stitcher.Stitch(images);
                        imageBox1.Image = result;
                    }
                }
                finally
                {
                    foreach (Image <Bgr, Byte> image in images)
                    {
                        ((IDisposable)image).Dispose();
                    }
                }
            }
        }
Ejemplo n.º 19
0
        public static Bitmap ImgPj(string str, string str2)
        {
            Bitmap            bmp      = null;
            Image <Bgr, byte> a        = new Image <Bgr, byte>(str);
            Image <Bgr, byte> b        = new Image <Bgr, byte>(str2);
            Stitcher          stitcher = new Stitcher(false);
            Mat outimg = new Mat();

            try {
                if (T_ConFigure.SfName.Trim().Length > 0)
                {
                    stitcher.Stitch(new VectorOfMat(new Mat[] { a.Mat, b.Mat }), outimg);
                }
            } catch {
                return(bmp);
            }
            return(outimg.Bitmap);
        }
Ejemplo n.º 20
0
        public static Bitmap ImgPj(Bitmap b1, Bitmap b2, Bitmap b3, Bitmap b4)
        {
            Bitmap            bmp      = null;
            Image <Bgr, byte> a        = new Image <Bgr, byte>(b1);
            Image <Bgr, byte> b        = new Image <Bgr, byte>(b2);
            Image <Bgr, byte> c        = new Image <Bgr, byte>(b3);
            Image <Bgr, byte> d        = new Image <Bgr, byte>(b4);
            Stitcher          stitcher = new Stitcher(false);
            Mat outimg = new Mat();

            try {
                if (T_ConFigure.SfName.Trim().Length > 0)
                {
                    stitcher.Stitch(new VectorOfMat(new Mat[] { a.Mat, b.Mat, c.Mat, d.Mat }), outimg);
                }
            } catch {
                return(bmp);
            }
            return(outimg.Bitmap);
        }
Ejemplo n.º 21
0
    public bool Equip(GameObject obj, string slot)
    {
        if (obj == null)
        {
            return(false);
        }

        if (equipment.ContainsKey(slot))
        {
            GameObject worn = equipment[slot];
            MonoBehaviour.Destroy(worn);
            equipment.Remove(slot);
        }

        GameObject newEquipment = MonoBehaviour.Instantiate(obj);

        stitcher.Stitch(newEquipment, parent);
        equipment[slot] = newEquipment;
        return(true);
    }
Ejemplo n.º 22
0
        public void hebing(Bitmap btm2)
        {
            sol_image.Add(btm2);
            Mat outimg            = new Mat();
            Image <Bgr, Byte> src = new Image <Bgr, Byte>(btm2);

            if (btm3 == null)
            {
                btm3 = btm2;
            }
            else
            {
                btm3 = outimg.Bitmap;
            }
            if (btm3 == null)
            {
                btm3 = btm2;
            }
            Image <Bgr, Byte> src2     = new Image <Bgr, Byte>(btm3);
            Stitcher          stitcher = new Stitcher(false);

            try
            {
                imageBox2.Image = src2.Mat;
                imageBox3.Image = src.Mat;
                stitcher.Stitch(new VectorOfMat(new Mat[] { src2.Mat, src.Mat }), outimg);
                j++;
                label4.Text = j + "";
                if (outimg.Bitmap == null)
                {
                    k++;
                    label5.Text = k + "";
                }
                //MessageBox.Show("s");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            imageBox1.Image = outimg;
        }
Ejemplo n.º 23
0
        private void button5_Click(object sender, EventArgs e)
        {
            Stitcher    _sticher     = new Stitcher(Stitcher.Mode.Scans); //创建一个 Sticher 类。
            Mat         result_image = new Mat();                         //创建 Mat 存储输出全景图
            VectorOfMat sti_image    = new VectorOfMat();                 //创建 VectorOfMat 类型, 输入图像拼接数组

            // 添加图像到 sti_image 中, 不按照循序进行添加, 说明拼接图像与顺序无关*//
            sti_image.Push(image1);
            sti_image.Push(image2);
            sti_image.Push(image3);
            sti_image.Push(image4);
            Stitcher.Status status = _sticher.Stitch(sti_image, result_image);//进行图像拼接, 返回 bool 类型, 是否拼接成功。
            if (status == Stitcher.Status.Ok)
            {
                imageBox5.Image = result_image;//显示图像。
            }
            else
            {
                MessageBox.Show("拼接失败", "提示");
            }
        }
Ejemplo n.º 24
0
        private void jointBtn_Click(object sender, EventArgs e)
        {
            MessageBox.Show("此过程可能需要几秒钟的时间,请稍候...");
            Image <Bgr, byte>[] sources;
            Image  img1 = this.pictureBox1.Image;
            Bitmap map1 = new Bitmap(img1);
            Image  img2 = this.pictureBox2.Image;
            Bitmap map2 = new Bitmap(img2);

            sources = new Image <Bgr, byte> [2];      //图像集初始化,确定了图像集的页数。

            sources[0] = new Image <Bgr, byte>(map1); //填入位图数据
            sources[1] = new Image <Bgr, byte>(map2);

            Stitcher stitcher      = new Stitcher(false); //true代表使用GPU,false代表不使用GPU
            Mat      panoramic_img = new Mat();
            bool     ok            = true;                //定义并初始化ok,用来标识是否拼接成功

            Mat[]       mat = new Mat[] { sources[0].Mat, sources[1].Mat };
            VectorOfMat vc  = new VectorOfMat(mat);

            try
            {
                ok = stitcher.Stitch(vc, panoramic_img);
            }  //ok为真,则拼接成功;ok为假,则拼接失败。
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            if (ok)
            {
                pictureBox3.Image = (Image)panoramic_img.Bitmap;
                MessageBox.Show("两张图像合成成功");
            }
            else
            {
                MessageBox.Show("合成失败,图像相似区域太少或者无法合成");; //拼接失败
            }
        }
Ejemplo n.º 25
0
        public static Bitmap ImgPj(List <Bitmap> strfile)
        {
            Bitmap bmp = null;
            Mat    outimg;

            try {
                List <Mat> listmat = new List <Mat>();
                for (int i = 0; i < strfile.Count; i++)
                {
                    Bitmap            bmp1 = strfile[i];
                    Image <Bgr, byte> a    = new Image <Bgr, byte>(bmp1);
                    listmat.Add(a.Mat);
                }
                Stitcher stitcher = new Stitcher(false);
                outimg = new Mat();
                if (T_ConFigure.SfName.Trim().Length > 0)
                {
                    stitcher.Stitch(new VectorOfMat(listmat.ToArray()), outimg);
                }
            } catch {
                return(bmp);
            }
            return(outimg.Bitmap);
        }
Ejemplo n.º 26
0
        private void 合成测试ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            List <Image <Bgr, Byte> > tmp = new List <Image <Bgr, byte> >();
            Mat outimg = new Mat();

            for (int i = 0; i < sol_image.Count; i++)
            {
                Image <Bgr, Byte> src = new Image <Bgr, Byte>(sol_image[i]);
                tmp.Add(src);
            }
            MessageBox.Show(tmp.Count.ToString());
            Stitcher stitcher = new Stitcher(false);

            try
            {
                stitcher.Stitch(new VectorOfMat(new Mat[] { tmp[1].Mat, tmp[2].Mat, tmp[3].Mat, tmp[4].Mat, tmp[5].Mat, tmp[6].Mat, tmp[7].Mat, tmp[8].Mat, tmp[9].Mat, tmp[10].Mat }), outimg);
                //MessageBox.Show("s");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            imageBox1.Image = outimg;
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Default home page view.
        /// </summary>
        /// <returns></returns>
        // GET: /<controller>/
        public IActionResult Index(string reason = null, string searchPhrase = null)
        {
            var model = new HomePageDto();

            // Use the search service if search phrase is passed
            if (!string.IsNullOrEmpty(searchPhrase) && !string.IsNullOrWhiteSpace(searchPhrase))
            {
                // store the phrase that user typed.
                _searchEntryService.AddSearchEntry(new SearchEntryDto
                {
                    SearchPhrase = searchPhrase,
                    UserId       = GetUserId(User, _userService)
                });

                model.TopToday.Answers = _answerService.FindLastAnswers(searchPhrase).ToList();
                model.Keyword          = searchPhrase;
                model.HeaderText       = string.Format(_resourcesService.GetString(this.Culture, Lines.SEARCH_RESULTS_FOR), searchPhrase);
                model.IsSearch         = true;
            }
            else
            {
                model.TopToday.Answers = _answerService.FindAnswersTrendingToday().ToList();
                model.HeaderText       = _resourcesService.GetString(this.Culture, Lines.TRENDING_TODAY);
            }

            // Answer service does not do any stiching. Meaning it can not set user information in the model/answers.
            // Need to add user info to answers
            Stitcher <AnswerDto> .Stitch(model.TopToday.Answers, _userService);

            model.Reason = reason;

            // Check if we need to debug react
            model.DebugReactControls = ReadUrlParameterAsBoolean(DEBUG_REACTJS_URL_PARAMETER_NAME);

            return(View(model));
        }
Ejemplo n.º 28
0
        void stitch(String path)
        {
            Stitcher stitcher = Stitcher.Create(Stitcher.Mode.Scans);
            Mat      result   = new Mat();

            try
            {
                var status = stitcher.Stitch(images, result);
                if (status != Stitcher.Status.OK)
                {
                    MessageBox.Show("拼接失败");
                    return;
                }
                else
                {
                    String savepath = path + "/" + "stitch.jpg";
                    Cv2.ImWrite(savepath, result);
                    dealimage(savepath, path);
                }
            }catch (Exception e)
            {
                MessageBox.Show("拼接失败");
            }
        }
Ejemplo n.º 29
0
        private void open_Click(object sender, EventArgs e)
        {
            //MessageBox.Show(Convert.ToString(treshold));
            if (KazeRadio.Checked)
            {
                descriptorTipus = AKAZE.DescriptorType.Kaze;
            }
            else if (KazeUpRadio.Checked)
            {
                descriptorTipus = AKAZE.DescriptorType.KazeUpright;
            }
            else if (MldbRadio.Checked)
            {
                descriptorTipus = AKAZE.DescriptorType.Mldb;
            }
            else if (MldbUpRadio.Checked)
            {
                descriptorTipus = AKAZE.DescriptorType.MldbUpright;
            }
            else
            {
                MldbRadio.Checked = true;
            }


            if (Channel1Radio.Checked)
            {
                channelNumber = 1;
            }
            else if (Channel2Radio.Checked)
            {
                channelNumber = 2;
            }
            else if (Channerl3Radio.Checked)
            {
                channelNumber = 3;
            }
            else
            {
                Channerl3Radio.Checked = true;
            }

            if (CharbonnierRadio.Checked)
            {
                difuzivitasi = KAZE.Diffusivity.Charbonnier;
            }
            else if (PmG1Radio.Checked)
            {
                difuzivitasi = KAZE.Diffusivity.PmG1;
            }
            else if (PmG2Radio.Checked)
            {
                difuzivitasi = KAZE.Diffusivity.PmG2;
            }
            else if (WeickerRadio.Checked)
            {
                difuzivitasi = KAZE.Diffusivity.Weickert;
            }
            else
            {
                PmG1Radio.Checked = true;
            }


            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Multiselect = true;
            dlg.Filter      = "jpg files (*.jpg)|*.jpg";
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                dataGridViewKepek.Rows.Clear();
                Image <Bgr, byte>[] forrasKepek = new Image <Bgr, byte> [dlg.FileNames.Length];
                for (int i = 0; i < forrasKepek.Length; i++)
                {
                    forrasKepek[i] = new Image <Bgr, byte>(dlg.FileNames[i]);
                    using (Image <Bgr, byte> miniPicture = forrasKepek[i].Resize(200, 200, Emgu.CV.CvEnum.Inter.Cubic, true))
                    {
                        DataGridViewRow sor = dataGridViewKepek.Rows[dataGridViewKepek.Rows.Add()];
                        sor.Cells["FileName"].Value = dlg.FileNames[i];
                        sor.Cells["View"].Value     = miniPicture.ToBitmap();
                        sor.Height = 200;
                    }
                }
                miniPicture = null;
                try
                {
                    //0 - Panormáma; 1 - Szekkenlés
                    //true - Try GPU; false - No
                    using (Stitcher varras = new Stitcher(0, true))
                    {
                        using (AKAZEFeaturesFinder kereso = new AKAZEFeaturesFinder(descriptorTipus, 0, channelNumber, treshold, 4, 4, difuzivitasi))
                        {
                            varras.SetFeaturesFinder(kereso);
                            using (VectorOfMat vm = new VectorOfMat())
                            {
                                Mat result = new Mat();
                                vm.Push(forrasKepek);
                                Stitcher.Status stitchStatus = varras.Stitch(vm, result);
                                if (stitchStatus == Stitcher.Status.Ok)
                                {
                                    resultImage.Image = result;
                                    forrasKepek       = null;
                                }
                                else
                                {
                                    MessageBox.Show(this, String.Format("Stiching Error: {0}", stitchStatus));
                                    resultImage.Image = null;
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                }
            }
        }
Ejemplo n.º 30
0
        public void Evaluate(int SpreadMax)
        {
            for (int i = SpreadMax; i < FOutput.SliceCount; i++)
            {
                FOutput[i].Dispose();
            }
            while (FOutput.SliceCount < SpreadMax)
            {
                FOutput.Add(new CVImageLink());
            }

            FStatus.SliceCount = SpreadMax;

            for (int i = 0; i < SpreadMax; i++)
            {
                if (!FDo[i])
                {
                    continue;
                }

                var inputSpread = FInput[i];
                var output      = FOutput[i];

                foreach (var image in inputSpread)
                {
                    image.LockForReading();
                }

                CVImage result = new CVImage();
                try
                {
                    int size = inputSpread.SliceCount;

                    Image <Bgr, Byte>[] images    = new Image <Bgr, byte> [size];
                    List <CVImage>      ToDispose = new List <CVImage>();

                    for (int j = 0; j < size; j++)
                    {
                        if (inputSpread[j].FrontImage.ImageAttributes.ColourFormat == TColorFormat.RGB8)
                        {
                            images[j] = inputSpread[j].FrontImage.GetImage() as Image <Bgr, Byte>;
                        }
                        else
                        {
                            var image = new CVImage();
                            ToDispose.Add(image);
                            image.Initialise(inputSpread[j].FrontImage.Size, TColorFormat.RGB8);
                            inputSpread[j].FrontImage.GetImage(image);
                            images[j] = image.GetImage() as Image <Bgr, Byte>;
                        }
                    }

                    result.SetImage(FStitcher.Stitch(images));

                    foreach (var image in ToDispose)
                    {
                        image.Dispose();
                    }

                    FStatus[i] = "OK";
                }
                catch (Exception e)
                {
                    FStatus[i] = e.Message;
                }
                finally
                {
                    foreach (var image in inputSpread)
                    {
                        image.ReleaseForReading();
                    }
                }

                output.Send(result);
            }
        }