Modules-old/ImageProc/lua_goal.cpp
// Loop through scan lines and check connected regions
Loop through scan lines and check connected regions
Loop through scan lines and check connected regions
int connectRegion (bool is_lower) {
	enum {STATE_NONE, STATE_FIELD, STATE_POST};
	static int state = STATE_NONE;
	static int width = 0;
	switch (state) {
    case STATE_NONE:
      if (!is_lower) {
        state = STATE_FIELD;
      } else {
      	state = STATE_POST;
      }
      break;
    case STATE_FIELD:
      if (is_lower) {
      	state = STATE_POST;
      	width = 1;
      }
      break;
    case STATE_POST:
      if (is_lower) {
      	width++;
      } else {
      	state = STATE_FIELD;
      	return width;
      }
  }
  return 0;
}
int connectRegion ( bool is_lower ) { enum { STATE_NONE , STATE_FIELD , STATE_POST } ; static int state = STATE_NONE ; static int width = 0 ; switch ( state ) { case STATE_NONE : if ( ! is_lower ) { state = STATE_FIELD ; } else { state = STATE_POST ; } break ; case STATE_FIELD : if ( is_lower ) { state = STATE_POST ; width = 1 ; } break ; case STATE_POST : if ( is_lower ) { width ++ ; } else { state = STATE_FIELD ; return width ; } } return 0 ; }
Loop through scan lines and check connected regions
Loop through scan lines and check connected regions