Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

OpenCV 3.1 allocated 660meg while loading 5meg jpeg

Hello, Please help. I've got a docker image (Debian 8 64 bit inside) with OpenCV 3.1 and java application using it to load and manipulate images. While running docker on Windows (in Virtual Box) it allocates reasonable amount of RAM while loading images. When running the container on Linux (it is also Debian 8) I've got error:

OpenCV Error: Insufficient memory (Failed to allocate 697811968 bytes) in OutOfMemoryError, file /opencv-3.1.0/modules/core/src/alloc.cpp, line 52 OpenCV Error: Assertion failed (u != 0) in create, file /opencv-3.1.0/modules/co re/src/matrix.cpp, line 424 2016-04-14 18:40:46.615 ERROR 1 --- [-nio-443-exec-8] : cv::Exception: /opencv-3.1.0/modules/core/src/matrix.cpp:424: e rror: (-215) u != 0 in function create

It is 665Megabytes while loading 5 Meg jpeg! What I do there: I load an image and resize it to have thumbnail. What happens? Please help. Thank you.

OpenCV 3.1 allocated 660meg while loading 5meg jpeg

Hello, Please help. I've got a docker image (Debian 8 64 bit inside) with OpenCV 3.1 and java application using it to load and manipulate images. While running docker on Windows (in Virtual Box) it allocates reasonable amount of RAM while loading images. When running the container on Linux (it is also Debian 8) I've got error:

OpenCV Error: Insufficient memory (Failed to allocate 697811968 bytes) in OutOfMemoryError, file /opencv-3.1.0/modules/core/src/alloc.cpp, line 52 OpenCV Error: Assertion failed (u != 0) in create, file /opencv-3.1.0/modules/co re/src/matrix.cpp, line 424 2016-04-14 18:40:46.615 ERROR 1 --- [-nio-443-exec-8] : cv::Exception: /opencv-3.1.0/modules/core/src/matrix.cpp:424: e rror: (-215) u != 0 in function create

It is 665Megabytes while loading 5 Meg jpeg! What I do there: I load an image and resize it to have thumbnail. What happens? Please help. Thank you.

        final Mat image;

        MatOfByte matOfByte = new MatOfByte(buffer);
        try {
            image = Imgcodecs.imdecode(matOfByte, Imgcodecs.CV_LOAD_IMAGE_UNCHANGED);
        } finally {
            matOfByte.release();
            buffer = null;
        }

        try {
            size = new ImageSize(image.size());
            index = getIndex(image);
            faces = objectDetector.detectFaces(metadata, image);
            fileService.createThumbnail(image, photo.getThumbnail(),
                    directoryProperties.getSourceThumbnailSize(), false);
        } finally {
            image.release();
        }

OpenCV 3.1 allocated 660meg while loading 5meg jpeg

Hello, Please help. I've got a docker image (Debian 8 64 bit inside) with OpenCV 3.1 and java application using it to load and manipulate images. While running docker on Windows (in Virtual Box) it allocates reasonable amount of RAM while loading images. When running the container on Linux (it is also Debian 8) I've got error:

OpenCV Error: Insufficient memory (Failed to allocate 697811968 bytes) in OutOfMemoryError, file /opencv-3.1.0/modules/core/src/alloc.cpp, line 52 OpenCV Error: Assertion failed (u != 0) in create, file /opencv-3.1.0/modules/co re/src/matrix.cpp, line 424 2016-04-14 18:40:46.615 ERROR 1 --- [-nio-443-exec-8] : cv::Exception: /opencv-3.1.0/modules/core/src/matrix.cpp:424: e rror: (-215) u != 0 in function create

It is 665Megabytes while loading 5 Meg jpeg! What I do there: I load an image and resize it to have thumbnail. What happens? Please help. Thank you.

        final Mat image;

        MatOfByte matOfByte = new MatOfByte(buffer);
        try {
            image = Imgcodecs.imdecode(matOfByte, Imgcodecs.CV_LOAD_IMAGE_UNCHANGED);
        } finally {
            matOfByte.release();
            buffer = null;
        }

        try {
            size = new ImageSize(image.size());
            index = getIndex(image);
            faces = objectDetector.detectFaces(metadata, image);
            fileService.createThumbnail(image, photo.getThumbnail(),
                    directoryProperties.getSourceThumbnailSize(), false);
        } finally {
            image.release();
        }

       public void createThumbnail(Mat mat, File thumbnail, int thumbSize, boolean markFolderLine) {
               MatOfInt pageParams = new MatOfInt(Imgcodecs.CV_IMWRITE_JPEG_QUALITY,            directoryProperties.getThumbnailIq());
    try {
        Mat thumb = new Mat();
        try {
            Size size = mat.size();
            double scaleBy = size.width > size.height ? size.width / thumbSize : size.height / thumbSize;

            Size size_ = new Size(size.width / scaleBy, size.height / scaleBy);
            Imgproc.resize(mat, thumb, size_);
            if (markFolderLine) {
                Imgproc.line(thumb, new Point(size_.width / 2, 0),
                        new Point(size_.width / 2, size_.height - 1), new Scalar(200, 200, 200), 1, Imgproc.LINE_AA, 0);
            }
            Imgcodecs.imwrite(thumbnail.getPath(), thumb, pageParams);
        } finally {
            thumb.release();
        }
    } finally {
        pageParams.release();
    }
}