OpenCv (正式篇) 5----Highgui板块 /* 不断更新 */

  1. Imread()
  2. Imwrite()
  3. Imshow()
  4. nameWindow()
  5. createTrackbar()
  6. setMouseCallback()

Imread():

转到定义查看:

CV_EXPORTS_W Mat imread( const String& filename, int flags = IMREAD_COLOR );
//
//
//! Imread flags
enum ImreadModes {
       IMREAD_UNCHANGED  = -1, //!< If set, return the loaded image as is (with alpha channel, otherwise it gets cropped).
       IMREAD_GRAYSCALE  = 0,  //!< If set, always convert image to the single channel grayscale image.
       IMREAD_COLOR      = 1,  //!< If set, always convert image to the 3 channel BGR color image.
       IMREAD_ANYDEPTH   = 2,  //!< If set, return 16-bit/32-bit image when the input has the corresponding depth, otherwise convert it to 8-bit.
       IMREAD_ANYCOLOR   = 4,  //!< If set, the image is read in any possible color format.
       IMREAD_LOAD_GDAL  = 8   //!< If set, use the gdal driver for loading the image.
     };

imread( const String& filename, int flags = IMREAD_COLOR );
第一个参数:String filename。
第二个参数:flag

   IMREAD_UNCHANGED  = -1, //!< If set, return the loaded image as is (with alpha channel, otherwise it gets cropped).(原始图片)
   IMREAD_GRAYSCALE  = 0,  //!< If set, always convert image to the single channel grayscale image.(灰度图)
   IMREAD_COLOR      = 1,  //!< If set, always convert image to the 3 channel BGR color image.(彩色图)
   IMREAD_ANYDEPTH   = 2,  //!< If set, return 16-bit/32-bit image when the input has the corresponding depth, otherwise convert it to 8-bit.
   IMREAD_ANYCOLOR   = 4,  //!< If set, the image is read in any possible color format.(IMREAD_ANYDEPTH| IMREAD_ANYCOLOR  最真实图片)
   IMREAD_LOAD_GDAL  = 8   //!< If set, use the gdal driver for loading the image.

Imwrite():
转到定义查看:

imwrite( const String& filename, InputArray img,
              const std::vector<int>& params = std::vector<int>());

第一个参数:filename---String
第二个参数: Mat
第三个参数:不了解 待解决(因为有默认值,所以一般不填写)


Imshow()
转到定义查看:

void imshow(const String& winname, InputArray mat);


这个最好明白:
第一个参数: String filename
第二个参数:       inputArray mat

namedWindow()
转到定义:
 void namedWindow(const String& winname, int flags = WINDOW_AUTOSIZE);


 // Flags for namedWindow
enum { WINDOW_NORMAL     = 0x00000000, // the user can resize the window (no constraint) / also use to switch a fullscreen window to a normal size
            WINDOW_AUTOSIZE   = 0x00000001, // the user cannot resize the window, the size is constrainted by the image displayed
            WINDOW_OPENGL     = 0x00001000, // window with opengl support

   WINDOW_FULLSCREEN = 1,          // change the window to fullscreen
   WINDOW_FREERATIO  = 0x00000100, // the image expends as much as it can (no ratio constraint)
   WINDOW_KEEPRATIO  = 0x00000000  // the ratio of the image is respected
 };
第一个参数:窗口名称:String name;
第二个参数:缺省值已经很好用了。自动调节。


 createTrackbar()







setMouseCallback()
转到定义:
void setMouseCallback(const String& window_name, MouseCallback onMouse, void* userdata = 0/*缺省值*/);
 #include "opencv2/highgui.hpp";
 #include <iostream>;

 using namespace std;
 using namespace cv;

 void onChange(int event, int x, int y, int flags, void* userdata){
 cout<<"test"<<endl; };  
 void main(){
namedWindow("test");
/*Mat image=imread("D:\\Picture\\Temp.jpg",-1);
imshow("test",image);*/
setMouseCallback("test",onChange);
waitKey(0);}

“`
各种有趣函数。。。从图像处理开始

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值