reference/ocr-simple/Component.h
changeset 0 6b8091ca909a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/reference/ocr-simple/Component.h	Thu May 18 23:12:51 2006 +0200
@@ -0,0 +1,122 @@
+#ifndef _COMPONENT_H
+#define _COMPONENT_H
+#include "system.h" 
+#include "list.h"
+#include "RLEMap.h"
+
+class BitMap;
+
+class Components: public List
+{
+ public:
+  Components();
+  ~Components();
+
+     
+};
+
+class Component{
+      public:
+
+       	Component(Point ul, Point lr)
+	  :ful(ul), flr(lr), fnumBits(0),fasciiId(0), fconfid(0),
+	  charGroup(0), ffontId(0)
+	    { fproperty = new Property[numProperties];
+	      for (int i = 0; i < numProperties; i++)
+	         fproperty[i] = 0;};
+
+	Component()
+	  :ful(-1), flr(-1), fnumBits(0),fasciiId(0),fconfid(0),
+	  charGroup(0), ffontId(0)
+	    { fproperty = new Property[numProperties];
+	      for (int i = 0; i < numProperties; i++)
+	         fproperty[i] = 0;};
+	~Component(){
+	    if (fproperty != NULL) delete fproperty;}
+
+
+	 inline Point & ul() {return ful;};
+	 inline Point & lr() {return flr;};
+
+	 inline double width() {return (double)(flr.x() - ful.x() + 1); };
+	 inline double height() {return (double)(flr.y() - ful.y() + 1); };
+         inline int & numBits(){return fnumBits;};
+	 short int charGroup; // values 0-3: 0=acemno, 1=gpqy, 2=dfhikl, 3=j([}
+         int vertShrink(BitMap * bitmap);									     
+	int AddToComponent(ListElement* intrvl, RLEMap* rlemap);
+	/*--------------------------------------------------------------
+	Primary Purpose: Extend boundaries of component by connected intervals.
+        Arguments: startIntrvl is interval to start from
+        Return Value: Number of intervals added. 
+	Effects: Updates component's LR and UL. Deletes all added intervals. 
+	----------------------------------------------------------------*/
+
+	 // Access entire property vector
+	 inline Property * properties()
+	   {return fproperty;}
+
+	 // Set or read one value in property vector
+	 inline Property & property(int p) // Possibly use overload []
+	   {return fproperty[p];};
+
+	 // Set or read ascii id;
+	 inline Character & asciiId(){ return fasciiId;};
+
+	// Set or read font id;
+	inline short int & fontId() {return ffontId;};
+
+	 inline Confidence & confid(){ return fconfid; };
+	// Determine heuristic distance between this and comp
+	 Distance distance(Component * comp);
+
+	// Use the BitMap map to set the property vector for 
+        // this component
+
+	void setProperties(RLEMap * map);
+	void setProperties(BitMap * map);
+	void setSectionFlags(short int hflag[], short int vflag[]);
+
+	void display_bounding_box();
+
+	Distance recognize(Component * learnedchars);
+	// find best match in learned characters.  Set ascii value
+        // and return distance.
+
+	Distance recognize(Components * learnedgroups, bool allGroups=FALSE);
+	// find best match from learned character groups. Set ascii value
+        // and return distance.
+
+        Property * fproperty;
+      private:
+       	Point ful;
+      	Point flr;
+       	int fnumBits;
+
+
+       	Character fasciiId;
+	short int ffontId;
+       	Confidence fconfid;     
+};
+
+
+#endif
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+