block_bytecode Struct Reference
[Compiled tree representations]

#include <faster_bytecode.h>

List of all members.


Detailed Description

This struct contains a byte code compiled version of the detector.

Definition at line 35 of file faster_bytecode.h.


Public Member Functions

bool detect_no_score (const CVD::byte *imp, int b) const
int detect (const CVD::byte *imp, int b) const
void print (std::ostream &o, int width) const
void detect (const CVD::Image< CVD::byte > &im, std::vector< int > &corners, int threshold, int xmin, int xmax, int ymin, int ymax)

Public Attributes

std::vector
< fast_detector_bit
d

Classes

struct  fast_detector_bit
 This is a bytecode element for the bytecode-compiled detector. More...

Member Function Documentation

bool block_bytecode::detect_no_score ( const CVD::byte *  imp,
int  b 
) const [inline]

Detects a corner at a given pointer, without the book keeping required to compute the score.

This is quite a lot faster than detect.

Parameters:
imp Pointer at which to detect corner
b FAST barrier
Returns:
is a corner or not

Definition at line 72 of file faster_bytecode.h.

References d.

Referenced by detect().

00073     {
00074         int n=0;    
00075         int cb = *imp + b;
00076         int c_b = *imp - b;
00077         int p;
00078 
00079         while(d[n].lt)
00080         {
00081             p = imp[d[n].offset];
00082 
00083             if(p > cb)
00084                 n = d[n].gt;
00085             else if(p < c_b)
00086                 n = d[n].lt;
00087             else
00088                 n = d[n].eq;
00089         }
00090         
00091         return d[n].gt;
00092     }

int block_bytecode::detect ( const CVD::byte *  imp,
int  b 
) const [inline]

Detects a corner at a given pointer, with book-keeping required for score computation.

Parameters:
imp Pointer at which to detect corner
b FAST barrier
Returns:
0 for non-corner, minimum increment required to make detector go down different branch, if it is a corner.

Definition at line 99 of file faster_bytecode.h.

References d.

Referenced by tree_detect_corners(), and tree_detect_corners_all().

00100     {
00101         int n=0;    
00102         int m = INT_MAX;
00103         int cb = *imp + b;
00104         int c_b = *imp - b;
00105         int p;
00106 
00107         while(d[n].lt)
00108         {
00109             p = imp[d[n].offset];
00110 
00111             if(p > cb)
00112             {
00113                 if(p-cb < m)
00114                     m = p-cb;
00115 
00116                 n = d[n].gt;
00117             }
00118             else if(p < c_b)
00119             {
00120                 if(c_b - p < m)
00121                     m = c_b - p;
00122             
00123                 n = d[n].lt;
00124             }
00125             else
00126                 n = d[n].eq;
00127         }
00128         
00129         if(d[n].gt)
00130             return m;
00131         else
00132             return 0;
00133     }

void block_bytecode::print ( std::ostream &  o,
int  width 
) const [inline]

Serialize the detector to an ostream.

The serialized detector a number of lines of the form:

       Block N [X Y] G E L
or:
       Block N corner
or:
       Block N non_corner
The first block type represents the code:
       if Image[current_pixel + (x, y)] > Image[current_pixel] + threshold
          goto block G
       elseif Image[current_pixel + (x, y)] < Image[current_pixel] -threshold
          goto block L
       else
          goto block E
       endif
Parameters:
o ostream for output
width width the detector was created at, required to back out the offsets correctly.

Definition at line 160 of file faster_bytecode.h.

References d.

Referenced by faster_learn::faster_learn(), and run_learn_detector().

00161     {
00162         using tag::operator<<;
00163         for(unsigned int i=0; i < d.size(); i++)
00164         {
00165             if(d[i].lt == 0)
00166                 o << tag::print << "Block" << i <<  (d[i].gt?"corner":"non_corner");
00167             else
00168             {
00169                 int a = abs(d[i].offset) + width / 2;
00170                 if(d[i].offset < 0)
00171                     a = -a;
00172                 int y = a / width;
00173 
00174                 int x = d[i].offset - y * width;
00175                 o << tag::print << "Block" << i << CVD::ImageRef(x , y) << d[i].gt << d[i].eq << d[i].lt;
00176             }
00177         }
00178     }

void block_bytecode::detect ( const CVD::Image< CVD::byte > &  im,
std::vector< int > &  corners,
int  threshold,
int  xmin,
int  xmax,
int  ymin,
int  ymax 
)

Detect corners in an image.

The width of the image must match the width the detector was compiled to (using tree_elemeent::make_fast_detector for the results to make sense. The bytecode is JIT coimpiled if possible.

Parameters:
im The image in which to detect corners
corners Detected corners are inserted in to this container.
threshold Corner detector threshold to use
xmin x coordinate to start at.
ymin y coordinate to start at.
xmax x coordinate to go up to.
ymax y coordinate to go up to.

Definition at line 329 of file faster_bytecode.cc.

References d, and detect_no_score().

00330 {
00331     #ifdef JIT
00332         jit_detector jit(d);
00333         for(int y = ymin; y < ymax; y++)
00334             jit.detect_in_row(im, y, xmin, xmax, corners, threshold);
00335     #else
00336         cerr << "Hello!\n";
00337         for(int y = ymin; y < ymax; y++)
00338             for(int x=xmin; x < xmax; x++)
00339                 if(detect_no_score(&im[y][x], threshold))
00340                     corners.push_back(&im[y][x] - im.data());
00341     #endif
00342 }


Member Data Documentation

std::vector<fast_detector_bit> block_bytecode::d

This contains the compiled bytecode.

Definition at line 64 of file faster_bytecode.h.

Referenced by detect(), detect_no_score(), and print().


The documentation for this struct was generated from the following files:
Generated on Mon Mar 2 12:47:12 2009 for FAST-ER by  doxygen 1.5.3