· 5 years ago · Aug 19, 2020, 05:08 PM
1######### python ########
2
3from kivy.app import App
4from kivy.graphics.texture import Texture
5from kivy.lang import Builder
6import cv2
7import numpy as np
8
9
10KV = """
11
12BoxLayout:
13 orientation: 'vertical'
14 Image:
15 id: im
16 FloatLayout:
17 size_hint_y: .4
18 Button:
19 size_hint: .2, .4
20 text: 'open'
21 pos_hint: {'center_x': .4, 'center_y': .5}
22 on_release:
23 app.open_image()
24 Button:
25 size_hint: .2, .4
26 text: 'clear'
27 pos_hint: {'center_x': .6, 'center_y': .5}
28 on_release:
29 app.clear_image()
30
31"""
32
33
34class OpenCVApp(App):
35
36 def build(self):
37 return Builder.load_string(KV)
38
39 def open_image(self):
40
41 texture = Texture.create(size=(640, 359), colorfmt="rgb")
42 arr = cv2.imread("img.jpg")[::-1]
43 raw_im = arr.tostring()
44 texture.blit_buffer(raw_im, bufferfmt="ubyte", colorfmt="rgb")
45 self.root.ids.im.texture = texture
46
47 def clear_image(self):
48 texture = Texture.create(size=(640, 359), colorfmt="rgb")
49 self.root.ids.im.texture = texture
50
51
52if __name__ == '__main__':
53 app = OpenCVApp()
54 app.run()
55
56##################
57# buildozer #
58##################
59
60[app]
61
62# (str) Title of your application
63title = My Application
64
65# (str) Package name
66package.name = myapp
67
68# (str) Package domain (needed for android/ios packaging)
69package.domain = org.test
70
71# (str) Source code where the main.py live
72source.dir = .
73
74# (list) Source files to include (let empty to include all the files)
75source.include_exts = py,png,jpg,kv,atlas
76
77# (list) List of inclusions using pattern matching
78#source.include_patterns = assets/*,images/*.png
79
80# (list) Source files to exclude (let empty to not exclude anything)
81source.exclude_exts = spec
82
83# (list) List of directory to exclude (let empty to not exclude anything)
84source.exclude_dirs = tests, bin
85
86# (list) List of exclusions using pattern matching
87#source.exclude_patterns = license,images/*/*.jpg
88
89# (str) Application versioning (method 1)
90version = 0.1
91
92# (str) Application versioning (method 2)
93# version.regex = __version__ = ['"](.*)['"]
94# version.filename = %(source.dir)s/main.py
95
96# (list) Application requirements
97# comma separated e.g. requirements = sqlite3,kivy
98requirements = python3,kivy==master,opencv,numpy
99
100# (str) Custom source folders for requirements
101# Sets custom source for any requirements with recipes
102# requirements.source.kivy = ../../kivy
103
104# (list) Garden requirements
105#garden_requirements =
106
107# (str) Presplash of the application
108#presplash.filename = %(source.dir)s/data/presplash.png
109
110# (str) Icon of the application
111#icon.filename = %(source.dir)s/data/icon.png
112
113# (str) Supported orientation (one of landscape, sensorLandscape, portrait or all)
114orientation = landscape
115
116# (list) List of service to declare
117#services = NAME:ENTRYPOINT_TO_PY,NAME2:ENTRYPOINT2_TO_PY
118
119#
120# OSX Specific
121#
122
123#
124# author = © Copyright Info
125
126# change the major version of python used by the app
127osx.python_version = 3
128
129# Kivy version to use
130osx.kivy_version = 1.9.1
131
132#
133# Android specific
134#
135
136# (bool) Indicate if the application should be fullscreen or not
137fullscreen = 0
138
139# (string) Presplash background color (for new android toolchain)
140# Supported formats are: #RRGGBB #AARRGGBB or one of the following names:
141# red, blue, green, black, white, gray, cyan, magenta, yellow, lightgray,
142# darkgray, grey, lightgrey, darkgrey, aqua, fuchsia, lime, maroon, navy,
143# olive, purple, silver, teal.
144#android.presplash_color = #FFFFFF
145
146# (list) Permissions
147#android.permissions = WRITE_EXTERNAL_STORAGE,READ_EXTERNAL_STORAGE
148
149# (int) Target Android API, should be as high as possible.
150android.api = 29
151
152# (int) Minimum API your APK will support.
153#android.minapi = 21
154
155# (int) Android SDK version to use
156#android.sdk = 20
157
158# (str) Android NDK version to use
159#android.ndk = 19b
160
161# (int) Android NDK API to use. This is the minimum API your app will support, it should usually match android.minapi.
162#android.ndk_api = 21
163
164# (bool) Use --private data storage (True) or --dir public storage (False)
165#android.private_storage = True
166
167# (str) Android NDK directory (if empty, it will be automatically downloaded.)
168#android.ndk_path =
169
170# (str) Android SDK directory (if empty, it will be automatically downloaded.)
171#android.sdk_path =
172
173# (str) ANT directory (if empty, it will be automatically downloaded.)
174#android.ant_path =
175
176# (bool) If True, then skip trying to update the Android sdk
177# This can be useful to avoid excess Internet downloads or save time
178# when an update is due and you just want to test/build your package
179android.skip_update = True
180
181# (bool) If True, then automatically accept SDK license
182# agreements. This is intended for automation only. If set to False,
183# the default, you will be shown the license when first running
184# buildozer.
185android.accept_sdk_license = True
186
187# (str) Android entry point, default is ok for Kivy-based app
188#android.entrypoint = org.renpy.android.PythonActivity
189
190# (str) Android app theme, default is ok for Kivy-based app
191# android.apptheme = "@android:style/Theme.NoTitleBar"
192
193# (list) Pattern to whitelist for the whole project
194#android.whitelist =
195
196# (str) Path to a custom whitelist file
197#android.whitelist_src =
198
199# (str) Path to a custom blacklist file
200#android.blacklist_src =
201
202# (list) List of Java .jar files to add to the libs so that pyjnius can access
203# their classes. Don't add jars that you do not need, since extra jars can slow
204# down the build process. Allows wildcards matching, for example:
205# OUYA-ODK/libs/*.jar
206#android.add_jars = foo.jar,bar.jar,path/to/more/*.jar
207
208# (list) List of Java files to add to the android project (can be java or a
209# directory containing the files)
210#android.add_src =
211
212# (list) Android AAR archives to add (currently works only with sdl2_gradle
213# bootstrap)
214#android.add_aars =
215
216# (list) Gradle dependencies to add (currently works only with sdl2_gradle
217# bootstrap)
218#android.gradle_dependencies =
219
220# (list) add java compile options
221# this can for example be necessary when importing certain java libraries using the 'android.gradle_dependencies' option
222# see https://developer.android.com/studio/write/java8-support for further information
223# android.add_compile_options = "sourceCompatibility = 1.8", "targetCompatibility = 1.8"
224
225# (list) Gradle repositories to add {can be necessary for some android.gradle_dependencies}
226# please enclose in double quotes
227# e.g. android.gradle_repositories = "maven { url 'https://kotlin.bintray.com/ktor' }"
228#android.add_gradle_repositories =
229
230# (list) packaging options to add
231# see https://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.PackagingOptions.html
232# can be necessary to solve conflicts in gradle_dependencies
233# please enclose in double quotes
234# e.g. android.add_packaging_options = "exclude 'META-INF/common.kotlin_module'", "exclude 'META-INF/*.kotlin_module'"
235#android.add_gradle_repositories =
236
237# (list) Java classes to add as activities to the manifest.
238#android.add_activities = com.example.ExampleActivity
239
240# (str) OUYA Console category. Should be one of GAME or APP
241# If you leave this blank, OUYA support will not be enabled
242#android.ouya.category = GAME
243
244# (str) Filename of OUYA Console icon. It must be a 732x412 png image.
245#android.ouya.icon.filename = %(source.dir)s/data/ouya_icon.png
246
247# (str) XML file to include as an intent filters in <activity> tag
248#android.manifest.intent_filters =
249
250# (str) launchMode to set for the main activity
251#android.manifest.launch_mode = standard
252
253# (list) Android additional libraries to copy into libs/armeabi
254#android.add_libs_armeabi = libs/android/*.so
255#android.add_libs_armeabi_v7a = libs/android-v7/*.so
256android.add_libs_arm64_v8a = libs/android-v8/*.so
257#android.add_libs_x86 = libs/android-x86/*.so
258#android.add_libs_mips = libs/android-mips/*.so
259
260# (bool) Indicate whether the screen should stay on
261# Don't forget to add the WAKE_LOCK permission if you set this to True
262#android.wakelock = False
263
264# (list) Android application meta-data to set (key=value format)
265#android.meta_data =
266
267# (list) Android library project to add (will be added in the
268# project.properties automatically.)
269#android.library_references =
270
271# (list) Android shared libraries which will be added to AndroidManifest.xml using <uses-library> tag
272#android.uses_library =
273
274# (str) Android logcat filters to use
275android.logcat_filters = *:S python:D
276
277# (bool) Copy library instead of making a libpymodules.so
278#android.copy_libs = 1
279
280# (str) The Android arch to build for, choices: armeabi-v7a, arm64-v8a, x86, x86_64
281android.arch = armeabi-v7a
282
283# (int) overrides automatic versionCode computation (used in build.gradle)
284# this is not the same as app version and should only be edited if you know what you're doing
285# android.numeric_version = 1
286
287#
288# Python for android (p4a) specific
289#
290
291# (str) python-for-android fork to use, defaults to upstream (kivy)
292#p4a.fork = kivy
293
294# (str) python-for-android branch to use, defaults to master
295#p4a.branch = master
296
297# (str) python-for-android git clone directory (if empty, it will be automatically cloned from github)
298#p4a.source_dir =
299
300# (str) The directory in which python-for-android should look for your own build recipes (if any)
301#p4a.local_recipes =
302
303# (str) Filename to the hook for p4a
304#p4a.hook =
305
306# (str) Bootstrap to use for android builds
307# p4a.bootstrap = sdl2
308
309# (int) port number to specify an explicit --port= p4a argument (eg for bootstrap flask)
310#p4a.port =
311
312
313#
314# iOS specific
315#
316
317# (str) Path to a custom kivy-ios folder
318#ios.kivy_ios_dir = ../kivy-ios
319# Alternately, specify the URL and branch of a git checkout:
320ios.kivy_ios_url = https://github.com/kivy/kivy-ios
321ios.kivy_ios_branch = master
322
323# Another platform dependency: ios-deploy
324# Uncomment to use a custom checkout
325#ios.ios_deploy_dir = ../ios_deploy
326# Or specify URL and branch
327ios.ios_deploy_url = https://github.com/phonegap/ios-deploy
328ios.ios_deploy_branch = 1.7.0
329
330# (str) Name of the certificate to use for signing the debug version
331# Get a list of available identities: buildozer ios list_identities
332#ios.codesign.debug = "iPhone Developer: <lastname> <firstname> (<hexstring>)"
333
334# (str) Name of the certificate to use for signing the release version
335#ios.codesign.release = %(ios.codesign.debug)s
336
337
338[buildozer]
339
340# (int) Log level (0 = error only, 1 = info, 2 = debug (with command output))
341log_level = 2
342
343# (int) Display warning if buildozer is run as root (0 = False, 1 = True)
344warn_on_root = 1
345
346# (str) Path to build artifact storage, absolute or relative to spec file
347# build_dir = ./.buildozer
348
349# (str) Path to build output (i.e. .apk, .ipa) storage
350# bin_dir = ./bin
351
352# -----------------------------------------------------------------------------
353# List as sections
354#
355# You can define all the "list" as [section:key].
356# Each line will be considered as a option to the list.
357# Let's take [app] / source.exclude_patterns.
358# Instead of doing:
359#
360#[app]
361#source.exclude_patterns = license,data/audio/*.wav,data/images/original/*
362#
363# This can be translated into:
364#
365#[app:source.exclude_patterns]
366#license
367#data/audio/*.wav
368#data/images/original/*
369#
370
371
372# -----------------------------------------------------------------------------
373# Profiles
374#
375# You can extend section / key with a profile
376# For example, you want to deploy a demo version of your application without
377# HD content. You could first change the title to add "(demo)" in the name
378# and extend the excluded directories to remove the HD content.
379#
380#[app@demo]
381#title = My Application (demo)
382#
383#[app:source.exclude_patterns@demo]
384#images/hd/*
385#
386# Then, invoke the command line with the "demo" profile:
387#
388#buildozer --profile demo android debug
389