Javacv: Array should be CvMat or IplImage in function 'cvGetSize'

Created on 24 Jan 2019  路  14Comments  路  Source: bytedeco/javacv

Exception in thread "main" java.lang.RuntimeException: OpenCV(4.0.1) C:\projects\javacpp-presets\opencv\cppbuild\windows-x86_64\opencv-4.0.1\modules\core\src\array.cpp:1246: error: (-5:Bad argument) Array should be CvMat or IplImage in function 'cvGetSize'

bug duplicate question

Most helpful comment

I have found a other way and its working good instead of using cvGetSize() i am using destImage.asCvMat().cvSize() and its working great. BTW great library.

All 14 comments

Just do what it says, pass a CvMat or an IplImage.

Sorry to say but i am doing just that and don't act like an smart ass cuz you are not bitch.

Ok, that's fine, please show your code. I can't guess what you're doing or not!

Getting error on this line :
IplImage destImage = downScaleImage(src, percent);
IplImage grayImage = IplImage.create(cvGetSize(destImage), IPL_DEPTH_8U, 1);

And what's in downScaleImage()?

private IplImage downScaleImage(IplImage src, int percent) {
    IplImage destImage = IplImage.create((src.width() * percent) / 100, (src.height() * percent) / 100, src.depth(),src.nChannels());
        cvResize(src, destImage);
        System.out.println("dest height " + destImage.height() + " dest witdth " + destImage.width());
        return destImage;
    }

And what is src? This works just fine:

IplImage img = IplImage.create(200, 200, IPL_DEPTH_8U, 3);
downScaleImage(img, 50);

As expected, it outputs:

dest height 100 dest witdth 100

I can't fix what isn't broken! You'll need to give me something to work with here.

I have found a other way and its working good instead of using cvGetSize() i am using destImage.asCvMat().cvSize() and its working great. BTW great library.

Hi kundanSingh11,

I have the same issue of "Array should be CvMat or IplImage in function 'cvGetSize'."
Can you let me know your solution?
Appreciated your kind support.

Yuan-Fa, Lee

I have the same issue

I'm not able to reproduce this issue with JavaCV 1.5.2 and OpenCV 4.1.2, so it looks like this is fixed.

If this is still happening for you guys though, please complain upstream at https://github.com/opencv/opencv/issues/6221.

@jessyuan24 , @970265 I am using it as
IplImage grayImage = IplImage.create(image.asCvMat().cvSize(), IPL_DEPTH_8U, 1);

BTW, this has now been fixed with OpenCV 4.2.0, see issue https://github.com/opencv/opencv/issues/15990

Was this page helpful?
0 / 5 - 0 ratings

Related issues

myScoopAndroidCamera picture myScoopAndroidCamera  路  4Comments

newstarbka picture newstarbka  路  5Comments

UpAndDownAgain picture UpAndDownAgain  路  3Comments

Bahramudin picture Bahramudin  路  3Comments

chenhl05 picture chenhl05  路  4Comments