// Set the upper limit of the number of insertable primitives // If the limit is reached, an error will be returned by medit_insert or medit_separate // In such cases, discard the class temporarily, re-create it, then call msetinsertmax and re-insert // Input: // int insertmax; The default value is 0. In a typical A3, 400dpi Japanese document, 10000 is sufficient. void msetinsertmax(int insertmax){minsertmax = insertmax;}Sample code
#include "ocrdef.h" #include "ocrco.h" #include "cjocrprim.h" #include "errcode.h" ... .... // Specify a 20-digit code supplied by the license manager or the path to a license code file to initialize the library CJocrPrim* pjocrprim = new CJocrPrim("ABCDEFGHJKLMNPQ23456"); // If using a license code file path: CJocrPrim* prim = new CJocrPrim("C:\\Program Files\\Foo\\primitive.kcd"); pjocrprim->msetdocument(mdata,0,mwidth,mheight); // Background is 0, foreground is 1 in the monochrome image pjocrprm->msetdpi(400); pjocrprm->msetinsertmax(10000); ret = pjocrprim->makeprim(); if(ret < 0) { Error; } delete pjocrprim; ...
// Delete primitive/cluster // Input // int flag; 1...reflect changes in the image data/0...don't reflect changes // PRIMITIVE* prim; primitive (don't make a copy, use the address) // Return // 0 normal termination // negative error int medit_delete(int flag,PRIMITIVE* prim); int medit_delete(int flag,CLUSTER* pcluster);Sample code
#include "ocrdef.h" #include "ocrco.h" #include "cjocrprim.h" #include "errcode.h" ... .... // Initialize the library by specifying the 20-digit code supplied by the licenser or the path to the license code file CJocrPrim* pjocrprim = new CJocrPrim("ABCDEFGHJKLMNPQ23456"); // If using the license code path, use CJocrPrim* prim = new CJocrPrim("C:\\Program Files\\Foo\\primitive.kcd"); pjocrprim->msetdocument(mdata,0,mwidth,mheight); // Monochrome image with background 0 and foreground 1 pjocrprm->msetdpi(400); pjocrprm->msetinsertmax(10000); ret = pjocrprim->makeprim(); if(ret < 0) { Error; } // 1...Select primitives or extract clusters // 2...Delete selected primitives and reflect changes in the original image int i1 = pjocrprim->medit_delete(1,prim); if(i1 < 0) { Error; } delete pjocrprim; ...
// Insert a primitive (if this is pjocrprim, it will be a copy) // Input // int flag; 1...Reflect in the image data/0...Do not reflect // CJocrPrim* pjocrprim; The instance of CJocrPrim to which the prim belongs // PRIMITIVE* prim; Primitive (copy is not allowed because the address is used) // CLUSTER* pcluster; Cluster (copy is not allowed because the address is used) // int left, top; Destination of movement // Output // PRIMITIVE*&priminsert; Address of the inserted primitive // Return Value // 0 Normal termination // Negative Error int medit_insert(int flag,CJocrPrim* pjocrprim,PRIMITIVE* prim,int left,int top,PRIMITIVE*& priminsert); int medit_insert(int flag,CJocrPrim* pjocrprim,CLUSTER* pcluster,int left,int top); // Clusterize all primitives // Used for rendering and cluster movement int mallprim2cluster();Sample code
#include "ocrdef.h" #include "ocrco.h" #include "cjocrprim.h" #include "errcode.h" ... .... // Initialize the library by specifying a 20-digit code supplied from the licenser or the path to the license code file CJocrPrim* pjocrprim = new CJocrPrim("ABCDEFGHJKLMNPQ23456"); // If it is the path to the license code, CJocrPrim* prim = new CJocrPrim("C:\\Program Files\\Foo\\primitive.kcd"); pjocrprim->msetdocument(mdata,0,mwidth,mheight); // Monochrome image with background 0 and foreground 1 pjocrprm->msetdpi(400); pjocrprm->msetinsertmax(10000); ret = pjocrprim->makeprim(); if(ret < 0) { Error; } // 1... Makeprim using another instance pjocrprim1 for the image to be inserted // 2... Use makeallprim2cluster to merge all primitives into one cluster // 3... Insert the cluster at the specified position int i1 = pjocrprim->medit_insert(1,pjocrprim1,pcluster,100,100); if(i1 < 0) { Error; } delete pjocrprim; ...
// Move the primitive / cluster (It is better to use this instead of copy + delete since it is costly) // Input // int flag; 1...Reflect in the image data / 0...Do not reflect // PRIMITIVE* prim; Primitive (copying is not allowed as it uses addresses) // CLUSTER* pcluster; Cluster (copying is not allowed as it uses addresses) // int left, top; Destination of movement // Return Value // 0 Normal termination // Negative Error int medit_move(int flag, PRIMITIVE* prim, int left, int top); int medit_move(int flag, CLUSTER* pcluster, int left, int top);Sample Code
#include "ocrdef.h" #include "ocrco.h" #include "cjocrprim.h" #include "errcode.h" ... .... // Initialize the library by specifying a 20-digit code supplied from the licenser or the path of the license code file CJocrPrim* pjocrprim = new CJocrPrim("ABCDEFGHJKLMNPQ23456"); // In case of license code path, CJocrPrim* prim = new CJocrPrim("C:\\Program Files\\Foo\\primitive.kcd"); pjocrprim->msetdocument(mdata,0,mwidth,mheight); // Monochrome image with background as 0 and foreground as 1 pjocrprm->msetdpi(400); pjocrprm->msetinsertmax(10000); ret = pjocrprim->makeprim(); if(ret < 0) { Error; } // 1... Primitive selection or cluster extraction operation // 2... Move the specified primitive and reflect it in the original image int i1 = pjocrprim->medit_move(1, prim, 100, 100); if(i1 < 0) { Error; } delete pjocrprim; ...
// Split cluster (Pixel data does not change. There is no visible breakage) // (Note that this process is computationally expensive: Reinitialization is faster if there are many targets to split) // 1...Copy the target primitive as a cluster // Input // int linenum; Number of cutting lines // int* px1; Starting and ending coordinates of cutting lines (linenum each) // int* py1; // int* px2; // int* py2; // CLUSTER* pcluster; Cluster to be cut // Return value // 0 Normal termination // Negative Error int medit_separate(int linenum,int* px1,int* py1,int* px2,int* py2,CLUSTER* pcluster);Sample code
#include "ocrdef.h" #include "ocrco.h" #include "cjocrprim.h" #include "errcode.h" ... .... // Initialize the library by specifying a 20-digit code provided by the licenser or the path of the license code file. CJocrPrim* pjocrprim = new CJocrPrim("ABCDEFGHJKLMNPQ23456"); // If it is the license code path, use CJocrPrim* prim = new CJocrPrim("C:\\Program Files\\Foo\\primitive.kcd"); pjocrprim->msetdocument(mdata,0,mwidth,mheight); // Monochrome image with background 0 and foreground 1 pjocrprm->msetdpi(400); pjocrprm->msetinsertmax(10000); ret = pjocrprim->makeprim(); if(ret < 0) { Error; } // 1...Cluster extraction operation // 2...Cut the specified cluster int x1[1]; int y1[1]; int x2[1]; int y2[1]; x1[0] = 100; y1[0] = 100; x2[0] = 200; y2[0] = 200; int i1 = pjocrprim->medit_separate(1,x1,y1,x2,y2,pcluster); if(i1 < 0) { Error; } delete pjocrprim; ...
// Divides the cluster (no pixel data change occurs. No visible cutting on display) // (Note: The processing cost is high. If there are many divisions, reinitialization is faster) // 1...Copies the target primitive as a cluster // Input // int linenum; Number of cutting lines // int* px1; Coordinates of the starting point and ending point of the cutting line (linenum for each) // int* py1; // int* px2; // int* py2; // CLUSTER* pcluster; Cluster to be severed // Return value // 0 Normal termination // Negative Error int medit_sever(int linenum,int* px1,int* py1,int* px2,int* py2,CLUSTER* pcluster);Sample code
#include "ocrdef.h" #include "ocrco.h" #include "cjocrprim.h" #include "errcode.h" ... .... // Initializes the library by specifying a 20-digit code provided from the licenser or a path to the license code file CJocrPrim* pjocrprim = new CJocrPrim("ABCDEFGHJKLMNPQ23456"); // If using a license code path: CJocrPrim* prim = new CJocrPrim("C:\\Program Files\\Foo\\primitive.kcd"); pjocrprim->msetdocument(mdata,0,mwidth,mheight); // Monochrome image with background of 0 and foreground of 1 pjocrprm->msetdpi(400); pjocrprm->msetinsertmax(10000); ret = pjocrprim->makeprim(); if(ret < 0) { Error; } // 1...Cluster extraction operation // 2...Sever the specified cluster int x1[1]; int y1[1]; int x2[1]; int y2[1]; x1[0] = 100; y1[0] = 100; x2[0] = 200; y2[0] = 200; int i1 = pjocrprim->medit_sever(1,x1,y1,x2,y2,pcluster); if(i1 < 0) { Error; } delete pjocrprim; ...