forum.alglib.net

ALGLIB forum
It is currently Mon Dec 23, 2024 3:32 am

All times are UTC


Forum rules


1. This forum can be used for discussion of both ALGLIB-related and general numerical analysis questions
2. This forum is English-only - postings in other languages will be removed.



Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Detect elliptical parts in a 2d laserscan
PostPosted: Mon Jun 11, 2012 1:24 pm 
Offline

Joined: Mon May 14, 2012 4:35 pm
Posts: 5
Hi,

I have to write a C++ Programm which is able to detect an elliptical part in a 2d laserscan.
My scaner gives x,y Data from the scene.
The next step after i have detected the elliptical Part is to say from which area of an completely elliptic circumference the detected part is.
I have breake down the Scan into segments which i check with the alglib::lsfitlinear().
But i think lsfitlinear is not the right method for this task because much segments of even lines are detected as an elliptical part. The sample data for lsfitlinear came from a scan segment representing the ellipse i'm searching for.
Now i have no idea how to continue or which method is the right for this task.
Here my code:
Code:
alglib::ae_int_t info;
   alglib::ae_int_t M = 1;
   alglib::real_1d_array c;
   alglib::lsfitreport rep;

   alglib::real_2d_array sample;
   alglib::real_1d_array experimentalData;

   //create segment from file
   Segment seg = this->createSampleSegmentFromFile("./samples/sample.txt", 130);

   //translate sample in the origin
   double avgXdist = this->calcAvgXDistance(seg);
   double avgYdist = this->calcAvgYDistance(seg);
   this->transformer->translateSegment(seg, -avgXdist, -avgYdist);
   
   //create real_2d_array sample
   sample = this->createReal2DArrayFromSegment(seg);

   Segment s;
   ScanPoint p1;
   ScanPoint p2;

   
   for (int i = 0; i < scan->getSegments()->size(); i++)
   {
      s = scan->getSegments()->at(i);

      p1 = s.getSegmentPoints()->at(0);
      p2 = s.getSegmentPoints()->at(s.getSegmentPoints()->size() - 1);

      s.setAvgDist(this->calcAvgDistance(s));
      s.setEuclidainDist(this->calcEuclidDist(p1, p2));

      //translate segment to be examined in the origin
      double avgSegXdist = this->calcAvgXDistance(s);
      double avgSegYdist = this->calcAvgYDistance(s);
      this->transformer->translateSegment(s, -avgSegXdist, -avgSegYdist);

      //create experimental data array
      experimentalData = this->createReal1DArrayFormSegment(s);
      
      //do fitting
      if (experimentalData.length() <= sample.rows()
         && s.getAvgDist() <= 6000
         && s.getAvgDist() >= 1500
         && s.getEuclidianDist() <= 1800)
      {

         //rotate Segment 360°
         for (int j = 0; j < 36; j++)
         {
         
            alglib::lsfitlinear(experimentalData, sample, experimentalData.length(),
               M, info, c, rep);
   
            //rotiere um 10°
            this->transformer->rotateSegment(s, 10);

            //std::cout<<"Fitting by: " << j << "°" << "\n";
         }

         scan->getSegments()->at(i).setAvgErr(rep.avgerror);
         scan->getSegments()->at(i).setMaxErr(rep.maxerror);

         if (scan->getSegments()->at(i).getAvgErr() < 150)
         {
            scan->getSegments()->at(i).setIsStation(true);
         }

         std::cout<<"is station: "<<scan->getSegments()->at(i).getIsStation()<<"\n";
         std::cout<<"SegNr: " << i << "  AvgERR: "<<rep.avgerror <<"\n";
         std::cout<<"SegNr: " << i << "  MaxERR: "<<rep.maxerror <<"\n";
         std::cout<<"euclid Dist: " << s.getEuclidianDist() <<"\n";
      }
      else
      {
         std::cout<<"Segment NR: "<< i <<  "is to large" <<"\n\n";
      }
   }


PLEASE HELP! -.-


Top
 Profile  
 
 Post subject: Re: Detect elliptical parts in a 2d laserscan
PostPosted: Tue Jun 12, 2012 8:11 am 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 927
Can you post some pictures which illustrate your problem? It is hard to understand specifics without graphical representation.


Top
 Profile  
 
 Post subject: Re: Detect elliptical parts in a 2d laserscan
PostPosted: Tue Jun 12, 2012 9:49 am 
Offline

Joined: Mon May 14, 2012 4:35 pm
Posts: 5
Hi,

many thanks for your very quick answer.
Here some pics to illustrate my problem and the results.
The sample.png represents the real_2d_array "sample" in my code. It is recorded with a minimum distance so that it gets maximal amount of x,y Points for fitting.
The fittingResult.png shows the result of lsfitlinear(). If the avgErr for an Segment is < 150 i estimate that this segment is an elliptical part an painted red. But as you can see the straight line is also an elliptical part and has even an avgErr < 30, but why?
The faildetect.png shows some more wrong detected segments.
Perhabs it is because i do some transformations on the segments but without these transformations i got worse results.

best regards
christian


Attachments:
faildetect.png
faildetect.png [ 8.21 KiB | Viewed 5571 times ]
fittingResult.png
fittingResult.png [ 12.29 KiB | Viewed 5571 times ]
sample.png
sample.png [ 3.72 KiB | Viewed 5571 times ]
Top
 Profile  
 
 Post subject: Re: Detect elliptical parts in a 2d laserscan
PostPosted: Mon Jun 18, 2012 8:29 am 
Offline

Joined: Mon May 14, 2012 4:35 pm
Posts: 5
nobody any idea?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: Bing [Bot] and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group