Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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);
like image 366
user1088595 Avatar asked Nov 16 '25 17:11

user1088595


2 Answers

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");
}
like image 135
Alexander Sidikov Pfeif Avatar answered Nov 19 '25 07:11

Alexander Sidikov Pfeif


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

like image 44
Namine Avatar answered Nov 19 '25 07:11

Namine



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!