Reputation: 4607
I am trying to define a custom kernel for OpenCV on iOS. I cannot seem to find a definitive method to do this. The method that I have seen some other people use is this one, and I can't seem to get it to work exactly how I want it to. I am using the cVVideoCamera delegate like this:
- (void)processImage:(Mat&)image;
{
// Do some OpenCV stuff with the image
double m[] = {1.0, 1.0, 1.0,
2.0, 2.0, 2.0,
1.0, 1.0, 1.0};
cv::Mat kernel = cv::Mat(3, 3, CV_32FC2, m);
int ddepth = -1;
cv::filter2D(image, image, ddepth, kernel);
}
This does not seem to work. I think it might be because of the type in the cv:Mat constructor (CV_32FC2). Does anyone know what this should be for an iPhone camera usually? Or is there some other problem?
Upvotes: 1
Views: 1077
Reputation: 10329
The type CV_32FC2 does not refer to the type of the image you are passing in, it refers to the type in the kernel you are making. Change the type of m to be float and change CV_32FC2 to CV_32f and it should work. You also should give Brad Larson's framework a try like he suggests if performance is a problem.
Upvotes: 2