OpenCV2.1 BUG

     今天在VS2008中使用OpenCV2.1,发现使用cvLoadImage读大图片文件时内存访问越界,网上搜了一下原来是BUG。

 

网上修改方法如下:

patch for file:
src/highgui/grfmt_bmp.cpp (line 198)

change from:
AutoBuffer _src, _bgr;

if( (m_bpp != 24 || !color) )
_src.allocate(src_pitch + 32);

to:

AutoBuffer _src, _bgr;

// bug fix, otherwise memcpy in getBytes in file bitstrm.cpp will
crash
if ( 4096 < src_pitch)
{
_src.allocate( src_pitch + (8 * nch) );
_bgr.allocate( src_pitch + (8 * nch) );
}

if( (m_bpp != 24 || !color) )
_src.allocate(src_pitch + 32);

修改后要重新编译OpenCV,才能使用正常。

之前使用2.1版本做Mean Shift分割测试也发现有BUG,还是开始使用OpenCV2.2了

posted @ 2011-01-21 22:20  寒山月  阅读(277)  评论(0编辑  收藏  举报