what's wrong with this code

Hey

Below is a code, which sometimes randomly says error, unhandled exception error something to do with access mask out of bond which is ridiculous and sometimes it works, i don't know why

1
2
3
4
5
6
7
8
9
10
11
12
13
for(int index=0;index<projectedpoints.size();index++)
{
    int dx = threedpoint[index].x, dy=threedpoint[index].y,dz=threedpoint[index].z;
    double check = threedimension[dx][dy][dz];
    if(check==1)
    {
        vertexpoints[index] = Point3f(dx,dy,dz);
	if(float(mask.at<uchar>(projectedpoints[index]))==255.0)
	{
	    threedimension[dx][dy][dz]=0.0;
	}							
    }
}


projected points is between between 0 and 480 for x and 0 and 640 for y and mask size is 480x640.
threedimension is a 3D array size 30x30x30, which the value of each location is either a 1 or a 0 and threedpoint contain the 3d coordinates, which is used as a lookup to threedimension array

vertex points contains 3D coordinates.

Thanks
Last edited on
Nobody can answer because nobody knows how many elements in container threedpoint or in threedimension or in vertexpoints.
i thought i mentioned it, ok never mind, here it is.

threedpoint contains 60x60x60 elements 216000 i think
threedimension is a 3D array containing 1s in all elements.

vertexpoints elements varies, as it depends on wether the 3d location at threedimension contains a value 1 if not it is not added to vertex points.
else it is.

it is cleared everytime to add new values which do contains ones in the 3d array threedimension.
Last edited on
$ g++ -ggdb foo.cpp
$ gdb a.out
> run
crash (unhandled exception)
> print index
> print projectedpoints[index]
i don't understand by what you wrote.
>i don't understand by what you wrote.

Use a debugger to trace the problem.
Topic archived. No new replies allowed.