opencv的简单使用

opencv官方网址opencv

一、图像读取

从 html canvas 或 img 元素中读取图像

imageSource:元素ID

cv.imread (imageSource)

let src = cv.imread('srcImg');

二、cv.Mat方法

cv.Mat(rows,cols,type)          //形成矩阵函数

  1. rows   Mat矩阵的行数
  2. cols    Mat矩阵的列数
  3. type    Mat的类型 

Depth

 用来度量每一个像素中每一个通道的精度,但它本身与图像的通道数无关!depth数值越大,精度越高。在Opencv中,Mat.depth()得到的是一个0~6的数字,分别代表不同的位数,对应关系如下:enum{CV_8U=0,CV_8S=1,CV_16U=2,CV_16S=3,CV_32S=4,CV_32F=5,CV_64F=6}          

其中U是unsigned的意思,S表示signed,也就是有符号和无符号数。

Channel

Mat矩阵元素拥有的通道数。例如常见的RGB彩色图像,channels==3;而灰度图像只有一个灰度分量信息,channels==1

 

三、设置图层色彩空间转换

cv.cvtColor(src, dst, code,dstCn);
  1. src:原图像
  2. dst:目标图像
  3. code:默认图片通道是BGR,不是RGB。
  4. dstCn:输出通道道数,默认为0

四、图像显示

cv.imshow(canvasSource, mat);
  1. canvasSource: canvas元素
  2. mat: 矩阵函数

五、绘制图形

  1. 画线段 cv.line

     2. 画圆形 cv.circle

    3. 画矩形 cv.rectangle

    4. 画椭圆 cv.ellipse

    5. 添加文本 cv.putText

文字类型主要有几种:

  1. cv.FONT_HERSHEY_SIMPLEX 正常尺寸无衬线
  2. cv.FONT_HERSHEY_PLAIN 小尺寸无衬线
  3. cv.FONT_HERSHEY_DUPLEX 正常尺寸(类型 1 的复制版)
  4. cv.FONT_HERSHEY_COMPLEX 正常尺寸有衬线
  5. cv.FONT_HERSHEY_TRIPLEX 正常尺寸有衬线(类型 4 的复杂版)
  6. cv.FONT_HERSHEY_COMPLEX_SMALL (类型 4 的小尺寸)
  7. cv.FONT_HERSHEY_SCRIPT_SIMPLEX 手写风格
  8. cv.FONT_HERSHEY_SCRIPT_COMPLEX (类型 7 的复杂版)
  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
由于文件大小超过csdn限制的60M,所以分割成2个文件了,请注意下载。 Delphi-OpenCV (master) OpenCV version - 2.4.8 Development environment - Delphi XE2-XE5 Contributors: Laentir Valetov email: [email protected] Mikhail Grigorev email: [email protected] How to install: 1.Download the archive Delphi-OpenCV-master.zip 2.Unzip it to a convenient directory, thus get the following directory structure <Directory, such as 'C:\OpenCV\' - <PROJECT_ROOT>> <bin> <component> <include> <opencv_classes> <samples> 3.Add the search path for the modules of the project in Delphi IDE (Tools-Options-Delphi Options-Library-Library path) <PROJECT_ROOT>\Include <PROJECT_ROOT>\Include\core <PROJECT_ROOT>\Include\highgui <PROJECT_ROOT>\Include\imgproc <PROJECT_ROOT>\Include\legacy <PROJECT_ROOT>\Include\nonfree <PROJECT_ROOT>\Include\objdetect <PROJECT_ROOT>\Include\calib3d <PROJECT_ROOT>\Include\contrib <PROJECT_ROOT>\Include\video <PROJECT_ROOT>\Include\ml <PROJECT_ROOT>\Include\stitching <PROJECT_ROOT>\component where <PROJECT_ROOT> directory, which was unzipped project. Additionally, you can specify the path to the library header files FFMPEG <PROJECT_ROOT>\Include\ffmpeg <PROJECT_ROOT>\Include\ffmpeg\ctypes <PROJECT_ROOT>\Include\ffmpeg\libavcodec <PROJECT_ROOT>\Include\ffmpeg\libavfilter <PROJECT_ROOT>\Include\ffmpeg\libavformat <PROJECT_ROOT>\Include\ffmpeg\libavutil <PROJECT_ROOT>\Include\ffmpeg\libswscale Examples of using FFMPEG library header files are in the <PROJECT_ROOT>\Delphi-OpenCV-master\Include\ffmpeg\examples 4.Open in Delphi IDE and compile: Examples of the use of certain functions and procedures <PROJECT_ROOT>\samples\LibDemo.groupproj Examples of the use of video processing algorithms <PROJECT_ROOT>\samples\MultiDemo.groupproj Examples of the use of video processing algorithms using VCL.Forms <PROJECT_ROOT>\samples\VCLDemo.groupproj Examples of use of components. To install the components, open and install <PROJECT_ROOT>\Include\component\OpenCV.dpk <PROJECT_ROOT>\samples\ComponentDemo.groupproj

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值