what's wrong with this code

Sep 4, 2013 at 7:50am
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 Sep 4, 2013 at 7:53am
Sep 4, 2013 at 8:46am
Nobody can answer because nobody knows how many elements in container threedpoint or in threedimension or in vertexpoints.
Sep 4, 2013 at 7:56pm
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 Sep 4, 2013 at 7:56pm
Sep 4, 2013 at 9:45pm
$ g++ -ggdb foo.cpp
$ gdb a.out
> run
crash (unhandled exception)
> print index
> print projectedpoints[index]
Sep 5, 2013 at 5:22pm
i don't understand by what you wrote.
Sep 5, 2013 at 5:31pm
>i don't understand by what you wrote.

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