#include <stdio.h>
#include <opencv2/opencv.hpp>

int main(int argc, char** argv )
{
    char * addr = "./src/cv_test/backGround.jpg";
    cv::String imageName(addr);
    //创建Mat
    cv::Mat image;
    //读取图片
    image = cv::imread(imageName, 1 );
    //判断图片是否存在
    if(!image.empty() && image.data){
        //创建窗口
        cv::namedWindow("Display Image", cv::WINDOW_AUTOSIZE );
        //显示图片
        cv::imshow("Display Image", image);
        //彩图转灰度图
        cv::Mat gray_image;
        cv::cvtColor(image, gray_image, cv::COLOR_BGR2GRAY);
        cv::namedWindow("Display Image2", cv::WINDOW_AUTOSIZE );
        cv::imshow("Display Image2", gray_image);
        //保存图片
        cv::imwrite( "./src/cv_test/Gray_Image.jpg", gray_image);
        //中断
        cv::waitKey(0);
    }else
    {
        std::cout<<imageName<<std::endl;
        std::cout<<"empty image"<<std::endl;
    }
    
    return 0;
}