说我在这里使用错误的类型。 img和图像都是iplImages,我应该使用哪种类型以及如何使用它?谢谢

                    IplImage image = IplImage.create(120, 120, IPL_DEPTH_8U, 4);
                    //resize the image
                     cvResize(img,image);

                    cvSaveImage("4-rjb" + capture + ".pgm", img);

最佳答案

这应该工作

IplImage resizeImage = IplImage.create(120, 120, origImg.depth(), origImg.nChannels());

这是一个完整的例子
OpenCVFrameGrabber frameGrabber = new OpenCVFrameGrabber(video_in);
try {
    frameGrabber.start();
    IplImage origImg = frameGrabber.grab();
    IplImage resizedImage = IplImage.create(IMG_WIDTH, IMG_HEIGHT, origImg.depth(), origImg.nChannels());

    //cvSmooth(origImg, origImg);
    cvResize(origImg, resizedImage);
    cvSaveImage(image_out.getAbsolutePath(),resizedImage);
    cvReleaseImage(resizedImage);

} catch (OpenCVFrameGrabber.Exception e) {
    e.printStackTrace();
    throw new NullPointerException("fileExtension");
}

10-04 21:04