00001 #include "Robots/SeaBeeIII/StraightEdgeFinder.H"
00002
00003 #include "Component/ModelParam.H"
00004 #include "Component/ModelOptionDef.H"
00005 #include "Image/OpenCVUtil.H"
00006 #include "Raster/Raster.H"
00007 #include "Image/Pixels.H"
00008
00009 #include "Image/Image.H"
00010 #include "Image/Pixels.H"
00011 #include "Raster/Raster.H"
00012 #include "Image/CutPaste.H"
00013 #include "Image/OpenCVUtil.H"
00014
00015 #include "BeoSub/IsolateColor.H"
00016 #include "Image/DrawOps.H"
00017 #include "Image/ColorOps.H"
00018
00019 #include "GUI/XWinManaged.H"
00020
00021 #include "SeaBee/PipeRecognizer.H"
00022 #include "BeoSub/ColorSegmenter.H"
00023 #include "SeaBee/VisionRecognizer.H"
00024
00025 #include "Image/ColorOps.H"
00026
00027
00028 #include "Media/MediaOpts.H"
00029
00030 #include "VFAT/segmentImageMerge.H"
00031
00032 #include "Util/Types.H"
00033 #include "Util/log.H"
00034
00035
00036 #ifndef STRAIGHT_EDGE_FINDER_C
00037 #define STRAIGHT_EDGE_FINDER_C
00038
00039 using namespace std;
00040
00041 #define MIN_CENTER_DIST 15
00042 #define MIN_AREA 150
00043 #define CORNER_TOLERANCE 4
00044
00045 #define IMG_WIDTH 320
00046 #define IMG_HEIGHT 240
00047 int thresh = 42;
00048 double angle_thresh = 0.3;
00049
00050
00051
00052 StraightEdgeFinder::StraightEdgeFinder
00053 ( OptionManager& mgr,
00054 const std::string& descrName,
00055 const std::string& tagName) :
00056 VisionBrainComponentI(mgr, descrName, tagName)
00057 {
00058
00059 itsWidth = IMG_WIDTH;
00060 itsHeight = IMG_HEIGHT;
00061 itsDispImg.resize(2*itsWidth, 2*itsHeight);
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078 }
00079
00080
00081
00082 StraightEdgeFinder::~StraightEdgeFinder()
00083 {
00084 }
00085
00086
00087 void StraightEdgeFinder::registerTopics()
00088 {
00089 LINFO("Registering StraightEdge Message");
00090 this->registerPublisher("StraightEdgeMessageTopic");
00091 registerVisionTopics();
00092 }
00093
00094
00095
00096
00097 void StraightEdgeFinder::updateFrame(Image<PixRGB<byte> > img, std::string cameraId)
00098 {
00099 bool isFwdCamera = false;
00100
00101 if(cameraId == "FwdCamera")
00102 isFwdCamera = true;
00103
00104 LINFO("Image Received: %d", itsFrameCount);
00105
00106 itsDispImg.clear();
00107 inplacePaste(itsDispImg, img, Point2D<int>(0, 0));
00108
00109 uint w = itsWidth; uint h = itsHeight;
00110 rutz::shared_ptr<Image< PixRGB<byte> > >
00111 outputImg(new Image<PixRGB<byte> >(w,h, ZEROS));
00112
00113
00114 rutz::shared_ptr<Image<byte> > orangeIsoImage;
00115 orangeIsoImage.reset(new Image<byte>(w,h, ZEROS));
00116 orangeIsoImage->resize(w,h);
00117 float res = isolateOrange(img, *orangeIsoImage);
00118 LINFO("result: %f", res);
00119
00120 inplacePaste(itsDispImg, toRGB(*orangeIsoImage), Point2D<int>(w,0));
00121
00122
00123 std::vector<LineSegment2D> pipelines =
00124 getPipeLocation
00125 (orangeIsoImage, outputImg, StraightEdgeFinder::HOUGH);
00126
00127 int minY = -1;
00128 int followLineIndex = -1;
00129
00130
00131 for(uint i = 0; i < pipelines.size(); i++)
00132 {
00133 if(pipelines[i].isValid())
00134 {
00135 LineSegment2D pipeline = pipelines[i];
00136 Point2D<int> midpoint = (pipeline.point1() + pipeline.point2())/2;
00137
00138 if(midpoint.j < minY || minY == -1)
00139 {
00140 minY = midpoint.j;
00141 followLineIndex = i;
00142 }
00143 }
00144 }
00145
00146
00147 if(followLineIndex != -1)
00148 {
00149 LineSegment2D followLine = pipelines[followLineIndex];
00150 Point2D<int> midpoint = (followLine.point1() + followLine.point2())/2;
00151
00152 Point2D<int> projPoint;
00153 projPoint.i = (int)(midpoint.i+30*cos(followLine.angle()));
00154 projPoint.j = (int)(midpoint.j+30*sin(followLine.angle()));
00155
00156 drawLine(*outputImg, midpoint, projPoint,
00157 PixRGB <byte> (255, 255,0), 3);
00158
00159 inplacePaste(itsDispImg, *outputImg, Point2D<int>(0,h));
00160
00161
00162 RobotSimEvents::StraightEdgeMessagePtr msg =
00163 new RobotSimEvents::StraightEdgeMessage;
00164
00165 ImageIceMod::LineIce line;
00166 line.pt1.i = midpoint.i;
00167 line.pt1.j = midpoint.j;
00168 line.pt2.i = projPoint.i;
00169 line.pt2.j = projPoint.j;
00170
00171 float radAngle,normalAngle;
00172 radAngle = followLine.angle();
00173 normalAngle = normalizeAngle(radAngle);
00174
00175 LINFO("angle in rads: %1.6f | normalized deg: %1.6f",radAngle,normalAngle);
00176
00177 line.angle = normalAngle;
00178 msg->line = line;
00179 msg->isFwdCamera = true;
00180
00181 LINFO("SEMessage: line: [%4d,%4d][%4d,%4d]: %10.6f",
00182 line.pt1.i, line.pt1.j,
00183 line.pt2.i, line.pt2.j, line.angle);
00184 this->publish("StraightEdgeMessageTopic", msg);
00185 }
00186
00187 itsOfs->writeRGB(itsDispImg, "Straight Edge Finder Image",
00188 FrameInfo("Straight Edge Finder Image", SRC_POS));
00189
00190 itsOfs->updateNext();
00191 }
00192
00193
00194 std::vector<LineSegment2D> StraightEdgeFinder::getPipeLocation
00195 (rutz::shared_ptr<Image<byte> > colorSegmentedImage,
00196 rutz::shared_ptr<Image<PixRGB <byte> > > outputImage,
00197 PipeRecognizeMethod method)
00198 {
00199 if(!colorSegmentedImage->initialized())
00200 return std::vector<LineSegment2D>();
00201
00202
00203 Image<byte> lum = *colorSegmentedImage;
00204
00205 switch(method)
00206 {
00207 case HOUGH:
00208 return calculateHoughTransform(lum,
00209 outputImage);
00210 break;
00211
00212 default:
00213 LERROR("Invalid pipe recognizer method specified");
00214 return std::vector<LineSegment2D>();
00215 }
00216 }
00217
00218
00219 std::vector<LineSegment2D> StraightEdgeFinder::calculateHoughTransform
00220 (Image<byte>& colorSegmentedImage,
00221 rutz::shared_ptr<Image<PixRGB<byte> > > outputImage)
00222 {
00223 #ifndef HAVE_OPENCV
00224 LFATAL("OpenCV must be installed in order to use this function");
00225 #else
00226
00227 IplImage cannyImage = getCannyImage( colorSegmentedImage );
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239 std::vector <LineSegment2D> lineSegments = getHoughLines( cannyImage );
00240
00241
00242 for(uint i = 0; i < lineSegments.size(); i++ )
00243 {
00244 Point2D<int> pt1 = lineSegments[i].point1();
00245 Point2D<int> pt2 = lineSegments[i].point2();
00246
00247 if(pt1.isValid() && pt2.isValid())
00248 {
00249
00250 drawLine(*outputImage, pt1, pt2, PixRGB<byte>(255,0,0));
00251 }
00252 }
00253
00254 std::vector <LineSegment2D> prunedHoughLines =
00255 pruneHoughLines( lineSegments );
00256
00257 return prunedHoughLines;
00258
00259 #endif // HAVE_OPENCV
00260 }
00261
00262
00263
00264 uint StraightEdgeFinder::calculateLineBestFit
00265 (Image<byte> &colorSegmentedImage,
00266 Image<PixRGB <byte> > &outputImage,
00267 Point2D<int> &pipeCenter,
00268 double &pipeAngle)
00269 {return 0;}
00270
00271 uint StraightEdgeFinder::calculateContours
00272 (Image<byte> &colorSegmentedImage,
00273 Image<PixRGB <byte> > &outputImage,
00274 Point2D<int> &pipeCenter,
00275 double &pipeAngle)
00276 {return 0;}
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405 std::vector<LineSegment2D> StraightEdgeFinder::getHoughLines
00406 ( IplImage cannyImage )
00407 {
00408 #ifndef HAVE_OPENCV
00409 LFATAL("OpenCV must be installed in order to use this function");
00410 #else
00411
00412 CvMemStorage* storage = cvCreateMemStorage(0);
00413
00414
00415 CvSeq* cvLines = cvHoughLines2(&cannyImage, storage, CV_HOUGH_PROBABILISTIC, 1, CV_PI/180, 30, 20, 10);
00416
00417
00418
00419 std::vector <LineSegment2D> lineSegments;
00420
00421
00422 for(int i = 0; i < cvLines->total; i++ )
00423 {
00424
00425 CvPoint* line = (CvPoint*)cvGetSeqElem(cvLines,i);
00426
00427
00428 Point2D<int> pt1 = Point2D<int>(line[0].x,line[0].y);
00429 Point2D<int> pt2 = Point2D<int>(line[1].x,line[1].y);
00430
00431
00432 lineSegments.push_back(LineSegment2D(pt1,pt2));
00433 }
00434 cvReleaseMemStorage( &storage );
00435
00436 return lineSegments;
00437 #endif // HAVE_OPENCV
00438 }
00439
00440
00441
00442 IplImage StraightEdgeFinder::getCannyImage( Image<byte> colorSegmentedImage )
00443 {
00444 #ifndef HAVE_OPENCV
00445 LFATAL("OpenCV must be installed in order to use this function");
00446 #else
00447
00448 IplImage *edge = cvCreateImage( cvGetSize( img2ipl( colorSegmentedImage ) ), 8, 1 );
00449 cvCanny( img2ipl( luminance( colorSegmentedImage ) ), edge, 100, 150, 3 );
00450
00451 return *edge;
00452 #endif // HAVE_OPENCV
00453 }
00454
00455
00456
00457 std::vector<LineSegment2D> StraightEdgeFinder::pruneHoughLines
00458 (const std::vector<LineSegment2D> lineSegments)
00459 {
00460 uint numLines = lineSegments.size();
00461 if(numLines == 0) { LDEBUG("No hough lines to prune"); }
00462
00463 std::vector< std::vector<LineSegment2D> > pipeLines;
00464
00465
00466 for(uint r = 0; r < numLines; r++)
00467 {
00468 int lnIndex = -1;
00469
00470
00471 for(uint c = 0; c < pipeLines.size(); c++)
00472 {
00473 LineSegment2D pipeLine = pipeLines[c][0];
00474
00475 if(pipeLine.isValid() && lineSegments[r].angleBetween(pipeLine) < 5*(M_PI/180))
00476 {
00477 lnIndex = c;
00478 break;
00479 }
00480 }
00481
00482
00483 if( lnIndex > 0 )
00484 {
00485 pipeLines[lnIndex].push_back(lineSegments[r]);
00486
00487
00488 Point2D<int> newPt1 =
00489 Point2D<int>(((lineSegments[r].point1().i + pipeLines[lnIndex][0].point1().i)/2),
00490 ((lineSegments[r].point1().j + pipeLines[lnIndex][0].point1().j)/2));
00491
00492 Point2D<int> newPt2 = Point2D<int>(((lineSegments[r].point2().i + pipeLines[lnIndex][0].point2().i)/2),
00493 ((lineSegments[r].point2().j + pipeLines[lnIndex][0].point2().j)/2));
00494
00495 pipeLines[lnIndex][0] = LineSegment2D(newPt1,newPt2);
00496
00497 }
00498
00499 else
00500 {
00501 std::vector<LineSegment2D> newCntrLines;
00502 newCntrLines.push_back(lineSegments[r]);
00503 pipeLines.push_back(newCntrLines);
00504 }
00505 }
00506
00507 std::vector<LineSegment2D> centerPipeLines;
00508
00509 uint pipeLineSize = pipeLines.size();
00510
00511 for(uint c = 0; c < pipeLineSize; c++)
00512 {
00513 centerPipeLines.push_back(pipeLines[c][0]);
00514 }
00515
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530 return centerPipeLines;
00531 }
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650
00651
00652
00653
00654
00655
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677
00678
00679
00680
00681
00682
00683 float StraightEdgeFinder::isolateOrange3(Image< PixRGB<byte> > &inputImage, Image<byte> &outputImage)
00684 {
00685
00686 readConfig colorConf;
00687 colorConf.openFile("colortrack.conf", false);
00688
00689 int orangeCount = 0;
00690
00691 Image<PixRGB<byte> >::iterator iptr = inputImage.beginw();
00692 Image<byte>::iterator optr = outputImage.beginw();
00693 Image<PixRGB<byte> >::iterator stop = inputImage.endw();
00694
00695
00696
00697
00698
00699
00700
00701
00702
00703
00704 float tR = 70.0;
00705 float tG = 200.0;
00706 float tB = 128.0;
00707
00708 float R = 255;
00709 float G = 198;
00710 float B = 0;
00711
00712
00713
00714
00715
00716 float totalHue = 0.0;
00717 int numTotal = 0;
00718
00719
00720 float pure_orange_hue = 60*(((G/255)-(B/255))/((R/255)-(B/255)))+0;
00721 float orange_hue = 60*(((tB/255)-(tR/255))/((tG/255) - (tR/255)))+120;
00722
00723 float orange_sat = ((200.0/255.0)-(70/255.0))/(2.0-(270.0/255.0));
00724 std::cout<<"orange hue is: "<<orange_hue<<std::endl;
00725 std::cout<<"orange saturation(purity) is: "<<orange_sat<<std::endl;
00726 std::cout<<"orange HSV saturation is: "<<(1.0-70.0/200.0)<<std::endl;
00727
00728 while (iptr != stop)
00729 {
00730 float hue = 0.0;
00731 float s = 0.0;
00732 float avgR = (*iptr).red();
00733 float avgG = (*iptr).green();
00734 float avgB = (*iptr).blue();
00735 float r = avgR/255;
00736 float g = avgG/255;
00737 float b = avgB/255;
00738
00739
00740
00741
00742
00743 float max = 0;
00744 float min = 1;
00745
00746 if(r > max) { max = r;}
00747 if(g > max) { max = g;}
00748 if(b > max) { max = b;}
00749
00750 if(r < min){min = r;}
00751 if(g < min){min = g;}
00752 if(b < min){min = b;}
00753
00754
00755 if(max == min) {hue = 0.0;}
00756 else if(max == r && g >= b) {hue = 60.0*((g-b)/(max - min)) + 0.0;}
00757 else if(max == r && g < b) {hue = 60.0*((g-b)/(max - min)) + 360.0;}
00758 else if(max == g) {hue = 60.0*((b-r)/(max-min))+120.0;}
00759 else if(max == b) {hue = 60.0*((r-g)/(max-min))+240.0;}
00760
00761
00762
00763 totalHue += hue;
00764 numTotal++;
00765
00766
00767 if(max){s = max;}
00768 if(max != 0){s = 1 - min/max;}
00769
00770 if(hue == orange_hue)
00771 {
00772
00773
00774 }
00775 if(hue == pure_orange_hue)
00776 {
00777
00778
00779 }
00780
00781
00782
00783
00784
00785
00786 if(!(120 <= hue && hue <= 145) &&
00787 s != 1)
00788 {
00789
00790 (*optr) = (byte)255;
00791 orangeCount++;
00792 }
00793
00794
00795
00796
00797
00798
00799 if (avgR > R - tR && avgR < R + tR &&
00800 avgG > G - tG && avgG < G + tG &&
00801 avgB > B - tB && avgB < B + tB )
00802 {
00803 (*optr) = (byte)255;
00804 orangeCount++;
00805 }
00806
00807
00808
00809
00810
00811
00812
00813 iptr++; optr++;
00814 }
00815
00816 std::cout<<"average hue was "<<totalHue/numTotal<<std::endl;
00817 return float(orangeCount)/float( (inputImage.getHeight() * inputImage.getWidth()));
00818 }
00819
00820
00821
00822 float StraightEdgeFinder::isolateOrange4(Image< PixRGB<byte> > &inputImage, Image<byte> &outputImage)
00823 {
00824
00825
00826
00827
00828
00829 Image< PixRGB<byte> > display;
00830
00831 uint width = itsWidth; uint height = itsHeight;
00832 Image< PixRGB<byte> > ima = inputImage;
00833 Image< PixRGB<float> > fima;
00834
00835
00836
00837 Image<PixH2SV2<float> > H2SVimage;
00838
00839
00840
00841
00842
00843
00844
00845 std::vector<float> color(3,0.0F);
00846 color[0] = 20.0F; color[1] = 0.25F; color[2] = 156.0F;
00847
00848
00849 std::vector<float> std(3,0.0F);
00850 std[0] = 30.0F; std[1] = 0.30F; std[2] = 60.0F;
00851
00852
00853 std::vector<float> norm(3,0.0F);
00854 norm[0] = 360.0F; norm[1] = 1.0F; norm[2] = 255.0F;
00855
00856
00857 std::vector<float> adapt(3,0.0F);
00858 adapt[0] = 3.5F; adapt[1] = 3.5F; adapt[2] = 3.5F;
00859
00860
00861 std::vector<float> upperBound(3,0.0F);
00862 upperBound[0] = 50.0F; upperBound[1] = 0.4F ; upperBound[2] = 180.0F;
00863
00864
00865 std::vector<float> lowerBound(3,0.0F);
00866 lowerBound[0] = 12.0F; lowerBound[1] = 0.1F; lowerBound[2] = 120.0F;
00867 */
00868
00869
00870
00871
00872
00873
00874
00875
00876
00877
00878
00879
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890
00891
00892
00893
00894
00895
00896
00897 std::vector<float> color(3,0.0F);
00898
00899 color[0] = 0.0F; color[1] = 0.88F; color[2] = 180.0F;
00900
00901
00902
00903
00904 std::vector<float> std(3,0.0F);
00905 std[0] = 60.0F; std[1] = 0.30F; std[2] = 60.0F;
00906
00907
00908 std::vector<float> norm(3,0.0F);
00909 norm[0] = 360.0F; norm[1] = 1.0F; norm[2] = 255.0F;
00910
00911
00912 std::vector<float> adapt(3,0.0F);
00913 adapt[0] = 3.5F; adapt[1] = 3.5F; adapt[2] = 3.5F;
00914
00915
00916 std::vector<float> upperBound(3,0.0F);
00917 upperBound[0] = 360.0F; upperBound[1] = 1.0F ; upperBound[2] = 255.0F;
00918
00919
00920 std::vector<float> lowerBound(3,0.0F);
00921 lowerBound[0] = 200.0F; lowerBound[1] = 0.1F; lowerBound[2] = 10.0F;
00922
00923
00924
00925
00926
00927
00928
00929
00930
00931
00932
00933
00934
00935
00936
00937
00938
00939
00940
00941
00942
00943
00944
00945
00946
00947
00948
00949
00950
00951
00952
00953
00954
00955
00956
00957 int wi = width/4;
00958 int hi = height/4;
00959
00960 segmentImageTrackMC<float,unsigned int, 4> segmenter(wi*hi);
00961
00962 segmenter.SITsetTrackColor(&color,&std,&norm,&adapt,&upperBound,&lowerBound);
00963
00964
00965
00966
00967
00968 segmenter.SITsetFrame(&wi,&hi);
00969
00970
00971
00972 segmenter.SITsetCircleColor(255,255,0);
00973 segmenter.SITsetBoxColor(255,255,0,0,255,255);
00974 segmenter.SITsetUseSmoothing(true,10);
00975
00976
00977 Image<PixRGB<byte> > Aux;
00978 Aux.resize(100,450,true);
00979
00980
00981 H2SVimage = ima;
00982 display = ima;
00983
00984
00985
00986
00987 segmenter.SITtrackImageAny(H2SVimage,&display,&Aux,true);
00988
00989
00990 Image<byte> temp = segmenter.SITreturnCandidateImage();
00991
00992
00993 outputImage = temp;
00994
00995 inplacePaste(itsDispImg, toRGB(temp), Point2D<int>(itsWidth,itsHeight));
00996
00997
00998
00999
01000
01001
01002
01003
01004
01005
01006
01007
01008
01009
01010
01011
01012
01013
01014
01015
01016
01017
01018
01019
01020 return 0.0;
01021 }
01022
01023
01024 float StraightEdgeFinder::isolateOrange5
01025 (Image< PixRGB<byte> > &inputImage, Image<byte> &outputImage)
01026 {
01027
01028 int width = itsWidth, height = itsHeight;
01029
01030 float H,S,V,Hs,Ss,Vs;
01031 float LOTcount = 0;
01032
01033
01034 Image< PixRGB<byte> > ima = inputImage;
01035 Image< PixRGB<float> > fima;
01036
01037
01038 segmentImage segment(HSV);
01039 segmentImageTrack track(1000, &segment);
01040 H = 10; Hs = 200;
01041 S = .70; Ss = .20;
01042 V = 150; Vs = 250;
01043 segment.setHue(H,Hs,0);
01044 segment.setSat(S,Ss,0);
01045 segment.setVal(V,Vs,0);
01046 segment.setHSVavg(15);
01047 segment.setFrame(0,0,width/4,height/4,width/4,height/4);
01048
01049
01050 fima = decXY(ima);
01051 fima = decXY(fima);
01052
01053
01054 segment.segment(fima);
01055 Image<byte> outputI = segment.returnNormalizedCandidates();
01056 segment.calcMassCenter();
01057 track.track(0);
01058
01059 for(int i = 0; i < segment.numberBlobs(); i++)
01060 {
01061 if(track.isCandidate(i) == true)
01062 {
01063 segment.getHSVvalueMean(i,&H,&S,&V,&Hs,&Ss,&Vs);
01064
01065
01066
01067
01068
01069
01070
01071
01072
01073
01074
01075
01076 }
01077 if(track.returnLOT() == true)
01078 {
01079 if(LOTcount == 2)
01080 {
01081 H = 200; Hs = 20;
01082 S = .70; Ss = .20;
01083 V = 150; Vs = 150;
01084 LOTcount = 0;
01085 }
01086 else
01087 {
01088 LOTcount++;
01089 }
01090 }
01091 segment.setHue(H,(Hs*3),0);
01092 segment.setSat(S,(Ss*3),0);
01093 segment.setVal(V,(Vs*3),0);
01094 }
01095
01096
01097
01098
01099
01100
01101
01102
01103
01104
01105
01106
01107
01108
01109
01110
01111
01112
01113
01114
01115
01116
01117
01118
01119
01120
01121
01122
01123
01124
01125
01126
01127
01128
01129
01130
01131
01132 outputImage = outputI;
01133
01134 itsDispImg.clear();
01135
01136 inplacePaste(itsDispImg, toRGB(outputI), Point2D<int>(itsWidth,itsHeight));
01137
01138
01139 return 1.0;
01140 }
01141
01142
01143 float StraightEdgeFinder::normalizeAngle(float angleInRads) {
01144 float angleInDegs;
01145
01146 angleInDegs = angleInRads * 180 / M_PI;
01147 if (angleInDegs < 0) angleInDegs += 90;
01148 else angleInDegs -= 90;
01149
01150 return angleInDegs;
01151 }
01152
01153
01154 #endif
01155
01156
01157
01158
01159
01160