我的第一个opencv的调试好的程序,开心

// Exercise4.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
#include<iostream> 


//#define OPENCV_CPP_INTERFACE
#include "opencv2/opencv.hpp"
#include <opencv2/core/core.hpp>           // cv::Mat
#include <opencv2/highgui/highgui.hpp>     // cv::imread()
#include <opencv2/imgproc/imgproc.hpp>     // cv::Canny()
using namespace cv;
int main()
{
    cv::Mat image1;
    cv::Mat image2;
    std::string image_filepath1 = "/Users/xxoo/source/repos/Exercise4/Exercise4/fd1.bmp";
    std::string image_filepath2 = "/Users/xxoo/source/repos/Exercise4/Exercise4/fd2.bmp";

    image1 = cv::imread(image_filepath1, 0);
    image2 = cv::imread(image_filepath2, 0);
    //================================================================
    //check if the image is properly laoded
    if (image1.data == NULL) {
        std::cout << "unable to load image1 with file path: " << image_filepath1 << std::endl;
        std::cout << "ending execution..." << std::endl;
        return 0;
    }
    if (image2.data == NULL) {
        std::cout << "unable to load image2 with file path: " << image_filepath2 << std::endl;
        std::cout << "ending execution..." << std::endl;
        return 0;

    }
    cv::Mat image_sub = abs(image1 - image2);

    cv::imshow("image1", image1);
    cv::imshow("image2", image2);
    cv::imshow("image_sub", image_sub);
    std::cout << "Press any key while focusing on the GUI to continue..." << std::endl;
    cv::waitKey();

}
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

和你在一起^_^

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值