Kivy安卓实战:9 |Kivy现实opencv结果| 寫個工具箱把9 - 图1
© Karobben

由於語法渲染問題而影響閱讀體驗, 請移步博客閱讀~
本文GitPage地址

  1. CryptoWatch-Kivy 1.13
  2. Kivy 2.0.0
  3. Kivy-Garden 0.1.4
  4. kivy-garden.wordcloud 1.0.0
  5. kivymd 0.104.2.dev0

Quick Review

  1. tree
  1. .
  2. ├── 123.fa
  3. ├── 123.html
  4. ├── Karobben_logo_horizontal_800.png
  5. ├── LICENSE
  6. ├── Layout
  7. ├── Blog.kv
  8. ├── CV_cm.kv
  9. ├── CV_test.kv
  10. ├── Data_table.kv
  11. ├── Font.kv
  12. ├── Navigation_Draw.kv
  13. ├── Navigation_Tabs.kv
  14. ├── Seq.kv
  15. ├── editor.kv
  16. ├── filechooser.kv
  17. └── menu.kv
  18. ├── README.md
  19. ├── alipay.jpg
  20. ├── buildozer.spec
  21. ├── config
  22. ├── Navi.json
  23. └── home.json
  24. ├── custom_camera
  25. ├── __init__.py
  26. ├── custom_camera.kv
  27. └── custom_camera.py
  28. ├── demo
  29. ├── clustal
  30. └── echart
  31. ├── favicon.ico
  32. ├── font
  33. ├── ArtificialBox-WdD4.ttf
  34. ├── FangZhengHeiTiFanTi-1.ttf
  35. ├── FangZhengHeiTiJianTi-1.ttf
  36. ├── FangZhengKaiTiPinYinZiKu-1.ttf
  37. ├── FangzhenXiaozhuan.ttf
  38. ├── HuaKangXinZhuanTi-1.ttf
  39. ├── JingDianFanJiaoZhuan-1.ttf
  40. ├── heydings-controls-1.ttf
  41. ├── heydings-icons-1.ttf
  42. ├── heydings-icons-2.ttf
  43. └── icon-works-webfont-2.ttf
  44. ├── image_processing
  45. ├── __init__.py
  46. ├── cascades
  47. └── haarcascade_frontalface_default.xml
  48. └── image_processing.py
  49. ├── libWidget
  50. ├── Blog.py
  51. ├── CV_cm.py
  52. ├── CV_test.py
  53. ├── Data_table.py
  54. ├── Font.py
  55. ├── Seq.py
  56. ├── editor.py
  57. ├── filechooser.py
  58. ├── menu.py
  59. └── model.txt
  60. ├── libs
  61. ├── bio_seq.py
  62. ├── clustalo.py
  63. ├── clustalo.pytxt
  64. ├── web_open.py
  65. └── webview.py
  66. ├── logo.png
  67. ├── main.py
  68. └── wepay.png

Function for Close Tab

This script originally contributed by okajun35 in GitHub.

CV_cm.py

  1. # -*- coding: utf-8 -*
  2. import numpy as np
  3. import cv2
  4. from kivy.uix.boxlayout import BoxLayout
  5. from PIL import Image
  6. from kivy.lang import Builder
  7. from kivy.uix.widget import Widget
  8. from kivy.graphics.texture import Texture
  9. from kivy.graphics import Rectangle
  10. class FunctionWidget():
  11. def main(self):
  12. Builder.unload_file("Layout/test.kv")
  13. self.Function_page = Builder.load_file("Layout/test.kv")
  14. self.Function_page.ids.button_load.on_release= self.run
  15. return self.Function_page
  16. def run(self, *args):
  17. img = cv2.imread('logo.png')
  18. img = cv2.cvtColor(img,cv2.COLOR_BGR2RGB)
  19. # 画像をグレイスケールに変換
  20. #gray_img = cv2.cvtColor(img,1)
  21. texture = Texture.create(size=(img.shape[1], img.shape[0]), colorfmt='rgb', bufferfmt='ubyte') # BGRモードで用意,ubyteはデフォルト引数なので指定なくてもよい
  22. texture.blit_buffer(img.tostring(),colorfmt='rgb', bufferfmt='ubyte') # ★ここもBGRで指定しないとRGBになって色の表示がおかしくなる
  23. texture.flip_vertical()
  24. self.Function_page.show_pic = texture

Layout

CV_cm.kv

  1. BoxLayout:
  2. orientation: "vertical"
  3. show_pic: None
  4. BoxLayout:
  5. canvas:
  6. Rectangle:
  7. texture: root.show_pic
  8. pos: self.pos
  9. size: self.size
  10. #pos_hint: {'center_x': .5, 'center_y': .5}
  11. #color: 0, 0, 0, 1
  12. BoxLayout:
  13. orientation: "vertical"
  14. BoxLayout
  15. MDRaisedButton:
  16. id: button_load
  17. text: 'F'
  18. font_size: 30
  19. font_name: './font/heydings-icons-1'
  20. width: root.width * 0.5
  21. line_color: 1, 1, 1, 1

It works on PC not in androied. And I don’t know why.


Enjoy~

本文由Python腳本GitHub/語雀自動更新

由於語法渲染問題而影響閱讀體驗, 請移步博客閱讀~
本文GitPage地址

GitHub: Karobben
Blog:Karobben
BiliBili:史上最不正經的生物狗