// Calculate the angle estimation of the cluster void mcalcangle(CLUSTER* pcluster, double& angle, int fusionflag = 1); Input: CLUSTER* pcluster; Cluster (acquired using mgetvalidcluster) int fusionflag; Usually no need to specify. If one primitive equals one character (capital alphabet, number, comma, etc.) and this is guaranteed, setting it to 0 will improve accuracy. Default value is 1. Output: double& angle; Estimated angle (in radians)Vectorization of partition lines
// Call mvectorizeline function to perform vectorization // By default, vectorization is disabled, so if you want to use partition lines, call this function at least once // It can be called multiple times without problems void menablevectorize(); // Do not call mvectorizeline function to perform vectorization // Partition line information is not used for angle estimation either // It can be called multiple times without problems void mdisablevectorize(); // Vectorize partition lines int mvectorizeline(); Return value 0...Normal completion (including the case where vectorization is not performed by mdisablevectorize) Negative...ErrorSample Code
#include "ocrdef.h" #include "ocrco.h" #include "cjocrprimrd.h" #include "errcode.h" ... .... // Initialize the library by specifying a 20-digit code supplied by the licenser or the path to a license code file CJocrPrimRD* pjocrprim = new CJocrPrimRD("ABCDEFGHJKLMNPQ23456"); // If using a 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); ret = pjocrprim->makeprim(); if(ret < 0) { Error; } /////////////////////// // Vectorization of rectangular lines pjocrprim->menablevectorize(); ret = pjocrprim->mvectorizeline(); if(ret < 0) { Error; } // Extract clusters (primitives belonging to clusters are moved to layer 1) ret = pjocrprim->mabstractcluster(0,1); if(ret < 0) { Error; } // Get the number of clusters int clusternum = pjocrprim->mgetvalidclusternum(); CLUSTER* pcluster = (CLUSTER*)malloc(sizeof(CLUSTER) * clusternum); if(pcluster) { // Get clusters mgetvalidcluster(pcluster); for(int i = 0 ; i < clusternum ; i++) { double angle; // The information of rectangular lines is used for angle estimation pjocrprim->mcalcangle(pcluster + i,angle); // angle is the estimated angle (in radians) // The actual baseline angle is either angle or angle+/2 .... ... } } delete pjocrprim; ...