Skip to content

Instantly share code, notes, and snippets.

@idiottiger
Last active October 13, 2015 23:38
Show Gist options
  • Save idiottiger/4274302 to your computer and use it in GitHub Desktop.
Save idiottiger/4274302 to your computer and use it in GitHub Desktop.
open cv android
open cv android 学习:
------------------------------------------------------------------
1.基本数据结构: java name -> c/c++ name
Point Point3 -> CvPoint, CvPoint2D32f, CvPoint3D32f
Size -> CvSize, CvSize2D32f
Rect -> CvRect
Scalar -> CvScalar 数据容器,最多可保存4个double值
TermCriteria -> CvTermCriteria ??
Mat -> CvMat 单通道或者多通道矩阵
Imgproc 图像处理函数类
2.图像处理:
Imgproc.gaussian blur 高斯模糊 参考:http://zh.wikipedia.org/wiki/%E9%AB%98%E6%96%AF%E6%A8%A1%E7%B3%8A
Mat 数据类型: CV_<bit_depth>(S|U|F)C<number_of_channels>
CV_8UC1 8位无符号整形单通道矩阵
CV_32FC3 32位浮点型3通道矩阵
Mat 包含两部分: Mat Header(包含:size,保存的方式,matrix 的内存地址),和 指向像素数据的指针
The assignment operator and the copy constructor (ctor)copies only the header. 赋值和拷贝只拷贝 header
Use the clone()or the copyTo() function to copy the underlying matrix of an image. 用 clone 或者 copyTo 会拷贝图像数据
color system 颜色系统:
HLS (Hue 色度,Lightness 亮度,Saturation 饱和度)
YCrCb=YUV 参考: http://baike.baidu.com/view/640197.htm
Contrast 对比度 Brightness 亮度 Saturation 饱和度
Core.LUT
Imgproc.filter2D 滤波器
Imgproc.cvtColor 颜色转换 如:BGR->RGB, BGR->RGBA...
Core.addWeighted 图像混合
Mat is that you no longer need to manually allocate its memory and release it
as soon as you do not need it. While doing this is still a possibility, most of the OpenCV functions will allocate its
output data automatically. As a nice bonus if you pass on an already existing Mat object, which has already allocated
the required space for the matrix, this will be reused. In other words we use at all times only as much memory as we
need to perform the task.
The idea is that each Mat object has its own header,
however the matrix may be shared between two instance of them by having their matrix pointers point to the same
address. Moreover, the copy operators will only copy the headers and the pointer to the large matrix, not the data
itself.
Storing methods
color space and the data type
There are, however, many other color systems each with their own advantages:
• RGB is the most common as our eyes use something similar, our display systems also compose colors using
these.
• The HSV and HLS decompose colors into their hue, saturation and value/luminance components, which is a
more natural way for us to describe colors. You might, for example, dismiss the last component, making your
algorithm less sensible to the light conditions of the input image.
• YCrCb is used by the popular JPEG image format.
• CIE L*a*b* is a perceptually uniform color space, which comes handy if you need to measure the distance of a
given color to another color.
Each of the building components has their own valid domains. This leads to the data type used. How we store a
component defines the control we have over its domain. The smallest data type possible is char, which means one
byte or 8 bits. This may be unsigned (so can store values from 0 to 255) or signed (values from -127 to +127).
Although in case of three components this already gives 16 million possible colors to represent (like in case of RGB)
we may acquire an even finer control by using the float (4 byte = 32 bit) or double (8 byte = 64 bit) data types for
each component. Nevertheless, remember that increasing the size of a component also increases the size of the whole
picture in the memory.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment