Click here to Skip to main content
15,894,405 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,
I have write a class to manage images and to verify value of pixel on a Mat image, in a test with if and else.

This is a part of the code that I've write, the specific procedure that creates problems:

C#
bool cubo::verifica_punti(Mat& I, double TC[4][4], double fc[2],double KC[5], double cc[2],double alpha){
    for (int i=0;i<8;i++){
        //normalizzazione
        double PN[2] = { V[i].x/V[i].z, V[i].y/V[i].z};

        //calcolo delle componenti
        double r2 = pow(PN[0],2.0) + pow(PN[1],2.0);
        //distorsione tangenziale
        double dx[2]={((2*KC[2]*PN[0]*PN[1])+(KC[3]*(r2+2*pow(PN[0],2.0)))),(KC[2]*(r2+2*pow(PN[1],2.0))+2*KC[3]*PN[0]*PN[1])};
        //componenti sul piano
        double xd[2]={((1+KC[0]*r2+KC[1]*pow(r2,2.0)+KC[4]*pow(r2,3.0))*PN[0]+dx[0]),((1+KC[0]*r2+KC[1]*pow(r2,2.0)+KC[4]*pow(r2,3.0))*PN[1]+dx[1])};

        //calcolo delle coordinate in pixel
        int xp = ceil(fc[0]*(xd[0]+alpha*xd[1])+cc[0]);
        int yp = ceil(fc[1]*xd[1]+cc[1]);

        //cout<<endl<<"XP = "<<xp<<" YP = "<<yp<<endl;
        //valore temporaneo per testare
        //uchar pix = 1;
        if ((yp>720||yp<0))
            {
            return false;
            }
        else if ((xp>1280||xp<0)){
            return false;
            }
        else
        {
            Scalar pix = I.at<uchar>(yp,xp);

            if (pix.val[0]==0)
            {
            return false;
            }
        else
            return true;
        }
    }

};


This is a method of my class CUBO.

When program run, I receive this error and program crash:

http://imageshack.com/i/10r512j[^]

can someone help me??
Posted
Updated 4-Dec-13 8:44am
v2
Comments
Sergey Alexandrovich Kryukov 4-Dec-13 14:47pm    
Instead of showing a picture, you should provide the message is a text form.
—SA

1 solution

make for loop 8 to 4

Quote:
bool cubo::verifica_punti(Mat& I, double TC[4][4], double fc[2],double KC[5], double cc[2],double alpha){
for (int i=0;i<4;i++){
//normalizzazione
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900