console . print
LetterBuild HTML LetterLibrary: "fastObjects(string)" http://www.dialtosee.com "save page as..."
FastObjects() photo OCR commercial
Overview
Explore the main Optical Character Recognition, alphabetical letter recognizer
the code comments begin from the author of LetterBuild: dial2c, & enjoy learning
Preliminary Search: function walkthrough
Instructions_&_& >> Scroll to: "//SCROLL HERE: A20230919_a" |
function fastObjects(s33k) { //console.log(Date(), "fastObjects"); document.getElementById("eListener").style = "display: none;"; kbHy0(); document.getElementById("wrhouse").disabled = true; document.getElementById("ime").disabled = true; document.getElementById("Vo").disabled = true; var cren = document.getElementById("scaleStill"); var duum = cren.getContext("2d"); duum.imageSmoothingEnabled = false; var Obj1 = document.getElementById("monochrome"); var ObjX = Obj1.getContext("2d"); ObjX.imageSmoothingEnabled = false; var reterr = ""; if(Pane === undefined) { reterr = "empty []"; } if(Llib === undefined) { reterr = "no objects"; } if(s33k === "") { reterr = "seek what?"; } if(reterr !== "") { // duum.drawImage(Obj1, 3, 3, cren.width - 6, cren.height - 6); var disp0 = Math.round(cxy.width * 0.097); var disp1 = Math.round(cxy.height - disp0); var earco = Math.round(cxy.width * 0.0833); duum.lineWidth = 16; duum.strokeStyle = "#FF00FF"; duum.font = earco + "px Courier New"; duum.strokeText(reterr, disp0, disp1); duum.lineWidth = 6; duum.strokeStyle = "#FF0000"; duum.font = earco + "px Courier New"; duum.strokeText(reterr, disp0, disp1); duum.lineWidth = 1; duum.strokeStyle = "#FFFF40"; duum.font = earco + "px Courier New"; duum.strokeText(reterr, disp0, disp1); document.getElementById("ime").select(); return; } var memyI = true; var ci = false, boull = false; var a65 = 0, b66 = 0, c67 = 0; var d68 = 0, e69 = 0, f70 = 0; var g71 = 0, h72 = 0, i73 = 0; var j74 = 0, k75 = 0, l76 = 0; var m77 = 0, n78 = 0, O79 = 0; var t84 = 0, u85 = 0, w87 = 0; var x88 = 0, y89 = 0, z90 = 0; var vol = 0, ume = 0, b1 = ""; var lupk = s33k.toUpperCase(); var p80 = [], q81 = []; var s83 = [], v86 = []; var r82 = []; for(u85 = 0; u85 < lupk.length; u85++) { r82.push(lupk.charAt(u85)); } var chrwren = window.setInterval(function () { duum.drawImage(Obj1, 3, 3, cren.width - 6, cren.height - 6); duum.fillStyle = "#303030"; duum.fillRect(16, 16, 111, 90); duum.font = "26px Courier New"; duum.fillStyle = "#808080"; duum.fillText("" + q81.length, 30, 44); if(m77 % 2 === 0){b1 = "+";}else{b1 = "x";} duum.fillText(b1 + "" + Llib.length, 27 , 64); duum.font = "bold 44px Courier New"; duum.fillStyle = "#FFFF80"; duum.fillText(" " + Math.floor((m77 / Llib.length) * 100) + "%", 20, 97); if(m77 === Llib.length - 1 || Llib[m77] === undefined || !memyI) { document.getElementById("wrhouse").disabled = false; document.getElementById("ime").disabled = false; document.getElementById("Vo").disabled = false; // document.addEventListener("keydown", worKe); document.removeEventListener("keydown", shoKe); /////////////////////////////////////// if(typeof(q81) === "undefined") { console.log("q81[empty] fail."); duum.drawImage(Obj1, 3, 3, cren.width - 6, cren.height - 6); var disp0 = Math.round(cxy.width * 0.097); var disp1 = Math.round(cxy.height - disp0); var earco = Math.round(cxy.width * 0.0833); duum.lineWidth = 16; duum.strokeStyle = "#FF00FF"; duum.font = earco + "px Courier New"; duum.strokeText("no thing", disp0, disp1); duum.lineWidth = 6; duum.strokeStyle = "#FF0000"; duum.font = earco + "px Courier New"; duum.strokeText("no thing", disp0, disp1); duum.lineWidth = 1; duum.strokeStyle = "#FFFF40"; duum.font = earco + "px Courier New"; duum.strokeText("no thing", disp0, disp1); document.getElementById("ime").select(); }else { //console.log(Date(), "end of loop"); window.setTimeout(function () { // var wait = document.getElementById("loadingPage"); // wait.setAttribute("style","display: inline"); // wait.focus(); // wait.play(); s83 = []; s83 = rowird(q81, cren.width / Obj1.width); v86 = []; v86 = st29ng(s83, s33k);//LOSTs33k); Gave(v86); //console.log(Date(), " letters up"); ImgController(1); DIAL2ContactCustomerService = true; console.log(Date(), " words done"); }, 100); clearInterval(chrwren); } } ////console.log(Llib.length); // for(m77 = 0; m77 < Llib.length; m77++) // { ////console.log(m77 + 1, "of", Llib.length); for(f70 = 0; f70 < Llib[m77].length; f70++) { s83 = [];
//SCROLL HERE: A20230919_a |
//Llib is all objects within monochrome conversion s83 = Llib[m77][f70]; //https://oercommons.org/courseware/lesson/108522/overview // "s83" is the working copy of the iterated 'object' for multi-dimesional purpose // if(s83 !== undefined && s83.length > 0) { // render object location within 'interval': "chrwren" ObjX.lineWidth = 12; ObjX.strokeStyle = "#008080"; ObjX.strokeRect(s83[s83.length - 6], s83[s83.length - 5], s83[s83.length - 4], s83[s83.length - 3]); z90 = -1; vol = 0; b1 = ""; for(u85 = 0; u85 < r82.length; u85++) { if(u85 < r82.length) { v86 = []; // SwapLetter function in: file >> "LangUS2022UpD.js" // otherwise known as the training array director // for each letter in the search string/array: "r82" << from s33k v86 = SwapLetter(r82[u85]); // https://oercommons.org/courseware/lesson/108604/overview // loop through widths of the training file for(t84 = 0; t84 < v86.length; t84++) { if(v86[t84][v86[t84].length - 2] === s83[s83.length - 2]) { // for qualifying width of object, // record index of matching width = "n78" n78 = t84; break; } } ci = false; i73 = 0; for(d68 = 0; d68 < s83[s83.length - 2]; d68++) { if(s83[d68] === true) {//flat_CRH_ i73 = d68; break; } } while(n78 < v86.length && v86[n78][v86[n78].length - 2] <= s83[s83.length - 2] - i73) { if(ci){break;} ObjX.lineWidth = 8; ObjX.strokeStyle = "#FF00FF"; ObjX.strokeRect(s83[s83.length - 6], s83[s83.length - 5], s83[s83.length - 4], s83[s83.length - 3]); ObjX.lineWidth = 4; ObjX.strokeStyle = "#00FF00"; ObjX.strokeRect(s83[s83.length - 6], s83[s83.length - 5], s83[s83.length - 4], s83[s83.length - 3]); if(v86[n78] !== undefined) { // // optional rotation match "d68" in degrees // for(d68 = 0; d68 < 1; d68 += 5) { if(ci){break;} p80 = []; // proprietary rotation function -- not necessary p80 = graphOf(v86[n78], d68, s83[s83.length - 2]); if(_CRH_ === p80[p80.length - 1]) { w87 = p80[p80.length - 2]; h72 = s83[s83.length - 2] - w87; if(h72 > -1) { k75 = s83[s83.length - 1] - _CRH_; a65 = e69 = 9999; // y-"g71" & x-"j74" for finding partial letter matches // // www.dialtosee.com for(g71 = 0; g71 < k75 + BT(k75 === 0); g71++) { if(ci){break;} for(j74 = 0; j74 < h72 + BT(h72 === 0); j74++) { if(ci){break;} t84 = b66 = 0; for(y89 = g71; y89 < g71 + _CRH_; y89++) { l76 = y89 * s83[s83.length - 2]; c67 = 0; for(x88 = j74; x88 < j74 + w87; x88++) { if(s83[x88 + l76]) { // escape at value true // since null, false array defaulted t84 = b66 = p80[p80.length - 3] + 1; // "t84" threshold for error on exact match }else { if(p80[(j74 + (c67 % w87)) + (w87 * Math.floor(c67++ * g71))] === false) { if(s83[x88 + l76] !== false) { // count mismatch for null b66++; } }else { if(s83[x88 + l76] === false) { // count mismatch for false t84++; } } } if(t84 > p80[p80.length - 3] || b66 > p80[p80.length - 3]){break;} }//x88 if(t84 > p80[p80.length - 3] || b66 > p80[p80.length - 3]){break;} }//y89 // record of how well match is ume = Math.round( ((p80[p80.length - 2] * p80[p80.length - 1] * (s83[s83.length - 3] / _CRH_)) / (s83[s83.length - 4] * s83[s83.length - 3])) * 100); if((t84 < p80[p80.length - 3] && b66 < p80[p80.length - 3]) && (b66 < e69 || t84 < a65) && vol <= ume // change per better match ) { vol = ume; z90 = u85; e69 = b66; a65 = t84; } if(z90 > -1 && u85 === r82.length - 1) { ci = true; // u85 = -1; ////console.log(window.perfomance.memory.jsHeapSizeLimit, window.perfomance.memory.usedJSHeapSize); //// if(q81.length < 32000) //// { if(q81.length > 0) { boull = false; // check for duplicates for(O79 = 0; O79 < q81.length; O79++) { if(s83[s83.length - 6] === q81[O79][1] && s83[s83.length - 5] === q81[O79][2] && s83[s83.length - 4] === q81[O79][3] && s83[s83.length - 3] === q81[O79][4]) { boull = true; q81[O79][0] = q81[O79][0] + r82[z90]; break; } } // if it does not match any then add it if(!boull) { q81.push([ r82[z90], s83[s83.length - 6], //1 s83[s83.length - 5], //2 s83[s83.length - 4], //3 s83[s83.length - 3]] ); //4 } }else { if(q81.length > 5279) { memyI = false; }else { q81.push([ r82[z90], s83[s83.length - 6], //1 s83[s83.length - 5], //2 s83[s83.length - 4], //3 s83[s83.length - 3]] ); //4 } } // }// memory restraints ///////////////////////////// RENDER VISUAL AID ////////////////////////////////////////////// k75 = Math.round(s83[s83.length - 3] / s83[s83.length - 1]); c67 = 0; ObjX.fillStyle = rainbo(m77 % 53);//"#0000FF"; for(y89 = g71; y89 < g71 + p80[p80.length - 1]; y89++) { /*!*/ l76 = y89 * s83[s83.length - 2]; for(x88 = j74 + i73; x88 < j74 + i73 + p80[p80.length - 2]; x88++) { if(p80[c67++] === false) { ObjX.fillRect( s83[s83.length - 6] + (x88 * k75), s83[s83.length - 5] + (y89 * k75), k75, k75 ); } // set escape for multiple partial matches /*!*/ s83[x88 + l76] = true; }//x88 }//y89 //corners // ObjX.beginPath(); // ObjX.lineWidth = 4; // ObjX.strokeStyle = "#FF8000"; // ObjX.strokeRect(s83[s83.length - 6], // s83[s83.length - 5], // 8, // 8); // ObjX.strokeRect(s83[s83.length - 6], // s83[s83.length - 5] + s83[s83.length - 3], // 8, // 8); // ObjX.strokeRect(s83[s83.length - 6] + s83[s83.length - 4], // s83[s83.length - 5], // 8, // 8); // ObjX.strokeRect(s83[s83.length - 6] + s83[s83.length - 4], // s83[s83.length - 5] + s83[s83.length - 3], // 8, // 8); //rect ObjX.beginPath(); ObjX.lineWidth = 2; ObjX.strokeStyle = "#00FFFF"; ObjX.strokeRect(s83[s83.length - 6], s83[s83.length - 5], s83[s83.length - 4], s83[s83.length - 3]); ObjX.beginPath(); ObjX.lineWidth = 4; ObjX.strokeStyle = "#FF0000"; ObjX.strokeRect((s83[s83.length - 6] + (j74 * k75) - 4), (s83[s83.length - 5] + (g71 * k75) - 4), ((p80[p80.length - 2] * k75) + 8), ((p80[p80.length - 1] * k75) + 8) ); s83[s83.length - 7] = r82[z90]; s83[s83.length - 8] = vol; //0-n s83[s83.length - 2] -= p80[p80.length - 2]; ObjX.font = "bold 64px Courier New"; ObjX.lineWidth = 6; ObjX.strokeStyle = "#FF0000"; ObjX.strokeText(r82[z90] + " " + n78, s83[s83.length - 6] + 20, s83[s83.length - 5] + 52); ObjX.lineWidth = 3; ObjX.font = "64px Courier New"; ObjX.strokeStyle = "#0000FF"; ObjX.strokeText(r82[z90] + " " + n78, s83[s83.length - 6] + 20, s83[s83.length - 5] + 52); ObjX.lineWidth = 16; ObjX.font = "128px Courier New"; ObjX.strokeStyle = "#FF80FF"; ObjX.strokeText(r82[z90], Obj1.width - ((z90 + 1) * 128), Obj1.height - 200); ////////////////////////// DONE RENDERING ////////////////////////////////////////////////////// }else { //continue }//!match if(ci){break;} }//j74 if(ci){break;} }//g71 }//multiple }//p80_CRH_ if(ci){break;} }//d68 if(ci){break;} }//!v86[empty] n78++;}//whildths }//emtyChr }//u85 }//!s83 }//f70 ////////////////////// //if(m77 % 1000 === 0) //{ //console.log(m77, "of", Llib.length); //} //}//m77 m77++;}, 1); // }//n-- }