zoukankan      html  css  js  c++  java
  • OpenCV学习笔记1_ShowImage_显示一幅图像

    显示一幅图像

    ShowImage.c
    /* 
    * Copyright (c) 2013,合肥学院智能视觉实验室 
    * All rights reserved. 
    * 
    * 文件名称:ShowImage.c
    * 摘    要:加载一幅图像
    * 
    * 当前版本:1.0 
    * 作    者:高全宁 
    * 完成日期:2013年5月2日 
    *
    *亲测有效
    */ 
    
    #include "stdafx.h"
    
    #include "cv.h"  
    #include "highgui.h" 
    #include "cxcore.h" 
    
    int main(int argc, char* argv[])
    {
    
        //读入图像,并且原始图像显示
        IplImage* img = cvLoadImage("F:\\tomato.jpg" ,IMREAD_ANYDEPTH | IMREAD_ANYCOLOR);
        //IplImage* img = cvLoadImage("F:\\tomato.jpg" ,1);     //一个宏定义:#define CV_LOAD_IMAGE_COLOR   1  表示彩色图像加载图片(3通道)
    
        cvNamedWindow("show_image",1);
    
        cvShowImage("show_image", img);
    
        cvWaitKey(0);
        
        cvReleaseImage(&img);
    
        cvDestroyWindow("show_image");
    }

    ShowImage.cpp
    /* 
    * Copyright (c++) 2013,合肥学院智能视觉与检测实验室 
    * All rights reserved. 
    * 
    * 文件名称:ShowImage.cpp
    * 摘    要:加载一幅图像
    * 
    * 当前版本:1.0 
    * 作    者:高全宁 
    * 完成日期:2013年5月2日
    *
    *亲测有效 
    */ 
    
    #include "stdafx.h"
    
    #include <opencv2/highgui/highgui.hpp>  
    #include <opencv2/imgproc/imgproc.hpp>  
    #include <opencv2/core/core.hpp>  
    
    using namespace std;
    using namespace cv; 
    
    int main()
    {
        //加载一幅图像
        string imagename = "F:\\tomato.jpg";
    
        //读入图像,并且原始图像显示
        Mat img = imread(imagename,IMREAD_ANYDEPTH | IMREAD_ANYCOLOR);
    
        //如果读入图像失败
        if(img.empty())
        {
            fprintf(stderr, "Can not load image %s\n", imagename);
            return -1;
        }
    
        namedWindow("image",1);
        imshow("image", img);
    
        waitKey(0);
    }
    
    

     

  • 相关阅读:
    Java Output流写入包装问题
    SpringBoot项目单元测试不经过过滤器问题
    SpringSecurity集成启动报 In the composition of all global method configuration, no annotation support was actually activated 异常
    JWT jti和kid属性的说明
    Maven 排除依赖
    第五章 基因概念的发现
    第三章 孟德尔遗传的拓展
    第二章 孟德尔遗传
    第一章 引言
    GWAS全基因组关联分析
  • 原文地址:https://www.cnblogs.com/gaoquanning/p/3066545.html
Copyright © 2011-2022 走看看