got stuck with the project
could some1 have a look at my code and tell me why there's segmentation fault, plz?
this project is simplified to find the white rectangle on the red wall of a given image.
my main:
Expand|Select|Wrap|Line Numbers
- BMP bmpIn;
- bmpIn.load("test3.jpg");
- bmpIn.moveCursorTo(0,30);
- firstvertex = bmpIn.findFirstWhite();
- one.x = firstvertex.x;
- one.y = firstvertex.y;
- cout<<one.x<<" "<<one.y<<endl;
- jb = bmpIn.findVertices2(one.x, one.y);
- lj = bmpIn.findVertices3(one.x, one.y);
- cout<<jb.x<<"."<<jb.y<<endl;
- cout<<lj.x<<"."<<lj.y<<endl;
cpp file:
Expand|Select|Wrap|Line Numbers
- OJ BMP::findVertices2(int a , int b)
- {
- int x, y;
- int c = 1;
- OJ jb;
- vector<int>sox;
- vector<int>soy;
- sox[0] = getCursorX();
- soy[0] = getCursorY();
- cout<<a<<" "<<b<<endl;
- cout<<"hi"<<endl;
- for (x = a; x < a + 30; x++){
- for(y = b; y< 85;y++){
- if (testwhite(x,y)==1)
- {
- sox[c] = x;
- soy[c] = y;
- c++;
- y = b;
- x++;
- cout<<"fk"<<endl;
- }
- if (sox[c] - sox[c -1] > 10 )
- {
- jb.x = sox[c-1];
- jb.y = soy[c-1];
- return jb;
- cout<<"yuou"<<endl;
- }
- if (y == 84 )
- {
- jb.x = sox[c-1];
- jb.y = soy[c-1];
- cout<<"lol"<<endl;
- }
- }}
- }
- OJ BMP::findVertices3(int a , int b)
- {
- int x, y;
- int c = 1;
- OJ lj;
- vector<int>hix;
- vector<int>hiy;
- hix[0] = getCursorX();
- hiy[0] = getCursorY();
- for (x = a; x > a + 30; x--){
- for(y = b; y < 85;y++){
- if (testwhite(x,y)==1)
- {
- hix[c] = x;
- hiy[c] = y;
- c++;
- y = b;
- x++;
- }
- if (hix[c] - hix[c -1] > 10 )
- {
- lj.x = hix[c-1];
- lj.y = hiy[c-1];
- return lj;
- }
- if (y == 84 )
- {
- lj.x = hix[c-1];
- lj.y = hiy[c-1];
- }
- }}
- }
testwhite() is basically the red green and blue values for defining white.