pyxllib 0.3.96__py3-none-any.whl → 0.3.200__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (358) hide show
  1. pyxllib/__init__.py +21 -21
  2. pyxllib/algo/__init__.py +8 -8
  3. pyxllib/algo/disjoint.py +54 -54
  4. pyxllib/algo/geo.py +541 -529
  5. pyxllib/algo/intervals.py +964 -964
  6. pyxllib/algo/matcher.py +389 -311
  7. pyxllib/algo/newbie.py +166 -166
  8. pyxllib/algo/pupil.py +629 -461
  9. pyxllib/algo/shapelylib.py +67 -67
  10. pyxllib/algo/specialist.py +241 -240
  11. pyxllib/algo/stat.py +494 -458
  12. pyxllib/algo/treelib.py +149 -149
  13. pyxllib/algo/unitlib.py +66 -66
  14. {pyxlpr → pyxllib/autogui}/__init__.py +5 -5
  15. pyxllib/autogui/activewin.py +246 -0
  16. pyxllib/autogui/all.py +9 -0
  17. pyxllib/{ext/autogui → autogui}/autogui.py +852 -823
  18. pyxllib/autogui/uiautolib.py +362 -0
  19. pyxllib/{ext/autogui → autogui}/virtualkey.py +102 -102
  20. pyxllib/autogui/wechat.py +827 -0
  21. pyxllib/autogui/wechat_msg.py +421 -0
  22. pyxllib/autogui/wxautolib.py +84 -0
  23. pyxllib/cv/__init__.py +5 -5
  24. pyxllib/cv/expert.py +267 -267
  25. pyxllib/cv/imfile.py +159 -159
  26. pyxllib/cv/imhash.py +39 -39
  27. pyxllib/cv/pupil.py +9 -9
  28. pyxllib/cv/rgbfmt.py +1525 -1525
  29. pyxllib/cv/slidercaptcha.py +137 -0
  30. pyxllib/cv/trackbartools.py +251 -251
  31. pyxllib/cv/xlcvlib.py +1040 -1040
  32. pyxllib/cv/xlpillib.py +423 -423
  33. pyxllib/data/echarts.py +240 -129
  34. pyxllib/data/jsonlib.py +89 -0
  35. pyxllib/data/oss.py +72 -72
  36. pyxllib/data/pglib.py +1127 -643
  37. pyxllib/data/sqlite.py +568 -341
  38. pyxllib/data/sqllib.py +297 -297
  39. pyxllib/ext/JLineViewer.py +505 -492
  40. pyxllib/ext/__init__.py +6 -6
  41. pyxllib/ext/demolib.py +246 -246
  42. pyxllib/ext/drissionlib.py +277 -0
  43. pyxllib/ext/kq5034lib.py +12 -1606
  44. pyxllib/ext/old.py +663 -663
  45. pyxllib/ext/qt.py +449 -449
  46. pyxllib/ext/robustprocfile.py +497 -0
  47. pyxllib/ext/seleniumlib.py +76 -76
  48. pyxllib/ext/tk.py +173 -173
  49. pyxllib/ext/unixlib.py +827 -826
  50. pyxllib/ext/utools.py +351 -338
  51. pyxllib/ext/webhook.py +124 -101
  52. pyxllib/ext/win32lib.py +40 -40
  53. pyxllib/ext/wjxlib.py +88 -0
  54. pyxllib/ext/wpsapi.py +124 -0
  55. pyxllib/ext/xlwork.py +9 -0
  56. pyxllib/ext/yuquelib.py +1105 -173
  57. pyxllib/file/__init__.py +17 -17
  58. pyxllib/file/docxlib.py +761 -761
  59. pyxllib/file/gitlib.py +309 -309
  60. pyxllib/file/libreoffice.py +165 -0
  61. pyxllib/file/movielib.py +148 -139
  62. pyxllib/file/newbie.py +10 -10
  63. pyxllib/file/onenotelib.py +1469 -1469
  64. pyxllib/file/packlib/__init__.py +330 -293
  65. pyxllib/file/packlib/zipfile.py +2441 -2441
  66. pyxllib/file/pdflib.py +426 -426
  67. pyxllib/file/pupil.py +185 -185
  68. pyxllib/file/specialist/__init__.py +685 -685
  69. pyxllib/file/specialist/dirlib.py +799 -799
  70. pyxllib/file/specialist/download.py +193 -186
  71. pyxllib/file/specialist/filelib.py +2829 -2618
  72. pyxllib/file/xlsxlib.py +3131 -2976
  73. pyxllib/file/xlsyncfile.py +341 -0
  74. pyxllib/prog/__init__.py +5 -5
  75. pyxllib/prog/cachetools.py +64 -0
  76. pyxllib/prog/deprecatedlib.py +233 -233
  77. pyxllib/prog/filelock.py +42 -0
  78. pyxllib/prog/ipyexec.py +253 -253
  79. pyxllib/prog/multiprogs.py +940 -0
  80. pyxllib/prog/newbie.py +451 -444
  81. pyxllib/prog/pupil.py +1197 -1128
  82. pyxllib/prog/sitepackages.py +33 -33
  83. pyxllib/prog/specialist/__init__.py +391 -217
  84. pyxllib/prog/specialist/bc.py +203 -200
  85. pyxllib/prog/specialist/browser.py +497 -488
  86. pyxllib/prog/specialist/common.py +347 -347
  87. pyxllib/prog/specialist/datetime.py +199 -131
  88. pyxllib/prog/specialist/tictoc.py +240 -241
  89. pyxllib/prog/specialist/xllog.py +180 -180
  90. pyxllib/prog/xlosenv.py +108 -101
  91. pyxllib/stdlib/__init__.py +17 -17
  92. pyxllib/stdlib/tablepyxl/__init__.py +10 -10
  93. pyxllib/stdlib/tablepyxl/style.py +303 -303
  94. pyxllib/stdlib/tablepyxl/tablepyxl.py +130 -130
  95. pyxllib/text/__init__.py +8 -8
  96. pyxllib/text/ahocorasick.py +39 -39
  97. pyxllib/text/airscript.js +744 -0
  98. pyxllib/text/charclasslib.py +121 -109
  99. pyxllib/text/jiebalib.py +267 -264
  100. pyxllib/text/jinjalib.py +32 -0
  101. pyxllib/text/jsa_ai_prompt.md +271 -0
  102. pyxllib/text/jscode.py +922 -767
  103. pyxllib/text/latex/__init__.py +158 -158
  104. pyxllib/text/levenshtein.py +303 -303
  105. pyxllib/text/nestenv.py +1215 -1215
  106. pyxllib/text/newbie.py +300 -288
  107. pyxllib/text/pupil/__init__.py +8 -8
  108. pyxllib/text/pupil/common.py +1121 -1095
  109. pyxllib/text/pupil/xlalign.py +326 -326
  110. pyxllib/text/pycode.py +47 -47
  111. pyxllib/text/specialist/__init__.py +8 -8
  112. pyxllib/text/specialist/common.py +112 -112
  113. pyxllib/text/specialist/ptag.py +186 -186
  114. pyxllib/text/spellchecker.py +172 -172
  115. pyxllib/text/templates/echart_base.html +11 -0
  116. pyxllib/text/templates/highlight_code.html +17 -0
  117. pyxllib/text/templates/latex_editor.html +103 -0
  118. pyxllib/text/vbacode.py +17 -17
  119. pyxllib/text/xmllib.py +747 -685
  120. pyxllib/xl.py +42 -38
  121. pyxllib/xlcv.py +17 -17
  122. pyxllib-0.3.200.dist-info/METADATA +48 -0
  123. pyxllib-0.3.200.dist-info/RECORD +126 -0
  124. {pyxllib-0.3.96.dist-info → pyxllib-0.3.200.dist-info}/WHEEL +1 -2
  125. {pyxllib-0.3.96.dist-info → pyxllib-0.3.200.dist-info/licenses}/LICENSE +190 -190
  126. pyxllib/ext/autogui/__init__.py +0 -8
  127. pyxllib-0.3.96.dist-info/METADATA +0 -51
  128. pyxllib-0.3.96.dist-info/RECORD +0 -333
  129. pyxllib-0.3.96.dist-info/top_level.txt +0 -2
  130. pyxlpr/ai/__init__.py +0 -5
  131. pyxlpr/ai/clientlib.py +0 -1281
  132. pyxlpr/ai/specialist.py +0 -286
  133. pyxlpr/ai/torch_app.py +0 -172
  134. pyxlpr/ai/xlpaddle.py +0 -655
  135. pyxlpr/ai/xltorch.py +0 -705
  136. pyxlpr/data/__init__.py +0 -11
  137. pyxlpr/data/coco.py +0 -1325
  138. pyxlpr/data/datacls.py +0 -365
  139. pyxlpr/data/datasets.py +0 -200
  140. pyxlpr/data/gptlib.py +0 -1291
  141. pyxlpr/data/icdar/__init__.py +0 -96
  142. pyxlpr/data/icdar/deteval.py +0 -377
  143. pyxlpr/data/icdar/icdar2013.py +0 -341
  144. pyxlpr/data/icdar/iou.py +0 -340
  145. pyxlpr/data/icdar/rrc_evaluation_funcs_1_1.py +0 -463
  146. pyxlpr/data/imtextline.py +0 -473
  147. pyxlpr/data/labelme.py +0 -866
  148. pyxlpr/data/removeline.py +0 -179
  149. pyxlpr/data/specialist.py +0 -57
  150. pyxlpr/eval/__init__.py +0 -85
  151. pyxlpr/paddleocr.py +0 -776
  152. pyxlpr/ppocr/__init__.py +0 -15
  153. pyxlpr/ppocr/configs/rec/multi_language/generate_multi_language_configs.py +0 -226
  154. pyxlpr/ppocr/data/__init__.py +0 -135
  155. pyxlpr/ppocr/data/imaug/ColorJitter.py +0 -26
  156. pyxlpr/ppocr/data/imaug/__init__.py +0 -67
  157. pyxlpr/ppocr/data/imaug/copy_paste.py +0 -170
  158. pyxlpr/ppocr/data/imaug/east_process.py +0 -437
  159. pyxlpr/ppocr/data/imaug/gen_table_mask.py +0 -244
  160. pyxlpr/ppocr/data/imaug/iaa_augment.py +0 -114
  161. pyxlpr/ppocr/data/imaug/label_ops.py +0 -789
  162. pyxlpr/ppocr/data/imaug/make_border_map.py +0 -184
  163. pyxlpr/ppocr/data/imaug/make_pse_gt.py +0 -106
  164. pyxlpr/ppocr/data/imaug/make_shrink_map.py +0 -126
  165. pyxlpr/ppocr/data/imaug/operators.py +0 -433
  166. pyxlpr/ppocr/data/imaug/pg_process.py +0 -906
  167. pyxlpr/ppocr/data/imaug/randaugment.py +0 -143
  168. pyxlpr/ppocr/data/imaug/random_crop_data.py +0 -239
  169. pyxlpr/ppocr/data/imaug/rec_img_aug.py +0 -533
  170. pyxlpr/ppocr/data/imaug/sast_process.py +0 -777
  171. pyxlpr/ppocr/data/imaug/text_image_aug/__init__.py +0 -17
  172. pyxlpr/ppocr/data/imaug/text_image_aug/augment.py +0 -120
  173. pyxlpr/ppocr/data/imaug/text_image_aug/warp_mls.py +0 -168
  174. pyxlpr/ppocr/data/lmdb_dataset.py +0 -115
  175. pyxlpr/ppocr/data/pgnet_dataset.py +0 -104
  176. pyxlpr/ppocr/data/pubtab_dataset.py +0 -107
  177. pyxlpr/ppocr/data/simple_dataset.py +0 -372
  178. pyxlpr/ppocr/losses/__init__.py +0 -61
  179. pyxlpr/ppocr/losses/ace_loss.py +0 -52
  180. pyxlpr/ppocr/losses/basic_loss.py +0 -135
  181. pyxlpr/ppocr/losses/center_loss.py +0 -88
  182. pyxlpr/ppocr/losses/cls_loss.py +0 -30
  183. pyxlpr/ppocr/losses/combined_loss.py +0 -67
  184. pyxlpr/ppocr/losses/det_basic_loss.py +0 -208
  185. pyxlpr/ppocr/losses/det_db_loss.py +0 -80
  186. pyxlpr/ppocr/losses/det_east_loss.py +0 -63
  187. pyxlpr/ppocr/losses/det_pse_loss.py +0 -149
  188. pyxlpr/ppocr/losses/det_sast_loss.py +0 -121
  189. pyxlpr/ppocr/losses/distillation_loss.py +0 -272
  190. pyxlpr/ppocr/losses/e2e_pg_loss.py +0 -140
  191. pyxlpr/ppocr/losses/kie_sdmgr_loss.py +0 -113
  192. pyxlpr/ppocr/losses/rec_aster_loss.py +0 -99
  193. pyxlpr/ppocr/losses/rec_att_loss.py +0 -39
  194. pyxlpr/ppocr/losses/rec_ctc_loss.py +0 -44
  195. pyxlpr/ppocr/losses/rec_enhanced_ctc_loss.py +0 -70
  196. pyxlpr/ppocr/losses/rec_nrtr_loss.py +0 -30
  197. pyxlpr/ppocr/losses/rec_sar_loss.py +0 -28
  198. pyxlpr/ppocr/losses/rec_srn_loss.py +0 -47
  199. pyxlpr/ppocr/losses/table_att_loss.py +0 -109
  200. pyxlpr/ppocr/metrics/__init__.py +0 -44
  201. pyxlpr/ppocr/metrics/cls_metric.py +0 -45
  202. pyxlpr/ppocr/metrics/det_metric.py +0 -82
  203. pyxlpr/ppocr/metrics/distillation_metric.py +0 -73
  204. pyxlpr/ppocr/metrics/e2e_metric.py +0 -86
  205. pyxlpr/ppocr/metrics/eval_det_iou.py +0 -274
  206. pyxlpr/ppocr/metrics/kie_metric.py +0 -70
  207. pyxlpr/ppocr/metrics/rec_metric.py +0 -75
  208. pyxlpr/ppocr/metrics/table_metric.py +0 -50
  209. pyxlpr/ppocr/modeling/architectures/__init__.py +0 -32
  210. pyxlpr/ppocr/modeling/architectures/base_model.py +0 -88
  211. pyxlpr/ppocr/modeling/architectures/distillation_model.py +0 -60
  212. pyxlpr/ppocr/modeling/backbones/__init__.py +0 -54
  213. pyxlpr/ppocr/modeling/backbones/det_mobilenet_v3.py +0 -268
  214. pyxlpr/ppocr/modeling/backbones/det_resnet_vd.py +0 -246
  215. pyxlpr/ppocr/modeling/backbones/det_resnet_vd_sast.py +0 -285
  216. pyxlpr/ppocr/modeling/backbones/e2e_resnet_vd_pg.py +0 -265
  217. pyxlpr/ppocr/modeling/backbones/kie_unet_sdmgr.py +0 -186
  218. pyxlpr/ppocr/modeling/backbones/rec_mobilenet_v3.py +0 -138
  219. pyxlpr/ppocr/modeling/backbones/rec_mv1_enhance.py +0 -258
  220. pyxlpr/ppocr/modeling/backbones/rec_nrtr_mtb.py +0 -48
  221. pyxlpr/ppocr/modeling/backbones/rec_resnet_31.py +0 -210
  222. pyxlpr/ppocr/modeling/backbones/rec_resnet_aster.py +0 -143
  223. pyxlpr/ppocr/modeling/backbones/rec_resnet_fpn.py +0 -307
  224. pyxlpr/ppocr/modeling/backbones/rec_resnet_vd.py +0 -286
  225. pyxlpr/ppocr/modeling/heads/__init__.py +0 -54
  226. pyxlpr/ppocr/modeling/heads/cls_head.py +0 -52
  227. pyxlpr/ppocr/modeling/heads/det_db_head.py +0 -118
  228. pyxlpr/ppocr/modeling/heads/det_east_head.py +0 -121
  229. pyxlpr/ppocr/modeling/heads/det_pse_head.py +0 -37
  230. pyxlpr/ppocr/modeling/heads/det_sast_head.py +0 -128
  231. pyxlpr/ppocr/modeling/heads/e2e_pg_head.py +0 -253
  232. pyxlpr/ppocr/modeling/heads/kie_sdmgr_head.py +0 -206
  233. pyxlpr/ppocr/modeling/heads/multiheadAttention.py +0 -163
  234. pyxlpr/ppocr/modeling/heads/rec_aster_head.py +0 -393
  235. pyxlpr/ppocr/modeling/heads/rec_att_head.py +0 -202
  236. pyxlpr/ppocr/modeling/heads/rec_ctc_head.py +0 -88
  237. pyxlpr/ppocr/modeling/heads/rec_nrtr_head.py +0 -826
  238. pyxlpr/ppocr/modeling/heads/rec_sar_head.py +0 -402
  239. pyxlpr/ppocr/modeling/heads/rec_srn_head.py +0 -280
  240. pyxlpr/ppocr/modeling/heads/self_attention.py +0 -406
  241. pyxlpr/ppocr/modeling/heads/table_att_head.py +0 -246
  242. pyxlpr/ppocr/modeling/necks/__init__.py +0 -32
  243. pyxlpr/ppocr/modeling/necks/db_fpn.py +0 -111
  244. pyxlpr/ppocr/modeling/necks/east_fpn.py +0 -188
  245. pyxlpr/ppocr/modeling/necks/fpn.py +0 -138
  246. pyxlpr/ppocr/modeling/necks/pg_fpn.py +0 -314
  247. pyxlpr/ppocr/modeling/necks/rnn.py +0 -92
  248. pyxlpr/ppocr/modeling/necks/sast_fpn.py +0 -284
  249. pyxlpr/ppocr/modeling/necks/table_fpn.py +0 -110
  250. pyxlpr/ppocr/modeling/transforms/__init__.py +0 -28
  251. pyxlpr/ppocr/modeling/transforms/stn.py +0 -135
  252. pyxlpr/ppocr/modeling/transforms/tps.py +0 -308
  253. pyxlpr/ppocr/modeling/transforms/tps_spatial_transformer.py +0 -156
  254. pyxlpr/ppocr/optimizer/__init__.py +0 -61
  255. pyxlpr/ppocr/optimizer/learning_rate.py +0 -228
  256. pyxlpr/ppocr/optimizer/lr_scheduler.py +0 -49
  257. pyxlpr/ppocr/optimizer/optimizer.py +0 -160
  258. pyxlpr/ppocr/optimizer/regularizer.py +0 -52
  259. pyxlpr/ppocr/postprocess/__init__.py +0 -55
  260. pyxlpr/ppocr/postprocess/cls_postprocess.py +0 -33
  261. pyxlpr/ppocr/postprocess/db_postprocess.py +0 -234
  262. pyxlpr/ppocr/postprocess/east_postprocess.py +0 -143
  263. pyxlpr/ppocr/postprocess/locality_aware_nms.py +0 -200
  264. pyxlpr/ppocr/postprocess/pg_postprocess.py +0 -52
  265. pyxlpr/ppocr/postprocess/pse_postprocess/__init__.py +0 -15
  266. pyxlpr/ppocr/postprocess/pse_postprocess/pse/__init__.py +0 -29
  267. pyxlpr/ppocr/postprocess/pse_postprocess/pse/setup.py +0 -14
  268. pyxlpr/ppocr/postprocess/pse_postprocess/pse_postprocess.py +0 -118
  269. pyxlpr/ppocr/postprocess/rec_postprocess.py +0 -654
  270. pyxlpr/ppocr/postprocess/sast_postprocess.py +0 -355
  271. pyxlpr/ppocr/tools/__init__.py +0 -14
  272. pyxlpr/ppocr/tools/eval.py +0 -83
  273. pyxlpr/ppocr/tools/export_center.py +0 -77
  274. pyxlpr/ppocr/tools/export_model.py +0 -129
  275. pyxlpr/ppocr/tools/infer/predict_cls.py +0 -151
  276. pyxlpr/ppocr/tools/infer/predict_det.py +0 -300
  277. pyxlpr/ppocr/tools/infer/predict_e2e.py +0 -169
  278. pyxlpr/ppocr/tools/infer/predict_rec.py +0 -414
  279. pyxlpr/ppocr/tools/infer/predict_system.py +0 -204
  280. pyxlpr/ppocr/tools/infer/utility.py +0 -629
  281. pyxlpr/ppocr/tools/infer_cls.py +0 -83
  282. pyxlpr/ppocr/tools/infer_det.py +0 -134
  283. pyxlpr/ppocr/tools/infer_e2e.py +0 -122
  284. pyxlpr/ppocr/tools/infer_kie.py +0 -153
  285. pyxlpr/ppocr/tools/infer_rec.py +0 -146
  286. pyxlpr/ppocr/tools/infer_table.py +0 -107
  287. pyxlpr/ppocr/tools/program.py +0 -596
  288. pyxlpr/ppocr/tools/test_hubserving.py +0 -117
  289. pyxlpr/ppocr/tools/train.py +0 -163
  290. pyxlpr/ppocr/tools/xlprog.py +0 -748
  291. pyxlpr/ppocr/utils/EN_symbol_dict.txt +0 -94
  292. pyxlpr/ppocr/utils/__init__.py +0 -24
  293. pyxlpr/ppocr/utils/dict/ar_dict.txt +0 -117
  294. pyxlpr/ppocr/utils/dict/arabic_dict.txt +0 -162
  295. pyxlpr/ppocr/utils/dict/be_dict.txt +0 -145
  296. pyxlpr/ppocr/utils/dict/bg_dict.txt +0 -140
  297. pyxlpr/ppocr/utils/dict/chinese_cht_dict.txt +0 -8421
  298. pyxlpr/ppocr/utils/dict/cyrillic_dict.txt +0 -163
  299. pyxlpr/ppocr/utils/dict/devanagari_dict.txt +0 -167
  300. pyxlpr/ppocr/utils/dict/en_dict.txt +0 -63
  301. pyxlpr/ppocr/utils/dict/fa_dict.txt +0 -136
  302. pyxlpr/ppocr/utils/dict/french_dict.txt +0 -136
  303. pyxlpr/ppocr/utils/dict/german_dict.txt +0 -143
  304. pyxlpr/ppocr/utils/dict/hi_dict.txt +0 -162
  305. pyxlpr/ppocr/utils/dict/it_dict.txt +0 -118
  306. pyxlpr/ppocr/utils/dict/japan_dict.txt +0 -4399
  307. pyxlpr/ppocr/utils/dict/ka_dict.txt +0 -153
  308. pyxlpr/ppocr/utils/dict/korean_dict.txt +0 -3688
  309. pyxlpr/ppocr/utils/dict/latin_dict.txt +0 -185
  310. pyxlpr/ppocr/utils/dict/mr_dict.txt +0 -153
  311. pyxlpr/ppocr/utils/dict/ne_dict.txt +0 -153
  312. pyxlpr/ppocr/utils/dict/oc_dict.txt +0 -96
  313. pyxlpr/ppocr/utils/dict/pu_dict.txt +0 -130
  314. pyxlpr/ppocr/utils/dict/rs_dict.txt +0 -91
  315. pyxlpr/ppocr/utils/dict/rsc_dict.txt +0 -134
  316. pyxlpr/ppocr/utils/dict/ru_dict.txt +0 -125
  317. pyxlpr/ppocr/utils/dict/ta_dict.txt +0 -128
  318. pyxlpr/ppocr/utils/dict/table_dict.txt +0 -277
  319. pyxlpr/ppocr/utils/dict/table_structure_dict.txt +0 -2759
  320. pyxlpr/ppocr/utils/dict/te_dict.txt +0 -151
  321. pyxlpr/ppocr/utils/dict/ug_dict.txt +0 -114
  322. pyxlpr/ppocr/utils/dict/uk_dict.txt +0 -142
  323. pyxlpr/ppocr/utils/dict/ur_dict.txt +0 -137
  324. pyxlpr/ppocr/utils/dict/xi_dict.txt +0 -110
  325. pyxlpr/ppocr/utils/dict90.txt +0 -90
  326. pyxlpr/ppocr/utils/e2e_metric/Deteval.py +0 -574
  327. pyxlpr/ppocr/utils/e2e_metric/polygon_fast.py +0 -83
  328. pyxlpr/ppocr/utils/e2e_utils/extract_batchsize.py +0 -87
  329. pyxlpr/ppocr/utils/e2e_utils/extract_textpoint_fast.py +0 -457
  330. pyxlpr/ppocr/utils/e2e_utils/extract_textpoint_slow.py +0 -592
  331. pyxlpr/ppocr/utils/e2e_utils/pgnet_pp_utils.py +0 -162
  332. pyxlpr/ppocr/utils/e2e_utils/visual.py +0 -162
  333. pyxlpr/ppocr/utils/en_dict.txt +0 -95
  334. pyxlpr/ppocr/utils/gen_label.py +0 -81
  335. pyxlpr/ppocr/utils/ic15_dict.txt +0 -36
  336. pyxlpr/ppocr/utils/iou.py +0 -54
  337. pyxlpr/ppocr/utils/logging.py +0 -69
  338. pyxlpr/ppocr/utils/network.py +0 -84
  339. pyxlpr/ppocr/utils/ppocr_keys_v1.txt +0 -6623
  340. pyxlpr/ppocr/utils/profiler.py +0 -110
  341. pyxlpr/ppocr/utils/save_load.py +0 -150
  342. pyxlpr/ppocr/utils/stats.py +0 -72
  343. pyxlpr/ppocr/utils/utility.py +0 -80
  344. pyxlpr/ppstructure/__init__.py +0 -13
  345. pyxlpr/ppstructure/predict_system.py +0 -187
  346. pyxlpr/ppstructure/table/__init__.py +0 -13
  347. pyxlpr/ppstructure/table/eval_table.py +0 -72
  348. pyxlpr/ppstructure/table/matcher.py +0 -192
  349. pyxlpr/ppstructure/table/predict_structure.py +0 -136
  350. pyxlpr/ppstructure/table/predict_table.py +0 -221
  351. pyxlpr/ppstructure/table/table_metric/__init__.py +0 -16
  352. pyxlpr/ppstructure/table/table_metric/parallel.py +0 -51
  353. pyxlpr/ppstructure/table/table_metric/table_metric.py +0 -247
  354. pyxlpr/ppstructure/table/tablepyxl/__init__.py +0 -13
  355. pyxlpr/ppstructure/table/tablepyxl/style.py +0 -283
  356. pyxlpr/ppstructure/table/tablepyxl/tablepyxl.py +0 -118
  357. pyxlpr/ppstructure/utility.py +0 -71
  358. pyxlpr/xlai.py +0 -10
@@ -0,0 +1,137 @@
1
+ import os
2
+ import cv2
3
+ import numpy as np
4
+ from xlproject.code4101 import XlPath
5
+
6
+ from pyxllib.file.specialist import download_file
7
+ from pyxllib.prog.pupil import is_url
8
+
9
+
10
+ class SliderCaptchaLocator:
11
+ """ 滑动验证码的位置定位
12
+
13
+ 由于缺口一般是一个黑底图,整体颜色是偏暗的,可以利用这个特性来定位列所在位置
14
+ """
15
+
16
+ def __init__(self, background_image_path, slider_image_path=None):
17
+ """
18
+ :param background_image_path: 背景主图片
19
+ :param slider_image_path: 滑动条图片
20
+ """
21
+ # 支持输入是url的情况
22
+ if is_url(background_image_path):
23
+ background_image_path = download_file(background_image_path, temp=True, ext='.png')
24
+ if is_url(slider_image_path):
25
+ slider_image_path = download_file(slider_image_path, temp=True, ext='.png')
26
+ # 初始化图片等数据
27
+ self.image_path = background_image_path
28
+ self.image = cv2.imread(self.image_path)
29
+ self.darkest_rows = None
30
+ self.column_averages = None
31
+ self.enhanced_averages = None
32
+ self.radius = 24
33
+ if slider_image_path is not None:
34
+ # 先读取图片
35
+ template_image = cv2.imread(slider_image_path)
36
+ # 取图片宽度的40%作为radius
37
+ self.radius = int(template_image.shape[1] * 0.4)
38
+
39
+ def select_darkest_part_rows(self, fraction=0.1):
40
+ """
41
+ 选择最暗的部分行,供下游计算列的平均暗度
42
+
43
+ :param float fraction: 最暗行的比例
44
+ :return: 最暗行的图像部分
45
+ """
46
+ if self.darkest_rows is None:
47
+ average_row_values = np.mean(self.image, axis=(1, 2))
48
+ threshold_index = int(len(average_row_values) * fraction)
49
+ darkest_indices = np.argsort(average_row_values)[:threshold_index]
50
+ self.darkest_rows = self.image[darkest_indices]
51
+ return self.darkest_rows
52
+
53
+ def calculate_column_averages(self):
54
+ """
55
+ 计算列的平均强度。
56
+
57
+ :return: 列的平均强度
58
+ """
59
+ if self.column_averages is None:
60
+ rows = self.select_darkest_part_rows()
61
+ column_values = np.mean(rows, axis=0)
62
+ column_intensity = np.mean(column_values, axis=1)
63
+ min_val, max_val = np.min(column_intensity), np.max(column_intensity)
64
+ self.column_averages = ((column_intensity - min_val) / (max_val - min_val) * 255).astype(
65
+ np.uint8) if max_val != min_val else np.zeros_like(column_intensity)
66
+ return self.column_averages
67
+
68
+ def enhance_column_averages(self):
69
+ """
70
+ 增强列平均值,利用验证码的黑度图的对称性,进行一个增强,使得其他非验证码的零散黑条变白
71
+
72
+ :param int radius: 对比半径,这个建议设成模版图宽度的40%~50%
73
+ :return: 增强后的列平均值
74
+ """
75
+ if self.enhanced_averages is None:
76
+ averages = self.calculate_column_averages()
77
+ length = len(averages)
78
+ enhanced = np.zeros_like(averages)
79
+ for i in range(length):
80
+ max_value = averages[i]
81
+ for j in range(1, self.radius // 2 + 1):
82
+ if i - j >= 0 and i + j < length:
83
+ max_value = max(max_value, abs(int(averages[i - j]) - int(averages[i + j])))
84
+ enhanced[i] = max_value
85
+ self.enhanced_averages = enhanced
86
+ return self.enhanced_averages
87
+
88
+ def find_captcha_position(self, threshold=50):
89
+ """
90
+ 查找验证码的位置。
91
+
92
+ :param int threshold: 达到多少像素后,开始计算中位数
93
+ :return: 验证码的列中心位置
94
+ """
95
+ intensities = self.enhance_column_averages()
96
+ indices = []
97
+ for intensity in range(256):
98
+ new_indices = np.where(intensities == intensity)[0]
99
+ if len(indices) + len(new_indices) > threshold:
100
+ indices.extend(new_indices[:threshold - len(indices)])
101
+ break
102
+ indices.extend(new_indices)
103
+ return int(np.median(indices))
104
+
105
+ def draw_red_line(self, position, line_thickness=3):
106
+ """
107
+ 在图像上绘制红线。
108
+
109
+ :param int position: 红线位置
110
+ :param int line_thickness: 线宽
111
+ :return: 绘制红线后的图像
112
+ """
113
+ gray_image = np.tile(self.calculate_column_averages(), (100, 1)).astype(np.uint8)
114
+ color_image = cv2.cvtColor(gray_image, cv2.COLOR_GRAY2BGR)
115
+ cv2.line(color_image, (position, 0), (position, gray_image.shape[0]), (0, 0, 255), line_thickness)
116
+ return color_image
117
+
118
+ def debug(self):
119
+ position = self.find_captcha_position()
120
+ final_image = self.draw_red_line(position)
121
+ cv2.imshow('Image with Red Line', final_image)
122
+ cv2.waitKey(0)
123
+ cv2.destroyAllWindows()
124
+
125
+
126
+ def main():
127
+ os.chdir(XlPath.desktop())
128
+ locator = SliderCaptchaLocator('cap_union_new_getcapbysig.png')
129
+ position = locator.find_captcha_position()
130
+ final_image = locator.draw_red_line(position)
131
+ cv2.imshow('Image with Red Line', final_image)
132
+ cv2.waitKey(0)
133
+ cv2.destroyAllWindows()
134
+
135
+
136
+ if __name__ == '__main__':
137
+ main()
@@ -1,251 +1,251 @@
1
- #!/usr/bin/env python3
2
- # -*- coding: utf-8 -*-
3
- # @Author : 陈坤泽
4
- # @Email : 877362867@qq.com
5
- # @Date : 2020/09/30 10:45
6
-
7
- """
8
- 这个文件默认不加载到cv里,需要使用的时候再导入
9
-
10
- from pyxlib.cv.debugtools import *
11
- """
12
-
13
- import math
14
- import time
15
-
16
- import cv2
17
- import numpy as np
18
-
19
- from pyxllib.prog.specialist import TicToc
20
- from pyxllib.cv.expert import xlcv
21
-
22
-
23
- class TrackbarTool:
24
- """ 滑动条控件组
25
- """
26
-
27
- def __init__(self, winname=None, *, imgproc=None, img=None, flags=1, verbose=0, delay=100):
28
- """
29
- Args:
30
- winname: 窗口名可以不输入,可以从func获取,或者有默认窗口名
31
- imgproc: 有时候明确要对指定的函数进行可视化分析
32
- img: 图片可以不输入,可以内置一个图片
33
- flags: 0 窗口可以调节大小,1 窗口按照图片大小固定
34
- verbose: 0 静默模式,1 显示每次运行时间,2 显示每次运行时间及参数值
35
- delay: 有时候改动滑动条,并不想立即生效,可以设置延时,这里单位是ms
36
- 即如果delay时间段内已经有执行过回调函数,会避免重复执行
37
- """
38
-
39
- if winname is None:
40
- if imgproc:
41
- winname = imgproc.__name__
42
- else:
43
- winname = 'TrackbarTool'
44
-
45
- if img is None:
46
- img = np.zeros([500, 100, 3], dtype='uint8')
47
- else:
48
- img = xlcv.read(img)
49
-
50
- self.winname = winname
51
- self.img = img
52
- cv2.namedWindow(winname, flags)
53
- cv2.imshow(winname, self.img)
54
-
55
- self.imgproc = imgproc
56
- self.trackbar_names = {}
57
-
58
- self.verbose = verbose
59
-
60
- self.delay = delay
61
- self.last_run_time = 0
62
-
63
- @classmethod
64
- def from_album(cls, obj, **kwargs):
65
- """ albumentations的类功能 """
66
-
67
- def imgproc(img, **kws):
68
- f = obj(**kws, p=1) # p是概率,这里做可视化,是百分百执行
69
- return f(image=img)['image']
70
-
71
- return cls(**kwargs, imgproc=imgproc, winname=obj.__name__)
72
-
73
- def imshow(self, img=None):
74
- """ 刷新显示的图片 """
75
- if img is None:
76
- img = self.img
77
- cv2.imshow(self.winname, img)
78
-
79
- def create_trackbar(self, name, count, value=0, *, vmaps=None, on_change=None):
80
- """ 创建一个滑动条
81
-
82
- :param name: 滑动条名称
83
- :param int count: 上限值
84
- :param int value: 初始值
85
- :param list[func(int)] vmaps: 滑动条只能设置整数值,但有些参数不一定是整数,可以写个自定义的映射函数
86
- :param on_change: 自定义,额外扩展的回调函数
87
- :return:
88
- """
89
- if on_change is None:
90
- on_change = self._on_change
91
- self.trackbar_names[name] = {'count': count, 'value': value, 'vmaps': vmaps}
92
- cv2.createTrackbar(name, self.winname, value, count, on_change)
93
-
94
- def default_run(self, **kwargs):
95
- """ 默认执行器,这个在类继承后,基本都是要自定义成自己的功能的
96
-
97
- kwargs里存储了当前所有滑动条的取值
98
- 如果有设置vmap,
99
- """
100
- pass
101
-
102
- def _on_change(self, x):
103
- """ 默认的回调函数,x是对应滑动条当前的取值
104
-
105
- 如果需要对每个特定滑动条做特殊定制操作,可以create_trackbar传入特殊on_change
106
- 这里的_on_change是所有滑动条统一回调版本,不区分是哪个滑动条改动了
107
- """
108
- # 1 记录运行时间
109
- cur_time = time.time() * 1000
110
- if cur_time - self.last_run_time < self.delay:
111
- return
112
- else:
113
- self.last_run_time = cur_time
114
-
115
- # 2 生成、解析滑动条的参数值
116
- kwargs = {}
117
- for k, v in self.trackbar_names.items():
118
- x = cv2.getTrackbarPos(k, self.winname)
119
- if v['vmaps']:
120
- for kk, func in v['vmaps'].items():
121
- kwargs[kk] = func(x)
122
- else:
123
- kwargs[k] = x
124
-
125
- # 3 执行绑定的功能
126
- tt = TicToc()
127
- if self.imgproc:
128
- try:
129
- dst = self.imgproc(self.img, **kwargs)
130
- self.imshow(dst)
131
- except Exception as e:
132
- if 'missing required argument' in e.args[0]:
133
- pass
134
- else:
135
- raise e
136
- else:
137
- self.default_run(**kwargs)
138
-
139
- # 4 是否显示运行信息
140
- if self.verbose == 1:
141
- tt.toc()
142
- elif self.verbose == 2:
143
- tt.toc(kwargs)
144
-
145
- def __getitem__(self, item):
146
- """ 可以通过 Trackbars 来获取滑动条当前值
147
-
148
- :param item: 滑动条名称
149
- 扩展:也支持获取vmaps后对应的名称及值
150
- :return: 当前取值
151
- """
152
- if item in self.trackbar_names:
153
- return cv2.getTrackbarPos(item, self.winname)
154
- else:
155
- for k, v in self.trackbar_names.items():
156
- if v['vmaps'] and item in v['vmaps'].keys():
157
- x = cv2.getTrackbarPos(k, self.winname)
158
- return v['vmaps']['item'](x)
159
-
160
-
161
- class ErodeTool(TrackbarTool):
162
- r""" 腐蚀 erode
163
-
164
- HoughLinesPTool('handwriting/C100001448573-002.png')
165
- """
166
-
167
- def __init__(self, img, winname='ErodeTool', flags=1, *, verbose=2):
168
- super().__init__(winname, img=img, flags=flags, verbose=verbose)
169
- self.create_trackbar('size_x', 100, 15)
170
- self.create_trackbar('size_y', 100, 15)
171
-
172
- def default_run(self, **kwargs):
173
- """ 默认执行器
174
- """
175
- size = kwargs['size_x'], kwargs['size_y']
176
- element = cv2.getStructuringElement(cv2.MORPH_RECT, size)
177
- dst = cv2.erode(self.img, element)
178
- self.imshow(dst)
179
-
180
-
181
- class HoughLinesPTool(TrackbarTool):
182
- r""" 霍夫线段检测
183
-
184
- HoughLinesPTool('handwriting/C100001448573-002.png')
185
- """
186
-
187
- def __init__(self, img, winname='HoughLinesPTool', flags=1, *, verbose=2):
188
- super().__init__(winname, img=img, flags=flags, verbose=verbose)
189
-
190
- # 1 增加控件
191
- # 以像素为单位的距离精度
192
- self.create_trackbar('rho*10', 100, 10, vmaps={'rho': lambda x: x / 10})
193
- # 以弧度为单位的角度精度
194
- self.create_trackbar('theta*pi/360', 10, 2, vmaps={'theta': lambda x: x * math.pi / 360})
195
- # 累加平面的阈值参数
196
- self.create_trackbar('threshold', 200, 80)
197
- # 最低线段长度
198
- self.create_trackbar('minLineLength', 200, 50) # 如果要显示全,这里名称最好只有10个字符,也可能是跟图片尺寸有关,有待进一步观察
199
- # 允许将同一行点与点之间连接起来的最大的距离
200
- self.create_trackbar('maxLineGap', 100, 10)
201
-
202
- # 2 图片预处理,这里暂时用自适应二值化,后面可以把该部分也变成可调试项
203
- if self.img.ndim == 3:
204
- gray_img = cv2.cvtColor(self.img, cv2.COLOR_BGR2GRAY)
205
- else:
206
- gray_img = self.img
207
- self.binary_img = cv2.adaptiveThreshold(gray_img, 255, 0, 1, 11, 3)
208
-
209
- def default_run(self, **kwargs):
210
- """ 默认执行器
211
- """
212
- lines = cv2.HoughLinesP(self.binary_img, kwargs['rho'], kwargs['theta'],
213
- kwargs['threshold'], kwargs['minLineLength'], kwargs['maxLineGap'])
214
- if lines is None: lines = np.array([])
215
- # 处理用二值化,显示用原图
216
- self.imshow(xlcv.lines(self.img, lines))
217
-
218
-
219
- def test_adaptiveThreshold(img=None):
220
- """ 滑动条工具使用方法的示例 """
221
- # 1 图片可以传入路径,这里做一个随机图片
222
- if img is None:
223
- img = np.random.randint(0, 255, [500, 200], dtype='uint8')
224
- else:
225
- img = xlcv.read(img, 0) # 确保是单通道灰度图
226
-
227
- # 2 指定要分析的函数
228
- t = TrackbarTool(imgproc=cv2.adaptiveThreshold, img=img, verbose=2, delay=100)
229
- t.create_trackbar('maxValue', 255, 255) # 添加滑动条:名称,最大值,默认值
230
- # 创建滑动条过程中,可能会报错,因为参数还不全,指定的imgproc还无法运行,可以先不用管
231
- t.create_trackbar('adaptiveMethod', 10, 0)
232
- t.create_trackbar('thresholdType', 10, 1)
233
- t.create_trackbar('blockSize', 100, 11)
234
- t.create_trackbar('C', 20, 3)
235
- # t.imshow(img2) # 临时显式其他图片处理效果。如果需要持久修改,可以更改self.img的值
236
- cv2.waitKey()
237
-
238
-
239
- def test_CoarseDropout(img=None):
240
- """ 做albumentations库里类功能的示例写法 """
241
- import albumentations as A
242
-
243
- if img is None:
244
- img = np.random.randint(0, 255, [500, 200], dtype='uint8')
245
-
246
- t = TrackbarTool.from_album(A.CoarseDropout, img=img, verbose=2)
247
- t.create_trackbar('max_holes', 50, 8)
248
- t.create_trackbar('max_height', 50, 8)
249
- t.create_trackbar('max_width', 50, 8)
250
- t.create_trackbar('fill_value', 255, 0)
251
- cv2.waitKey()
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ # @Author : 陈坤泽
4
+ # @Email : 877362867@qq.com
5
+ # @Date : 2020/09/30 10:45
6
+
7
+ """
8
+ 这个文件默认不加载到cv里,需要使用的时候再导入
9
+
10
+ from pyxlib.cv.debugtools import *
11
+ """
12
+
13
+ import math
14
+ import time
15
+
16
+ import cv2
17
+ import numpy as np
18
+
19
+ from pyxllib.prog.specialist import TicToc
20
+ from pyxllib.cv.expert import xlcv
21
+
22
+
23
+ class TrackbarTool:
24
+ """ 滑动条控件组
25
+ """
26
+
27
+ def __init__(self, winname=None, *, imgproc=None, img=None, flags=1, verbose=0, delay=100):
28
+ """
29
+ Args:
30
+ winname: 窗口名可以不输入,可以从func获取,或者有默认窗口名
31
+ imgproc: 有时候明确要对指定的函数进行可视化分析
32
+ img: 图片可以不输入,可以内置一个图片
33
+ flags: 0 窗口可以调节大小,1 窗口按照图片大小固定
34
+ verbose: 0 静默模式,1 显示每次运行时间,2 显示每次运行时间及参数值
35
+ delay: 有时候改动滑动条,并不想立即生效,可以设置延时,这里单位是ms
36
+ 即如果delay时间段内已经有执行过回调函数,会避免重复执行
37
+ """
38
+
39
+ if winname is None:
40
+ if imgproc:
41
+ winname = imgproc.__name__
42
+ else:
43
+ winname = 'TrackbarTool'
44
+
45
+ if img is None:
46
+ img = np.zeros([500, 100, 3], dtype='uint8')
47
+ else:
48
+ img = xlcv.read(img)
49
+
50
+ self.winname = winname
51
+ self.img = img
52
+ cv2.namedWindow(winname, flags)
53
+ cv2.imshow(winname, self.img)
54
+
55
+ self.imgproc = imgproc
56
+ self.trackbar_names = {}
57
+
58
+ self.verbose = verbose
59
+
60
+ self.delay = delay
61
+ self.last_run_time = 0
62
+
63
+ @classmethod
64
+ def from_album(cls, obj, **kwargs):
65
+ """ albumentations的类功能 """
66
+
67
+ def imgproc(img, **kws):
68
+ f = obj(**kws, p=1) # p是概率,这里做可视化,是百分百执行
69
+ return f(image=img)['image']
70
+
71
+ return cls(**kwargs, imgproc=imgproc, winname=obj.__name__)
72
+
73
+ def imshow(self, img=None):
74
+ """ 刷新显示的图片 """
75
+ if img is None:
76
+ img = self.img
77
+ cv2.imshow(self.winname, img)
78
+
79
+ def create_trackbar(self, name, count, value=0, *, vmaps=None, on_change=None):
80
+ """ 创建一个滑动条
81
+
82
+ :param name: 滑动条名称
83
+ :param int count: 上限值
84
+ :param int value: 初始值
85
+ :param list[func(int)] vmaps: 滑动条只能设置整数值,但有些参数不一定是整数,可以写个自定义的映射函数
86
+ :param on_change: 自定义,额外扩展的回调函数
87
+ :return:
88
+ """
89
+ if on_change is None:
90
+ on_change = self._on_change
91
+ self.trackbar_names[name] = {'count': count, 'value': value, 'vmaps': vmaps}
92
+ cv2.createTrackbar(name, self.winname, value, count, on_change)
93
+
94
+ def default_run(self, **kwargs):
95
+ """ 默认执行器,这个在类继承后,基本都是要自定义成自己的功能的
96
+
97
+ kwargs里存储了当前所有滑动条的取值
98
+ 如果有设置vmap,
99
+ """
100
+ pass
101
+
102
+ def _on_change(self, x):
103
+ """ 默认的回调函数,x是对应滑动条当前的取值
104
+
105
+ 如果需要对每个特定滑动条做特殊定制操作,可以create_trackbar传入特殊on_change
106
+ 这里的_on_change是所有滑动条统一回调版本,不区分是哪个滑动条改动了
107
+ """
108
+ # 1 记录运行时间
109
+ cur_time = time.time() * 1000
110
+ if cur_time - self.last_run_time < self.delay:
111
+ return
112
+ else:
113
+ self.last_run_time = cur_time
114
+
115
+ # 2 生成、解析滑动条的参数值
116
+ kwargs = {}
117
+ for k, v in self.trackbar_names.items():
118
+ x = cv2.getTrackbarPos(k, self.winname)
119
+ if v['vmaps']:
120
+ for kk, func in v['vmaps'].items():
121
+ kwargs[kk] = func(x)
122
+ else:
123
+ kwargs[k] = x
124
+
125
+ # 3 执行绑定的功能
126
+ tt = TicToc()
127
+ if self.imgproc:
128
+ try:
129
+ dst = self.imgproc(self.img, **kwargs)
130
+ self.imshow(dst)
131
+ except Exception as e:
132
+ if 'missing required argument' in e.args[0]:
133
+ pass
134
+ else:
135
+ raise e
136
+ else:
137
+ self.default_run(**kwargs)
138
+
139
+ # 4 是否显示运行信息
140
+ if self.verbose == 1:
141
+ tt.toc()
142
+ elif self.verbose == 2:
143
+ tt.toc(kwargs)
144
+
145
+ def __getitem__(self, item):
146
+ """ 可以通过 Trackbars 来获取滑动条当前值
147
+
148
+ :param item: 滑动条名称
149
+ 扩展:也支持获取vmaps后对应的名称及值
150
+ :return: 当前取值
151
+ """
152
+ if item in self.trackbar_names:
153
+ return cv2.getTrackbarPos(item, self.winname)
154
+ else:
155
+ for k, v in self.trackbar_names.items():
156
+ if v['vmaps'] and item in v['vmaps'].keys():
157
+ x = cv2.getTrackbarPos(k, self.winname)
158
+ return v['vmaps']['item'](x)
159
+
160
+
161
+ class ErodeTool(TrackbarTool):
162
+ r""" 腐蚀 erode
163
+
164
+ HoughLinesPTool('handwriting/C100001448573-002.png')
165
+ """
166
+
167
+ def __init__(self, img, winname='ErodeTool', flags=1, *, verbose=2):
168
+ super().__init__(winname, img=img, flags=flags, verbose=verbose)
169
+ self.create_trackbar('size_x', 100, 15)
170
+ self.create_trackbar('size_y', 100, 15)
171
+
172
+ def default_run(self, **kwargs):
173
+ """ 默认执行器
174
+ """
175
+ size = kwargs['size_x'], kwargs['size_y']
176
+ element = cv2.getStructuringElement(cv2.MORPH_RECT, size)
177
+ dst = cv2.erode(self.img, element)
178
+ self.imshow(dst)
179
+
180
+
181
+ class HoughLinesPTool(TrackbarTool):
182
+ r""" 霍夫线段检测
183
+
184
+ HoughLinesPTool('handwriting/C100001448573-002.png')
185
+ """
186
+
187
+ def __init__(self, img, winname='HoughLinesPTool', flags=1, *, verbose=2):
188
+ super().__init__(winname, img=img, flags=flags, verbose=verbose)
189
+
190
+ # 1 增加控件
191
+ # 以像素为单位的距离精度
192
+ self.create_trackbar('rho*10', 100, 10, vmaps={'rho': lambda x: x / 10})
193
+ # 以弧度为单位的角度精度
194
+ self.create_trackbar('theta*pi/360', 10, 2, vmaps={'theta': lambda x: x * math.pi / 360})
195
+ # 累加平面的阈值参数
196
+ self.create_trackbar('threshold', 200, 80)
197
+ # 最低线段长度
198
+ self.create_trackbar('minLineLength', 200, 50) # 如果要显示全,这里名称最好只有10个字符,也可能是跟图片尺寸有关,有待进一步观察
199
+ # 允许将同一行点与点之间连接起来的最大的距离
200
+ self.create_trackbar('maxLineGap', 100, 10)
201
+
202
+ # 2 图片预处理,这里暂时用自适应二值化,后面可以把该部分也变成可调试项
203
+ if self.img.ndim == 3:
204
+ gray_img = cv2.cvtColor(self.img, cv2.COLOR_BGR2GRAY)
205
+ else:
206
+ gray_img = self.img
207
+ self.binary_img = cv2.adaptiveThreshold(gray_img, 255, 0, 1, 11, 3)
208
+
209
+ def default_run(self, **kwargs):
210
+ """ 默认执行器
211
+ """
212
+ lines = cv2.HoughLinesP(self.binary_img, kwargs['rho'], kwargs['theta'],
213
+ kwargs['threshold'], kwargs['minLineLength'], kwargs['maxLineGap'])
214
+ if lines is None: lines = np.array([])
215
+ # 处理用二值化,显示用原图
216
+ self.imshow(xlcv.lines(self.img, lines))
217
+
218
+
219
+ def test_adaptiveThreshold(img=None):
220
+ """ 滑动条工具使用方法的示例 """
221
+ # 1 图片可以传入路径,这里做一个随机图片
222
+ if img is None:
223
+ img = np.random.randint(0, 255, [500, 200], dtype='uint8')
224
+ else:
225
+ img = xlcv.read(img, 0) # 确保是单通道灰度图
226
+
227
+ # 2 指定要分析的函数
228
+ t = TrackbarTool(imgproc=cv2.adaptiveThreshold, img=img, verbose=2, delay=100)
229
+ t.create_trackbar('maxValue', 255, 255) # 添加滑动条:名称,最大值,默认值
230
+ # 创建滑动条过程中,可能会报错,因为参数还不全,指定的imgproc还无法运行,可以先不用管
231
+ t.create_trackbar('adaptiveMethod', 10, 0)
232
+ t.create_trackbar('thresholdType', 10, 1)
233
+ t.create_trackbar('blockSize', 100, 11)
234
+ t.create_trackbar('C', 20, 3)
235
+ # t.imshow(img2) # 临时显式其他图片处理效果。如果需要持久修改,可以更改self.img的值
236
+ cv2.waitKey()
237
+
238
+
239
+ def test_CoarseDropout(img=None):
240
+ """ 做albumentations库里类功能的示例写法 """
241
+ import albumentations as A
242
+
243
+ if img is None:
244
+ img = np.random.randint(0, 255, [500, 200], dtype='uint8')
245
+
246
+ t = TrackbarTool.from_album(A.CoarseDropout, img=img, verbose=2)
247
+ t.create_trackbar('max_holes', 50, 8)
248
+ t.create_trackbar('max_height', 50, 8)
249
+ t.create_trackbar('max_width', 50, 8)
250
+ t.create_trackbar('fill_value', 255, 0)
251
+ cv2.waitKey()