1.读取视频
CvCapture *cvVideo;
id res = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"video2.mp4"];
cvVideo = cvCreateFileCapture([res cStringUsingEncoding:NSUTF8StringEncoding]);
IplImage* cvim = cvQueryFrame(cvVideo);
- IpIImage 和 Mat 转换
to IpPImage
Mat image1;
IplImage* image2=cvCloneImage(&(IplImage)image1);
to Mat
IplImage* oldC0 = cvCreateImage(cvSize(320,240),16,1);
Mat newC = cvarrToMat(oldC0);
- IplImage 和 uiimage 转换
https://blog.csdn.net/yishengzhiai005/article/details/51261344
to IpIImage
-(IplImage*)convertToIplImage:(UIImage*)image{
CGImageRef imageRef = image.CGImage;
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
IplImage *iplImage = cvCreateImage(cvSize(image.size.width, image.size.height), IPL_DEPTH_8U, 4);
CGContextRef contextRef = CGBitmapContextCreate(iplImage->imageData, iplImage->width, iplImage->height, iplImage->depth, iplImage->widthStep, colorSpace, kCGImageAlphaPremultipliedLast | kCGBitmapByteOrderDefault);
CGContextDrawImage(contextRef, CGRectMake(0, 0, image.size.width, image.size.height), imageRef);
CGContextRelease(contextRef);
CGColorSpaceRelease(colorSpace);
IplImage *ret = cvCreateImage(cvGetSize(iplImage), IPL_DEPTH_8U, 3);
cvCvtColor(iplImage, ret, CV_RGB2BGR);
cvReleaseImage(&iplImage);
return ret;
}
to UIImage
-(UIImage*)convertToUIImage:(IplImage*)image{
cvCvtColor(image, image, CV_BGR2RGB);
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
NSData *data = [NSData dataWithBytes:image->imageData length:image->imageSize];
CGDataProviderRef provider = CGDataProviderCreateWithCFData((CFDataRef)data);
CGImageRef imageRef = CGImageCreate(image->width, image->height, image->depth, image->depth * image->nChannels, image->widthStep, colorSpace, kCGImageAlphaNone | kCGBitmapByteOrderDefault, provider, NULL, false, kCGRenderingIntentDefault);
UIImage *ret = [UIImage imageWithCGImage:imageRef];
CGImageRelease(imageRef);
CGDataProviderRelease(provider);
CGColorSpaceRelease(colorSpace);
return ret;
}
- 图像平移
https://blog.csdn.net/qq_29540745/article/details/52513181
http://answers.opencv.org/question/61754/translate-mat-by-x-and-y-offset/
https://stackoverflow.com/questions/19068085/shift-image-content-with-opencv
··
5.旋转图片
https://stackoverflow.com/questions/15043152/rotate-opencv-matrix-by-90-180-270-degrees
https://stackoverflow.com/questions/22041699/rotate-an-image-without-cropping-in-opencv-in-c