Showing posts with label oepncv. Show all posts
Showing posts with label oepncv. Show all posts

Thursday, November 7, 2019

[OpenCV Tutorial] $1 - Load and Display an Image

Goal

In this tutorial you will learn how to:

Source Code

Download the source code from here.

#include <iostream>
#include <string>
using namespace cv;
using namespace std;
int main( int argc, char** argv )
{
String imageName( "HappyFish.jpg" ); // by default
if( argc > 1)
{
imageName = argv[1];
}
Mat image;
image = imread( imageName, IMREAD_COLOR ); // Read the file
if( image.empty() ) // Check for invalid input
{
cout << "Could not open or find the image" << std::endl ;
return -1;
}
namedWindow( "Display window", WINDOW_AUTOSIZE ); // Create a window for display.
imshow( "Display window", image ); // Show our image inside it.
waitKey(0); // Wait for a keystroke in the window
return 0;
}
Back to Top