Use EMGUCV's Imagebox () to open and display a pair of images in C #

Source: Internet
Author: User

1. Add a PictureBox in the toolbox to the interface.

2. Find the definition code for the PictureBox control you just added in the code snippet generated by the Windows window designer XXXXX.Designer.cs:

Modified to:

This allows you to display an image (image, Mat) to the control in the main program through code.

3. Add a TextBox control to display the picture path, and change it to "read-only" in the property.

4. Add a control OpenFileDialog to open the file.

5. Add a button to open the image and add the following code to the calling function:

            DialogResult result = openfiledialog1.showdialog ();             if (Result = = DialogResult.OK | | result = = Dialogresult.yes)            {                = openfiledialog1.filename;            }

The above code OPENFILEDIALOG1 and textBox1 based on actual modifications.

6. Add code to read in and display the image

         Public voidperformshapedetection () {if(TextBox1.Text! = String.Empty)//determine if the address in the text box is empty{StringBuilder Msgbuilder=NewStringBuilder ("Performance:"); //Load the image from file and resize it for displayImage < Bgr,byte> img =NewIMAGE&LT;BGR,byte>(TextBox1.Text). Resize (814,539, Emgu.CV.CvEnum.Inter.Linear,true);//the size of the image is determined by the actual size of the control//Mat srcimg = Cvinvoke.imread (TextBox1.Text);pictureBox1.Image = img;//display image to control                 This. Text =msgbuilder.tostring (); 

7. When the address changes in the Add text box control, the calling code of the image code is displayed.

        Private void textbox1_textchanged (object  sender, EventArgs e)        {            performshapedetection ();        }
 This New System.EventHandler (this. textbox1_textchanged)//In the code snippet generated by the Windows window designer in XXXXX.Designer.cs

Use EMGUCV's Imagebox () to open and display a pair of images in C #

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.