基于C++的OpenCV常用函数

本文详细介绍了C++版本OpenCV库中的常用函数,包括图像读取、显示、处理、视频操作、矩阵操作等多个方面,如imread、imshow、waitKey、cvtColor等,并提供了相关示例,帮助开发者更好地理解和运用OpenCV进行图像处理工作。
摘要由CSDN通过智能技术生成
               

C++版本的好处:

1、在于可以尽量避免使用指针这种危险的东西;

2、不用费心去release资源了,因为在其destructor里面,系统会自动帮你搞定。

3、在某些情况下会比C版本运行速度快。

在文件中包含 using namespace cv;

 

1.        imread(cvLoadImage):loads an image from a file;

2.        imshow(cvShowImage):displays an image in the specifiedwidow;

3.        waitKey(cvWaitKey):waits for a pressed key;

4.        cvtColor(cvCvtColor):converts an image from one colorspace to another;

5.        reduce(cvReduce):reduces a matrix to a vector;

6.        minMaxLoc(cvMinMaxLoc):finds the global minimum andmaximum in a whole array or sub-array;

7.        namedWindow(cvNamedWindow):creates a window;

8.        destroyWindow(cvDestroyWindow):destroys a window;

9.        destroyAllWindows(cvDestroyAllWindows):destroys all of the HighGUIwindows;

10.    imwrite(cvSaveImage):saves an image to a specified file;

11.    resize(cvResize):resizes an image;

12.    pyrDown(cvPyrDown):blurs an image and downsamples it;

13.    pyrUp(cvPyrUp):upsamples an image and then blursit;

14.    threshold(cvThreshold):applies a fixed-level threshold toeach array element;

15.    adaptiveThreshold(cvAdaptiveThreshold):applies an adaptive threshold toan array;

16.    VideoCapthure::open(cvCaptureFromFile):open video file or a capturingdevice for video capturing;

17.    VideoCapture::isOpened:returns true if video capturinghas been initialized already;

18.    VideoCapture::release(cvReleaseCapture):closes video file or capturingdevice;

19.    VideoCapture::grab(cvGrabFrame):grabs the next frame from videofile or capturing device;

20.    VideoCaputre::retrieve(cvRetrieveFrame):decodes and returns the grabbedvideo frame;

21.    VideoCapture::read(cvQueryFrame):grabs,decodes and returns the nextvideo frame;

22.    VideoCapture::get(cvGetCaptureProperty):returns the specified VideoCaptureproperty;

23.    VideoCapture::set(cvSetCaptureProperty):sets a property in theVideoCapture;

24.    VideoWriter::open:initializes or reinitializes videowriter;

25.    VideoWriter::isOpened:returns true if video writer hasbeen successfully initialized;

26.    VideoWriter::write:writes the next video frame;

27.    Mat::row:creates a matrix header for thespecified matrix row;

28.    Mat::col:creates a matrix header for thespecified matrix column;

29.    Mat::rowRange:creates a matrix header for thespecified row span;

30.    Mat::colRange:creates a matrix header for thespecified col span;

31.    Mat::diag:extracts a diagonal from a matrix,or creates a diagonal matrix;

32.    Mat::clone:creates a full copy of the arrayand the underlying data;

33.    Mat::copyTo(cvCopy):copies the matrix to another one;

34.    Mat::convertTo(cvConvertScale):converts an array to anotherdatatype with optional scaling;

35.    Mat::assignTo:provides a functional form ofconvertTo;

36.    Mat::setTo:sets all or some of the arrayelements to the specified value;

37.    Mat::reshape:changes the shape and/or thenumber of channels of a 2D matrix without copying the data;

38.    Mat::t:transposes a matrix;

39.    Mat::inv:inverses a matrix;

40.    Mat::mul:performs an element-wisemultiplication or division of the two matrices;

41.    Mat::cross:computes a cross-product of two3-element vectors;

42.    Mat::dot:computes a dot-product of twovectors;

43.    Mat::zeros:returns a zero array of thespecified size and type;

44.    Mat::ones:returns an array of all 1’s of thespecified size and type;

45.    Mat::eye:returns an identity matrix of thespecified size and type;

46.    Mat::create:allocates new array data if needed;

47.    Mat::addref:increments the reference counter;

48.    Mat::release:decrements the reference counterand deallocates the matrix if needed;

49.    Mat::resize:changes the number of matrix rows;

50.    Mat::reserve:reserves space for the certainnumber of rows;

51.    Mat::push_back:adds elements to the bottom of thematrix;

52.    Mat::pop_back:removes elements from the bottomof the matrix;

53.    Mat::locateROI:locates the matrix header within aparent matrix;

54.    Mat::adjustROI:adjusts a submatrix size andposition within the parent matrix;

55.    M

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值