Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include <stdint.h>
00029 #include <stdlib.h>
00030 #include "cvWrapper.h"
00031 #include "agast5_8.h"
00032
00033 using namespace std;
00034 using namespace agast;
00035
00036 void AgastDetector5_8::detect(const unsigned char* im, std::vector<CvPoint>& corners_all)
00037 {
00038 int total=0;
00039 int nExpectedCorners=corners_all.capacity();
00040 CvPoint h;
00041 register int x, y;
00042 register int xsizeB=xsize - 2;
00043 register int ysizeB=ysize - 1;
00044 register int_fast16_t offset0, offset1, offset2, offset3, offset4, offset5, offset6, offset7;
00045 register int width;
00046
00047 corners_all.resize(0);
00048
00049 offset0=s_offset0;
00050 offset1=s_offset1;
00051 offset2=s_offset2;
00052 offset3=s_offset3;
00053 offset4=s_offset4;
00054 offset5=s_offset5;
00055 offset6=s_offset6;
00056 offset7=s_offset7;
00057 width=xsize;
00058
00059 for(y=1; y < ysizeB; y++)
00060 {
00061 x=0;
00062 while(1)
00063 {
00064 homogeneous:
00065 {
00066 x++;
00067 if(x>xsizeB)
00068 break;
00069 else
00070 {
00071 register const unsigned char* const p = im + y*width + x;
00072 register const int cb = *p + b;
00073 register const int c_b = *p - b;
00074 if(p[offset0] > cb)
00075 if(p[offset2] > cb)
00076 if(p[offset3] > cb)
00077 if(p[offset5] > cb)
00078 if(p[offset1] > cb)
00079 if(p[offset4] > cb)
00080 goto success_structured;
00081 else
00082 if(p[offset7] > cb)
00083 goto success_structured;
00084 else
00085 goto homogeneous;
00086 else
00087 if(p[offset4] > cb)
00088 if(p[offset6] > cb)
00089 goto success_structured;
00090 else
00091 goto homogeneous;
00092 else
00093 goto homogeneous;
00094 else
00095 if(p[offset1] > cb)
00096 if(p[offset4] > cb)
00097 goto success_homogeneous;
00098 else
00099 if(p[offset7] > cb)
00100 goto success_homogeneous;
00101 else
00102 goto homogeneous;
00103 else
00104 goto homogeneous;
00105 else
00106 if(p[offset7] > cb)
00107 if(p[offset6] > cb)
00108 if(p[offset5] > cb)
00109 if(p[offset1] > cb)
00110 goto success_structured;
00111 else
00112 if(p[offset4] > cb)
00113 goto success_structured;
00114 else
00115 goto homogeneous;
00116 else
00117 if(p[offset1] > cb)
00118 goto success_homogeneous;
00119 else
00120 goto homogeneous;
00121 else
00122 goto homogeneous;
00123 else
00124 if(p[offset5] < c_b)
00125 if(p[offset3] < c_b)
00126 if(p[offset7] < c_b)
00127 if(p[offset4] < c_b)
00128 if(p[offset6] < c_b)
00129 goto success_structured;
00130 else
00131 goto structured;
00132 else
00133 goto homogeneous;
00134 else
00135 goto homogeneous;
00136 else
00137 goto homogeneous;
00138 else
00139 goto homogeneous;
00140 else
00141 if(p[offset5] > cb)
00142 if(p[offset7] > cb)
00143 if(p[offset6] > cb)
00144 if(p[offset1] > cb)
00145 goto success_homogeneous;
00146 else
00147 if(p[offset4] > cb)
00148 goto success_homogeneous;
00149 else
00150 goto homogeneous;
00151 else
00152 goto homogeneous;
00153 else
00154 goto homogeneous;
00155 else
00156 if(p[offset5] < c_b)
00157 if(p[offset3] < c_b)
00158 if(p[offset2] < c_b)
00159 if(p[offset1] < c_b)
00160 if(p[offset4] < c_b)
00161 goto success_structured;
00162 else
00163 goto homogeneous;
00164 else
00165 if(p[offset4] < c_b)
00166 if(p[offset6] < c_b)
00167 goto success_structured;
00168 else
00169 goto homogeneous;
00170 else
00171 goto homogeneous;
00172 else
00173 if(p[offset7] < c_b)
00174 if(p[offset4] < c_b)
00175 if(p[offset6] < c_b)
00176 goto success_structured;
00177 else
00178 goto homogeneous;
00179 else
00180 goto homogeneous;
00181 else
00182 goto homogeneous;
00183 else
00184 goto homogeneous;
00185 else
00186 goto homogeneous;
00187 else if(p[offset0] < c_b)
00188 if(p[offset2] < c_b)
00189 if(p[offset7] > cb)
00190 if(p[offset3] < c_b)
00191 if(p[offset5] < c_b)
00192 if(p[offset1] < c_b)
00193 if(p[offset4] < c_b)
00194 goto success_structured;
00195 else
00196 goto structured;
00197 else
00198 if(p[offset4] < c_b)
00199 if(p[offset6] < c_b)
00200 goto success_structured;
00201 else
00202 goto structured;
00203 else
00204 goto homogeneous;
00205 else
00206 if(p[offset1] < c_b)
00207 if(p[offset4] < c_b)
00208 goto success_structured;
00209 else
00210 goto homogeneous;
00211 else
00212 goto homogeneous;
00213 else
00214 if(p[offset5] > cb)
00215 if(p[offset3] > cb)
00216 if(p[offset4] > cb)
00217 if(p[offset6] > cb)
00218 goto success_structured;
00219 else
00220 goto structured;
00221 else
00222 goto homogeneous;
00223 else
00224 goto homogeneous;
00225 else
00226 goto homogeneous;
00227 else
00228 if(p[offset7] < c_b)
00229 if(p[offset3] < c_b)
00230 if(p[offset5] < c_b)
00231 if(p[offset1] < c_b)
00232 goto success_structured;
00233 else
00234 if(p[offset4] < c_b)
00235 if(p[offset6] < c_b)
00236 goto success_structured;
00237 else
00238 goto structured;
00239 else
00240 goto homogeneous;
00241 else
00242 if(p[offset1] < c_b)
00243 goto success_homogeneous;
00244 else
00245 goto homogeneous;
00246 else
00247 if(p[offset6] < c_b)
00248 if(p[offset5] < c_b)
00249 if(p[offset1] < c_b)
00250 goto success_structured;
00251 else
00252 if(p[offset4] < c_b)
00253 goto success_structured;
00254 else
00255 goto homogeneous;
00256 else
00257 if(p[offset1] < c_b)
00258 goto success_homogeneous;
00259 else
00260 goto homogeneous;
00261 else
00262 goto homogeneous;
00263 else
00264 if(p[offset3] < c_b)
00265 if(p[offset5] < c_b)
00266 if(p[offset1] < c_b)
00267 if(p[offset4] < c_b)
00268 goto success_structured;
00269 else
00270 goto homogeneous;
00271 else
00272 if(p[offset4] < c_b)
00273 if(p[offset6] < c_b)
00274 goto success_structured;
00275 else
00276 goto homogeneous;
00277 else
00278 goto homogeneous;
00279 else
00280 if(p[offset1] < c_b)
00281 if(p[offset4] < c_b)
00282 goto success_homogeneous;
00283 else
00284 goto homogeneous;
00285 else
00286 goto homogeneous;
00287 else
00288 goto homogeneous;
00289 else
00290 if(p[offset5] > cb)
00291 if(p[offset3] > cb)
00292 if(p[offset2] > cb)
00293 if(p[offset1] > cb)
00294 if(p[offset4] > cb)
00295 goto success_structured;
00296 else
00297 goto homogeneous;
00298 else
00299 if(p[offset4] > cb)
00300 if(p[offset6] > cb)
00301 goto success_structured;
00302 else
00303 goto homogeneous;
00304 else
00305 goto homogeneous;
00306 else
00307 if(p[offset7] > cb)
00308 if(p[offset4] > cb)
00309 if(p[offset6] > cb)
00310 goto success_structured;
00311 else
00312 goto homogeneous;
00313 else
00314 goto homogeneous;
00315 else
00316 goto homogeneous;
00317 else
00318 goto homogeneous;
00319 else
00320 if(p[offset5] < c_b)
00321 if(p[offset7] < c_b)
00322 if(p[offset6] < c_b)
00323 if(p[offset1] < c_b)
00324 goto success_homogeneous;
00325 else
00326 if(p[offset4] < c_b)
00327 goto success_homogeneous;
00328 else
00329 goto homogeneous;
00330 else
00331 goto homogeneous;
00332 else
00333 goto homogeneous;
00334 else
00335 goto homogeneous;
00336 else
00337 if(p[offset3] > cb)
00338 if(p[offset5] > cb)
00339 if(p[offset2] > cb)
00340 if(p[offset1] > cb)
00341 if(p[offset4] > cb)
00342 goto success_homogeneous;
00343 else
00344 goto homogeneous;
00345 else
00346 if(p[offset4] > cb)
00347 if(p[offset6] > cb)
00348 goto success_homogeneous;
00349 else
00350 goto homogeneous;
00351 else
00352 goto homogeneous;
00353 else
00354 if(p[offset7] > cb)
00355 if(p[offset4] > cb)
00356 if(p[offset6] > cb)
00357 goto success_homogeneous;
00358 else
00359 goto homogeneous;
00360 else
00361 goto homogeneous;
00362 else
00363 goto homogeneous;
00364 else
00365 goto homogeneous;
00366 else
00367 if(p[offset3] < c_b)
00368 if(p[offset5] < c_b)
00369 if(p[offset2] < c_b)
00370 if(p[offset1] < c_b)
00371 if(p[offset4] < c_b)
00372 goto success_homogeneous;
00373 else
00374 goto homogeneous;
00375 else
00376 if(p[offset4] < c_b)
00377 if(p[offset6] < c_b)
00378 goto success_homogeneous;
00379 else
00380 goto homogeneous;
00381 else
00382 goto homogeneous;
00383 else
00384 if(p[offset7] < c_b)
00385 if(p[offset4] < c_b)
00386 if(p[offset6] < c_b)
00387 goto success_homogeneous;
00388 else
00389 goto homogeneous;
00390 else
00391 goto homogeneous;
00392 else
00393 goto homogeneous;
00394 else
00395 goto homogeneous;
00396 else
00397 goto homogeneous;
00398 }
00399 }
00400 structured:
00401 {
00402 x++;
00403 if(x>xsizeB)
00404 break;
00405 else
00406 {
00407 register const unsigned char* const p = im + y*width + x;
00408 register const int cb = *p + b;
00409 register const int c_b = *p - b;
00410 if(p[offset0] > cb)
00411 if(p[offset2] > cb)
00412 if(p[offset3] > cb)
00413 if(p[offset5] > cb)
00414 if(p[offset7] > cb)
00415 if(p[offset1] > cb)
00416 goto success_structured;
00417 else
00418 if(p[offset4] > cb)
00419 if(p[offset6] > cb)
00420 goto success_structured;
00421 else
00422 goto structured;
00423 else
00424 goto structured;
00425 else
00426 if(p[offset1] > cb)
00427 if(p[offset4] > cb)
00428 goto success_structured;
00429 else
00430 goto structured;
00431 else
00432 if(p[offset4] > cb)
00433 if(p[offset6] > cb)
00434 goto success_structured;
00435 else
00436 goto structured;
00437 else
00438 goto structured;
00439 else
00440 if(p[offset7] > cb)
00441 if(p[offset1] > cb)
00442 goto success_structured;
00443 else
00444 goto structured;
00445 else
00446 if(p[offset1] > cb)
00447 if(p[offset4] > cb)
00448 goto success_structured;
00449 else
00450 goto structured;
00451 else
00452 goto structured;
00453 else
00454 if(p[offset7] > cb)
00455 if(p[offset6] > cb)
00456 if(p[offset5] > cb)
00457 if(p[offset1] > cb)
00458 goto success_structured;
00459 else
00460 if(p[offset4] > cb)
00461 goto success_structured;
00462 else
00463 goto structured;
00464 else
00465 if(p[offset1] > cb)
00466 goto success_structured;
00467 else
00468 goto structured;
00469 else
00470 goto structured;
00471 else
00472 if(p[offset5] < c_b)
00473 if(p[offset3] < c_b)
00474 if(p[offset7] < c_b)
00475 if(p[offset4] < c_b)
00476 if(p[offset6] < c_b)
00477 goto success_structured;
00478 else
00479 goto structured;
00480 else
00481 goto structured;
00482 else
00483 goto homogeneous;
00484 else
00485 goto homogeneous;
00486 else
00487 goto structured;
00488 else
00489 if(p[offset5] > cb)
00490 if(p[offset7] > cb)
00491 if(p[offset6] > cb)
00492 if(p[offset1] > cb)
00493 goto success_structured;
00494 else
00495 if(p[offset4] > cb)
00496 goto success_structured;
00497 else
00498 goto structured;
00499 else
00500 goto structured;
00501 else
00502 goto structured;
00503 else
00504 if(p[offset5] < c_b)
00505 if(p[offset3] < c_b)
00506 if(p[offset2] < c_b)
00507 if(p[offset1] < c_b)
00508 if(p[offset4] < c_b)
00509 goto success_structured;
00510 else
00511 goto structured;
00512 else
00513 if(p[offset4] < c_b)
00514 if(p[offset6] < c_b)
00515 goto success_structured;
00516 else
00517 goto structured;
00518 else
00519 goto structured;
00520 else
00521 if(p[offset7] < c_b)
00522 if(p[offset4] < c_b)
00523 if(p[offset6] < c_b)
00524 goto success_homogeneous;
00525 else
00526 goto homogeneous;
00527 else
00528 goto homogeneous;
00529 else
00530 goto homogeneous;
00531 else
00532 goto structured;
00533 else
00534 goto homogeneous;
00535 else if(p[offset0] < c_b)
00536 if(p[offset2] < c_b)
00537 if(p[offset7] > cb)
00538 if(p[offset3] < c_b)
00539 if(p[offset5] < c_b)
00540 if(p[offset1] < c_b)
00541 if(p[offset4] < c_b)
00542 goto success_structured;
00543 else
00544 goto structured;
00545 else
00546 if(p[offset4] < c_b)
00547 if(p[offset6] < c_b)
00548 goto success_structured;
00549 else
00550 goto structured;
00551 else
00552 goto structured;
00553 else
00554 if(p[offset1] < c_b)
00555 if(p[offset4] < c_b)
00556 goto success_structured;
00557 else
00558 goto structured;
00559 else
00560 goto structured;
00561 else
00562 if(p[offset5] > cb)
00563 if(p[offset3] > cb)
00564 if(p[offset4] > cb)
00565 if(p[offset6] > cb)
00566 goto success_structured;
00567 else
00568 goto structured;
00569 else
00570 goto structured;
00571 else
00572 goto homogeneous;
00573 else
00574 goto structured;
00575 else
00576 if(p[offset7] < c_b)
00577 if(p[offset3] < c_b)
00578 if(p[offset5] < c_b)
00579 if(p[offset1] < c_b)
00580 goto success_structured;
00581 else
00582 if(p[offset4] < c_b)
00583 if(p[offset6] < c_b)
00584 goto success_structured;
00585 else
00586 goto structured;
00587 else
00588 goto structured;
00589 else
00590 if(p[offset1] < c_b)
00591 goto success_structured;
00592 else
00593 goto structured;
00594 else
00595 if(p[offset6] < c_b)
00596 if(p[offset5] < c_b)
00597 if(p[offset1] < c_b)
00598 goto success_structured;
00599 else
00600 if(p[offset4] < c_b)
00601 goto success_structured;
00602 else
00603 goto structured;
00604 else
00605 if(p[offset1] < c_b)
00606 goto success_structured;
00607 else
00608 goto structured;
00609 else
00610 goto structured;
00611 else
00612 if(p[offset3] < c_b)
00613 if(p[offset5] < c_b)
00614 if(p[offset1] < c_b)
00615 if(p[offset4] < c_b)
00616 goto success_homogeneous;
00617 else
00618 goto homogeneous;
00619 else
00620 if(p[offset4] < c_b)
00621 if(p[offset6] < c_b)
00622 goto success_homogeneous;
00623 else
00624 goto homogeneous;
00625 else
00626 goto homogeneous;
00627 else
00628 if(p[offset1] < c_b)
00629 if(p[offset4] < c_b)
00630 goto success_homogeneous;
00631 else
00632 goto homogeneous;
00633 else
00634 goto homogeneous;
00635 else
00636 goto homogeneous;
00637 else
00638 if(p[offset5] > cb)
00639 if(p[offset3] > cb)
00640 if(p[offset2] > cb)
00641 if(p[offset1] > cb)
00642 if(p[offset4] > cb)
00643 goto success_structured;
00644 else
00645 goto structured;
00646 else
00647 if(p[offset4] > cb)
00648 if(p[offset6] > cb)
00649 goto success_structured;
00650 else
00651 goto structured;
00652 else
00653 goto structured;
00654 else
00655 if(p[offset7] > cb)
00656 if(p[offset4] > cb)
00657 if(p[offset6] > cb)
00658 goto success_homogeneous;
00659 else
00660 goto homogeneous;
00661 else
00662 goto homogeneous;
00663 else
00664 goto homogeneous;
00665 else
00666 goto structured;
00667 else
00668 if(p[offset5] < c_b)
00669 if(p[offset7] < c_b)
00670 if(p[offset6] < c_b)
00671 if(p[offset1] < c_b)
00672 goto success_structured;
00673 else
00674 if(p[offset4] < c_b)
00675 goto success_structured;
00676 else
00677 goto structured;
00678 else
00679 goto structured;
00680 else
00681 goto structured;
00682 else
00683 goto homogeneous;
00684 else
00685 if(p[offset3] > cb)
00686 if(p[offset5] > cb)
00687 if(p[offset2] > cb)
00688 if(p[offset1] > cb)
00689 if(p[offset4] > cb)
00690 goto success_homogeneous;
00691 else
00692 goto homogeneous;
00693 else
00694 if(p[offset4] > cb)
00695 if(p[offset6] > cb)
00696 goto success_homogeneous;
00697 else
00698 goto homogeneous;
00699 else
00700 goto homogeneous;
00701 else
00702 if(p[offset7] > cb)
00703 if(p[offset4] > cb)
00704 if(p[offset6] > cb)
00705 goto success_homogeneous;
00706 else
00707 goto homogeneous;
00708 else
00709 goto homogeneous;
00710 else
00711 goto homogeneous;
00712 else
00713 goto homogeneous;
00714 else
00715 if(p[offset3] < c_b)
00716 if(p[offset5] < c_b)
00717 if(p[offset2] < c_b)
00718 if(p[offset1] < c_b)
00719 if(p[offset4] < c_b)
00720 goto success_homogeneous;
00721 else
00722 goto homogeneous;
00723 else
00724 if(p[offset4] < c_b)
00725 if(p[offset6] < c_b)
00726 goto success_homogeneous;
00727 else
00728 goto homogeneous;
00729 else
00730 goto homogeneous;
00731 else
00732 if(p[offset7] < c_b)
00733 if(p[offset4] < c_b)
00734 if(p[offset6] < c_b)
00735 goto success_homogeneous;
00736 else
00737 goto homogeneous;
00738 else
00739 goto homogeneous;
00740 else
00741 goto homogeneous;
00742 else
00743 goto homogeneous;
00744 else
00745 goto homogeneous;
00746 }
00747 }
00748 success_homogeneous:
00749 if(total == nExpectedCorners)
00750 {
00751 if(nExpectedCorners==0)
00752 {
00753 nExpectedCorners=512;
00754 corners_all.reserve(nExpectedCorners);
00755 }
00756 else
00757 {
00758 nExpectedCorners *=2;
00759 corners_all.reserve(nExpectedCorners);
00760 }
00761 }
00762 h.x=x;
00763 h.y=y;
00764 corners_all.push_back(h);
00765 total++;
00766 goto homogeneous;
00767 success_structured:
00768 if(total == nExpectedCorners)
00769 {
00770 if(nExpectedCorners==0)
00771 {
00772 nExpectedCorners=512;
00773 corners_all.reserve(nExpectedCorners);
00774 }
00775 else
00776 {
00777 nExpectedCorners *=2;
00778 corners_all.reserve(nExpectedCorners);
00779 }
00780 }
00781 h.x=x;
00782 h.y=y;
00783 corners_all.push_back(h);
00784 total++;
00785 goto structured;
00786 }
00787 }
00788 }
00789
00790