Core模块其他常用知识点[OpenCV 笔记14]

Matx

轻量级的Mat,必须在使用前规定好大小,比如一个2x3的float型的Matx,可以声明为Matx23f

Vec

Vec是Matx的一个派生类,是一个一维的Matx,跟vector很相似。在OpenCV源码中定义如下:

template<typename _TP, int n> class Vec : public Matx<_Tp, n, 1> {...};
typedef Vec<uchar, 2> Vec2b;

Range

使OpenCV的使用更像MATLAB, Range::all()等同于MATLAB的:,Range(a,b)等同于MATLAB的a:b,其中a, b为整型

内存溢出

防止内存溢出的函数有alignPtr, alignSize, allocate, deallocate, fastMalloc, fastFree

math.h函数

float cv::fastAtan2 (   float y, float x ); // 计算向量角度

float cv::cubeRoot (float val);  // 计算立方根

int     cvCeil (double value);
int     cvCeil (float value);
int     cvCeil (int value);  // 向上取整

int     cvFloor (double value);
int     cvFloor (float value);
int     cvFloor (int value);  // 向下取整

int     cvRound (double value)
int     cvRound (float value)
int     cvRound (int value)  // 四舍五入

int     cvIsInf (double value);
int     cvIsInf (float value);  // 自变量是否无穷大

int     cvIsNaN (double value);
int     cvIsNaN (float value);  // 自变量是否为NaN

文字显示函数

Size cv::getTextSize(   const String & text, int fontFace, double fontScale, int thickness, int * baseLine );
// Calculates the width and height of a text string.
//  baseLine:   y-coordinate of the baseline relative to the bottom-most text point.

void    cv::putText (InputOutputArray img, const String &text, Point org, int fontFace, double fontScale, Scalar color, int thickness=1, int lineType=LINE_8, bool bottomLeftOrigin=false)
// Renders the specified text string in the image.

void cvInitFont( CvFont * font, int font_face, double hscale, double vscale, double shear = 0, int thickness = 1, int line_type = 8 )
// Initializes the font structure that can be passed to text rendering functions.

作图函数

可参考链接

void    cv::circle (InputOutputArray img, Point center, int radius, const Scalar &color, int thickness=1, int lineType=LINE_8, int shift=0);
// Draw a circle.

bool    cv::clipLine (Size imgSize, Point &pt1, Point &pt2)
// Clips the line against the image rectangle.

void    cv::ellipse (InputOutputArray img, Point center, Size axes, double angle, double startAngle, double endAngle, const Scalar &color, int thickness=1, int lineType=LINE_8, int shift=0)
// Draws a simple or thick elliptic arc or fills an ellipse sector.

void    cv::ellipse (InputOutputArray img, const RotatedRect &box, const Scalar &color, int thickness=1, int lineType=LINE_8)

void    cv::ellipse2Poly (Point center, Size axes, int angle, int arcStart, int arcEnd, int delta, std::vector< Point > &pts)
// Approximates an elliptic arc with a polyline.

void    cv::line (InputOutputArray img, Point pt1, Point pt2, const Scalar &color, int thickness=1, int lineType=LINE_8, int shift=0)
// Draws a line segment connecting two points.

void    cv::polylines (Mat &img, const Point *const *pts, const int *npts, int ncontours, bool isClosed, const Scalar &color, int thickness=1, int lineType=LINE_8, int shift=0)

void    cv::polylines (InputOutputArray img, InputArrayOfArrays pts, bool isClosed, const Scalar &color, int thickness=1, int lineType=LINE_8, int shift=0)
// Draws several polygonal curves.

class   cv::LineIterator;

填充函数

void cv::fillConvexPoly (Mat &img, const Point *pts, int npts, const Scalar &color, int lineType=LINE_8, int shift=0)

void cv::fillConvexPoly (InputOutputArray img, InputArray points, const Scalar &color, int lineType=LINE_8, int shift=0)
// Fills a convex polygon.

void    cv::fillPoly (Mat &img, const Point **pts, const int *npts, int ncontours, const Scalar &color, int lineType=LINE_8, int shift=0, Point offset=Point())

void    cv::fillPoly (InputOutputArray img, InputArrayOfArrays pts, const Scalar &color, int lineType=LINE_8, int shift=0, Point offset=Point())
// Fills the area bounded by one or more polygons. 

随机数生成器

class RNG;
时间: 2024-08-27 07:28:05

Core模块其他常用知识点[OpenCV 笔记14]的相关文章

常用数据结构[OpenCV 笔记12]

Point 二维坐标系下的整数点, 定义如下 typedef Point_<int> Point2i; typedef Point2i Point; typedef Point_<float> Point2f; 构造函数如下: Point_ () Point_ (_Tp _x, _Tp _y) Point_ (const Point_ &pt) Point_ (const Size_< _Tp > &sz) Point_ (const Vec< _

图像载入 imshow()[OpenCV 笔记5]

void imshow(const string& winname InputArray mat); winname 窗口表识名称 mat 需要显示的图像.InputArray类型,声明如下 typedef const _InputArray& InputArray; _InputArray定义比较复杂,类里先定义了一个枚举,然后是各类的模版类型和一些方法.遇到InputArray/OutputArray类型,可以把它当作Mat类型处理. 图像大小缩放 如果窗口是用CV_WINDOW_AU

OpenCV基本架构[OpenCV 笔记0]

最近正在系统学习OpenCV,将不定期发布笔记,主要按照毛星云的<OpenCV3编程入门>的顺序学习,会参考官方教程和文档.学习工具是Xcode+CMake,会对书中一部分内容更正,并加入cmakelist的内容. 书中大部分内容来自OpenCV文档,其实比较推荐官方文档和教程 OpenCV2.4.13: http://docs.opencv.org/2.4/index.html OpenCV安装路径下的include文件夹包含opencv和opencv2两个文件夹.opencv文件夹包含Op

OpenCV Tricks[OpenCV 笔记3]

官方例程 事例程序位于opencv-3.1.0/samples/cpp/ 目录下,可以通过编译整个工程,编译所有的Sample Code 显示当前使用的OpenCV版本 CV_VERSION为标识当前OpenCV版本的宏 printf("\t OpenCV Version: OpenCV " CV_VERSION); 头文件opencv.hpp opencv2/opencv.hpp中包含了OpenCV各模块的头文件,原则上仅写一句: #include <opencv2/openc

查找并绘制轮廓[OpenCV 笔记XX]

好久没有更新了,原谅自己放了个假最近又在赶进度,所以...更新的内容是很靠后的第八章,因为最近工作要用就先跳了,后面会更新笔记编号...加油加油! 在二值图像中寻找轮廓 void cv::findContours ( InputOutputArray image, OutputArrayOfArrays contours, OutputArray hierarchy, int mode, int method, Point offset = Point() ) image: 输入图像,需为8位单

输出图像到文件 imwrite()[OpenCV 笔记7]

bool imwrite(const string& filename, InputArray img, const vector<int>& params=vector<int>()); filename 待写入的文件名.保存图像的格式由扩展名决定. img 一般为一个Mat类型的图像 params 特定格式保存的参数编码: JPEG:params表示0到100的图片质量(CV_IMWRITE_JPEG_QUALITY),默认值为95: PNG:params表示压

图像处理简单实例[OpenCV 笔记1]

几个入门的简单程序,和对应的CMakeList, 虽然简单重新测一下写一下也是好的. CMake教程传送门 图像显示 ShowImage.cxx #include <opencv2/opencv.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/imgcodecs/imgcodecs.hpp> int main(){ cv::Mat srcImage = cv::imread("1.jp

实例:图像载入、显示、混合与输出[OpenCV 笔记8]

是的是的,忍着尿意努力更新,就是为了更到wuli男神的部分,当然要把男神放在前面镇楼,欢迎下载配图,具体操作见code wuliEddie.jpg logo.png results.jpg LoadShowWriteImage.cxx #include <opencv2/opencv.hpp> #include <opencv2/highgui/highgui.hpp> //#include <opencv2/imgcodecs/imgcodecs.hpp> //#in

视频处理简单实例 [OpenCV 笔记2]

VideoCapture是OpenCV 2.X中新增的类,提供从摄像机或视频文件捕获视频的C++接口.利用它读入视频的方法一般有两种: // method 1 VideoCapture capture; capture.open("1.avi"); // method 2 VideoCapture capture("1.avi"); 读取并播放视频 ReadPlayVideo.cxx #include <opencv2/opencv.hpp> int m