cvGet2D error

asked 2013-05-08 02:12:37 -0600

decoz gravatar image

i think this two parts of code is independent to each of them.

CvMat *itgMap = cvCreateMat(gray->height + 1,gray->width + 1,CV_32SC1);

for(int> y=0;y<itgmap->height;y++)

for(int> x=0;x<itgmap->width;x++) {>

double pvalue = cvGet2D(gray,y-1,x-1).val[0]; // part1

double itg = cvGet2D(itgMap,y,x-1).val[0]; // part2

....... it makes segmentation fault error

but

for(int y=0;y<itgmap->height;y++)

for(int x=0;x<itgmap->width;x++) {

    double pvalue =  cvGet2D(gray,y-1,x-1).val[0];

this works ok .. and

for(int y=0;y<itgmap->height;y++)

for(int x=0;x<itgmap->width;x++) {

   double itg = cvGet2D(itgMap,y,x-1).val[0];

and it works well too..

only when both codes are enabled at same time, it makes segmentation faults but I can't see any relation of them.. how is it possible?

edit retag flag offensive close merge delete

Comments

Both functions are actually related since the use the same pointers x and y to the data. Could you please post the exact error?

StevenPuttemans gravatar imageStevenPuttemans ( 2013-05-08 06:00:39 -0600 )edit

this is simple test code for gray image .. I tried it by opencv 2.2 and 2.45 but got same segmentation fault

void testProblem(IplImage *srcImg){ int width = srcImg->width; int height = srcImg->height;

CvMat *mat = cvCreateMat(height,width,CV_32SC1);

cvSet(mat,cvScalar(0));
for(int y=0;y&lt;height;y++){
    for(int x=0;x&lt;width;x++){
        double val1 = cvGet2D(srcImg,y,x).val[0];
        double val2 = cvGet2D(mat,y,x).val[0];
    }
}

}

decoz gravatar imagedecoz ( 2013-05-08 10:23:46 -0600 )edit

I'm sorry.. cuz it's my first time to post question at opencv forum. , I can't post image or correctly boxed source code.

decoz gravatar imagedecoz ( 2013-05-08 10:36:00 -0600 )edit