blender/extern/libmv/third_party/fast/fast_12.c
Sergey Sharybin 27d42c63d9 Camera tracking integration
===========================

Commiting camera tracking integration gsoc project into trunk.

This commit includes:

- Bundled version of libmv library (with some changes against official repo,
  re-sync with libmv repo a bit later)
- New datatype ID called MovieClip which is optimized to work with movie
  clips (both of movie files and image sequences) and doing camera/motion
  tracking operations.
- New editor called Clip Editor which is currently used for motion/tracking
  stuff only, but which can be easily extended to work with masks too.

  This editor supports:
  * Loading movie files/image sequences
  * Build proxies with different size for loaded movie clip, also supports
    building undistorted proxies to increase speed of playback in
    undistorted mode.
  * Manual lens distortion mode calibration using grid and grease pencil
  * Supervised 2D tracking using two different algorithms KLT and SAD.
  * Basic algorithm for feature detection
  * Camera motion solving. scene orientation

- New constraints to "link" scene objects with solved motions from clip:

  * Follow Track (make object follow 2D motion of track with given name
    or parent object to reconstructed 3D position of track)
  * Camera Solver to make camera moving in the same way as reconstructed camera

This commit NOT includes changes from tomato branch:

- New nodes (they'll be commited as separated patch)
- Automatic image offset guessing for image input node and image editor
  (need to do more tests and gather more feedback)
- Code cleanup in libmv-capi. It's not so critical cleanup, just increasing
  readability and understanadability of code. Better to make this chaneg when
  Keir will finish his current patch.

More details about this project can be found on this page:
    http://wiki.blender.org/index.php/User:Nazg-gul/GSoC-2011

Further development of small features would be done in trunk, bigger/experimental
features would first be implemented in tomato branch.
2011-11-07 12:55:18 +00:00

3135 lines
97 KiB
C

/*This is mechanically generated code*/
#include <stdlib.h>
typedef struct { int x, y; } xy;
typedef unsigned char byte;
int fast12_corner_score(const byte* p, const int pixel[], int bstart)
{
int bmin = bstart;
int bmax = 255;
int b = (bmax + bmin)/2;
/*Compute the score using binary search*/
for(;;)
{
int cb = *p + b;
int c_b= *p - b;
if( p[pixel[0]] > cb)
if( p[pixel[1]] > cb)
if( p[pixel[2]] > cb)
if( p[pixel[3]] > cb)
if( p[pixel[4]] > cb)
if( p[pixel[5]] > cb)
if( p[pixel[6]] > cb)
if( p[pixel[7]] > cb)
if( p[pixel[8]] > cb)
if( p[pixel[9]] > cb)
if( p[pixel[10]] > cb)
if( p[pixel[11]] > cb)
goto is_a_corner;
else
if( p[pixel[15]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[14]] > cb)
if( p[pixel[15]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[13]] > cb)
if( p[pixel[14]] > cb)
if( p[pixel[15]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[12]] > cb)
if( p[pixel[13]] > cb)
if( p[pixel[14]] > cb)
if( p[pixel[15]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[11]] > cb)
if( p[pixel[12]] > cb)
if( p[pixel[13]] > cb)
if( p[pixel[14]] > cb)
if( p[pixel[15]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[10]] > cb)
if( p[pixel[11]] > cb)
if( p[pixel[12]] > cb)
if( p[pixel[13]] > cb)
if( p[pixel[14]] > cb)
if( p[pixel[15]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[9]] > cb)
if( p[pixel[10]] > cb)
if( p[pixel[11]] > cb)
if( p[pixel[12]] > cb)
if( p[pixel[13]] > cb)
if( p[pixel[14]] > cb)
if( p[pixel[15]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else if( p[pixel[4]] < c_b)
if( p[pixel[8]] > cb)
if( p[pixel[9]] > cb)
if( p[pixel[10]] > cb)
if( p[pixel[11]] > cb)
if( p[pixel[12]] > cb)
if( p[pixel[13]] > cb)
if( p[pixel[14]] > cb)
if( p[pixel[15]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else if( p[pixel[8]] < c_b)
if( p[pixel[5]] < c_b)
if( p[pixel[6]] < c_b)
if( p[pixel[7]] < c_b)
if( p[pixel[9]] < c_b)
if( p[pixel[10]] < c_b)
if( p[pixel[11]] < c_b)
if( p[pixel[12]] < c_b)
if( p[pixel[13]] < c_b)
if( p[pixel[14]] < c_b)
if( p[pixel[15]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[8]] > cb)
if( p[pixel[9]] > cb)
if( p[pixel[10]] > cb)
if( p[pixel[11]] > cb)
if( p[pixel[12]] > cb)
if( p[pixel[13]] > cb)
if( p[pixel[14]] > cb)
if( p[pixel[15]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else if( p[pixel[3]] < c_b)
if( p[pixel[15]] > cb)
if( p[pixel[7]] > cb)
if( p[pixel[8]] > cb)
if( p[pixel[9]] > cb)
if( p[pixel[10]] > cb)
if( p[pixel[11]] > cb)
if( p[pixel[12]] > cb)
if( p[pixel[13]] > cb)
if( p[pixel[14]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else if( p[pixel[7]] < c_b)
if( p[pixel[4]] < c_b)
if( p[pixel[5]] < c_b)
if( p[pixel[6]] < c_b)
if( p[pixel[8]] < c_b)
if( p[pixel[9]] < c_b)
if( p[pixel[10]] < c_b)
if( p[pixel[11]] < c_b)
if( p[pixel[12]] < c_b)
if( p[pixel[13]] < c_b)
if( p[pixel[14]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[4]] < c_b)
if( p[pixel[5]] < c_b)
if( p[pixel[6]] < c_b)
if( p[pixel[7]] < c_b)
if( p[pixel[8]] < c_b)
if( p[pixel[9]] < c_b)
if( p[pixel[10]] < c_b)
if( p[pixel[11]] < c_b)
if( p[pixel[12]] < c_b)
if( p[pixel[13]] < c_b)
if( p[pixel[14]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[7]] > cb)
if( p[pixel[8]] > cb)
if( p[pixel[9]] > cb)
if( p[pixel[10]] > cb)
if( p[pixel[11]] > cb)
if( p[pixel[12]] > cb)
if( p[pixel[13]] > cb)
if( p[pixel[14]] > cb)
if( p[pixel[15]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else if( p[pixel[7]] < c_b)
if( p[pixel[4]] < c_b)
if( p[pixel[5]] < c_b)
if( p[pixel[6]] < c_b)
if( p[pixel[8]] < c_b)
if( p[pixel[9]] < c_b)
if( p[pixel[10]] < c_b)
if( p[pixel[11]] < c_b)
if( p[pixel[12]] < c_b)
if( p[pixel[13]] < c_b)
if( p[pixel[14]] < c_b)
if( p[pixel[15]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else if( p[pixel[2]] < c_b)
if( p[pixel[6]] > cb)
if( p[pixel[7]] > cb)
if( p[pixel[8]] > cb)
if( p[pixel[9]] > cb)
if( p[pixel[10]] > cb)
if( p[pixel[11]] > cb)
if( p[pixel[12]] > cb)
if( p[pixel[13]] > cb)
if( p[pixel[14]] > cb)
if( p[pixel[15]] > cb)
goto is_a_corner;
else
if( p[pixel[3]] > cb)
if( p[pixel[4]] > cb)
if( p[pixel[5]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else if( p[pixel[6]] < c_b)
if( p[pixel[4]] < c_b)
if( p[pixel[5]] < c_b)
if( p[pixel[7]] < c_b)
if( p[pixel[8]] < c_b)
if( p[pixel[9]] < c_b)
if( p[pixel[10]] < c_b)
if( p[pixel[11]] < c_b)
if( p[pixel[12]] < c_b)
if( p[pixel[13]] < c_b)
if( p[pixel[3]] < c_b)
goto is_a_corner;
else
if( p[pixel[14]] < c_b)
if( p[pixel[15]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[6]] > cb)
if( p[pixel[7]] > cb)
if( p[pixel[8]] > cb)
if( p[pixel[9]] > cb)
if( p[pixel[10]] > cb)
if( p[pixel[11]] > cb)
if( p[pixel[12]] > cb)
if( p[pixel[13]] > cb)
if( p[pixel[14]] > cb)
if( p[pixel[15]] > cb)
goto is_a_corner;
else
if( p[pixel[3]] > cb)
if( p[pixel[4]] > cb)
if( p[pixel[5]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else if( p[pixel[6]] < c_b)
if( p[pixel[4]] < c_b)
if( p[pixel[5]] < c_b)
if( p[pixel[7]] < c_b)
if( p[pixel[8]] < c_b)
if( p[pixel[9]] < c_b)
if( p[pixel[10]] < c_b)
if( p[pixel[11]] < c_b)
if( p[pixel[12]] < c_b)
if( p[pixel[13]] < c_b)
if( p[pixel[14]] < c_b)
if( p[pixel[3]] < c_b)
goto is_a_corner;
else
if( p[pixel[15]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else if( p[pixel[1]] < c_b)
if( p[pixel[5]] > cb)
if( p[pixel[6]] > cb)
if( p[pixel[7]] > cb)
if( p[pixel[8]] > cb)
if( p[pixel[9]] > cb)
if( p[pixel[10]] > cb)
if( p[pixel[11]] > cb)
if( p[pixel[12]] > cb)
if( p[pixel[13]] > cb)
if( p[pixel[14]] > cb)
if( p[pixel[15]] > cb)
goto is_a_corner;
else
if( p[pixel[3]] > cb)
if( p[pixel[4]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[2]] > cb)
if( p[pixel[3]] > cb)
if( p[pixel[4]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else if( p[pixel[5]] < c_b)
if( p[pixel[4]] < c_b)
if( p[pixel[6]] < c_b)
if( p[pixel[7]] < c_b)
if( p[pixel[8]] < c_b)
if( p[pixel[9]] < c_b)
if( p[pixel[10]] < c_b)
if( p[pixel[11]] < c_b)
if( p[pixel[12]] < c_b)
if( p[pixel[3]] < c_b)
if( p[pixel[2]] < c_b)
goto is_a_corner;
else
if( p[pixel[13]] < c_b)
if( p[pixel[14]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[13]] < c_b)
if( p[pixel[14]] < c_b)
if( p[pixel[15]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[5]] > cb)
if( p[pixel[6]] > cb)
if( p[pixel[7]] > cb)
if( p[pixel[8]] > cb)
if( p[pixel[9]] > cb)
if( p[pixel[10]] > cb)
if( p[pixel[11]] > cb)
if( p[pixel[12]] > cb)
if( p[pixel[13]] > cb)
if( p[pixel[14]] > cb)
if( p[pixel[15]] > cb)
goto is_a_corner;
else
if( p[pixel[3]] > cb)
if( p[pixel[4]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[2]] > cb)
if( p[pixel[3]] > cb)
if( p[pixel[4]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else if( p[pixel[5]] < c_b)
if( p[pixel[4]] < c_b)
if( p[pixel[6]] < c_b)
if( p[pixel[7]] < c_b)
if( p[pixel[8]] < c_b)
if( p[pixel[9]] < c_b)
if( p[pixel[10]] < c_b)
if( p[pixel[11]] < c_b)
if( p[pixel[12]] < c_b)
if( p[pixel[13]] < c_b)
if( p[pixel[3]] < c_b)
if( p[pixel[2]] < c_b)
goto is_a_corner;
else
if( p[pixel[14]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[14]] < c_b)
if( p[pixel[15]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else if( p[pixel[0]] < c_b)
if( p[pixel[1]] > cb)
if( p[pixel[5]] > cb)
if( p[pixel[4]] > cb)
if( p[pixel[6]] > cb)
if( p[pixel[7]] > cb)
if( p[pixel[8]] > cb)
if( p[pixel[9]] > cb)
if( p[pixel[10]] > cb)
if( p[pixel[11]] > cb)
if( p[pixel[12]] > cb)
if( p[pixel[3]] > cb)
if( p[pixel[2]] > cb)
goto is_a_corner;
else
if( p[pixel[13]] > cb)
if( p[pixel[14]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[13]] > cb)
if( p[pixel[14]] > cb)
if( p[pixel[15]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else if( p[pixel[5]] < c_b)
if( p[pixel[6]] < c_b)
if( p[pixel[7]] < c_b)
if( p[pixel[8]] < c_b)
if( p[pixel[9]] < c_b)
if( p[pixel[10]] < c_b)
if( p[pixel[11]] < c_b)
if( p[pixel[12]] < c_b)
if( p[pixel[13]] < c_b)
if( p[pixel[14]] < c_b)
if( p[pixel[15]] < c_b)
goto is_a_corner;
else
if( p[pixel[3]] < c_b)
if( p[pixel[4]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[2]] < c_b)
if( p[pixel[3]] < c_b)
if( p[pixel[4]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else if( p[pixel[1]] < c_b)
if( p[pixel[2]] > cb)
if( p[pixel[6]] > cb)
if( p[pixel[4]] > cb)
if( p[pixel[5]] > cb)
if( p[pixel[7]] > cb)
if( p[pixel[8]] > cb)
if( p[pixel[9]] > cb)
if( p[pixel[10]] > cb)
if( p[pixel[11]] > cb)
if( p[pixel[12]] > cb)
if( p[pixel[13]] > cb)
if( p[pixel[3]] > cb)
goto is_a_corner;
else
if( p[pixel[14]] > cb)
if( p[pixel[15]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else if( p[pixel[6]] < c_b)
if( p[pixel[7]] < c_b)
if( p[pixel[8]] < c_b)
if( p[pixel[9]] < c_b)
if( p[pixel[10]] < c_b)
if( p[pixel[11]] < c_b)
if( p[pixel[12]] < c_b)
if( p[pixel[13]] < c_b)
if( p[pixel[14]] < c_b)
if( p[pixel[15]] < c_b)
goto is_a_corner;
else
if( p[pixel[3]] < c_b)
if( p[pixel[4]] < c_b)
if( p[pixel[5]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else if( p[pixel[2]] < c_b)
if( p[pixel[3]] > cb)
if( p[pixel[15]] < c_b)
if( p[pixel[7]] > cb)
if( p[pixel[4]] > cb)
if( p[pixel[5]] > cb)
if( p[pixel[6]] > cb)
if( p[pixel[8]] > cb)
if( p[pixel[9]] > cb)
if( p[pixel[10]] > cb)
if( p[pixel[11]] > cb)
if( p[pixel[12]] > cb)
if( p[pixel[13]] > cb)
if( p[pixel[14]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else if( p[pixel[7]] < c_b)
if( p[pixel[8]] < c_b)
if( p[pixel[9]] < c_b)
if( p[pixel[10]] < c_b)
if( p[pixel[11]] < c_b)
if( p[pixel[12]] < c_b)
if( p[pixel[13]] < c_b)
if( p[pixel[14]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[4]] > cb)
if( p[pixel[5]] > cb)
if( p[pixel[6]] > cb)
if( p[pixel[7]] > cb)
if( p[pixel[8]] > cb)
if( p[pixel[9]] > cb)
if( p[pixel[10]] > cb)
if( p[pixel[11]] > cb)
if( p[pixel[12]] > cb)
if( p[pixel[13]] > cb)
if( p[pixel[14]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else if( p[pixel[3]] < c_b)
if( p[pixel[4]] > cb)
if( p[pixel[8]] > cb)
if( p[pixel[5]] > cb)
if( p[pixel[6]] > cb)
if( p[pixel[7]] > cb)
if( p[pixel[9]] > cb)
if( p[pixel[10]] > cb)
if( p[pixel[11]] > cb)
if( p[pixel[12]] > cb)
if( p[pixel[13]] > cb)
if( p[pixel[14]] > cb)
if( p[pixel[15]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else if( p[pixel[8]] < c_b)
if( p[pixel[9]] < c_b)
if( p[pixel[10]] < c_b)
if( p[pixel[11]] < c_b)
if( p[pixel[12]] < c_b)
if( p[pixel[13]] < c_b)
if( p[pixel[14]] < c_b)
if( p[pixel[15]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else if( p[pixel[4]] < c_b)
if( p[pixel[5]] < c_b)
if( p[pixel[6]] < c_b)
if( p[pixel[7]] < c_b)
if( p[pixel[8]] < c_b)
if( p[pixel[9]] < c_b)
if( p[pixel[10]] < c_b)
if( p[pixel[11]] < c_b)
goto is_a_corner;
else
if( p[pixel[15]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[14]] < c_b)
if( p[pixel[15]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[13]] < c_b)
if( p[pixel[14]] < c_b)
if( p[pixel[15]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[12]] < c_b)
if( p[pixel[13]] < c_b)
if( p[pixel[14]] < c_b)
if( p[pixel[15]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[11]] < c_b)
if( p[pixel[12]] < c_b)
if( p[pixel[13]] < c_b)
if( p[pixel[14]] < c_b)
if( p[pixel[15]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[10]] < c_b)
if( p[pixel[11]] < c_b)
if( p[pixel[12]] < c_b)
if( p[pixel[13]] < c_b)
if( p[pixel[14]] < c_b)
if( p[pixel[15]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[9]] < c_b)
if( p[pixel[10]] < c_b)
if( p[pixel[11]] < c_b)
if( p[pixel[12]] < c_b)
if( p[pixel[13]] < c_b)
if( p[pixel[14]] < c_b)
if( p[pixel[15]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[8]] < c_b)
if( p[pixel[9]] < c_b)
if( p[pixel[10]] < c_b)
if( p[pixel[11]] < c_b)
if( p[pixel[12]] < c_b)
if( p[pixel[13]] < c_b)
if( p[pixel[14]] < c_b)
if( p[pixel[15]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[7]] > cb)
if( p[pixel[4]] > cb)
if( p[pixel[5]] > cb)
if( p[pixel[6]] > cb)
if( p[pixel[8]] > cb)
if( p[pixel[9]] > cb)
if( p[pixel[10]] > cb)
if( p[pixel[11]] > cb)
if( p[pixel[12]] > cb)
if( p[pixel[13]] > cb)
if( p[pixel[14]] > cb)
if( p[pixel[15]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else if( p[pixel[7]] < c_b)
if( p[pixel[8]] < c_b)
if( p[pixel[9]] < c_b)
if( p[pixel[10]] < c_b)
if( p[pixel[11]] < c_b)
if( p[pixel[12]] < c_b)
if( p[pixel[13]] < c_b)
if( p[pixel[14]] < c_b)
if( p[pixel[15]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[6]] > cb)
if( p[pixel[4]] > cb)
if( p[pixel[5]] > cb)
if( p[pixel[7]] > cb)
if( p[pixel[8]] > cb)
if( p[pixel[9]] > cb)
if( p[pixel[10]] > cb)
if( p[pixel[11]] > cb)
if( p[pixel[12]] > cb)
if( p[pixel[13]] > cb)
if( p[pixel[14]] > cb)
if( p[pixel[3]] > cb)
goto is_a_corner;
else
if( p[pixel[15]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else if( p[pixel[6]] < c_b)
if( p[pixel[7]] < c_b)
if( p[pixel[8]] < c_b)
if( p[pixel[9]] < c_b)
if( p[pixel[10]] < c_b)
if( p[pixel[11]] < c_b)
if( p[pixel[12]] < c_b)
if( p[pixel[13]] < c_b)
if( p[pixel[14]] < c_b)
if( p[pixel[15]] < c_b)
goto is_a_corner;
else
if( p[pixel[3]] < c_b)
if( p[pixel[4]] < c_b)
if( p[pixel[5]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[5]] > cb)
if( p[pixel[4]] > cb)
if( p[pixel[6]] > cb)
if( p[pixel[7]] > cb)
if( p[pixel[8]] > cb)
if( p[pixel[9]] > cb)
if( p[pixel[10]] > cb)
if( p[pixel[11]] > cb)
if( p[pixel[12]] > cb)
if( p[pixel[13]] > cb)
if( p[pixel[3]] > cb)
if( p[pixel[2]] > cb)
goto is_a_corner;
else
if( p[pixel[14]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[14]] > cb)
if( p[pixel[15]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else if( p[pixel[5]] < c_b)
if( p[pixel[6]] < c_b)
if( p[pixel[7]] < c_b)
if( p[pixel[8]] < c_b)
if( p[pixel[9]] < c_b)
if( p[pixel[10]] < c_b)
if( p[pixel[11]] < c_b)
if( p[pixel[12]] < c_b)
if( p[pixel[13]] < c_b)
if( p[pixel[14]] < c_b)
if( p[pixel[15]] < c_b)
goto is_a_corner;
else
if( p[pixel[3]] < c_b)
if( p[pixel[4]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[2]] < c_b)
if( p[pixel[3]] < c_b)
if( p[pixel[4]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[4]] > cb)
if( p[pixel[5]] > cb)
if( p[pixel[6]] > cb)
if( p[pixel[7]] > cb)
if( p[pixel[8]] > cb)
if( p[pixel[9]] > cb)
if( p[pixel[10]] > cb)
if( p[pixel[11]] > cb)
if( p[pixel[12]] > cb)
if( p[pixel[3]] > cb)
if( p[pixel[2]] > cb)
if( p[pixel[1]] > cb)
goto is_a_corner;
else
if( p[pixel[13]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[13]] > cb)
if( p[pixel[14]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[13]] > cb)
if( p[pixel[14]] > cb)
if( p[pixel[15]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else if( p[pixel[4]] < c_b)
if( p[pixel[5]] < c_b)
if( p[pixel[6]] < c_b)
if( p[pixel[7]] < c_b)
if( p[pixel[8]] < c_b)
if( p[pixel[9]] < c_b)
if( p[pixel[10]] < c_b)
if( p[pixel[11]] < c_b)
if( p[pixel[12]] < c_b)
if( p[pixel[3]] < c_b)
if( p[pixel[2]] < c_b)
if( p[pixel[1]] < c_b)
goto is_a_corner;
else
if( p[pixel[13]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[13]] < c_b)
if( p[pixel[14]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[13]] < c_b)
if( p[pixel[14]] < c_b)
if( p[pixel[15]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
is_a_corner:
bmin=b;
goto end_if;
is_not_a_corner:
bmax=b;
goto end_if;
end_if:
if(bmin == bmax - 1 || bmin == bmax)
return bmin;
b = (bmin + bmax) / 2;
}
}
static void make_offsets(int pixel[], int row_stride)
{
pixel[0] = 0 + row_stride * 3;
pixel[1] = 1 + row_stride * 3;
pixel[2] = 2 + row_stride * 2;
pixel[3] = 3 + row_stride * 1;
pixel[4] = 3 + row_stride * 0;
pixel[5] = 3 + row_stride * -1;
pixel[6] = 2 + row_stride * -2;
pixel[7] = 1 + row_stride * -3;
pixel[8] = 0 + row_stride * -3;
pixel[9] = -1 + row_stride * -3;
pixel[10] = -2 + row_stride * -2;
pixel[11] = -3 + row_stride * -1;
pixel[12] = -3 + row_stride * 0;
pixel[13] = -3 + row_stride * 1;
pixel[14] = -2 + row_stride * 2;
pixel[15] = -1 + row_stride * 3;
}
int* fast12_score(const byte* i, int stride, xy* corners, int num_corners, int b)
{
int* scores = (int*)malloc(sizeof(int)* num_corners);
int n;
int pixel[16];
make_offsets(pixel, stride);
for(n=0; n < num_corners; n++)
scores[n] = fast12_corner_score(i + corners[n].y*stride + corners[n].x, pixel, b);
return scores;
}
xy* fast12_detect(const byte* im, int xsize, int ysize, int stride, int b, int* ret_num_corners)
{
int num_corners=0;
xy* ret_corners;
int rsize=512;
int pixel[16];
int x, y;
ret_corners = (xy*)malloc(sizeof(xy)*rsize);
make_offsets(pixel, stride);
for(y=3; y < ysize - 3; y++)
for(x=3; x < xsize - 3; x++)
{
const byte* p = im + y*stride + x;
int cb = *p + b;
int c_b= *p - b;
if(p[pixel[0]] > cb)
if(p[pixel[1]] > cb)
if(p[pixel[2]] > cb)
if(p[pixel[3]] > cb)
if(p[pixel[4]] > cb)
if(p[pixel[5]] > cb)
if(p[pixel[6]] > cb)
if(p[pixel[7]] > cb)
if(p[pixel[8]] > cb)
if(p[pixel[9]] > cb)
if(p[pixel[10]] > cb)
if(p[pixel[11]] > cb)
{}
else
if(p[pixel[15]] > cb)
{}
else
continue;
else
if(p[pixel[14]] > cb)
if(p[pixel[15]] > cb)
{}
else
continue;
else
continue;
else
if(p[pixel[13]] > cb)
if(p[pixel[14]] > cb)
if(p[pixel[15]] > cb)
{}
else
continue;
else
continue;
else
continue;
else
if(p[pixel[12]] > cb)
if(p[pixel[13]] > cb)
if(p[pixel[14]] > cb)
if(p[pixel[15]] > cb)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
if(p[pixel[11]] > cb)
if(p[pixel[12]] > cb)
if(p[pixel[13]] > cb)
if(p[pixel[14]] > cb)
if(p[pixel[15]] > cb)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
if(p[pixel[10]] > cb)
if(p[pixel[11]] > cb)
if(p[pixel[12]] > cb)
if(p[pixel[13]] > cb)
if(p[pixel[14]] > cb)
if(p[pixel[15]] > cb)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
if(p[pixel[9]] > cb)
if(p[pixel[10]] > cb)
if(p[pixel[11]] > cb)
if(p[pixel[12]] > cb)
if(p[pixel[13]] > cb)
if(p[pixel[14]] > cb)
if(p[pixel[15]] > cb)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else if(p[pixel[4]] < c_b)
if(p[pixel[8]] > cb)
if(p[pixel[9]] > cb)
if(p[pixel[10]] > cb)
if(p[pixel[11]] > cb)
if(p[pixel[12]] > cb)
if(p[pixel[13]] > cb)
if(p[pixel[14]] > cb)
if(p[pixel[15]] > cb)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else if(p[pixel[8]] < c_b)
if(p[pixel[5]] < c_b)
if(p[pixel[6]] < c_b)
if(p[pixel[7]] < c_b)
if(p[pixel[9]] < c_b)
if(p[pixel[10]] < c_b)
if(p[pixel[11]] < c_b)
if(p[pixel[12]] < c_b)
if(p[pixel[13]] < c_b)
if(p[pixel[14]] < c_b)
if(p[pixel[15]] < c_b)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
if(p[pixel[8]] > cb)
if(p[pixel[9]] > cb)
if(p[pixel[10]] > cb)
if(p[pixel[11]] > cb)
if(p[pixel[12]] > cb)
if(p[pixel[13]] > cb)
if(p[pixel[14]] > cb)
if(p[pixel[15]] > cb)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else if(p[pixel[3]] < c_b)
if(p[pixel[15]] > cb)
if(p[pixel[7]] > cb)
if(p[pixel[8]] > cb)
if(p[pixel[9]] > cb)
if(p[pixel[10]] > cb)
if(p[pixel[11]] > cb)
if(p[pixel[12]] > cb)
if(p[pixel[13]] > cb)
if(p[pixel[14]] > cb)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else if(p[pixel[7]] < c_b)
if(p[pixel[4]] < c_b)
if(p[pixel[5]] < c_b)
if(p[pixel[6]] < c_b)
if(p[pixel[8]] < c_b)
if(p[pixel[9]] < c_b)
if(p[pixel[10]] < c_b)
if(p[pixel[11]] < c_b)
if(p[pixel[12]] < c_b)
if(p[pixel[13]] < c_b)
if(p[pixel[14]] < c_b)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
if(p[pixel[4]] < c_b)
if(p[pixel[5]] < c_b)
if(p[pixel[6]] < c_b)
if(p[pixel[7]] < c_b)
if(p[pixel[8]] < c_b)
if(p[pixel[9]] < c_b)
if(p[pixel[10]] < c_b)
if(p[pixel[11]] < c_b)
if(p[pixel[12]] < c_b)
if(p[pixel[13]] < c_b)
if(p[pixel[14]] < c_b)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
if(p[pixel[7]] > cb)
if(p[pixel[8]] > cb)
if(p[pixel[9]] > cb)
if(p[pixel[10]] > cb)
if(p[pixel[11]] > cb)
if(p[pixel[12]] > cb)
if(p[pixel[13]] > cb)
if(p[pixel[14]] > cb)
if(p[pixel[15]] > cb)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else if(p[pixel[7]] < c_b)
if(p[pixel[4]] < c_b)
if(p[pixel[5]] < c_b)
if(p[pixel[6]] < c_b)
if(p[pixel[8]] < c_b)
if(p[pixel[9]] < c_b)
if(p[pixel[10]] < c_b)
if(p[pixel[11]] < c_b)
if(p[pixel[12]] < c_b)
if(p[pixel[13]] < c_b)
if(p[pixel[14]] < c_b)
if(p[pixel[15]] < c_b)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else if(p[pixel[2]] < c_b)
if(p[pixel[6]] > cb)
if(p[pixel[7]] > cb)
if(p[pixel[8]] > cb)
if(p[pixel[9]] > cb)
if(p[pixel[10]] > cb)
if(p[pixel[11]] > cb)
if(p[pixel[12]] > cb)
if(p[pixel[13]] > cb)
if(p[pixel[14]] > cb)
if(p[pixel[15]] > cb)
{}
else
if(p[pixel[3]] > cb)
if(p[pixel[4]] > cb)
if(p[pixel[5]] > cb)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else if(p[pixel[6]] < c_b)
if(p[pixel[4]] < c_b)
if(p[pixel[5]] < c_b)
if(p[pixel[7]] < c_b)
if(p[pixel[8]] < c_b)
if(p[pixel[9]] < c_b)
if(p[pixel[10]] < c_b)
if(p[pixel[11]] < c_b)
if(p[pixel[12]] < c_b)
if(p[pixel[13]] < c_b)
if(p[pixel[3]] < c_b)
{}
else
if(p[pixel[14]] < c_b)
if(p[pixel[15]] < c_b)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
if(p[pixel[6]] > cb)
if(p[pixel[7]] > cb)
if(p[pixel[8]] > cb)
if(p[pixel[9]] > cb)
if(p[pixel[10]] > cb)
if(p[pixel[11]] > cb)
if(p[pixel[12]] > cb)
if(p[pixel[13]] > cb)
if(p[pixel[14]] > cb)
if(p[pixel[15]] > cb)
{}
else
if(p[pixel[3]] > cb)
if(p[pixel[4]] > cb)
if(p[pixel[5]] > cb)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else if(p[pixel[6]] < c_b)
if(p[pixel[4]] < c_b)
if(p[pixel[5]] < c_b)
if(p[pixel[7]] < c_b)
if(p[pixel[8]] < c_b)
if(p[pixel[9]] < c_b)
if(p[pixel[10]] < c_b)
if(p[pixel[11]] < c_b)
if(p[pixel[12]] < c_b)
if(p[pixel[13]] < c_b)
if(p[pixel[14]] < c_b)
if(p[pixel[3]] < c_b)
{}
else
if(p[pixel[15]] < c_b)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else if(p[pixel[1]] < c_b)
if(p[pixel[5]] > cb)
if(p[pixel[6]] > cb)
if(p[pixel[7]] > cb)
if(p[pixel[8]] > cb)
if(p[pixel[9]] > cb)
if(p[pixel[10]] > cb)
if(p[pixel[11]] > cb)
if(p[pixel[12]] > cb)
if(p[pixel[13]] > cb)
if(p[pixel[14]] > cb)
if(p[pixel[15]] > cb)
{}
else
if(p[pixel[3]] > cb)
if(p[pixel[4]] > cb)
{}
else
continue;
else
continue;
else
if(p[pixel[2]] > cb)
if(p[pixel[3]] > cb)
if(p[pixel[4]] > cb)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else if(p[pixel[5]] < c_b)
if(p[pixel[4]] < c_b)
if(p[pixel[6]] < c_b)
if(p[pixel[7]] < c_b)
if(p[pixel[8]] < c_b)
if(p[pixel[9]] < c_b)
if(p[pixel[10]] < c_b)
if(p[pixel[11]] < c_b)
if(p[pixel[12]] < c_b)
if(p[pixel[3]] < c_b)
if(p[pixel[2]] < c_b)
{}
else
if(p[pixel[13]] < c_b)
if(p[pixel[14]] < c_b)
{}
else
continue;
else
continue;
else
if(p[pixel[13]] < c_b)
if(p[pixel[14]] < c_b)
if(p[pixel[15]] < c_b)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
if(p[pixel[5]] > cb)
if(p[pixel[6]] > cb)
if(p[pixel[7]] > cb)
if(p[pixel[8]] > cb)
if(p[pixel[9]] > cb)
if(p[pixel[10]] > cb)
if(p[pixel[11]] > cb)
if(p[pixel[12]] > cb)
if(p[pixel[13]] > cb)
if(p[pixel[14]] > cb)
if(p[pixel[15]] > cb)
{}
else
if(p[pixel[3]] > cb)
if(p[pixel[4]] > cb)
{}
else
continue;
else
continue;
else
if(p[pixel[2]] > cb)
if(p[pixel[3]] > cb)
if(p[pixel[4]] > cb)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else if(p[pixel[5]] < c_b)
if(p[pixel[4]] < c_b)
if(p[pixel[6]] < c_b)
if(p[pixel[7]] < c_b)
if(p[pixel[8]] < c_b)
if(p[pixel[9]] < c_b)
if(p[pixel[10]] < c_b)
if(p[pixel[11]] < c_b)
if(p[pixel[12]] < c_b)
if(p[pixel[13]] < c_b)
if(p[pixel[3]] < c_b)
if(p[pixel[2]] < c_b)
{}
else
if(p[pixel[14]] < c_b)
{}
else
continue;
else
if(p[pixel[14]] < c_b)
if(p[pixel[15]] < c_b)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else if(p[pixel[0]] < c_b)
if(p[pixel[1]] > cb)
if(p[pixel[5]] > cb)
if(p[pixel[4]] > cb)
if(p[pixel[6]] > cb)
if(p[pixel[7]] > cb)
if(p[pixel[8]] > cb)
if(p[pixel[9]] > cb)
if(p[pixel[10]] > cb)
if(p[pixel[11]] > cb)
if(p[pixel[12]] > cb)
if(p[pixel[3]] > cb)
if(p[pixel[2]] > cb)
{}
else
if(p[pixel[13]] > cb)
if(p[pixel[14]] > cb)
{}
else
continue;
else
continue;
else
if(p[pixel[13]] > cb)
if(p[pixel[14]] > cb)
if(p[pixel[15]] > cb)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else if(p[pixel[5]] < c_b)
if(p[pixel[6]] < c_b)
if(p[pixel[7]] < c_b)
if(p[pixel[8]] < c_b)
if(p[pixel[9]] < c_b)
if(p[pixel[10]] < c_b)
if(p[pixel[11]] < c_b)
if(p[pixel[12]] < c_b)
if(p[pixel[13]] < c_b)
if(p[pixel[14]] < c_b)
if(p[pixel[15]] < c_b)
{}
else
if(p[pixel[3]] < c_b)
if(p[pixel[4]] < c_b)
{}
else
continue;
else
continue;
else
if(p[pixel[2]] < c_b)
if(p[pixel[3]] < c_b)
if(p[pixel[4]] < c_b)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else if(p[pixel[1]] < c_b)
if(p[pixel[2]] > cb)
if(p[pixel[6]] > cb)
if(p[pixel[4]] > cb)
if(p[pixel[5]] > cb)
if(p[pixel[7]] > cb)
if(p[pixel[8]] > cb)
if(p[pixel[9]] > cb)
if(p[pixel[10]] > cb)
if(p[pixel[11]] > cb)
if(p[pixel[12]] > cb)
if(p[pixel[13]] > cb)
if(p[pixel[3]] > cb)
{}
else
if(p[pixel[14]] > cb)
if(p[pixel[15]] > cb)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else if(p[pixel[6]] < c_b)
if(p[pixel[7]] < c_b)
if(p[pixel[8]] < c_b)
if(p[pixel[9]] < c_b)
if(p[pixel[10]] < c_b)
if(p[pixel[11]] < c_b)
if(p[pixel[12]] < c_b)
if(p[pixel[13]] < c_b)
if(p[pixel[14]] < c_b)
if(p[pixel[15]] < c_b)
{}
else
if(p[pixel[3]] < c_b)
if(p[pixel[4]] < c_b)
if(p[pixel[5]] < c_b)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else if(p[pixel[2]] < c_b)
if(p[pixel[3]] > cb)
if(p[pixel[15]] < c_b)
if(p[pixel[7]] > cb)
if(p[pixel[4]] > cb)
if(p[pixel[5]] > cb)
if(p[pixel[6]] > cb)
if(p[pixel[8]] > cb)
if(p[pixel[9]] > cb)
if(p[pixel[10]] > cb)
if(p[pixel[11]] > cb)
if(p[pixel[12]] > cb)
if(p[pixel[13]] > cb)
if(p[pixel[14]] > cb)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else if(p[pixel[7]] < c_b)
if(p[pixel[8]] < c_b)
if(p[pixel[9]] < c_b)
if(p[pixel[10]] < c_b)
if(p[pixel[11]] < c_b)
if(p[pixel[12]] < c_b)
if(p[pixel[13]] < c_b)
if(p[pixel[14]] < c_b)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
if(p[pixel[4]] > cb)
if(p[pixel[5]] > cb)
if(p[pixel[6]] > cb)
if(p[pixel[7]] > cb)
if(p[pixel[8]] > cb)
if(p[pixel[9]] > cb)
if(p[pixel[10]] > cb)
if(p[pixel[11]] > cb)
if(p[pixel[12]] > cb)
if(p[pixel[13]] > cb)
if(p[pixel[14]] > cb)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else if(p[pixel[3]] < c_b)
if(p[pixel[4]] > cb)
if(p[pixel[8]] > cb)
if(p[pixel[5]] > cb)
if(p[pixel[6]] > cb)
if(p[pixel[7]] > cb)
if(p[pixel[9]] > cb)
if(p[pixel[10]] > cb)
if(p[pixel[11]] > cb)
if(p[pixel[12]] > cb)
if(p[pixel[13]] > cb)
if(p[pixel[14]] > cb)
if(p[pixel[15]] > cb)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else if(p[pixel[8]] < c_b)
if(p[pixel[9]] < c_b)
if(p[pixel[10]] < c_b)
if(p[pixel[11]] < c_b)
if(p[pixel[12]] < c_b)
if(p[pixel[13]] < c_b)
if(p[pixel[14]] < c_b)
if(p[pixel[15]] < c_b)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else if(p[pixel[4]] < c_b)
if(p[pixel[5]] < c_b)
if(p[pixel[6]] < c_b)
if(p[pixel[7]] < c_b)
if(p[pixel[8]] < c_b)
if(p[pixel[9]] < c_b)
if(p[pixel[10]] < c_b)
if(p[pixel[11]] < c_b)
{}
else
if(p[pixel[15]] < c_b)
{}
else
continue;
else
if(p[pixel[14]] < c_b)
if(p[pixel[15]] < c_b)
{}
else
continue;
else
continue;
else
if(p[pixel[13]] < c_b)
if(p[pixel[14]] < c_b)
if(p[pixel[15]] < c_b)
{}
else
continue;
else
continue;
else
continue;
else
if(p[pixel[12]] < c_b)
if(p[pixel[13]] < c_b)
if(p[pixel[14]] < c_b)
if(p[pixel[15]] < c_b)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
if(p[pixel[11]] < c_b)
if(p[pixel[12]] < c_b)
if(p[pixel[13]] < c_b)
if(p[pixel[14]] < c_b)
if(p[pixel[15]] < c_b)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
if(p[pixel[10]] < c_b)
if(p[pixel[11]] < c_b)
if(p[pixel[12]] < c_b)
if(p[pixel[13]] < c_b)
if(p[pixel[14]] < c_b)
if(p[pixel[15]] < c_b)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
if(p[pixel[9]] < c_b)
if(p[pixel[10]] < c_b)
if(p[pixel[11]] < c_b)
if(p[pixel[12]] < c_b)
if(p[pixel[13]] < c_b)
if(p[pixel[14]] < c_b)
if(p[pixel[15]] < c_b)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
if(p[pixel[8]] < c_b)
if(p[pixel[9]] < c_b)
if(p[pixel[10]] < c_b)
if(p[pixel[11]] < c_b)
if(p[pixel[12]] < c_b)
if(p[pixel[13]] < c_b)
if(p[pixel[14]] < c_b)
if(p[pixel[15]] < c_b)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
if(p[pixel[7]] > cb)
if(p[pixel[4]] > cb)
if(p[pixel[5]] > cb)
if(p[pixel[6]] > cb)
if(p[pixel[8]] > cb)
if(p[pixel[9]] > cb)
if(p[pixel[10]] > cb)
if(p[pixel[11]] > cb)
if(p[pixel[12]] > cb)
if(p[pixel[13]] > cb)
if(p[pixel[14]] > cb)
if(p[pixel[15]] > cb)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else if(p[pixel[7]] < c_b)
if(p[pixel[8]] < c_b)
if(p[pixel[9]] < c_b)
if(p[pixel[10]] < c_b)
if(p[pixel[11]] < c_b)
if(p[pixel[12]] < c_b)
if(p[pixel[13]] < c_b)
if(p[pixel[14]] < c_b)
if(p[pixel[15]] < c_b)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
if(p[pixel[6]] > cb)
if(p[pixel[4]] > cb)
if(p[pixel[5]] > cb)
if(p[pixel[7]] > cb)
if(p[pixel[8]] > cb)
if(p[pixel[9]] > cb)
if(p[pixel[10]] > cb)
if(p[pixel[11]] > cb)
if(p[pixel[12]] > cb)
if(p[pixel[13]] > cb)
if(p[pixel[14]] > cb)
if(p[pixel[3]] > cb)
{}
else
if(p[pixel[15]] > cb)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else if(p[pixel[6]] < c_b)
if(p[pixel[7]] < c_b)
if(p[pixel[8]] < c_b)
if(p[pixel[9]] < c_b)
if(p[pixel[10]] < c_b)
if(p[pixel[11]] < c_b)
if(p[pixel[12]] < c_b)
if(p[pixel[13]] < c_b)
if(p[pixel[14]] < c_b)
if(p[pixel[15]] < c_b)
{}
else
if(p[pixel[3]] < c_b)
if(p[pixel[4]] < c_b)
if(p[pixel[5]] < c_b)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
if(p[pixel[5]] > cb)
if(p[pixel[4]] > cb)
if(p[pixel[6]] > cb)
if(p[pixel[7]] > cb)
if(p[pixel[8]] > cb)
if(p[pixel[9]] > cb)
if(p[pixel[10]] > cb)
if(p[pixel[11]] > cb)
if(p[pixel[12]] > cb)
if(p[pixel[13]] > cb)
if(p[pixel[3]] > cb)
if(p[pixel[2]] > cb)
{}
else
if(p[pixel[14]] > cb)
{}
else
continue;
else
if(p[pixel[14]] > cb)
if(p[pixel[15]] > cb)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else if(p[pixel[5]] < c_b)
if(p[pixel[6]] < c_b)
if(p[pixel[7]] < c_b)
if(p[pixel[8]] < c_b)
if(p[pixel[9]] < c_b)
if(p[pixel[10]] < c_b)
if(p[pixel[11]] < c_b)
if(p[pixel[12]] < c_b)
if(p[pixel[13]] < c_b)
if(p[pixel[14]] < c_b)
if(p[pixel[15]] < c_b)
{}
else
if(p[pixel[3]] < c_b)
if(p[pixel[4]] < c_b)
{}
else
continue;
else
continue;
else
if(p[pixel[2]] < c_b)
if(p[pixel[3]] < c_b)
if(p[pixel[4]] < c_b)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
if(p[pixel[4]] > cb)
if(p[pixel[5]] > cb)
if(p[pixel[6]] > cb)
if(p[pixel[7]] > cb)
if(p[pixel[8]] > cb)
if(p[pixel[9]] > cb)
if(p[pixel[10]] > cb)
if(p[pixel[11]] > cb)
if(p[pixel[12]] > cb)
if(p[pixel[3]] > cb)
if(p[pixel[2]] > cb)
if(p[pixel[1]] > cb)
{}
else
if(p[pixel[13]] > cb)
{}
else
continue;
else
if(p[pixel[13]] > cb)
if(p[pixel[14]] > cb)
{}
else
continue;
else
continue;
else
if(p[pixel[13]] > cb)
if(p[pixel[14]] > cb)
if(p[pixel[15]] > cb)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else if(p[pixel[4]] < c_b)
if(p[pixel[5]] < c_b)
if(p[pixel[6]] < c_b)
if(p[pixel[7]] < c_b)
if(p[pixel[8]] < c_b)
if(p[pixel[9]] < c_b)
if(p[pixel[10]] < c_b)
if(p[pixel[11]] < c_b)
if(p[pixel[12]] < c_b)
if(p[pixel[3]] < c_b)
if(p[pixel[2]] < c_b)
if(p[pixel[1]] < c_b)
{}
else
if(p[pixel[13]] < c_b)
{}
else
continue;
else
if(p[pixel[13]] < c_b)
if(p[pixel[14]] < c_b)
{}
else
continue;
else
continue;
else
if(p[pixel[13]] < c_b)
if(p[pixel[14]] < c_b)
if(p[pixel[15]] < c_b)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
if(num_corners == rsize)
{
rsize*=2;
ret_corners = (xy*)realloc(ret_corners, sizeof(xy)*rsize);
}
ret_corners[num_corners].x = x;
ret_corners[num_corners].y = y;
num_corners++;
}
*ret_num_corners = num_corners;
return ret_corners;
}