ClearImage SDK
Programming
Java
step 1 install clearimage sdk download and install the clearimage sdk step 2 configure your project add clearimagej jar clearimagej jar to classpath typically file is located in c \program files (x86)\inlite\libs c \program files (x86)\inlite\libs folder java api uses several methods to locate clearimage dll clearimage dll listed below in descending priority explicit path using the ciserver loadclearimage(clearimagedllpath) ciserver loadclearimage(clearimagedllpath) method folder specified by djava library path="clearimagedllpath" djava library path="clearimagedllpath" on the java command line folders specified by the path path environmental variable use the correct 32 bit or 64 bit version of clearimage dll clearimage dll , that matches your java runtime version clearimage dll clearimage dll is located in subfolder of c \program files (x86)\inlite\clearimagesdk c \program files (x86)\inlite\clearimagesdk f older \win32 \win32 and \x64 \x64 this code demonstrates the use of clearimage java api runtime errors are reported in exception exception object iciserver initclearimage() { 	 try { 	 ciserver loadclearimage("c \\\program files (x86)\\\inlite\\\clearimagesdk\\\x64\\\clearimage dll"); 	 // create clearimage server 	 ciserver objserver = new ciserver(); 	 iciserver server = onjserver geticiserver(); 	 return server; 	 } catch (exception ex) { 	 system out println(ex getmessage()); 	 return null; 	 } } void readbarcodes(iciserver ci, string filename, int page) { 	 icibarcodepro reader = null; 	 try { 	 reader = ci createbarcodepro(); // create and configure barcode reader 	 reader settype(new fbarcodetype(fbarcodetype cibfcode39, fbarcodetype cibfcode128)); 	 reader getimage() open(filename, page); // open image from an image file 	 int n = reader find(0); // read barcodes 	 for (int i = 1; i <= n; i++) { // process results 	 icibarcode bc = reader getbarcodes() getitem(i); // getitem is 1 based 	 system out println(" barcode + type " + bc gettype() + " text \n" + bc gettext()); 	 } 	 } catch (exception ex) { // process exceptions 	 system out println(); ex printstacktrace(); 	 } finally { 	 if (reader != null) try { 	 reader getimage() close(); // close images and free memory 	 } catch (exception ex) {;} 	 } } clearimage project development extend functionality while developing your application, you can combine code examples on this page with methods described in clearimage api documentation exception handling clearimage java api reports errors as an exception exception object try { // call clearimage net api } catch (exception ex) { 	 system out println(ex getmessage()); 	} barcode reading read 1d barcodes from a page this example reads code 39 and code 128 barcodes set barcode types used in your application setting reader setautodetect1d(eboolean citrue); reader setautodetect1d(eboolean citrue); automatically finds the barcode type, but it is slower and is not recommended for production void readbarcode1d page(iciserver server, string filename, int page) { 	try { 	 icibarcodepro reader = server createbarcodepro(); 	 reader settype(new fbarcodetype(fbarcodetype cibfcode39, 	 fbarcodetype cibfcode128)); 	 // readerbcr setautodetect1d(eboolean citrue); 	 reader getimage() open(filename, page); 	 reader find(0); 	 for (int i = 1; i <= reader getbarcodes() getcount(); i++) { 	 icibarcode bc = reader getbarcodes() getitem(i); 	 system out println(bc gettext()); 	 } 	} catch (exception ex) { 	 system out println(ex getmessage()); 	} finally { 	 system gc(); 	} } read 2d barcode from a page this example reads pdf417, datamatrix, and qr code 2d barcodes might contain binary data available from bc getdata() bc getdata() as byte\[] byte\[] void readbarcode2d page(iciserver server, string filename, int page) { 	try { 	 iciqr reader = server createqr(); 	 // icipdf417 reader = server createpdf417(); 	 // icidatamatrix reader = server createdatamatrix(); 	 reader getimage() open(filename, page); 	 reader find(0); 	 for (int i = 1; i <= reader getbarcodes() getcount(); i++) { 	 icibarcode bc = reader getbarcodes() getitem(i); 	 system out println(bc gettext()); 	 } 	} catch (exception ex) { 	 system out println(ex getmessage()); 	} finally { 	 system gc(); 	} } read postal barcodes from a page this example reads postal barcodes from an image file page void readbarcodepostal page(iciserver server, string filename, int page) { 	try { 	 icibarcodepro reader = server createbarcodepro(); 	 reader settype(new fbarcodetype(fbarcodetype cibf4state)); 	 reader getimage() open(filename, page); 	 reader find(0); 	 for (int i = 1; i <= reader getbarcodes() getcount(); i++) { 	 icibarcode bc = reader getbarcodes() getitem(i); 	 ebarcodetype type = bc gettype(); 	 if (type == ebarcodetype cibuspsintelligentmail) 	 system out println(" us intelligent mail "); 	 if (type == ebarcodetype cibbpopostcode) 	 system out println("uk royal mail "); 	 if (type == ebarcodetype cibaustralianpost) 	 system out println("australian mail "); 	 if (type == ebarcodetype cibsingaporepost) 	 system out println("singapore mail "); 	 system out println(bc gettext()); 	 } 	} catch (exception ex) { 	 system out println(ex getmessage()); 	} finally { 	 system gc(); 	} } read driver's license barcode this example reads the driver's license barcode from an image file page void readbarcode2d page(iciserver server, string filename, int page) { 	try { 	 icipdf417 reader = server createpdf417(); 	 reader getimage() open(filename, page); 	 reader find(0); 	 for (int i = 1; i <= reader getbarcodes() getcount(); i++) { 	 icibarcode bc = reader getbarcodes() getitem(i); 	 system out println(bc gettext()); 	 if (bc getinfo("last") != "") { 	 system out println("last " + bc getinfo("last")); 	 system out println("first " + bc getinfo("first")); 	 system out println("middle " + bc getinfo("middle")); 	 system out println("suffix " + bc getinfo("suffix")); 	 system out println("dob " + bc getinfo("dob")); 	 system out println("eyes " + bc getinfo("eyes")); 	 system out println("hair " + bc getinfo("hair")); 	 system out println("sex " + bc getinfo("sex")); 	 system out println("height " + bc getinfo("height")); 	 system out println("weight " + bc getinfo("weight")); 	 system out println("street " + bc getinfo("street")); 	 system out println("city " + bc getinfo("city")); 	 system out println("state " + bc getinfo("state")); 	 system out println("postal " + bc getinfo("postal")); 	 system out println("country " + bc getinfo("country")); 	 system out println("id " + bc getinfo("id")); 	 system out println("issued " + bc getinfo("issued")); 	 system out println("expires " + bc getinfo("expires")); 	 } 	 } 	} catch (exception ex) { 	 system out println(ex getmessage()); 	} finally { 	 system gc(); 	} } read from a multi page image file this example reads barcodes from a single page or all pages of a multi page image file void readbarcode1d page(iciserver server, string filename, int page) { 	try { 	 icibarcodepro reader = server createbarcodepro(); 	 reader settype(new fbarcodetype(fbarcodetype cibfcode39, 	 fbarcodetype cibfcode128)); 	 int page = 1; 	 while (true) { 	 reader getimage() open(filename, page); 	 reader find(0); 	 for (int i = 1; i <= reader getbarcodes() getcount(); i++) { 	 icibarcode bc = reader getbarcodes() getitem(i); 	 system out println(bc gettext()); 	 } 	 page++; 	 if (page > reader getimage() getpagecount()) 	 break; 	 } 	} catch (exception ex) { 	 system out println(ex getmessage()); 	} finally { 	 system gc(); 	} } optimize barcode reading this optimize barcode reading docid\ smk4 lgrtfex0zacvu2lv describes methods for improving the recognition rate and/or speed image processing repair image page this example uses some of the most popular image processing functions in a production application, the specific sequence of functions should be selected based on specific application needs void repairpage (icirepair repair) 	{ 	repair autodeskew(); 	repair autorotate(); 	repair autocrop(10, 10, 10, 10); 	repair advancedbinarize(0, 0 , 0); 	repair borderextract(eborderextractflags cibexborderdeskewcrop, eborderextractalgorithm cibeacleaner); // deskew and crop based on black border 	repair removepunchholes(); 	repair smoothcharacters(esmoothtype cismoothdarkenedges); 	repair cleannoise(3); // clean black noise of 3 pixels 	 // repair cleannoiseext // clean black and white noise 	 // (new ecleannoiseflags(ecleannoiseflags cicnxblacknoise, ecleannoiseflags cicnxwhitenoise), 3, 3, 10, 0); 	repair reconstructlines(elinedirection cilinevertandhorz); 	} void repair page(iciserver server, string filename, int page, string fileout) { 	try { 	 icirepair repair = server createrepair (); 	 repair getimage() open (filename, page); 	 repairpage(repair); 	 repair getimage() saveas(fileout, efileformat ciext); 	} catch (exception ex) { 	 system out println(ex getmessage()); 	} finally { 	 system gc(); 	} } repair all images in a multi page file this example repairs all images in a multi page file and saves the result in the fileout fileout file void repair page(iciserver server, string filename, string fileout) { 	try { 	 icirepair repair = server createrepair (); 	 int page = 1; 	 while (true) { 	 repair getimage() open (filename, page); 	 repairpage(repair); // see code above 	 repair getimage() append(fileout, efileformat ciext); 	 page++;	 	 if (page > repair getimage() getpagecount()) 	 break; 	 } 	} catch (exception ex) { 	 system out println(ex getmessage()); 	} finally { 	 system gc(); 	} }