2

I'm using JavaCv with OpenCv 2.3 from Java (on Windows). Occasionally something goes wrong, and OpenCv throws an error, something like:

OpenCV Error: Bad argument (unrecognized or unsupported array type) in unknown function, file ..\..\..\..\ocv\opencv\modules\core\src\array.cpp, line 995

With the following Java stacktrace:

at com.googlecode.javacv.cpp.opencv_core.cvReleaseImage(Native Method)
at com.googlecode.javacv.cpp.opencv_core$IplImage$ReleaseDeallocator.deallocate(opencv_core.java:492)
at com.googlecode.javacpp.Pointer$DeallocatorReference.clear(Pointer.java:127)
at com.googlecode.javacpp.Pointer.deallocator(Pointer.java:171)
at com.googlecode.javacpp.Pointer.init(Pointer.java:61)
at com.googlecode.javacv.cpp.opencv_core$CvSize.allocate(Native Method)
at com.googlecode.javacv.cpp.opencv_core$CvSize.<init>(opencv_core.java:2152)
at com.googlecode.javacv.cpp.opencv_core.cvSize(opencv_core.java:2170)

I.e. it occurs when I try to deallocate an image. Since my knowledge of C++ and OpenCv internals is, well, not much, I thought I'd ask here.

What does the error message mean? Is there anything that could cause then to happen while releasing an IplImage?


Meta: the question previously also asked about catching/skipping a Microsoft Visual C++ Runtime Error dialogue. However, I realised I was asking two completely different questions, and migrated that part to this question.

Community
  • 1
  • 1
wen
  • 3,782
  • 9
  • 34
  • 54

1 Answers1

2

If you allocate your IplImage using IplImage.create(), you should not call cvReleaseImage() manually on it. <- This is most likely the cause of the error. Either call IplImage.release() or let the garbage collector deallocate it for you, at some point in the future...

Samuel Audet
  • 4,964
  • 1
  • 26
  • 33