sltk icon indicating copy to clipboard operation
sltk copied to clipboard

plotlens : segmentation fault.

Open prelard812 opened this issue 4 years ago • 0 comments

Hi, <Intro> This is my first active participation to a git project ( 3d scanner is really cool) . I started to compile your project, two days ago and things are going well now. All my modules talk together, and now I'm trying to get my first camera calibration... but I got into problems with plotlens... I got a segmentation fault...

Problem: the problem rises into the last loop to plot the grid image... pixb seems to be update to the first pixel of each row... so calculated index from this equation : int idx = 3(r*w+c);* will produce an overflow... I think you need to just calculate the offset of the current column with 3*C see corrected code below. What do you think of this... Maybe I don<t understand your code... but I'm pretty sure of this correction.

Prelard812.

`// generate grid image distorted with lens (simulated image of grid) if( gen_grid ) {

    int w = grid_img.cols;
    int h = grid_img.rows;
    for(int r=0; r<h; r++)
    {
         uchar* pixb = grid_img.ptr<unsigned char>(r);
         for(int c=0; c<w; c++)
         {
            //int idx = 3*(r*w+c);
            **int idx = 3*(c);**
            unsigned char v = 255;
            pixb[idx+0] = v;
            pixb[idx+1] = v;
            pixb[idx+2] = v;
         }
    }

}`

prelard812 avatar Apr 15 '20 03:04 prelard812