2010년 5월 7일 금요일

[GOCR] 소스분석 <gocr-0.48/src/ocr0.c/ocr0_oO()>

문자인식을 위한 프로젝트를 진행하기위해 gocr소스를 분석하였다.

일단 전체적으로 분석하기에는 구조가 조금 복잡한 면이 있어서

알파벳 o,O를 분석하는 함수인 ocr0_oO()를 분석하고자 한다.

 

static wchar_t ocr0_oO(ocr0_shared_t *sdata){...}

- 내부 사용 함수

 get_bw()

 num_cross()

 loop()

 setac()

 

1. char get_bw(int x0, int x1, int y0, int y1, pix * p, int cs, int mask)

  - Look for dots in the rectangular region x0 <= x <= x1 and y0 <= y <= y1 in pixmap p.  The two low order bits in mask indicate the color of dots to look for: If mask==1 then look for black dots (where a pixel value less than cs is considered black).  If mask==2 then look for white dots.  If mask==3 then look for both black and white dots. If the dots are found, the corresponding bits are set in the returned value.  Heavily used by the engine ocr0*.cc

  - pixmap p의 x0 <= x <= x1 와 y0 <= y <= y1 범위의 사각형 영역의 점을 찾는다. mask 변수의 하위 2비트는 찾으려고 하는 점들의 색을 나타낸다. : mask==1이면 검은점을 나타내고(cs보다 작은 값은 검은점으로), mask==2이면 흰점을 mask==3이면 검은점과 흰점 둘다 나타낸다. 특정 점을 찾아 그에 해당하는 리턴 값으로 셋팅된다. 주로 ocr0*.cc에서 쓰인다.

 

2. int num_cross(int x0, int x1, int y0, int y1, pix *p, int cs)

  - more general Mar2000 (x0,x1,y0,y1 instead of x0,y0,x1,y1! (history)) look for black crossings throw a line from x0,y0 to x1,y1 and count them follow line and count crossings ([white]-black-transitions)

  - ex: horizontal num_cross of 'm' would return 3
  - fail for:  .a... a-to-b counts no transitions, but there is
 *            ...#.
 *            ..#..
 *            .#..b

  - Mar2000보다 일반적인 형태로 x0,y0부터 x1,y1 선분에 있는 검은 색 교차지점(백-흑 변화)을 찾아 그 개수를 리턴한다.

  - 예) m의 가로 num_cross값은 3을 리턴한다.

 

3. int loop(pix *p,int x,int y,int l,int cs,int col, DIRECTION r)

  - move from x,y to direction r until pixel of color col is found or maximum of l steps return the number of steps done

  - x,y부터 r방향으로 이동하면서 col 색을 찾거나 최고 l스텝까지 이동하여 스텝값을 리턴한다.

 

4. int setac(struct box *b, wchar_t ac, int weight)

  - this function will be replaced by a call of setas() later

  - 이 함수는 추후 setas()로 대체될 것이다.

 

5. int setas(struct box *b, char *as, int weight)

  - set alternate chars and its weight, called from the engine if a char is recognized to (weight) percent can be used for filtering (only numbers etc) often usefull if Il1 are looking very similar
   should this function stay in box.c ??? weight is between 0 and 100 in percent, 100 means absolutely sure not final, not time critical (js) replace it by a string-function setaobj(*b,"string",weight) and let call setac the setas function

  - 서로 엇갈리는 문자들과 이 문자들의 가중치을 정하고, ........ ??? 가중치값은 0과 100퍼센트 사이값이다.

댓글 없음:

댓글 쓰기