user1088595
user1088595

Reputation: 151

cvResize function with JavaCV

Says I'm using the wrong types here. Both img and image are iplImages, what type should I be using and how do I use it? Thanks

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

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

Upvotes: 3

Views: 5411

Answers (3)

Alexander Sidikov Pfeif
Alexander Sidikov Pfeif

Reputation: 2435

this should work

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

and here a full example

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");
}

Upvotes: 2

user3076252
user3076252

Reputation: 1937

replace IPL_DEPTH_8U parameter with img.nChannels()

Upvotes: 1

Namine
Namine

Reputation: 45

you should use the same number of the channels as in the source image

Upvotes: 1

Related Questions