A few simple procedures for getting started, and the corresponding cmakelist, although a simple re-test it is also good to write a bit.
CMake Tutorial Portal
Image display
Showimage.cxx
#include <opencv2/opencv.hpp><opencv2/highgui/highgui.hpp><opencv2/imgcodecs/ imgcodecs.hpp>int main () { = Cv::imread ("1.jpg"); Imshow ("Original Image", srcimage); Cv::waitkey (0); return 0 ;}
CMakeLists.txt
2.8 ) Project (ShowImage) find_package (OpenCV REQUIRED) include_directories (${opencv_include_dirs}) # Add the Executableadd_executable (ShowImage showimage.cxx) target_link_libraries (ShowImage opencv_core Opencv_highgui OpenCV _IMGCODECS)
Image corrosion
Erodeimage.cxx
#include <opencv2/opencv.hpp>#include<opencv2/highgui/highgui.hpp>#include<opencv2/imgcodecs/imgcodecs.hpp>#include<opencv2/imgproc/imgproc.hpp>intMain () {//Read ImageCv::mat srcimage = Cv::imread ("1.jpg"); //Show Original ImageImshow ("Original Image", Srcimage); //Erode ImageCv::mat element = Getstructuringelement (Cv::morph_rect, Cv::size ( the, the)); Cv::mat Dstimage; Erode (Srcimage, dstimage, Element); //Show ResultsImshow ("Image Erosion", Dstimage); Cv::waitkey (0); return 0;}
CMakeList.txt
2.8find OpenCV packagesfind_package (OpenCV REQUIRED) include_directories (${opencv_ Include_dirs}) # Add the executableadd_executable (erodeimage erodeimage.cxx) target_link_libraries (ErodeImage opencv_ Core Opencv_highgui Opencv_imgproc opencv_imgcodecs)
Image Blur
Blurimage.cxx
#include <opencv2/opencv.hpp>#include<opencv2/highgui/highgui.hpp>#include<opencv2/imgcodecs/imgcodecs.hpp>#include<opencv2/imgproc/imgproc.hpp>intMain () {//Read ImageCv::mat srcimage = Cv::imread ("1.jpg"); //Show Original ImageImshow ("Original Image", Srcimage); //Blur ImageCv::mat Dstimage; Blur (Srcimage, Dstimage, Cv::size (7,7)); //Show ResultsImshow ("Image Blurring", Dstimage); Cv::waitkey (0); return 0;}
CMakeList.txt
2.8find OpenCV packagesfind_package (OpenCV REQUIRED) include_directories (${opencv_ Include_dirs}) # Add the executableadd_executable (blurimage blurimage.cxx) target_link_libraries (BlurImage opencv_ Core Opencv_highgui Opencv_imgproc opencv_imgcodecs)
Canny edge Detection
Cannyedgedetection.cxx
#include <opencv2/opencv.hpp>#include<opencv2/highgui/highgui.hpp>#include<opencv2/imgcodecs/imgcodecs.hpp>#include<opencv2/imgproc/imgproc.hpp>intMain () {//Read ImageCv::mat srcimage = Cv::imread ("1.jpg"); //Show Original ImageImshow ("Original Image", Srcimage); //Blur ImageCv::mat dstimage, Edge, grayimage; //Create a matrix the same size as Srcimagedstimage.create (Srcimage.size (), Srcimage.type ()); //Convert color image to Gray-scale image//OpenCV2//Cv::cvtcolor (Srcimage, Grayimage, Cv::cv_bgr2gray); //OpenCV3Cv::cvtcolor (Srcimage, Grayimage, Cv::color_bgr2gray); //denoisingBlur (Srcimage, Dstimage, Cv::size (3,3)); //Apply Canny operatorCanny (Dstimage, Edge,3,9,3); //Show ResultsImshow ("Canny Edge Detection", Edge); Cv::waitkey (0); return 0;}
CMakeList.txt
2.8find OpenCV packagesfind_package (OpenCV REQUIRED) include_directories (${opencv_ Include_dirs}) # Add the executableadd_executable (cannyedgedetection cannyedgedetection.cxx) target_link_libraries ( Cannyedgedetection opencv_core Opencv_highgui opencv_imgproc opencv_imgcodecs)
Simple example of image processing [OpenCV Note 1]