OpenCV using Imread (argv[1], 1) to read the picture

Source: Internet
Author: User

Show a Picture:
Mainly uses the function: Imread Namedwindow imshow
Imread: From the literal meaning we can understand, used to read pictures;
Namedwindow: Obviously, we can also see that this is used to name the window;
Imshow: This nature is to show the window, in the window of course is to display the picture.

Code from OPENCV Tutorials This file is very useful, recommended ~
The code is for informational purposes only:


#include <cv.h>//cv.h OpenCV The main function of the head file, be sure to;
#include
using namespace CV;

int main (int argc, char** argv)
{
Mat image; Define a file

Image = Imread (argv[1], 1); Read the picture to be displayed, "1" is the default value;

if (argc!=2 | |!image.data)//Determine if there is no picture, if not on the display error;
{
printf ("No image data \ n");
return-1;
}

Namedwindow ("Display Image", cv_window_autosize);//The name of the window displayed, followed by "Cv_window_autosize" is automatically displayed according to the image size parameters;
Imshow ("Display image", image);//The display will be called after the window is configured;

Waitkey (0);//wait until the user presses a key and exits.
return 0;
}

After generating exe in VS2010, go to console cmd, go to the directory where the program is located, enter: Program name + space + picture name to run normally (Pictures also need to add a table of contents or put together also line).

1. Start and run->cmd

2. Enter a disk, direct drive letter code: such as D:, without the CD command switch

3. Go to the root folder below the CD folder path for example, I want to enter E:/program files/php

Input E: Enter

Note: You cannot run CD E:/program files/php when you open cmd, you need to enter the disk first (if you run the CD E:/program files/php when you open cmd, the directory will not switch, but enter the last directory you want to enter the next time the drive letter is entered. , such as input e: will go directly into E:/program files/php)

Input CD "program Files"/php Enter

Note: If you need to view a folder with spaces under DOS (such as documents and Settings,program files), there are two ways to handle it:

1. Add quotation marks to the folder. such as C:/>CD c:/"Documents and Settings"
The benefit is that how long the filenames can be displayed.

2, because the General DOS system only supports 8.3 format file name, so in DOS encounter long file name folder, take the front 6 bits, and then add a ~ number and the number 1. You can enter C:/>CD c:/docume~1 to enter the documents and Settings folder. When a repetition occurs after the preceding 6 letters, you can change 1 to 2, and so on.

3. Go to the previous level directory CD. /

4. Display directory of files and directories dir



Transferred from: http://blog.sina.com.cn/s/blog_889f6dc4010115c9.html

Thank the blogger.

OpenCV using Imread (argv[1], 1) to read the picture

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.