Ask Your Question
0

issue with imread of opencv2.4.5

asked 2013-05-31 07:48:01 -0500

Padma gravatar image Padma
1

I get a runtime error saying memory access violation when i used imread function of opencv 2.4.5. The imread function is called within an application developed in Microsoft Visual Studio 2008.

delete close flag offensive retag edit

Comments

2

please check, that you did not end up in "dll hell", like :

  • running a release build, but link to debug libs ( the ones with a 'd' at the end )
  • the other way round, mix debug build and release libs
  • mix 32 bit build with 64bit libs
  • (guess what .. )
berak ( 2013-05-31 07:54:34 -0500 )edit
1

Also make sure to first try using absolute path variables, to make sure it has nothing to do with a wrong path. The imread of openCV 2.4.5 works perfectly, I had an application running for 3 days on a test setup, without a single crash, so I do not believe there is a memory leak inside the actual function if used correctly.

StevenPuttemans ( 2013-05-31 08:34:24 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2013-05-31 07:50:43 -0500

wuling gravatar image wuling flag of Taiwan, Province of China
229 2 8

Hi I think the same. http://answers.opencv.org/question/14251/detected-memory-leaks/ So the best way, you have better user under ver. 2.4.3

link delete flag offensive edit

Comments

1

I do not agree on this. Version 2.4.5 has been released as stable, and as mentioned in my comment, if an application reading images of 1500 x 1500 pixels, keeps running over 3 days none stop, then I doubt there would actually be a memory leak...

StevenPuttemans ( 2013-05-31 08:36:02 -0500 )edit

Hi, I just use debug mode to test program, I am not sure release mode is the sme or not. But I am sure in my computer every time i use imread ,and close the application.MFC shows memory leak message.

wuling ( 2013-05-31 08:44:50 -0500 )edit
1

But that doesn't mean that the imread causes the memory leak. What do you do with the object where the imread data is stored? Can you post some code? It seems to me you are using old data structures and forget to delete them manually...

StevenPuttemans ( 2013-05-31 08:49:42 -0500 )edit

HI,I post my code: void CHRMGDlg::OnBnClickedOpenfile() { CFileDialog dlg ( TRUE, _T(".bmp"), NULL, OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY|OFN_EXPLORER, _T("BMP(.bmp)|.bmp|JPG(.jpg)|.jpg|All Files (.) |.||"), NULL ); dlg.m_ofn.lpstrTitle = _T("Open Image File"); dlg.m_ofn.lpstrInitialDir="D:\20130319" ;

CString str1,str2;

if( dlg.DoModal() == IDOK ) 
{
    str2=dlg.GetPathName();
    src=cv::imread(str2.GetBuffer(),CV_LOAD_IMAGE_ANYCOLOR);// src is gobal

} }

void CHRMGDlg::OnPaint() { ........ CDC *pDC = GetDC(); CDC memDC; memDC.CreateCompatibleDC(pDC); CBitmap memBmp; CRect clipRect; GetDlgItem(IDC_SHOWIMG)->GetClientRect(clipRect); ShowImg(pDC, dst,&m_dcMem,offsetx,offsety,m_size.cx,m_size.cy,sourcex, sourcey ) } i

wuling ( 2013-05-31 08:59:17 -0500 )edit

I do not do every thing. I am sure.If you want all file i can give to to test.dst is gobal, dst=src; InvalidateRect(&rectStaticClient);

wuling ( 2013-05-31 09:00:52 -0500 )edit

It is normal that you are getting a memory leak. The new C++ interface is created to destroy the objects when leaving the scope. Using global variables however make this impossible so require you to delete them manually at the end. Create the src Mat inside the loop, and you will see that there will be no memory leak.

StevenPuttemans ( 2013-05-31 09:03:35 -0500 )edit

So,you mean when I close the applicaion i must delete mat variable ,if the varible is global. But why i can't see any memory leak in opencv2.4.3

wuling ( 2013-05-31 09:21:57 -0500 )edit

Login/Signup to Answer

Question tools

Follow

subscribe to rss feed

Stats

Asked: 2013-05-31 07:48:01 -0500

Seen: 417 times

Last updated: May 31 '13