forum.alglib.net http://forum.alglib.net/ |
|
Detect elliptical parts in a 2d laserscan http://forum.alglib.net/viewtopic.php?f=2&t=588 |
Page 1 of 1 |
Author: | christian_blesing [ Mon Jun 11, 2012 1:24 pm ] |
Post subject: | Detect elliptical parts in a 2d laserscan |
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! -.- |
Author: | Sergey.Bochkanov [ Tue Jun 12, 2012 8:11 am ] |
Post subject: | Re: Detect elliptical parts in a 2d laserscan |
Can you post some pictures which illustrate your problem? It is hard to understand specifics without graphical representation. |
Author: | christian_blesing [ Tue Jun 12, 2012 9:49 am ] | ||||
Post subject: | Re: Detect elliptical parts in a 2d laserscan | ||||
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
|
Author: | christian_blesing [ Mon Jun 18, 2012 8:29 am ] |
Post subject: | Re: Detect elliptical parts in a 2d laserscan |
nobody any idea? |
Page 1 of 1 | All times are UTC |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |