First of all, you must choose a favorite image to display
#include <opencv2/core/core.hpp>#include<opencv2/highgui/highgui.hpp>intMain () {//Read an imageCv::mat image= Cv::imread (".. /img.jpg"); //Create image window named "My image"Cv::namedwindow ("My Image"); //Show the image on windowCv::imshow ("My Image", image); //wait key for MsCv::waitkey ( the); return 1;}
Note here the path img.jpg to modify Ah, if you do not have time to see the Linux file system people directly in the program to write the folder of the upper-level path, their own copy of a img.jpg
It is also recommended to build a file in the programming folder.
1 #!/bin/sh2 3 if[ $#-GT 0]; Then4Base= ' basename $. C '5Echo"compiling $base"6Gcc-ggdb ' pkg-config opencv--cflags--libs '$base. c-o$base7 Else8 forIinch*.C; Do9Echo"compiling $i"TenGcc-ggdb ' pkg-config--cflags opencv '-O ' basename$i. C '$i' Pkg-config--Libs OpenCV '; One Done A forIinch*.cpp; Do -Echo"compiling $i" -g++-ggdb ' pkg-config--cflags opencv '-O ' basename$i. cpp '$i' Pkg-config--Libs OpenCV '; the Done -Fi
By the time, the execution instructions
./build_all.sh
Don't have to play that long code (please ignore the veteran)
LINUX Open CV exercises using small notes (1)