Issue 1:
Copied from https://stackoverflow.com/q/48088189/1531708 because I experience the same:

After updating the NDK to v16, the previously working x86 build now fails with hundreds of messages like:

C:/Android/sdk/ndk-bundle/toolchains/x86-4.9/prebuilt/windows-x86_64/lib/gcc/i686-linux-android/4.9.x/../../../../i686-linux-android/bin\ld: error: C:/Android/OpenCV-android-sdk/sdk/native/3rdparty/libs/x86/libippicv.a(jmp_icvippiCopyConstBorder_8u_C4IR_L_as.s.o): relocation R_386_GOTOFF against preemptible symbol icv_ippJumpIndexForMergedLibs cannot be used when making a shared object

C:/Android/sdk/ndk-bundle/toolchains/x86-4.9/prebuilt/windows-x86_64/lib/gcc/i686-linux-android/4.9.x/../../../../i686-linux-android/bin\ld: error: C:/Android/OpenCV-android-sdk/sdk/native/3rdparty/libs/x86/libippicv.a(jmp_icvippiConvert_32s16u_C1RSfs_as.s.o): relocation R_386_GOTOFF against preemptible symbol icv_ippJumpIndexForMergedLibs cannot be used when making a shared object

C:/Android/sdk/ndk-bundle/toolchains/x86-4.9/prebuilt/windows-x86_64/lib/gcc/i686-linux-android/4.9.x/../../../../i686-linux-android/bin\ld: error: C:/Android/OpenCV-android-sdk/sdk/native/3rdparty/libs/x86/libippicv.a(jmp_icvippiNormRel_L1_32f_C1R_as.s.o): relocation R_386_GOTOFF against preemptible symbol icv_ippJumpIndexForMergedLibs cannot be used when making a shared object

C:/Android/sdk/ndk-bundle/toolchains/x86-4.9/prebuilt/windows-x86_64/lib/gcc/i686-linux-android/4.9.x/../../../../i686-linux-android/bin\ld: error: C:/Android/OpenCV-android-sdk/sdk/native/3rdparty/libs/x86/libippicv.a(jmp_icvippiFilterBilateralBorderInit_L_as.s.o): relocation R_386_GOTOFF against preemptible symbol icv_ippJumpIndexForMergedLibs cannot be used when making a shared object

C:/Android/sdk/ndk-bundle/toolchains/x86-4.9/prebuilt/windows-x86_64/lib/gcc/i686-linux-android/4.9.x/../../../../i686-linux-android/bin\ld: error: C:/Android/OpenCV-android-sdk/sdk/native/3rdparty/libs/x86/libippicv.a(jmp_icvippiScaleC_32f8u_C1R_as.s.o): relocation R_386_GOTOFF against preemptible symbol icv_ippJumpIndexForMergedLibs cannot be used when making a shared object

Issue 2:
System information (version)

OpenCV => :2.4.9:

Operating System / Platform => :Windows 64 Bit

Compiler => :Visual Studio 2015 Professional

Detailed description

Call Stack show:

the program always crash on here:

cv::resize(*srcImg, mat2bitmap_img, cv::Size(draw_rect.Width(), draw_rect.Height()));

I think this problem is memory leak, resize function too many memory allocation, resulting in memory fragmentation and management problems.

Steps to reproduce

the program always run on loop,for example:

while(1) {

cv::resize...

}

/*! display Mat on Picture Control in MFC
*! Mat img: the image that to display
*! UINT nID: the ID of control
*! support BGR(Mat default),BGRA,GARY
*! other type need use cvtColor to convert
*/
void ImageDlg::DrawMat(cv::Mat *srcImg, UINT nID)
{
if (srcImg->empty() || srcImg->data == nullptr) {
return;
}

CDC *pDC = nullptr;
CWnd *pWnd = GetDlgItem(nID);
pWnd->GetClientRect(&draw_rect);
pDC = pWnd->GetDC();
cv::resize(*srcImg, mat2bitmap_img, cv::Size(draw_rect.Width(), draw_rect.Height()));
switch (srcImg->channels())
{
case 1:
cv::cvtColor(mat2bitmap_img, mat2bitmap_img, CV_GRAY2BGRA); // GRAY --> BGRA(CV_8UC4)
break;
case 3:
cv::cvtColor(mat2bitmap_img, mat2bitmap_img, CV_BGR2BGRA); // BGR --> BGRA(CV_8UC4)
break;
default:
break;
}

// why convert to CV_8UC4
// because windows need 4-byte aligned in a row
// if there are 3 pixels in a row,
// CV_8UC3: 3 pixel = 9 bytes, 9 % 4 = 1(no alignment)
// CV_8UC4: 3 pixel = 12 bytes, 12 % 4 = 0(it's ok)

// calculate how many bytes a pixel
int pixelBytes = mat2bitmap_img.channels()*(mat2bitmap_img.depth() + 1);

// create a header by using BITMAPINFO structure
draw_bitmapInfo.bmiHeader.biBitCount = 8 * pixelBytes;
draw_bitmapInfo.bmiHeader.biWidth = mat2bitmap_img.cols;
draw_bitmapInfo.bmiHeader.biHeight = -mat2bitmap_img.rows;

// display Mat
// Mat data + BITMAPINFO --> MFC DigItem
::StretchDIBits(
pDC->GetSafeHdc(),
draw_rect.left, draw_rect.top, draw_rect.Width(), draw_rect.Height(),
0, 0, draw_rect.Width(), draw_rect.Height(),
mat2bitmap_img.data,
&draw_bitmapInfo,
DIB_RGB_COLORS,
SRCCOPY
);
ReleaseDC(pDC);
pDC = nullptr;
pWnd = nullptr;
}

my idea:

I think resize function input params is piont,it will not need memory allocation

original:

void cv::resize( InputArray _src, OutputArray _dst, Size dsize,

double inv_scale_x, double inv_scale_y, int interpolation )

maybe fixed:

void cv::resize( InputArray *_src, OutputArray *_dst, Size dsize,

double inv_scale_x, double inv_scale_y, int interpolation )

@peters @eruffaldi