当我执行我的代码有时它工作正常,但一次是aprox。 7执行apperars错误。错误讯息:
jvacv cvReleaseData中的错误参数(无法识别或不支持的数组类型)
我的代码:
File imageFile = new File("/home/user/java.jpg");
BufferedImage bufferedImage= ImageIO.read(imageFile);
IplImage poColorPhoto = IplImage.createFrom(bufferedImage); // here sometimes appear error
IplImage poGrayPhoto = cvCreateImage(cvGetSize(poColorPhoto), IPL_DEPTH_8U, 1);
cvCvtColor(poColorPhoto, poGrayPhoto, CV_BGR2GRAY);
poColorPhoto.release();
答案 0 :(得分:0)
您可以将以下内容替换为3行: IplImage poColorPhoto = opencv_highgui.cvLoadImage(“yourImage.png”);
答案 1 :(得分:0)
您可以尝试创建一个与BufferedImage相同宽度和高度的IplImage,如下所示:
IplImage ipl_image = IplImage.create(your_buffered_image.getWidth(), your_buffered_image.getHeight(), IPL_DEPTH_8U, 1);
然后将BufferedImage分配给您的IplImage,如下所示:
ipl_image = IplImage.createFrom(your_buffered_image);
希望这有帮助。