OpenCV Help Library for iOS
OTHER License
This library helps OpenCV programming on iOS. Currently, it includes a mutual converter UIImage <->IplImage. You can convert them mutually without complicated codes.
// Convert to CGImageRef from IplImage
CGImageRef p = CGCreateImageWithIplImage(originalSourceImage);
// Convert to IplImage(RGB) from CGImageRef
IplImage *duplicatedFromCGImage = CGCreateIplImageWithCGImage(p);
NSString *path = [[NSBundle mainBundle] pathForResource:@"testImage_Gray_PNG24.png" ofType:nil];
IplImage *original = cvLoadImage([path UTF8String], CV_LOAD_IMAGE_COLOR);
+ (UIImage*)imageWithIplImage:(IplImage*)inputImage;
###Parameters ###inputImage The image to be converted to UIImage. ###Return value An autoreleased new bitmap image as UIImage. ###Discussion None.
- (IplImage*)createIplImage;
###Return value A new IpImage bitmap image. You are responsible for releasing this object by calling cvReleaseImage. ###Discussion Output image is 24bit color.
IplImage* CGCreateIplImageWithCGImage(
CGImageRef imageRef,
int iscolor
);
###Parameters ###inputImageRef The image to be converted to IplImage. ###iscolor Output IplImage's color type. You can use only CV_LOAD_IMAGE_GRAYSCALE, CV_LOAD_IMAGE_COLOR or CV_LOAD_IMAGE_ANYCOLOR and MUST NOT USE(NOT SUPPORTED) any combinations of these types. Specific color type of the loaded image: if , the loaded image is forced to be a 3-channel color image; if CV_LOAD_IMAGE_GRAYSCALE, the loaded image is forced to be grayscale; if , the loaded image will be loaded as is (note that in the current implementation the alpha channel, if CV_LOAD_IMAGE_ANYCOLOR, is stripped from the output image, e.g. 4-channel RGBA image will be loaded as RGB). ###Return value A new IpImage bitmap image. You are responsible for releasing this object by calling cvReleaseImage. ###Discussion None.
CGImageRef CGCreateImageWithIplImage(
IplImage* inputImage
);
###Parameters ###inputImage The image to be converted to CGImage. ###Return value A new Quartz bitmap image. You are responsible for releasing this object by calling CGImageRelease. ###Discussion None.
IplImage* cvLoadImage(const char* filename, int iscolor);
###Parameters ###filename The full or relative pathname of your image file. ###iscolor Output IplImage's color type. You can use only CV_LOAD_IMAGE_GRAYSCALE, CV_LOAD_IMAGE_COLOR or CV_LOAD_IMAGE_ANYCOLOR and MUST NOT USE(NOT SUPPORTED) any combinations of these types. Specific color type of the loaded image: if , the loaded image is forced to be a 3-channel color image; if CV_LOAD_IMAGE_GRAYSCALE, the loaded image is forced to be grayscale; if , the loaded image will be loaded as is (note that in the current implementation the alpha channel, if CV_LOAD_IMAGE_ANYCOLOR, is stripped from the output image, e.g. 4-channel RGBA image will be loaded as RGB).
###Return value A new IpImage bitmap image. You are responsible for releasing this object by calling cvReleaseImage. ###Discussion This function supports the following file formats only,
//#define CV_LOAD_IMAGE_UNCHANGED -1 // not supported
#define CV_LOAD_IMAGE_GRAYSCALE 0
#define CV_LOAD_IMAGE_COLOR 1
//#define CV_LOAD_IMAGE_ANYDEPTH 2 // not supported
#define CV_LOAD_IMAGE_ANYCOLOR 4
###CV_LOAD_IMAGE_GRAYSCALE ###CV_LOAD_IMAGE_COLOR ###CV_LOAD_IMAGE_ANYCOLOR