Ask Your Question
1

Feature Detector corrupts KeyPoint vector in OpenCV3.0 using MSVC 14: _BIG_ALLOCATION_ALIGNMENT Assertion message

asked 2016-01-02 15:15:56 -0500

grisch gravatar image

Hi there,

I am using OpenCV 3.0 with the latest Visual C++ (version 14) and Win10. When calling the detect() method of a feature detector, detection works fine but if the KeyPoint vector goes out of scope, the program crashes with the following assertion:

File: c:\program files (x86)\microsoft visual studio 14.0\vc\include\xmemory0
Line: 106

Expression: "(_Ptr_user & (_BIG_ALLOCATION_ALIGNMENT - 1)) == 0" && 0

If I comment out the detector->detect() part the assertion is gone.

I have extracted a small example to demonstrate what happens :

#include "opencv2/imgcodecs.hpp"
#include "opencv2/features2d/features2d.hpp"
#include <conio.h>
#include <iostream>
#include <vector>

using namespace cv;
using namespace std;

int main(void)
{
    Mat img(imread("lena.jpg", 1));  //Load grayscale image.
    Ptr<FeatureDetector> detector(FastFeatureDetector::create());
    vector<KeyPoint> features;

    detector->detect(img, features); 

    cout << features.size() << " features detected. Press return to crash :)" << endl;
    getch();

    cout << getBuildInformation();

    //... and crash
    return 0;
}

Here is the output of the above program (I've removed some parts):

3752 features detected. Press return to crash :)


General configuration for OpenCV 3.0.0 =====================================
  Version control:               3.0.0

  Platform:
    Host:                        Windows 6.1 AMD64
    CMake:                       2.8.11.2
    CMake generator:             Visual Studio 12
    CMake build tool:            C:/PROGRA~2/MSBuild/12.0/Bin/MSBuild.exe
    MSVC:                        1800

  C/C++:
    Built as dynamic libs?:      YES
    C++ Compiler:                C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/cl.exe  (ver 18.0.21005.1)
    C++ flags (Release):         /DWIN32 /D_WINDOWS /W4 /GR /EHa  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /arch:SSE2 /Oi /fp:fast  /wd4251 /wd4324 /MP4  /MD /O2 /Ob2 /D NDEBUG  /Zi
    C++ flags (Debug):           /DWIN32 /D_WINDOWS /W4 /GR /EHa  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /arch:SSE2 /Oi /fp:fast  /wd4251 /wd4324 /MP4  /D_DEBUG /MDd /Zi /Ob0 /Od /RTC1
    C Compiler:                  C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/cl.exe
    C flags (Release):           /DWIN32 /D_WINDOWS /W3  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /arch:SSE2 /Oi /fp:fast    /MP4  /MD /O2 /Ob2 /D NDEBUG  /Zi
    C flags (Debug):             /DWIN32 /D_WINDOWS /W3  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /arch:SSE2 /Oi /fp:fast    /MP4  /D_DEBUG /MDd /Zi /Ob0 /Od /RTC1
    Linker flags (Release):      /machine:X86   /INCREMENTAL:NO  /debug
    Linker flags (Debug):        /machine:X86   /debug /INCREMENTAL
    Precompiled headers:         YES
    Extra dependencies:
    3rdparty dependencies:       ippicv

  OpenCV modules:
    To be built:                 hal core flann imgproc ml photo video imgcodecs shape videoio highgui objdetect superres ts features2d calib3d stitching videostab world
    Disabled:                    -
    Disabled by dependency:      -
    Unavailable:                 cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev java python2 viz


  OpenCL:
    Version:                     dynamic
    Include path:                C:/builds/master_PackSlave-win32-vc12-shared/opencv/3rdparty/include/opencl/1.2 C:/Program Files (x86)/AMD/clAmdFft/include C:/Program Files (x86)/AMD/clAmdBlas/include
    Use AMDFFT:                  YES
    Use AMDBLAS:                 YES

-----------------------------------------------------------------
edit retag flag offensive close merge delete

3 answers

Sort by ยป oldest newest most voted
0

answered 2016-09-15 05:57:31 -0500

_AdT_ gravatar image

updated 2016-09-15 05:59:35 -0500

The problem is internal realocation of vector data in

detector->detect(img, features);

which does not retain the correct alignment of data (for me it was 32 -bit), so Visual dealoc cast assertion when deleting such vector. I solved the problem (for OpenCV 2.4.13 ) by reservation of vector size to prevent realocation. For example:

vector<KeyPoint> features;
features.reserve(10000);
detector->detect(img, features);
edit flag offensive delete link more
0

answered 2016-02-08 17:42:43 -0500

sunside gravatar image

I had the same problem - same compiler, same OS, same failed assertion in an x64 build. Upgrading to OpenCV 3.1 solved the problem for me.

edit flag offensive delete link more
0

answered 2016-07-04 03:14:33 -0500

RobRob gravatar image

Same problem here with Win 10, MSVC 14 and OpenCV 2.4.13 on a 32 bit build using CascadeClassifier on some images.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

2 followers

Stats

Asked: 2016-01-02 15:15:56 -0500

Seen: 961 times

Last updated: Sep 15 '16