- Imread()
- Imwrite()
- Imshow()
- nameWindow()
- createTrackbar()
- 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);}
“`
各种有趣函数。。。从图像处理开始