我尝试了一些方法从 3 channel IplImage 创建新的 4 channel IplImage。我尝试将此代码从 C 转换为 JavaCV:
CvMat * src; // your source image
CvMat * dst // your destination image
CvMat * zeros = cvCreateMat(src->cols, src->rows, CV_8UC1);
cvSet(zeros, cvScalar(0, 0, 0, 0));
CvArr * input[] = { src, zeros };
int from_to[] = { 0,0, 1,1, 2,2, 3,3 };
cvMixChannels(input, 2, &dst, 1, from_to, 4);
取自 here ,我的转换是:
CvMat src;
CvMat dst;
CvMat zeros = cvCreateMat(src.cols(), src.rows(), CV_8UC1);
cvSet(zeros, cvScalar(0, 0, 0, 0));
CvArr input[] = { src, zeros };
int from_to[] = { 0,0, 1,1, 2,2, 3,3 };
cvMixChannels(input, 2, dst, 1, from_to, 4);
但是eclipse说,JavaCV混合 channel 方法是这样的:
The method cvMixChannels(opencv_core.CvArr[], int, opencv_core.CvArr[], int, int[],int) in the type opencv_core is not applicable for the arguments opencv_core.CvArr[], int, opencv_core.CvMat, int, int[], int)
有人可以帮助我吗?
谢谢
最佳答案
您的错误是您将 CvMat
作为第一个和第三个参数传递给 cvMixChannels
,而您应该传递 CvMat[]
。
关于JavaCV将3 channel IplImage转换为4 channel IplImage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19914893/