cvcreateimage

一些常用的opencv函数

别说谁变了你拦得住时间么 提交于 2020-02-16 08:02:01
分配图像空间: IplImage* cvCreateImage(CvSize size, int depth, int channels); size: cvSize(width,height); depth: IPL_DEPTH_8U, IPL_DEPTH_8S, IPL_DEPTH_16U, IPL_DEPTH_16S, IPL_DEPTH_32S, IPL_DEPTH_32F,IPL_DEPTH_64F channels: 1, 2, 3 or 4. 注意数据为交叉存取.彩色图像的数据编排为b0 g0 r0 b1 g1 r1 ... 举例: // 分配一个单通道字节图像 IplImage* img1=cvCreateImage(cvSize(640,480),IPL_DEPTH_8U,1); // 分配一个三通道浮点图像 IplImage* img2=cvCreateImage(cvSize(640,480),IPL_DEPTH_32F,3); 释放图像空间: IplImage* img=cvCreateImage(cvSize(640,480),IPL_DEPTH_8U,1); cvReleaseImage(&img); 复制图像: IplImage* img1=cvCreateImage(cvSize(640,480),IPL_DEPTH_8U,1); IplImage*

OpenCV——肤色检测

允我心安 提交于 2019-12-30 03:00:03
一、RGB color space 检测代码如下: void SkinRGB(IplImage* src,IplImage* dst) { //RGB颜色空间 //均匀照明:R>95,G>40,B>20,R-B>15,R-G>15,R>B%R //侧向照明:R>200,G>210,B>170,R-B<=15,R>B,G>B int height = src->height, width = src->width, channel = src->nChannels, step = src->widthStep; int b = 0, g = 1, r = 2; cvZero(dst); unsigned char* p_src = (unsigned char*)src->imageData; unsigned char* p_dst = (unsigned char*)dst->imageData; for(int j = 0; j < height; j++){ for(int i = 0; i < width; i++){ if((p_src[j*step+i*channel+r] > 95 && p_src[j*step+i*channel+g] > 40 && p_src[j*step+i*channel+b] > 20 && (p_src[j*step+i*channel