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限制的70M. Delphi-OpenCV OpenCV version - 2.4.13 Development environment - Delphi 2010-10.1 Contributors: Laentir Valetov (email: laex@bk.ru) Mikhail Grigorev (email: sleuthhound@gmail.com) Requirements: Visual C++ redistributable for Visual Studio 2013 Files: msvcp120.dll, msvcr120.dll, msvcp120d.dll, msvcr120d.dll (1) 32-bit in the "Delphi-OpenCV\redist\VC2013x86\" (2) 64-bit in the "Delphi-OpenCV\redist\VC2013x64\" Shared library FFMPEG 3.2 for Windows can be downloaded from here (3) FFmpeg 32-bit Shared (4) FFmpeg 64-bit Shared Dynamic library OpenCV need to download here Files: _2413.dll and _2413d.dll After installing OpenCV: (5) 32-bit in the C:\OpenCV\build\x86\vc12\bin\ (6) 64-bit in the C:\OpenCV\build\x64\vc12\bin\ Some examples (FFMPEG) required SDL 2.0 and SDL 1.2 (7) SDL.dll and SDL2.dll Copy files OS Windows 64-bit Target platform 64-bit: (2),(4),(6) -> "C:\Windows\System32\" Target platform 32-bit: (1),(3),(5),(7) -> "C:\Windows\SysWOW64\" OS Windows 32-bit Target platform 32-bit: (1),(3),(5),(7) -> "C:\Windows\System32\" How to install: Download the archive. Unzip it to a convenient directory, thus get the following directory structure <PROJECT_ROOT> - Directory, for example, "C:\Delphi\OpenCV\" <bin> <redist> <resource> <samples> <source> Add the search path for the modules of the project in Delphi IDE (Tools-Options-Delphi Options-Library-Library path) <PROJECT_ROOT>\source <PROJECT_ROOT>\source\utils <PROJECT_ROOT>\source\component <PROJECT_ROOT>\source\sdl <PROJECT_ROOT>\source\opengl <PROJECT_ROOT>\source\ffmpeg <PROJECT_ROOT>\resource\facedetectxml where <PROJECT_ROOT> directory, which was unzipped project. To install the components, open and install <PROJECT_ROOT>\source\component\DelphiXX\OpenCVXXX.dpk <PROJECT_ROOT>\source\component\DelphiXX\dclCommonOpenCVXXX.dpk <PROJECT_ROOT>\source\component\DelphiXX\dclVCLOpenCVXXX.dpk <PROJECT_ROOT>\source\component\DelphiXX\dclFMXOpenCVXXX.dpk Open in Delphi IDE and compile: Examples of the use of certain functions and procedures <PROJECT_ROOT>\samples\LibDemo\LibDemo.groupproj Examples of the use of video processing algorithms <PROJECT_ROOT>\samples\MultiDemo\MultiDemo.groupproj Examples of the use of video processing algorithms using VCL.Forms <PROJECT_ROOT>\samples\VCLDemo\VCLDemo.groupproj Examples of using FFMPEG library header files are in the <PROJECT_ROOT>\samples\FFMpeg\FFMPEG.groupproj Examples of use of components <PROJECT_ROOT>\samples\Components\ComponentsDemo.groupproj Donate (PayPal USD) Donate (PayPal EUR) Donate (PayPal RUB) Yandex Money: 410012802258318
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值