且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在没有错误的情况下运行我的统一Lbp C ++

更新时间:2022-10-16 10:13:04

制作一些调试输出和间隔检查代码。这将导致你的错误;-)



我的提示是



 OPTR [J + I *宽度] =查找[代码]; 


i have this error when build my code

Unhandled exception at 0x00ce88ef in mycode.exe: 0xC0000005: Access violation reading location 0x000003bc.

my code is

void LBPFeatures::computeuniformlbp(Mat image,Mat &dst)
{
    uchar *ptr=image.data;
    image.copyTo(dst);
    uchar *optr=dst.data;
    int width=image.cols;
    int height=image.rows;

    for(int i=1;i<height-1;i++)
    {
        for(int j=1;j<width-1;j++)
        {
            int center=(int)ptr[j+i*width];
            unsigned char code=0;


            code|=((int)ptr[(j-1)+(i-1)*width] >=center)<<7;
            code|=((int)ptr[j+(i-1)*width] >=center)<<6 ;
            code|=((int)ptr[(j+1)+(i-1)*width] >=center)<<5 ;
            code|=((int)ptr[(j+1)+(i)*width] >=center)<<4 ;
            code|=((int)ptr[(j+1)+(i+1)*width] >=center)<<3 ;
            code|=((int)ptr[j+(i+1)*width] >=center)<<2 ;
            code|=((int)ptr[j-1+(i+1)*width] >=center)<<1 ;
            code|=((int)ptr[j-1+(i)*width] >=center)<<0 ;

        
            optr[j+i*width]=lookup[code];

        }
    }
    initUniform();
}




the image is loaded correctly but there is an error with variable code or with ptr really i don't know

can any one help me
thanks in advance

make some debug output and interval checking code. It will lead to your bug ;-)

My tip is

optr[j+i*width]=lookup[code];