00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "REdgeDetection.h"
00010 #include "Tools/Location.h"
00011 #include <math.h>
00012
00013 enum{DEFAULT_EDGE_THRESHOLD = 12};
00014
00015 REdgeDetection::REdgeDetection(
00016 ImageProcessor& processor)
00017 :ip(processor),
00018 susanDetector(8),
00019 threshold(DEFAULT_EDGE_THRESHOLD)
00020 {
00021
00022 }
00023
00024 REdgeDetection::~REdgeDetection(){
00025 }
00026
00027
00028 bool REdgeDetection::scanEast(int& x, int& y){
00029 if (!insideImage(x,y)) return false;
00030 int voteBuffer = 0;
00031 int vote = fastCrossEdgeVote(x,y);
00032 int x2 = ip.image.cameraInfo.resolutionWidth-1;
00033
00034 while(x < x2){
00035 if (vote > threshold || voteBuffer != 0){
00036 if (voteBuffer < vote) voteBuffer = vote;
00037 else{
00038 x--;
00039 return true;
00040 }
00041 }
00042 x++;
00043 vote = fastCrossEdgeVote(x,y);
00044 }
00045
00046 if (vote > threshold){
00047 x--;
00048 return true;
00049 }
00050 else return false;
00051 }
00052
00053 bool REdgeDetection::scanWest(int& x, int& y){
00054 if (!insideImage(x,y)) return false;
00055 int voteBuffer = 0;
00056 int vote = fastCrossEdgeVote(x,y);
00057
00058 while(x > 1){
00059 if (vote > threshold || voteBuffer != 0){
00060 if (voteBuffer < vote) voteBuffer = vote;
00061 else{
00062 x++;
00063 return true;
00064 }
00065 }
00066 x--;
00067 vote = fastCrossEdgeVote(x,y);
00068 }
00069
00070 if (vote > threshold){
00071 x++;
00072 return true;
00073 }
00074 else return false;
00075 }
00076
00077 bool REdgeDetection::scanNorth(int& x, int& y){
00078 if(!insideImage(x,y)) return false;
00079 int voteBuffer = 0;
00080 int vote = fastCrossEdgeVote(x,y);
00081
00082 while(y > 1){
00083 if (vote > threshold || voteBuffer != 0){
00084 if (voteBuffer < vote) voteBuffer = vote;
00085 else{
00086 y++;
00087 return true;
00088 }
00089 }
00090 y--;
00091 vote = fastCrossEdgeVote(x,y);
00092 }
00093
00094 if (vote > threshold){
00095 y++;
00096 return true;
00097 }
00098 else return false;
00099 }
00100
00101 bool REdgeDetection::scanSouth(int& x, int& y){
00102 if (!insideImage(x,y)) return false;
00103 int voteBuffer = 0;
00104 int vote = fastCrossEdgeVote(x,y);
00105 int y2 = ip.image.cameraInfo.resolutionHeight -2;
00106
00107 while(y < y2){
00108 if (vote > threshold || voteBuffer != 0){
00109 if (voteBuffer < vote) voteBuffer = vote;
00110 else{
00111 y--;
00112 return true;
00113 }
00114 }
00115 y++;
00116 vote = fastCrossEdgeVote(x,y);
00117 }
00118
00119 if (vote > threshold){
00120 y--;
00121 return true;
00122 }
00123 else return false;
00124 }
00125
00126 bool REdgeDetection::ballScanEast(int& x, int& y){
00127 int voteBuffer = 0;
00128 int vote = ballEdgeVote(x,y);
00129
00130 while(vote > -1){
00131 if (vote > threshold || voteBuffer != 0){
00132 if (voteBuffer < vote) voteBuffer = vote;
00133 else{
00134 x--;
00135 return true;
00136 }
00137 }
00138 x++;
00139 vote = ballEdgeVote(x,y);
00140 }
00141
00142 if (vote > threshold){
00143 x--;
00144 return true;
00145 }
00146 else return false;
00147 }
00148
00149 bool REdgeDetection::ballScanWest(int& x, int& y){
00150 int voteBuffer = 0;
00151 int vote = ballEdgeVote(x,y);
00152
00153 while(vote > -1){
00154 if (vote > threshold || voteBuffer != 0){
00155 if (voteBuffer < vote) voteBuffer = vote;
00156 else{
00157 x++;
00158 return true;
00159 }
00160 }
00161 x--;
00162 vote = ballEdgeVote(x,y);
00163 }
00164
00165 if (vote > threshold){
00166 x++;
00167 return true;
00168 }
00169 else return false;
00170 }
00171
00172 bool REdgeDetection::scan(int& x,int& y,Vector2<double> direction){
00173 cx = 1;
00174 cy = 1;
00175
00176 if (direction.x < 0) cx = -1;
00177 if (direction.y < 0) cy = -1;
00178
00179 tempX = x;
00180 tempY = y;
00181
00182 int vote = crossEdgeVote(x,y);
00183 int buffer = 0;
00184 if (vote > threshold) buffer = vote;
00185
00186
00187
00188 dx = abs((int)(direction.x * 500));
00189 dy = abs((int)(direction.y * 500));
00190
00191 if (dx > dy){
00192 e = dx - 2*dy;
00193 f = 2*(dx - dy);
00194 g = -2*dy;
00195
00196
00197 for (x+=cx;vote != -1;x+=cx) {
00198 if (e<0) {
00199 y+=cy;
00200 e+=f;
00201 }
00202 else {
00203 e+=g;
00204 }
00205
00206
00207
00208 vote = crossEdgeVote(x,y);
00209
00210 if (vote > threshold || buffer != 0){
00211 if (buffer < vote) buffer = vote;
00212 else{
00213 x = tempX;
00214 y = tempY;
00215 return true;
00216 }
00217 }
00218
00219 tempX = x;
00220 tempY = y;
00221 }
00222 }
00223 else{
00224 e = dy - 2*dx;
00225 f = 2*(dy - dx);
00226 g = -2*dx;
00227
00228
00229
00230 for (y+=cy;vote != -1;y+=cy) {
00231 if (e<0) {
00232 x+=cx;
00233 e+=f;
00234 }
00235 else {
00236 e+=g;
00237 }
00238
00239
00240
00241 vote = crossEdgeVote(x,y);
00242
00243 if (vote > threshold || buffer != 0){
00244 if (buffer < vote) buffer = vote;
00245 else{
00246 x = tempX;
00247 y = tempY;
00248 return true;
00249 }
00250 }
00251
00252 tempX = x;
00253 tempY = y;
00254 }
00255 }
00256
00257 if (buffer != 0){
00258 x = tempX;
00259 y = tempY;
00260 return true;
00261 }
00262
00263 return false;
00264 }
00265
00266 bool REdgeDetection::bufferedScan(int& x,int& y,Vector2<double> direction){
00267
00268 cx = 1;
00269 cy = 1;
00270
00271 if (direction.x < 0) cx = -1;
00272 if (direction.y < 0) cy = -1;
00273
00274 tempX = x;
00275 tempY = y;
00276
00277 int vote = crossEdgeVote(x,y);
00278 currentColor = lastColor = getColor(x,y);
00279 bufferSize = 0;
00280
00281 int buffer = 0;
00282 if (vote > threshold) buffer = vote;
00283
00284
00285
00286 dx = abs((int)(direction.x * 500));
00287 dy = abs((int)(direction.y * 500));
00288
00289 if (dx > dy){
00290 e = dx - 2*dy;
00291 f = 2*(dx - dy);
00292 g = -2*dy;
00293
00294
00295 for (x+=cx;vote != -1;x+=cx) {
00296 if (e<0) {
00297 y+=cy;
00298 e+=f;
00299 }
00300 else {
00301 e+=g;
00302 }
00303
00304
00305
00306 vote = crossEdgeVote(x,y);
00307 currentColor = getColor(x,y);
00308 colorRange++;
00309
00310 if (currentColor != lastColor){
00311 addColor();
00312
00313 if (bufferSize > 19) return false;
00314 }
00315
00316 if (vote > threshold || buffer != 0){
00317 if (buffer < vote) buffer = vote;
00318 else{
00319 x = tempX;
00320 y = tempY;
00321 if (colorRange!=0){
00322 lastColor = currentColor;
00323 addColor();
00324 }
00325 return true;
00326 }
00327 }
00328
00329 tempX = x;
00330 tempY = y;
00331 lastColor = currentColor;
00332 }
00333 }
00334 else{
00335 e = dy - 2*dx;
00336 f = 2*(dy - dx);
00337 g = -2*dx;
00338
00339
00340
00341 for (y+=cy;vote != -1;y+=cy) {
00342 if (e<0) {
00343 x+=cx;
00344 e+=f;
00345 }
00346 else {
00347 e+=g;
00348 }
00349
00350
00351
00352 vote = crossEdgeVote(x,y);
00353 currentColor = getColor(x,y);
00354 colorRange++;
00355
00356 if (currentColor != lastColor){
00357 addColor();
00358
00359 if (bufferSize > 19) return false;
00360 }
00361
00362 if (vote > threshold || buffer != 0){
00363 if (buffer < vote) buffer = vote;
00364 else{
00365 if (colorRange!=0){
00366 lastColor = currentColor;
00367 addColor();
00368 }
00369 x = tempX;
00370 y = tempY;
00371 return true;
00372 }
00373 }
00374
00375 tempX = x;
00376 tempY = y;
00377 lastColor = currentColor;
00378 }
00379 }
00380
00381 if (buffer != 0){
00382 if (colorRange!=0){
00383 lastColor = currentColor;
00384 addColor();
00385 }
00386 x = tempX;
00387 y = tempY;
00388 return true;
00389 }
00390
00391 return false;
00392 }
00393
00394 bool REdgeDetection::bufferedScan(int& x,int& y){
00395
00396 currentColor = lastColor = getColor(x,y);
00397 colorRange = 0;
00398 bufferSize = 0;
00399
00400
00401
00402 for (int i = 0;i<3;i++){
00403 skip(x,y);
00404 currentColor = getColor(x,y);
00405 colorRange++;
00406 if (currentColor != lastColor)addColor();
00407 lastColor = currentColor;
00408 }
00409
00410 tempX = x;
00411 tempY = y;
00412
00413 int vote = crossEdgeVote(x,y);
00414
00415 int buffer = 0;
00416 if (vote > threshold) buffer = vote;
00417
00418
00419
00420 if (dx > dy){
00421 for (x+=cx;vote != -1;x+=cx) {
00422 if (e<0) {
00423 y+=cy;
00424 e+=f;
00425 }
00426 else {
00427 e+=g;
00428 }
00429
00430
00431
00432 vote = crossEdgeVote(x,y);
00433 currentColor = getColor(x,y);
00434 colorRange++;
00435
00436 if (currentColor != lastColor){
00437 addColor();
00438
00439 if (bufferSize > 19) return false;
00440 }
00441
00442 if (vote > threshold || buffer != 0){
00443 if (buffer < vote) buffer = vote;
00444 else{
00445 x = tempX;
00446 y = tempY;
00447 if (colorRange!=0){
00448 lastColor = currentColor;
00449 addColor();
00450 }
00451 return true;
00452 }
00453 }
00454
00455 tempX = x;
00456 tempY = y;
00457 lastColor = currentColor;
00458 }
00459 }
00460 else{
00461 for (y+=cy;vote != -1;y+=cy) {
00462 if (e<0) {
00463 x+=cx;
00464 e+=f;
00465 }
00466 else {
00467 e+=g;
00468 }
00469
00470
00471
00472 vote = crossEdgeVote(x,y);
00473 currentColor = getColor(x,y);
00474 colorRange++;
00475
00476 if (currentColor != lastColor){
00477 addColor();
00478 }
00479
00480 if (vote > threshold || buffer != 0){
00481 if (buffer < vote) buffer = vote;
00482 else{
00483 if (colorRange!=0){
00484 lastColor = currentColor;
00485 addColor();
00486 }
00487 x = tempX;
00488 y = tempY;
00489 return true;
00490 }
00491 }
00492
00493 tempX = x;
00494 tempY = y;
00495 lastColor = currentColor;
00496 }
00497 }
00498
00499 if (buffer != 0){
00500 if (colorRange!=0){
00501 addColor();
00502 }
00503 x = tempX;
00504 y = tempY;
00505 return true;
00506 }
00507
00508 return false;
00509 }
00510
00511 bool REdgeDetection::scanField(int& x,int& y,Vector2<double> direction){
00512 cx = 1;
00513 cy = 1;
00514
00515 if (direction.x < 0) cx = -1;
00516 if (direction.y < 0) cy = -1;
00517
00518 tempX = x;
00519 tempY = y;
00520
00521 int vote = fieldEdgeVote(x,y);
00522 int buffer = 0;
00523 if (vote > threshold) buffer = vote;
00524
00525
00526
00527 dx = abs((int)(direction.x * 500));
00528 dy = abs((int)(direction.y * 500));
00529
00530 if (dx > dy){
00531 e = dx - 2*dy;
00532 f = 2*(dx - dy);
00533 g = -2*dy;
00534
00535
00536 for (x+=cx;vote != -1;x+=cx) {
00537 if (e<0) {
00538 y+=cy;
00539 e+=f;
00540 }
00541 else {
00542 e+=g;
00543 }
00544
00545
00546
00547 vote = fieldEdgeVote(x,y);
00548
00549 if (vote > threshold || buffer != 0){
00550 if (buffer < vote) buffer = vote;
00551 else{
00552 x = tempX;
00553 y = tempY;
00554 return true;
00555 }
00556 }
00557
00558 tempX = x;
00559 tempY = y;
00560 }
00561 }
00562 else{
00563 e = dy - 2*dx;
00564 f = 2*(dy - dx);
00565 g = -2*dx;
00566
00567
00568
00569 for (y+=cy;vote != -1;y+=cy) {
00570 if (e<0) {
00571 x+=cx;
00572 e+=f;
00573 }
00574 else {
00575 e+=g;
00576 }
00577
00578
00579
00580 vote = fieldEdgeVote(x,y);
00581
00582 if (vote > threshold || buffer != 0){
00583 if (buffer < vote) buffer = vote;
00584 else{
00585 x = tempX;
00586 y = tempY;
00587 return true;
00588 }
00589 }
00590
00591 tempX = x;
00592 tempY = y;
00593 }
00594 }
00595
00596 if (buffer != 0){
00597 x = tempX;
00598 y = tempY;
00599 return true;
00600 }
00601
00602 return false;
00603 }
00604
00605 bool REdgeDetection::scanField(int& x,int& y){
00606
00607 tempX = x;
00608 tempY = y;
00609
00610 int vote = fieldEdgeVote(x,y);
00611 int buffer = 0;
00612 if (vote > threshold) buffer = vote;
00613
00614
00615 if (dx > dy){
00616 for (x+=cx;vote != -1;x+=cx) {
00617 if (e<0) {
00618 y+=cy;
00619 e+=f;
00620 }
00621 else {
00622 e+=g;
00623 }
00624
00625
00626
00627 vote = fieldEdgeVote(x,y);
00628
00629 if (vote > threshold || buffer != 0){
00630 if (buffer < vote) buffer = vote;
00631 else{
00632 x = tempX;
00633 y = tempY;
00634 return true;
00635 }
00636 }
00637
00638 tempX = x;
00639 tempY = y;
00640 }
00641 }
00642 else{
00643 for (y+=cy;vote != -1;y+=cy) {
00644 if (e<0) {
00645 x+=cx;
00646 e+=f;
00647 }
00648 else {
00649 e+=g;
00650 }
00651
00652
00653
00654 vote = fieldEdgeVote(x,y);
00655
00656 if (vote > threshold || buffer != 0){
00657 if (buffer < vote) buffer = vote;
00658 else{
00659 x = tempX;
00660 y = tempY;
00661 return true;
00662 }
00663 }
00664 tempX = x;
00665 tempY = y;
00666 }
00667 }
00668
00669 if (buffer != 0){
00670 x = tempX;
00671 y = tempY;
00672 return true;
00673 }
00674
00675 return false;
00676 }
00677
00678 bool REdgeDetection::scan(int& x,int& y,int x1,int y1){
00679 cx = 1;
00680 cy = 1;
00681
00682 dx = x1 - x;
00683 dy = y1 - y;
00684
00685 if (dx < 0) cx = -1;
00686 if (dy < 0) cy = -1;
00687
00688 tempX = x;
00689 tempY = y;
00690
00691 int vote = crossEdgeVote(x,y);
00692 int buffer = 0;
00693 if (vote > threshold) buffer = vote;
00694
00695
00696 if (dx > dy){
00697 e = dx - 2*dy;
00698 f = 2*(dx - dy);
00699 g = -2*dy;
00700
00701
00702 for (x+=cx;x<x1;x+=cx) {
00703 if (e<0) {
00704 y+=cy;
00705 e+=f;
00706 }
00707 else {
00708 e+=g;
00709 }
00710
00711
00712
00713 vote = fastCrossEdgeVote(x,y);
00714
00715 if (vote > threshold || buffer != 0){
00716 if (buffer < vote) buffer = vote;
00717 else{
00718 x = tempX;
00719 y = tempY;
00720 return true;
00721 }
00722 }
00723
00724 tempX = x;
00725 tempY = y;
00726 }
00727 }
00728 else{
00729 e = dy - 2*dx;
00730 f = 2*(dy - dx);
00731 g = -2*dx;
00732
00733
00734
00735 for (y+=cy;y<y1;y+=cy) {
00736 if (e<0) {
00737 x+=cx;
00738 e+=f;
00739 }
00740 else {
00741 e+=g;
00742 }
00743
00744
00745
00746 vote = fastCrossEdgeVote(x,y);
00747
00748 if (vote > threshold || buffer != 0){
00749 if (buffer < vote) buffer = vote;
00750 else{
00751 x = tempX;
00752 y = tempY;
00753 return true;
00754 }
00755 }
00756
00757 tempX = x;
00758 tempY = y;
00759 }
00760 }
00761
00762 if (buffer != 0){
00763 x = tempX;
00764 y = tempY;
00765 return true;
00766 }
00767
00768 return false;
00769 }
00770
00771 bool REdgeDetection::colorScan(int& x,int& y,int x1,int y1,colorClass& lastColor){
00772 cx = 1;
00773 cy = 1;
00774
00775 colorClass start = getColor(x,y);
00776 colorClass current = start;
00777
00778 dx = x1 - x;
00779 dy = y1 - y;
00780
00781 if (dx < 0) cx = -1;
00782 if (dy < 0) cy = -1;
00783
00784
00785 if (dx > dy){
00786 e = dx - 2*dy;
00787 f = 2*(dx - dy);
00788 g = -2*dy;
00789
00790 int count = 0;
00791
00792
00793 for (x+=cx ; current == start && count < dx ; x+=cx,count++) {
00794 if (e<0) {
00795 y+=cy;
00796 e+=f;
00797 }
00798 else {
00799 e+=g;
00800 }
00801
00802
00803
00804 current = getColor(x,y);
00805 }
00806 }
00807 else{
00808 e = dy - 2*dx;
00809 f = 2*(dy - dx);
00810 g = -2*dx;
00811 int count = 0;
00812
00813
00814
00815 for (y+=cy; current==start && count<dy; y+=cy,count++) {
00816 if (e<0) {
00817 x+=cx;
00818 e+=f;
00819 }
00820 else {
00821 e+=g;
00822 }
00823
00824
00825
00826 current = getColor(x,y);
00827 }
00828 }
00829
00830 if (current == -1){
00831 lastColor = noColor;
00832 return false;
00833 }
00834 else {
00835 lastColor = start;
00836 return true;
00837 }
00838 }
00839
00840 bool REdgeDetection::colorScan(int& x,int& y,Vector2<double> direction,colorClass& lastColor){
00841 cx = 1;
00842 cy = 1;
00843
00844 colorClass start = getColor(x,y);
00845 colorClass current = start;
00846
00847 if (direction.x < 0) cx = -1;
00848 if (direction.y < 0) cy = -1;
00849
00850
00851
00852
00853 dx = abs((int)(direction.x * 500));
00854 dy = abs((int)(direction.y * 500));
00855
00856 if (dx > dy){
00857 e = dx - 2*dy;
00858 f = 2*(dx - dy);
00859 g = -2*dy;
00860
00861
00862 for (x+=cx;current == start && current != -1;x+=cx) {
00863 if (e<0) {
00864 y+=cy;
00865 e+=f;
00866 }
00867 else {
00868 e+=g;
00869 }
00870
00871
00872
00873 current = getColor(x,y);
00874 }
00875 }
00876 else{
00877 e = dy - 2*dx;
00878 f = 2*(dy - dx);
00879 g = -2*dx;
00880
00881
00882
00883 for (y+=cy;current == start && current != -1;y+=cy) {
00884 if (e<0) {
00885 x+=cx;
00886 e+=f;
00887 }
00888 else {
00889 e+=g;
00890 }
00891
00892
00893
00894 current = getColor(x,y);
00895 }
00896 }
00897
00898 if (current == -1){
00899 lastColor = noColor;
00900 return false;
00901 }
00902 else {
00903 lastColor = start;
00904 return true;
00905 }
00906 }
00907
00908 bool REdgeDetection::colorScan(int& x,int& y,colorClass& lastColor){
00909
00910 colorClass start = getColor(x,y);
00911 colorClass current = start;
00912
00913
00914 if (dx > dy){
00915 for (x+=cx;current == start && current != -1;x+=cx) {
00916 if (e<0) {
00917 y+=cy;
00918 e+=f;
00919 }
00920 else {
00921 e+=g;
00922 }
00923
00924
00925
00926 current = getColor(x,y);
00927 }
00928 }
00929 else{
00930 for (y+=cy;current == start && current != -1;y+=cy) {
00931 if (e<0) {
00932 x+=cx;
00933 e+=f;
00934 }
00935 else {
00936 e+=g;
00937 }
00938
00939
00940
00941 current = getColor(x,y);
00942 }
00943 }
00944
00945 if (current == -1){
00946 lastColor = noColor;
00947 return false;
00948 }
00949 else {
00950 lastColor = start;
00951 return true;
00952 }
00953 }
00954
00955 bool REdgeDetection::susanScan(int& x,int& y,Vector2<double> direction){
00956 cx = 1;
00957 cy = 1;
00958
00959 if (direction.x < 0) cx = -1;
00960 if (direction.y < 0) cy = -1;
00961
00962 tempX = x;
00963 tempY = y;
00964
00965 int vote = susanVote(x,y);
00966 int buffer = 0;
00967 if (vote > 0) buffer = vote;
00968
00969
00970
00971 dx = abs((int)(direction.x * 500));
00972 dy = abs((int)(direction.y * 500));
00973
00974 if (dx > dy){
00975 e = dx - 2*dy;
00976 f = 2*(dx - dy);
00977 g = -2*dy;
00978
00979
00980 for (x+=cx;vote != -1;x+=cx) {
00981 if (e<0) {
00982 y+=cy;
00983 e+=f;
00984 }
00985 else {
00986 e+=g;
00987 }
00988
00989
00990
00991 vote = susanVote(x,y);
00992
00993 if (vote > 0 || buffer != 0){
00994 if (buffer < vote) buffer = vote;
00995 else{
00996 x = tempX;
00997 y = tempY;
00998 return true;
00999 }
01000 }
01001
01002 tempX = x;
01003 tempY = y;
01004 }
01005 }
01006 else{
01007 e = dy - 2*dx;
01008 f = 2*(dy - dx);
01009 g = -2*dx;
01010
01011
01012
01013 for (y+=cy;vote != -1;y+=cy) {
01014 if (e<0) {
01015 x+=cx;
01016 e+=f;
01017 }
01018 else {
01019 e+=g;
01020 }
01021
01022
01023
01024 vote = susanVote(x,y);
01025
01026 if (vote > 0 || buffer != 0){
01027 if (buffer < vote) buffer = vote;
01028 else{
01029 x = tempX;
01030 y = tempY;
01031 return true;
01032 }
01033 }
01034
01035 tempX = x;
01036 tempY = y;
01037 }
01038 }
01039
01040 if (buffer != 0){
01041 x = tempX;
01042 y = tempY;
01043 return true;
01044 }
01045
01046 return false;
01047 }
01048
01049 bool REdgeDetection::scan(int& x,int& y){
01050
01051 tempX = x;
01052 tempY = y;
01053
01054 int vote = crossEdgeVote(x,y);
01055 int buffer = 0;
01056 if (vote > threshold) buffer = vote;
01057
01058
01059 if (dx > dy){
01060 for (x+=cx;vote != -1;x+=cx) {
01061 if (e<0) {
01062 y+=cy;
01063 e+=f;
01064 }
01065 else {
01066 e+=g;
01067 }
01068
01069
01070
01071 vote = crossEdgeVote(x,y);
01072
01073 if (vote > threshold || buffer != 0){
01074 if (buffer < vote) buffer = vote;
01075 else{
01076 x = tempX;
01077 y = tempY;
01078 return true;
01079 }
01080 }
01081
01082 tempX = x;
01083 tempY = y;
01084 }
01085 }
01086 else{
01087 for (y+=cy;vote != -1;y+=cy) {
01088 if (e<0) {
01089 x+=cx;
01090 e+=f;
01091 }
01092 else {
01093 e+=g;
01094 }
01095
01096
01097
01098 vote = crossEdgeVote(x,y);
01099
01100 if (vote > threshold || buffer != 0){
01101 if (buffer < vote) buffer = vote;
01102 else{
01103 x = tempX;
01104 y = tempY;
01105 return true;
01106 }
01107 }
01108
01109 tempX = x;
01110 tempY = y;
01111 }
01112 }
01113
01114 if (buffer != 0){
01115 x = tempX;
01116 y = tempY;
01117 return true;
01118 }
01119
01120 return false;
01121 }
01122
01123
01124
01125
01126
01127
01128
01129
01130
01131
01132
01133
01134
01135
01136
01137
01138
01139
01140
01141
01142
01143
01144
01145
01146
01147
01148
01149
01150
01151
01152
01153
01154
01155
01156
01157
01158
01159
01160