内存问题 触发断点

lwhlx 2013-06-18 05:41:52
程序运行一段时间后会触发一个断点,不知道什么原因
...全文
85 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
lwhlx 2013-06-18
  • 打赏
  • 举报
回复
引用 6 楼 dahaiI0 的回复:
pGrayscale[(i+1)*(Width-2)+j+1]) + abs(pGrayscale[(i+1)*(Width-2)+j]写错了吧 pGrayscale[(i+1)*(Width-2)+j+1])] + abs(pGrayscale[(i+1)*(Width-2)+j]
应该没错:
(  abs(pGrayscale[i*(Width-2)+j] - pGrayscale[(i+1)*(Width-2)+j+1]) 
+  abs(pGrayscale[(i+1)*(Width-2)+j] - pGrayscale[i*(Width-2)+j+1])  )
dahaiI0 2013-06-18
  • 打赏
  • 举报
回复
pGrayscale[(i+1)*(Width-2)+j+1]) + abs(pGrayscale[(i+1)*(Width-2)+j]写错了吧 pGrayscale[(i+1)*(Width-2)+j+1])] + abs(pGrayscale[(i+1)*(Width-2)+j]
lwhlx 2013-06-18
  • 打赏
  • 举报
回复
该函数是一直循环执行
int ProcessingFunc(UCHAR *pBayerBuffer, int nBayerWidth, int nBayerHeight, \
    UCHAR *pFrameBuffer, int nFrameBufferPitch, int nFrameBufferHeight, \
    void *pMiscellaneousArg)
lwhlx 2013-06-18
  • 打赏
  • 举报
回复
引用 2 楼 starytx 的回复:
确保nBayerWidth ,nBayerHeight都大于2吗?
都肯定大于2,测试时是1920,1080
lwhlx 2013-06-18
  • 打赏
  • 举报
回复
int ProcessingFunc(UCHAR *pBayerBuffer, int nBayerWidth, int nBayerHeight, \
    UCHAR *pFrameBuffer, int nFrameBufferPitch, int nFrameBufferHeight, \
    void *pMiscellaneousArg)
{
    UCHAR *pGrayscaleBuffer = new UCHAR[(nBayerWidth-2)*(nBayerHeight-2)];

    Bayer2Rgb(pBayerBuffer, pFrameBuffer, pGrayscaleBuffer, nBayerWidth, nBayerHeight, 1);//给pGrayscaleBuffer赋值
    UINT sum = GetGrayscaleSubtract(pGrayscaleBuffer, nBayerWidth, nBayerHeight);

    delete []pGrayscaleBuffer;
    return 0;
}

UINT  GetGrayscaleSubtract(unsigned char *pGrayscale, int Width, int Height)
{
    unsigned int sum = 0;
    int i, j;
    for (i=0; i<Height-3; i++) {
        for (j=0; j<Width-3; j++) {
            //屏蔽下面语句后不会触发断点
            sum += (abs(pGrayscale[i*(Width-2)+j] - pGrayscale[(i+1)*(Width-2)+j+1]) +  abs(pGrayscale[(i+1)*(Width-2)+j] - pGrayscale[i*(Width-2)+j+1]));
        }
    }

    return sum;
}
starytx 2013-06-18
  • 打赏
  • 举报
回复
确保nBayerWidth ,nBayerHeight都大于2吗?
lwhlx 2013-06-18
  • 打赏
  • 举报
回复
代码:
int ProcessingFunc(UCHAR *pBayerBuffer, int nBayerWidth, int nBayerHeight, \ UCHAR *pFrameBuffer, int nFrameBufferPitch, int nFrameBufferHeight, \ void *pMiscellaneousArg) { UCHAR *pGrayscaleBuffer = new UCHAR[(nBayerWidth-2)*(nBayerHeight-2)]; Bayer2Rgb(pBayerBuffer, pFrameBuffer, pGrayscaleBuffer, nBayerWidth, nBayerHeight, 1);//给pGrayscaleBuffer赋值 UINT sum = GetGrayscaleSubtract(pGrayscaleBuffer, nBayerWidth, nBayerHeight); delete []pGrayscaleBuffer; return 0; } UINT GetGrayscaleSubtract(unsigned char *pGrayscale, int Width, int Height) { unsigned int sum = 0; int i, j; for (i=0; i<Height-3; i++) { for (j=0; j<Width-3; j++) { //屏蔽下面语句后不会触发断点 sum += (abs(pGrayscale[i*(Width-2)+j] - pGrayscale[(i+1)*(Width-2)+j+1]) + abs(pGrayscale[(i+1)*(Width-2)+j] - pGrayscale[i*(Width-2)+j+1])); } } return sum; }

64,654

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧