B2BÍøÂçÈí¼þ

 ÕÒ»ØÃÜÂë
 Á¢¼´×¢²á ÉóºËÍøÕ¾ºÅ:QQ:896757558
ËÑË÷
²é¿´: 7|»Ø¸´: 0
´òÓ¡ ÉÏÒ»Ö÷Ìâ ÏÂÒ»Ö÷Ìâ

AIWROKÈí¼þͼÏñ¶þÖµ»¯µÄ¸÷ÖÖ·½·¨ºÍÓ¦Óó¡¾°

[¸´ÖÆÁ´½Ó]

974

Ö÷Ìâ

979

Ìû×Ó

7173

»ý·Ö

abc

Rank: 9Rank: 9Rank: 9

»ý·Ö
7173
Ìø×ªµ½Ö¸¶¨Â¥²ã
Â¥Ö÷
AIWROKÈí¼þͼÏñ¶þÖµ»¯µÄ¸÷ÖÖ·½·¨ºÍÓ¦Óó¡¾°
AIWROKÈí¼þͼÏñ¶þÖµ»¯µÄ¸÷ÖÖ·½·¨ºÍÓ¦Óó¡¾° B2BÍøÂçÈí¼þ

AIWROKÈí¼þͼÏñ¶þÖµ»¯µÄ¸÷ÖÖ·½·¨ºÍÓ¦Óó¡¾° B2BÍøÂçÈí¼þ

AIWROKÈí¼þͼÏñ¶þÖµ»¯µÄ¸÷ÖÖ·½·¨ºÍÓ¦Óó¡¾° B2BÍøÂçÈí¼þ

  1. //🍎½»Á÷ QQ Ⱥ 711841924 Ⱥһ£¬Æ»¹ûÄÚ²âȺ£¬528816639
  2. //ÊÊÓñ¾ÎĵµES5ϵͳ°²×¿ JavaScriptÒýÇæRhino

  3. /**
  4. * ͼƬ¶þÖµ»¯Ê¾Àý(¼ò»¯°æ)
  5. * ¹¦ÄÜ˵Ã÷£ºÕ¹Ê¾ÔÚAIWROKÈí¼þÖÐʹÓÃOpenCV½øÐÐͼÏñ¶þÖµ»¯µÄ¸÷ÖÖ·½·¨ºÍÓ¦Óó¡¾°
  6. * ¶þÖµ»¯Ô­Àí£º½«Í¼Ïñת»»ÎªÖ»ÓкںͰ×Á½ÖÖÑÕÉ«µÄ¹ý³Ì£¬³£ÓÃÓÚͼÏñÔ¤´¦Àí¡¢ÌØÕ÷ÌáÈ¡µÈ
  7. */

  8. /**
  9. * »ù±¾¶þÖµ»¯Ê¾Àý
  10. * @param {number} lowThreshold µÍãÐÖµ£¬µÍÓÚ´ËÖµµÄÏñËØ×ªÎªºÚÉ«
  11. * @param {number} highThreshold ¸ßãÐÖµ£¬¸ßÓÚ´ËÖµµÄÏñËØ×ªÎª°×É«
  12. * @returns {Object} °üº¬¶þÖµ»¯½á¹ûµÄ¶ÔÏó
  13. */
  14. function basicThresholdDemo(lowThreshold, highThreshold) {
  15.     printl("Ö´Ðлù±¾¶þÖµ»¯Ê¾Àý...");
  16.    
  17.     // ÉèÖÃĬÈÏãÐÖµ
  18.     lowThreshold = lowThreshold || 50;
  19.     highThreshold = highThreshold || 150;
  20.    
  21.     // »ñÈ¡ÆÁÄ»³ß´ç
  22.     var screenWidth = typeof screen !== 'undefined' && typeof screen.getScreenWidth === 'function' ?
  23.                      screen.getScreenWidth() : 1080;
  24.     var screenHeight = typeof screen !== 'undefined' && typeof screen.getScreenHeight === 'function' ?
  25.                       screen.getScreenHeight() : 1920;
  26.    
  27.     // ½ØÍ¼²¢»ñÈ¡Mat¶ÔÏó
  28.     var screenshot = screen.screenShotFull();
  29.     var mat = screenshot.getMat();
  30.    
  31.     if (!mat) {
  32.         return { error: true, message: "ÎÞ·¨»ñȡͼÏñMat¶ÔÏó" };
  33.     }
  34.    
  35.     printl("ԭͼ´óС: " + screenshot.getWidth() + "x" + screenshot.getHeight());
  36.     printl("ʹÓÃãÐÖµ: " + lowThreshold + " - " + highThreshold);
  37.    
  38.     // Ö´ÐжþÖµ»¯²Ù×÷
  39.     opencv.threshold(mat, lowThreshold, highThreshold);
  40.    
  41.     // Êä³ö½á¹ûÐÅÏ¢
  42.     printl("¶þÖµ»¯ºóMatÐÅÏ¢:");
  43.     printl(mat);
  44.    
  45.     printl("»ù±¾¶þÖµ»¯Íê³É");
  46.    
  47.     return {
  48.         error: false,
  49.         mat: mat,
  50.         message: "»ù±¾¶þÖµ»¯³É¹¦"
  51.     };
  52. }

  53. /**
  54. * ÇøÓò¶þÖµ»¯Ê¾Àý
  55. * @param {number} x ÇøÓòÆðʼx×ø±ê
  56. * @param {number} y ÇøÓòÆðʼy×ø±ê
  57. * @param {number} width ÇøÓò¿í¶È
  58. * @param {number} height ÇøÓò¸ß¶È
  59. * @param {number} threshold ¶þÖµ»¯ãÐÖµ
  60. * @returns {Object} °üº¬¶þÖµ»¯½á¹ûµÄ¶ÔÏó
  61. */
  62. function regionThresholdDemo(x, y, width, height, threshold) {
  63.     printl("Ö´ÐÐÇøÓò¶þÖµ»¯Ê¾Àý...");
  64.    
  65.     // »ñÈ¡ÆÁÄ»³ß´ç
  66.     var screenWidth = typeof screen !== 'undefined' && typeof screen.getScreenWidth === 'function' ?
  67.                      screen.getScreenWidth() : 1080;
  68.     var screenHeight = typeof screen !== 'undefined' && typeof screen.getScreenHeight === 'function' ?
  69.                       screen.getScreenHeight() : 1920;
  70.    
  71.     // ĬÈÏÖµÉèÖÃ
  72.     x = x || 0;
  73.     y = y || 0;
  74.     width = width || Math.floor(screenWidth / 2);
  75.     height = height || Math.floor(screenHeight / 2);
  76.     threshold = threshold || 100;
  77.    
  78.     // È·±£ÇøÓò²ÎÊýÔÚÓÐЧ·¶Î§ÄÚ
  79.     x = Math.max(0, x);
  80.     y = Math.max(0, y);
  81.     width = Math.min(screenWidth - x, width);
  82.     height = Math.min(screenHeight - y, height);
  83.    
  84.     printl("ÇøÓò´óС: " + width + "x" + height);
  85.     printl("ÇøÓòλÖÃ: (" + x + ", " + y + ")");
  86.     printl("ʹÓÃãÐÖµ: " + threshold);
  87.    
  88.     // ½ØÍ¼
  89.     var fullScreenshot = screen.screenShotFull();
  90.     var fullMat = fullScreenshot.getMat();
  91.    
  92.     if (!fullMat) {
  93.         return { error: true, message: "ÎÞ·¨»ñȡͼÏñMat¶ÔÏó" };
  94.     }
  95.    
  96.     // ʹÓÃsubmat·½·¨ÌáÈ¡ÇøÓò¶ø²»ÊÇextractRegion
  97.     var mat = fullMat.submat(y, y + height, x, x + width);
  98.    
  99.     if (!mat) {
  100.         return { error: true, message: "ÎÞ·¨»ñÈ¡ÇøÓòͼÏñMat¶ÔÏó" };
  101.     }
  102.    
  103.     // Êä³öÌáÈ¡µÄÇøÓòÐÅÏ¢
  104.     printl("ÌáÈ¡ÇøÓòºóMatÐÅÏ¢:");
  105.     printl(mat);
  106.    
  107.     // Ö´ÐжþÖµ»¯²Ù×÷
  108.     opencv.threshold(mat, threshold, 255);
  109.    
  110.     // Êä³ö¶þÖµ»¯ºóµÄ½á¹û
  111.     printl("ÇøÓò¶þÖµ»¯ºóMatÐÅÏ¢:");
  112.     printl(mat);
  113.    
  114.     printl("ÇøÓò¶þÖµ»¯Íê³É");
  115.    
  116.     return {
  117.         error: false,
  118.         mat: mat,
  119.         message: "ÇøÓò¶þÖµ»¯³É¹¦"
  120.     };
  121. }

  122. /**
  123. * ¶àãÐÖµ¶Ô±È¶þÖµ»¯Ê¾Àý
  124. * չʾ²»Í¬ãÐÖµ¶Ô¶þÖµ»¯½á¹ûµÄÓ°Ïì
  125. */
  126. function multiThresholdComparison() {
  127.     printl("Ö´ÐжàãÐÖµ¶Ô±È¶þÖµ»¯Ê¾Àý...");
  128.    
  129.     // »ñÈ¡ÆÁÄ»³ß´ç
  130.     var screenWidth = typeof screen !== 'undefined' && typeof screen.getScreenWidth === 'function' ?
  131.                      screen.getScreenWidth() : 1080;
  132.     var screenHeight = typeof screen !== 'undefined' && typeof screen.getScreenHeight === 'function' ?
  133.                       screen.getScreenHeight() : 1920;
  134.    
  135.     // ½ØÍ¼²¢»ñȡԭʼMat¶ÔÏó
  136.     var screenshot = screen.screenShotFull();
  137.     var originalMat = screenshot.getMat();
  138.    
  139.     if (!originalMat) {
  140.         printl("ÎÞ·¨»ñȡͼÏñMat¶ÔÏó");
  141.         return false;
  142.     }
  143.    
  144.     // ¶¨ÒåÒª²âÊÔµÄãÐÖµ×éºÏ
  145.     var thresholdSets = [
  146.         { low: 30, high: 100, name: "µÍãÐÖµ" },
  147.         { low: 80, high: 180, name: "ÖеÈãÐÖµ" },
  148.         { low: 120, high: 220, name: "¸ßãÐÖµ" }
  149.     ];
  150.    
  151.     // ¶Ôÿ¸öãÐÖµ×éºÏÖ´ÐжþÖµ»¯
  152.     for (var i = 0; i < thresholdSets.length; i++) {
  153.         var set = thresholdSets[i];
  154.         printl("\n²âÊÔ" + set.name + ": µÍ=" + set.low + ", ¸ß=" + set.high);
  155.         
  156.         // ´´½¨Ô­Ê¼Í¼ÏñµÄ¸±±¾ÒÔ±ÜÃâÐÞ¸Äԭͼ
  157.         var matCopy = originalMat.clone();
  158.         
  159.         // Ö´ÐжþÖµ»¯
  160.         opencv.threshold(matCopy, set.low, set.high);
  161.         
  162.         // Êä³ö½á¹ûÐÅÏ¢
  163.         printl(set.name + "¶þÖµ»¯ºóMatÐÅÏ¢:");
  164.         printl(matCopy);
  165.         
  166.         // ¿ÉÒÔÔÚÕâÀォ½á¹û±£´æ»òÏÔʾ
  167.         printl(set.name + "¶þÖµ»¯Íê³É");
  168.     }
  169.    
  170.     printl("\n¶àãÐÖµ¶Ô±ÈÍê³É");
  171.     return true;
  172. }

  173. /**
  174. * »Ò¶Èת»»ºó¶þÖµ»¯Ê¾Àý
  175. * ÏȽ«Í¼ÏñתΪ»Ò¶È£¬ÔÙ½øÐжþÖµ»¯´¦Àí
  176. */
  177. function grayThenThresholdDemo() {
  178.     printl("Ö´ÐлҶÈת»»ºó¶þÖµ»¯Ê¾Àý...");
  179.    
  180.     // »ñÈ¡ÆÁÄ»³ß´ç
  181.     var screenWidth = typeof screen !== 'undefined' && typeof screen.getScreenWidth === 'function' ?
  182.                      screen.getScreenWidth() : 1080;
  183.     var screenHeight = typeof screen !== 'undefined' && typeof screen.getScreenHeight === 'function' ?
  184.                       screen.getScreenHeight() : 1920;
  185.    
  186.     // ½ØÍ¼
  187.     var screenshot = screen.screenShotFull();
  188.     var mat = screenshot.getMat();
  189.    
  190.     if (!mat) {
  191.         return { error: true, message: "ÎÞ·¨»ñȡͼÏñMat¶ÔÏó" };
  192.     }
  193.    
  194.     // ÏÈת»»Îª»Ò¶Èͼ
  195.     printl("ת»»Îª»Ò¶Èͼ...");
  196.     opencv.toGray(mat);
  197.    
  198.     // Êä³ö»Ò¶ÈͼÐÅÏ¢
  199.     printl("»Ò¶ÈͼMatÐÅÏ¢:");
  200.     printl(mat);
  201.    
  202.     // ÔÙ½øÐжþÖµ»¯
  203.     printl("Ö´ÐжþÖµ»¯...");
  204.     opencv.threshold(mat, 80, 200);
  205.    
  206.     // Êä³ö¶þÖµ»¯ºóµÄ½á¹û
  207.     printl("»Ò¶Èºó¶þÖµ»¯MatÐÅÏ¢:");
  208.     printl(mat);
  209.    
  210.     printl("»Ò¶Èºó¶þÖµ»¯Íê³É");
  211.    
  212.     return {
  213.         error: false,
  214.         mat: mat,
  215.         message: "»Ò¶Èת»»ºó¶þÖµ»¯³É¹¦"
  216.     };
  217. }

  218. /**
  219. * Ó¦Ó󡾰ʾÀý£º¶þÖµ»¯ºó½øÐÐÂÖÀª¼ì²â
  220. * @param {number} threshold ¶þÖµ»¯ãÐÖµ
  221. */
  222. function thresholdForContourDetection(threshold) {
  223.     printl("Ö´ÐжþÖµ»¯ºóÂÖÀª¼ì²âʾÀý...");
  224.    
  225.     threshold = threshold || 100;
  226.    
  227.     // »ñÈ¡ÆÁÄ»³ß´ç
  228.     var screenWidth = typeof screen !== 'undefined' && typeof screen.getScreenWidth === 'function' ?
  229.                      screen.getScreenWidth() : 1080;
  230.     var screenHeight = typeof screen !== 'undefined' && typeof screen.getScreenHeight === 'function' ?
  231.                       screen.getScreenHeight() : 1920;
  232.    
  233.     // ½ØÍ¼²¢×ª»»Îª»Ò¶È
  234.     var screenshot = screen.screenShotFull();
  235.     var mat = screenshot.getMat();
  236.    
  237.     if (!mat) {
  238.         printl("ÎÞ·¨»ñȡͼÏñMat¶ÔÏó");
  239.         return false;
  240.     }
  241.    
  242.     // ת»»Îª»Ò¶Èͼ
  243.     opencv.toGray(mat);
  244.    
  245.     // Êä³ö»Ò¶ÈͼÐÅÏ¢
  246.     printl("»Ò¶ÈͼMatÐÅÏ¢:");
  247.     printl(mat);
  248.    
  249.     // ¶þÖµ»¯
  250.     opencv.threshold(mat, threshold, 255);
  251.    
  252.     // Êä³ö¶þÖµ»¯ºóµÄ½á¹û
  253.     printl("¶þÖµ»¯ºóMatÐÅÏ¢:");
  254.     printl(mat);
  255.    
  256.     // ½øÐÐÂÖÀª¼ì²â
  257.     printl("½øÐÐÂÖÀª¼ì²â...");
  258.     var contours = opencv.getContours(mat);
  259.    
  260.     if (contours && contours.length > 0) {
  261.         printl("ÕÒµ½ " + contours.length + " ¸öÂÖÀª");
  262.         
  263.         // ¿ÉÒÔÔÚÕâÀï¶ÔÂÖÀª½øÐнøÒ»²½´¦Àí
  264.         for (var i = 0; i < Math.min(5, contours.length); i++) { // Ö»ÏÔʾǰ5¸öÂÖÀªÐÅÏ¢
  265.             var contour = contours[i];
  266.             printl("ÂÖÀª " + (i+1) + ": λÖÃ(" + contour.x + "," + contour.y + "), ´óС " + contour.width + "x" + contour.height);
  267.         }
  268.     } else {
  269.         printl("δÕÒµ½ÂÖÀª");
  270.     }
  271.    
  272.     printl("ÂÖÀª¼ì²âʾÀýÍê³É");
  273.     return true;
  274. }

  275. /**
  276. * Ó¦Ó󡾰ʾÀý£º¶þÖµ»¯ºó½øÐÐOCRʶ±ð
  277. * ¶ÔÎÄ×ÖÇøÓò½øÐжþÖµ»¯ÒÔÌá¸ßOCRʶ±ðÂÊ
  278. * @param {number} x ÎÄ×ÖÇøÓòx×ø±ê
  279. * @param {number} y ÎÄ×ÖÇøÓòy×ø±ê
  280. * @param {number} width ÎÄ×ÖÇøÓò¿í¶È
  281. * @param {number} height ÎÄ×ÖÇøÓò¸ß¶È
  282. */
  283. function thresholdForOCRDemo(x, y, width, height) {
  284.     printl("Ö´ÐжþÖµ»¯ºóOCRʶ±ðʾÀý...");
  285.    
  286.     // »ñÈ¡ÆÁÄ»³ß´ç
  287.     var screenWidth = typeof screen !== 'undefined' && typeof screen.getScreenWidth === 'function' ?
  288.                      screen.getScreenWidth() : 1080;
  289.     var screenHeight = typeof screen !== 'undefined' && typeof screen.getScreenHeight === 'function' ?
  290.                       screen.getScreenHeight() : 1920;
  291.    
  292.     // ĬÈÏÖµÉèÖà - ʹÓÃÆÁÄ»ÖÐÐÄÇøÓò
  293.     x = x || Math.floor(screenWidth / 4);
  294.     y = y || Math.floor(screenHeight / 4);
  295.     width = width || Math.floor(screenWidth / 2);
  296.     height = height || Math.floor(screenHeight / 4);
  297.    
  298.     // È·±£ÇøÓò²ÎÊýÔÚÓÐЧ·¶Î§ÄÚ
  299.     x = Math.max(0, x);
  300.     y = Math.max(0, y);
  301.     width = Math.min(screenWidth - x, width);
  302.     height = Math.min(screenHeight - y, height);
  303.    
  304.     printl("ÎÄ×ÖÇøÓò: (" + x + "," + y + ") " + width + "x" + height);
  305.    
  306.     // ½ØÍ¼
  307.     var fullScreenshot = screen.screenShotFull();
  308.     var fullMat = fullScreenshot.getMat();
  309.    
  310.     if (!fullMat) {
  311.         printl("ÎÞ·¨»ñȡͼÏñMat¶ÔÏó");
  312.         return false;
  313.     }
  314.    
  315.     // ʹÓÃsubmat·½·¨ÌáÈ¡ÇøÓò
  316.     var mat = fullMat.submat(y, y + height, x, x + width);
  317.    
  318.     if (!mat) {
  319.         printl("ÎÞ·¨»ñÈ¡ÎÄ×ÖÇøÓòͼÏñ");
  320.         return false;
  321.     }
  322.    
  323.     printl("ÌáÈ¡µÄÎÄ×ÖÇøÓòMatÐÅÏ¢:");
  324.     printl(mat);
  325.    
  326.     printl("ÎÄ×ÖÇøÓò: (" + x + "," + y + ") " + width + "x" + height);
  327.    
  328.     // Ô¤´¦Àí£º×ª»»Îª»Ò¶È
  329.     opencv.toGray(mat);
  330.    
  331.     // Êä³ö»Ò¶ÈͼÐÅÏ¢
  332.     printl("ÎÄ×ÖÇøÓò»Ò¶ÈͼÐÅÏ¢:");
  333.     printl(mat);
  334.    
  335.     // ¶þÖµ»¯ - ÎÄ×Öʶ±ðͨ³£ÐèÒª½Ï¸ßµÄãÐÖµÀ´Í»³öÎÄ×Ö
  336.     opencv.threshold(mat, 100, 200);
  337.    
  338.     // Êä³ö¶þÖµ»¯ºóµÄ½á¹û
  339.     printl("ÎÄ×ÖÇøÓò¶þÖµ»¯ºóMatÐÅÏ¢:");
  340.     printl(mat);
  341.    
  342.     printl("¶þÖµ»¯Ô¤´¦ÀíÍê³É£¬×¼±¸OCRʶ±ð");
  343.    
  344.     // ×¢Ò⣺ʵ¼ÊʹÓÃÖУ¬ÕâÀïÓ¦¸Ãµ÷ÓÃAIWROKµÄOCR¹¦ÄÜ
  345.     printl("Ìáʾ£ºÔÚʵ¼ÊÓ¦ÓÃÖУ¬ÕâÀïÓ¦µ÷ÓÃocr.recognize()»òÆäËûOCR·½·¨");
  346.    
  347.     return true;
  348. }

  349. /**
  350. * ×ÔÊÊÓ¦ãÐÖµ¶þÖµ»¯Ä£Äâ
  351. * Ä£Äâ×ÔÊÊÓ¦ãÐÖµµÄЧ¹û£¬Í¨¹ý¶ÔͼÏñ²»Í¬ÇøÓòʹÓò»Í¬ãÐÖµ
  352. * @param {number} blockSize ¿é´óС
  353. */
  354. function adaptiveThresholdSimulation(blockSize) {
  355.     printl("Ö´ÐÐ×ÔÊÊÓ¦ãÐÖµ¶þÖµ»¯Ä£Äâ...");
  356.    
  357.     blockSize = blockSize || 4; // ½«Í¼Ïñ·Ö³ÉblockSize x blockSize¿é
  358.    
  359.     // »ñÈ¡ÆÁÄ»³ß´ç
  360.     var screenWidth = typeof screen !== 'undefined' && typeof screen.getScreenWidth === 'function' ?
  361.                      screen.getScreenWidth() : 1080;
  362.     var screenHeight = typeof screen !== 'undefined' && typeof screen.getScreenHeight === 'function' ?
  363.                       screen.getScreenHeight() : 1920;
  364.    
  365.     var screenshot = screen.screenShotFull();
  366.     var mat = screenshot.getMat();
  367.    
  368.     if (!mat) {
  369.         printl("ÎÞ·¨»ñȡͼÏñMat¶ÔÏó");
  370.         return false;
  371.     }
  372.    
  373.     var imgWidth = screenshot.getWidth();
  374.     var imgHeight = screenshot.getHeight();
  375.    
  376.     // ¼ÆËãÿ¸ö¿éµÄ´óС
  377.     var blockW = Math.floor(imgWidth / blockSize);
  378.     var blockH = Math.floor(imgHeight / blockSize);
  379.    
  380.     printl("ͼÏñ·Ö¸îΪ " + blockSize + "x" + blockSize + " ¿é£¬Ã¿¿é´óСԼ " + blockW + "x" + blockH);
  381.    
  382.     // ת»»Îª»Ò¶Èͼ
  383.     opencv.toGray(mat);
  384.    
  385.     // Êä³ö»Ò¶ÈͼÐÅÏ¢
  386.     printl("ÕûÌå»Ò¶ÈͼÐÅÏ¢:");
  387.     printl(mat);
  388.    
  389.     // ¶Ôÿ¸ö¿éʹÓò»Í¬µÄãÐÖµ£¨ÕâÀïʹÓüòµ¥µÄËæ»úãÐֵģÄâ×ÔÊÊӦЧ¹û£©
  390.     for (var i = 0; i < blockSize; i++) {
  391.         for (var j = 0; j < blockSize; j++) {
  392.             // ¼ÆËã¿éµÄ×ø±ê
  393.             var blockX = i * blockW;
  394.             var blockY = j * blockH;
  395.             var currentBlockW = (i === blockSize - 1) ? imgWidth - blockX : blockW;
  396.             var currentBlockH = (j === blockSize - 1) ? imgHeight - blockY : blockH;
  397.             
  398.             // È·±£ÇøÓò²ÎÊýÓÐЧ
  399.             currentBlockW = Math.min(currentBlockW, imgWidth - blockX);
  400.             currentBlockH = Math.min(currentBlockH, imgHeight - blockY);
  401.             
  402.             // Ϊÿ¸ö¿éÉú³ÉÒ»¸öËæ»úãÐÖµ£¨ÔÚÒ»¶¨·¶Î§ÄÚ£©
  403.             var blockThreshold = 80 + Math.floor(Math.random() * 60);
  404.             
  405.             // ʹÓÃsubmat·½·¨ÌáÈ¡ÇøÓò
  406.             if (blockY + currentBlockH <= imgHeight && blockX + currentBlockW <= imgWidth) {
  407.                 var blockMat = mat.submat(blockY, blockY + currentBlockH, blockX, blockX + currentBlockW);
  408.                
  409.                 // Êä³ö¿éÐÅÏ¢
  410.                 printl("´¦Àí¿é(" + i + "," + j + ")£¬×ø±ê:(" + blockX + "," + blockY + ")£¬´óС:" + currentBlockW + "x" + currentBlockH);
  411.                
  412.                 // ¶Ô¿é½øÐжþÖµ»¯
  413.                 opencv.threshold(blockMat, blockThreshold, 200);
  414.                
  415.                 // Êä³ö¿é¶þÖµ»¯ºóµÄ½á¹û
  416.                 printl("¿é(" + i + "," + j + ")¶þÖµ»¯ºó:");
  417.                 printl(blockMat);
  418.             }
  419.         }
  420.     }
  421.    
  422.     printl("×ÔÊÊÓ¦ãÐֵģÄâÍê³É£¬×îÖÕMatÐÅÏ¢:");
  423.     printl(mat);
  424.    
  425.     return true;
  426. }

  427. /**
  428. * Ö÷º¯Êý£ºÔËÐÐËùÓжþÖµ»¯Ê¾Àý
  429. */
  430. function runAllThresholdDemos() {
  431.     printl("==================================================");
  432.     printl("                ͼƬ¶þÖµ»¯Ê¾Àý¼¯");
  433.     printl("==================================================\n");
  434.    
  435.     // ¼ì²é»·¾³
  436.     if (typeof opencv === 'undefined') {
  437.         printl("´íÎó: δÕÒµ½OpenCVÄ£¿é£¬ÇëÈ·±£ÔÚAIWROK»·¾³ÖÐÔËÐÐ");
  438.         return;
  439.     }
  440.    
  441.     // »ñÈ¡ÆÁÄ»³ß´ç
  442.     var screenWidth = typeof screen !== 'undefined' && typeof screen.getScreenWidth === 'function' ?
  443.                      screen.getScreenWidth() : 1080;
  444.     var screenHeight = typeof screen !== 'undefined' && typeof screen.getScreenHeight === 'function' ?
  445.                       screen.getScreenHeight() : 1920;
  446.    
  447.     printl("µ±Ç°ÆÁÄ»³ß´ç: " + screenWidth + "x" + screenHeight);
  448.    
  449.     // 1. »ù±¾¶þÖµ»¯Ê¾Àý
  450.     printl("1. »ù±¾¶þÖµ»¯Ê¾Àý");
  451.     basicThresholdDemo(50, 150);
  452.     printl("----------------------------------------\n");
  453.    
  454.     // 2. ÇøÓò¶þÖµ»¯Ê¾Àý
  455.     printl("2. ÇøÓò¶þÖµ»¯Ê¾Àý");
  456.     // ʹÓÃÆÁÄ»ÖÐÐĵÄÒ»¸öÇøÓò
  457.     var regionX = Math.floor(screenWidth / 4);
  458.     var regionY = Math.floor(screenHeight / 4);
  459.     var regionWidth = Math.floor(screenWidth / 2);
  460.     var regionHeight = Math.floor(screenHeight / 3);
  461.     regionThresholdDemo(regionX, regionY, regionWidth, regionHeight, 100);
  462.     printl("----------------------------------------\n");
  463.    
  464.     safeSleep(1000); // Ìí¼ÓÑÓ³Ù£¬±ÜÃâÁ¬Ðø²Ù×÷¹ý¿ì
  465.    
  466.     // 3. ¶àãÐÖµ¶Ô±È
  467.     printl("3. ¶àãÐÖµ¶Ô±ÈʾÀý");
  468.     multiThresholdComparison();
  469.     printl("----------------------------------------\n");
  470.    
  471.     // 4. »Ò¶Èºó¶þÖµ»¯
  472.     printl("4. »Ò¶Èת»»ºó¶þÖµ»¯Ê¾Àý");
  473.     grayThenThresholdDemo();
  474.     printl("----------------------------------------\n");
  475.    
  476.     safeSleep(1000); // Ìí¼ÓÑÓ³Ù
  477.    
  478.     // 5. ¶þÖµ»¯ºóÂÖÀª¼ì²â
  479.     printl("5. ¶þÖµ»¯ºóÂÖÀª¼ì²âʾÀý");
  480.     thresholdForContourDetection(100);
  481.     printl("----------------------------------------\n");
  482.    
  483.     safeSleep(1000); // Ìí¼ÓÑÓ³Ù
  484.    
  485.     // 6. ¶þÖµ»¯ºóOCRʾÀý
  486.     printl("6. ¶þÖµ»¯ºóOCRʶ±ðʾÀý");
  487.     thresholdForOCRDemo(Math.floor(screenWidth / 4), Math.floor(screenHeight / 3), Math.floor(screenWidth / 2), Math.floor(screenHeight / 4));
  488.     printl("----------------------------------------\n");
  489.    
  490.     safeSleep(1000); // Ìí¼ÓÑÓ³Ù
  491.    
  492.     // 7. ×ÔÊÊÓ¦ãÐֵģÄâ
  493.     printl("7. ×ÔÊÊÓ¦ãÐÖµ¶þÖµ»¯Ä£Äâ");
  494.     adaptiveThresholdSimulation(4);
  495.     printl("----------------------------------------\n");
  496.    
  497.     printl("ËùÓжþÖµ»¯Ê¾ÀýÖ´ÐÐÍê³É£¡");
  498. }

  499. /**
  500. * ¹¤¾ßº¯Êý£º°²È«ÑÓ³Ù
  501. * @param {number} ms ÑÓ³ÙºÁÃëÊý
  502. */
  503. function safeSleep(ms) {
  504.     if (typeof sleep !== 'undefined' && sleep.millisecond) {
  505.         sleep.millisecond(ms);
  506.     } else if (typeof java !== 'undefined') {
  507.         java.lang.Thread.sleep(ms);
  508.     }
  509. }

  510. /**
  511. * ¶þÖµ»¯¹¤¾ßÀà - Ìṩ±ã½ÝµÄ¶þÖµ»¯·½·¨
  512. */
  513. var ThresholdUtils = {
  514.     /**
  515.      * ¿ìËÙ¶þÖµ»¯Í¼Ïñ
  516.      * @param {Object} options ÅäÖÃÑ¡Ïî
  517.      * @returns {Object} ¶þÖµ»¯½á¹û
  518.      */
  519.     quickThreshold: function(options) {
  520.         options = options || {};
  521.         
  522.         // »ñÈ¡ÆÁÄ»³ß´ç
  523.         var screenWidth = typeof screen !== 'undefined' && typeof screen.getScreenWidth === 'function' ?
  524.                          screen.getScreenWidth() : 1080;
  525.         var screenHeight = typeof screen !== 'undefined' && typeof screen.getScreenHeight === 'function' ?
  526.                           screen.getScreenHeight() : 1920;
  527.         
  528.         var screenshot = options.image || screen.screenShotFull();
  529.         var mat = screenshot.getMat();
  530.         
  531.         if (options.toGray !== false) {
  532.             opencv.toGray(mat);
  533.         }
  534.         
  535.         opencv.threshold(
  536.             mat,
  537.             options.lowThreshold || 80,
  538.             options.highThreshold || 200
  539.         );
  540.         
  541.         // Êä³ö½á¹ûÐÅÏ¢
  542.         printl("¿ìËÙ¶þÖµ»¯½á¹û:");
  543.         printl(mat);
  544.         
  545.         return {
  546.             success: true,
  547.             mat: mat
  548.         };
  549.     },
  550.    
  551.     /**
  552.      * ´¦ÀíÎÄ×ÖͼÏñµÄ¶þÖµ»¯²ÎÊý
  553.      * @returns {Object} ÊʺÏÎÄ×ֵĶþÖµ»¯²ÎÊý
  554.      */
  555.     getTextThresholdParams: function() {
  556.         return {
  557.             lowThreshold: 100,
  558.             highThreshold: 220,
  559.             toGray: true
  560.         };
  561.     },
  562.    
  563.     /**
  564.      * ´¦ÀíͼÏñ±ßÔµµÄ¶þÖµ»¯²ÎÊý
  565.      * @returns {Object} ÊʺϱßÔµ¼ì²âµÄ¶þÖµ»¯²ÎÊý
  566.      */
  567.     getEdgeThresholdParams: function() {
  568.         return {
  569.             lowThreshold: 50,
  570.             highThreshold: 150,
  571.             toGray: true
  572.         };
  573.     }
  574. };

  575. // Ö´ÐÐËùÓжþÖµ»¯Ê¾Àý
  576. runAllThresholdDemos();
¸´ÖÆ´úÂë




»Ø¸´

ʹÓõÀ¾ß ¾Ù±¨

¹Ø±Õ

QQ|»ÓªÏúÈí¼þ×ÛºÏÌÖÂÛ|»ÓªÏúÈí¼þÓÐÎʱشð|»ÓªÏúÈí¼þ½Ì³Ì×¨Çø|»ÓªÏúÈí¼þPOST½Å±¾·ÖÏí|»ÓªÏúÈí¼þÆÕͨ½Å±¾·ÖÏí|»ÓªÏúÈí¼þÈí¼þ×ÊѶ|»ÓªÏúÈí¼þ¾«Æ·Èí¼þ|»ÓªÏúÈí¼þ¸üй«¸æ|ÓªÏúÈí¼þ|B2BÈí¼þ|B2BÍøÂçÈí¼þ ( ¾©ICP±¸09078825ºÅ )±¾ÍøÕ¾¿ª·¢µÄÓªÏúÈí¼þÊÇÒ»¿îеÄÍøÂçÓªÏúÈí¼þ£¬Õâ¿îÓªÏú¿ÉÒÔÈ¥ÍøÕ¾Èí¼þ£¬²©¿ÍÈí¼þ£¬B2BÈí¼þ£¬·ÖÀàÐÅÏ¢Íø·¢Ìù£¬¿ÉÒÔÇÀɳ·¢£¬¿ÉÒÔµ½°Ù¶ÈÎÄ¿âÉÏ´«WORDÎĵµ£¬¿ÉÒÔµ½Ò»Ð©ÊÇÏà²áÍøÕ¾×Ô¶¯ÉÏ´«Í¼Æ¬£¬Õâ¸ö×Ô¶¯·¢ÌûÈí¼þ×Ô´øÔÆÖ©Ö룬¼Ó¿ìÊÕ¼£¬ÓÐ6ÖÖ¶Ô½Ó´òÂë½Ó¿Ú£¬·½±ã£¬Ð§Âʸߣ¬Ëٶȿ죬¶øÇÒ¶ÔÍ϶¯µÄÑéÖ¤ÂëÈ«ÍøµÚÒ»¼Ò¶À¼ÒÖ§³Ö£¬È«²¿Ô­´´¼¼Êõ£¬¶À¼ÒÑз¢£¬Õý°æÔ­´´´ø°æÈ¨Èí¼þ¡£Ñ¡ÔñÍòÄÜÓªÏúÈí¼þ£¬¾ÍÑ¡ÔñÁËÒ»ÖÖ׬ǮµÄЧÂÊ£¬´ÓûÓб»³¬Ô½¹ý£¬Ò»Ö±ÔÚŬÁ¦Ñз¢Ð¼¼Êõ¡£·Å·ÉÃÎÏ룬½â·ÅË«ÊÖ£¬À´µã´´Ò⣬³É¾ÍÄãµÄÃÎÏ룬¾ÍÔÚÍòÄÜÓªÏúÈí¼þ¿ªÊ¼

map2

GMT+8, 2025-11-5 13:14 , Processed in 0.174697 second(s), 34 queries .

¿ìËٻظ´ ·µ»Ø¶¥²¿ ·µ»ØÁбí