学习资料:

http://www.opencv.org.cn/opencvdoc/2.3.2/html/doc/tutorials/tutorials.html

 

包含头文件

core.hpp:包含了基本的定义和库

highgui.hpp:包含了基本的输入输出操作

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>

创建一个矩阵对象来存储和载入图像数据

Mat image;

imread函数的第一个参数时载入图像的文件名,第二个参数时图像的格式。格式可以为:

CV_LOAD_IMAGE_UNCHANGED (<0) loads the image as is (including the alpha channel if present)

CV_LOAD_IMAGE_GRAYSCALE ( 0) loads the image as an intensity one

CV_LOAD_IMAGE_COLOR (>0) loads the image in the RGB format

image = imread(argv[1], CV_LOAD_IMAGE_COLOR);   // Read the file

创建窗口

CV_WINDOW_AUTOSIZE is the only supported one if you do not use the Qt backend. In this case the window size will take up the size of the image it shows. No resize permitted!

CV_WINDOW_NORMAL on Qt you may use this to allow window resize. The image will resize itself according to the current window size. By using the | operator you also need to specify if you would like the image to keep its aspect ratio (CV_WINDOW_KEEPRATIO) or not (CV_WINDOW_FREERATIO).

namedWindow( "Display window", CV_WINDOW_AUTOSIZE );// Create a window for display.

显示图片

imshow( "Display window", image );   // Show our image inside it.

等待显示

waitKey(0);   // Wait for a keystroke in the window

编译运行

./DisplayImage HappyFish.jpg

[学习OpenCV攻略][011][显示图片]的更多相关文章

  1. [学习OpenCV攻略][007][缩小图片]

    cvPryDown(输入图片,输出图片) 根据输出图片的大小,把输入图片进行压缩 cvPryUp(输入图片,输出图片) 根据输出图片的大小,把输入图片进行放大 #include "cv.h& ...

  2. [学习OpenCV攻略][006][平滑图片]

    cvCreateImage(图片大小,像素位数,通道数) 创建图片,根据输入的图片大小,各个通道像素点的位数,和通道数.像素点宏IPL_DEPTH_8U cvGetSize(图片) 得到图片的大小信息 ...

  3. [学习OpenCV攻略][003[初试牛刀——显示图片]

    cvLoadImage(路径) 加载指定路径的图片到内存 cvNamedWindow("窗口名称", 属性) 创建窗口,窗口名称用来被其他函数引用,属性:0表示窗口大小不变,CV_ ...

  4. [学习OpenCV攻略][002][Ubuntu下OpenCV安装]

    配置环境 操作系统 Ubuntu 12.04 OpenCV版本 opencv-1.0.0 学习书籍 <学习OpenCV> Liunx软件安装方法主要有3种: 1.编译安装,也就是通过编译源 ...

  5. [学习OpenCV攻略][017][ARM9下移植OpenCV]

    安装环境 宿主机: Red Hat Enterprise Linux Server 6.3 开发板: mini2440 相关软件: cmake-3.5.1.tar.gz.OpenCV-2.3.1a.t ...

  6. [学习OpenCV攻略][016][RedHat下安装OpenCV]

    安装环境 操作系统: Red Hat Enterprise Linux Server 6.3 相关软件: ffmpeg-0.8.15.tar.bz2.cmake-3.5.1.tar.gz.OpenCV ...

  7. [学习OpenCV攻略][013][Mat - 基本图像容器]

    Mat 是一个类,由两个数据部分组成:矩阵头(包含矩阵尺寸,存储方法,存储地址等信息)和一个指向存储所有像素值的矩阵(根据所选存储方法的不同矩阵可以是不同的维数)的指针. 矩阵属于多个 Mat 对象, ...

  8. [学习OpenCV攻略][010][写入AVI文件]

    cvSize(文件宽度,文件高度) 通过图片或视频文件的宽高得到尺寸信息,返回值是CvSize cvCreateVideoWriter(输出文件名,编码格式,帧率,图像大小) 通过设置输出视频的格式信 ...

  9. [学习OpenCV攻略][008][Canny边缘检测]

    cvGetSize(输入图片) 得到输入图片的大小 cvCanny(输入图片,输出图片,lowThresh,highThresh,aperture) 把输入图片按设定光圈值进行Canny边缘检测,然后 ...

随机推荐

  1. PredictionIO+Universal Recommender快速开发部署推荐引擎的问题总结(2)

    1, 对Universal Recommender进行pio build成功,但是却提示No engine found Building and delpoying model [INFO] [Eng ...

  2. MySQL小抄

    以下是MySQL5.7中的一些tips&tricks(持续更新中): Use of an unqualified * with other items in the select list m ...

  3. Spring之DAO二

    上一篇算是把JdbcDaoSupport的使用演示了一下,这篇主要是演示MappingSqlQuery.SqlUpdate.SqlFunction的使用以及Spring的事务管理. 一.Mapping ...

  4. CRM项目总结

                CRM项目总结      一:开发背景 在公司日益扩大的过程中,不可避免的会伴随着更多问题出现. 对外 : 如何更好的管理客户与公司的关系?如何更及时的了解客户日益发展的需求变 ...

  5. 去除测序reads中的接头:adaptor

    之前用c写过一个程序,查找reads中是否包含了adaptor,如果检测到的话就过滤掉含有adaptor的reads,这次在过滤完数据之后发现接头序列比较多,为了提升组装效果,又不能很大地影响数据量, ...

  6. 关于swing的一些问题

    -问题1 :Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 1 & ...

  7. ASP.NET Core学习之二 菜鸟踩坑

    对于像我这样没接触过core的人,坑还是比较多的,一些基础配置和以前差别很大,这里做下记录 一.Startup 1.注册服务 // This method gets called by the run ...

  8. Looping over the databases on a server

    SP_MSFOREACHDB 获得所有实例下数据库名称 EXEC sp_MSForEachDB 'PRINT "?"'   sp_MSforeachtable   USE MAST ...

  9. openldap 编译报错MozNSS not found

    openldap 编译报错 1)报错 MozNSS not found - please specify the location to the NSPR and NSS header files i ...

  10. ubuntu16.04安装flash player与谷歌浏览器(chrome)

    一,安装 adobe flash player sudo apt-get upgradesudo apt-get install flashplugin-installer 二,安装chrome浏览器 ...