OpenCV IplImage图片结构
前言
IplImage在4.0版本中对应的操作函数大多被废弃,例如cvCreateImage,所以如果需要使用目前在3.0版本上测试通过
当前以对接虹软SDK的例子为例子简单说明
//裁剪图片
void CutIplImage(IplImage* src, IplImage* dst, int x, int y)
{
CvSize size = cvSize(dst->width, dst->height);//区域大小
cvSetImageROI(src, cvRect(x, y, size.width, size.height));//设置源图像ROI
cvCopy(src, dst); //复制图像
cvResetImageROI(src);//源图像用完后,清空ROI
}
IplImage* img1 = cvLoadImage("F:/2-123.jpg");
IplImage* cutImg1 = cvCreateImage(cvSize(img1->width - img1->width % 4, img1->height), IPL_DEPTH_8U, img1->nChannels);
CutIplImage(img1, cutImg1, 0, 0);
ASVLOFFSCREEN offscreen1 = { 0 };
offscreen1.u32PixelArrayFormat = ASVL_PAF_RGB24_B8G8R8;
offscreen1.i32Width = cutImg1->width;
offscreen1.i32Height = cutImg1->height;
offscreen1.pi32Pitch[0] = cutImg1->widthStep;
offscreen1.ppu8Plane[0] = (MUInt8*)cutImg1->imageData;
res = ASFDetectFacesEx(handle, &offscreen1, &detectedFaces1);