community
community copied to clipboard
Camera does not work on kivy 2.0.0 Windows10
Software Versions
- Python: v3.9.1 (tags/v3.9.1:1e5d33e, Dec 7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)]
- OS: Windows10
- Kivy :v2.0.0
- Kivy installation method: pip installed in a venv using: python -m pip install kivy[full] kivy_examples; and also python -m pip install kivy[base, media] kivy_examples
Describe the bug App fails to run. [CRITICAL] [Camera ] Unable to find any valuable Camera provider.
Expected behavior The same simple program works properly on kivy 1.11.1
To Reproduce
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.boxlayout import BoxLayout
import time
kv = '''
CameraClick:
orientation: 'vertical'
Camera:
id: camera
resolution: (640, 480)
play: True
Button:
text: 'Capture'
size_hint_y: None
height: '48dp'
on_release: root.capture()
'''
class CameraClick(BoxLayout):
def capture(self):
camera = self.ids.camera
time_str = time.strftime("%Y%m%d_%H%M%S")
camera.export_to_png(f'IMG_{time_str}.png')
print("Captured")
class TestCamera(App):
def build(self):
return Builder.load_string(kv)
TestCamera().run()
Code and Logs and screenshots
(kivymd_venv) C:\Users\ellio\PycharmProjects\KivyMD200>python camtest.py -d
[INFO ] [Logger ] Record log in C:\Users\ellio\.kivy\logs\kivy_20-12-23_3.txt
[INFO ] [deps ] Successfully imported "kivy_deps.gstreamer" 0.3.1
[INFO ] [deps ] Successfully imported "kivy_deps.angle" 0.3.0
[INFO ] [deps ] Successfully imported "kivy_deps.glew" 0.3.0
[INFO ] [deps ] Successfully imported "kivy_deps.sdl2" 0.3.1
[INFO ] [Kivy ] v2.0.0
[INFO ] [Kivy ] Installed at "C:\Users\ellio\kivymd_venv\lib\site-packages\kivy\__init__.py"
[INFO ] [Python ] v3.9.1 (tags/v3.9.1:1e5d33e, Dec 7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)]
[INFO ] [Python ] Interpreter at "C:\Users\ellio\kivymd_venv\Scripts\python.exe"
[INFO ] [Factory ] 186 symbols loaded
[DEBUG ] [Cache ] register <kv.lang> with limit=None, timeout=None
[DEBUG ] [Cache ] register <kv.image> with limit=None, timeout=60
[DEBUG ] [Cache ] register <kv.atlas> with limit=None, timeout=None
[INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_pil (img_ffpyplayer ignored)
[DEBUG ] [Cache ] register <kv.texture> with limit=1000, timeout=60
[DEBUG ] [Cache ] register <kv.shader> with limit=1000, timeout=3600
[DEBUG ] [App ] Loading kv <C:\Users\ellio\PycharmProjects\KivyMD200\testcamera.kv>
[DEBUG ] [App ] kv <C:\Users\ellio\PycharmProjects\KivyMD200\testcamera.kv> not found
[INFO ] [Window ] Provider: sdl2
[INFO ] [GL ] Using the "OpenGL" graphics system
[INFO ] [GL ] GLEW initialization succeeded
[DEBUG ] [GL ] available extensions: b'GL_AMD_multi_draw_indirect GL_AMD_seamless_cubemap_per_texture GL_AMD_vertex_shader_viewport_index GL_AMD_vertex_shader_layer GL_ARB_arrays_of_arrays GL_ARB_base_instance GL_ARB_bindless_texture GL_ARB_blend_func_extended GL_ARB_buffer_storage GL_AR
B_clear_buffer_object GL_ARB_clear_texture GL_ARB_clip_control GL_ARB_color_buffer_float GL_ARB_compatibility GL_ARB_compressed_texture_pixel_storage GL_ARB_conservative_depth GL_ARB_compute_shader GL_ARB_compute_variable_group_size GL_ARB_conditional_render_inverted GL_ARB_copy_buffer GL_ARB_copy
_image GL_ARB_cull_distance GL_ARB_debug_output GL_ARB_depth_buffer_float GL_ARB_depth_clamp GL_ARB_depth_texture GL_ARB_derivative_control GL_ARB_direct_state_access GL_ARB_draw_buffers GL_ARB_draw_buffers_blend GL_ARB_draw_indirect GL_ARB_draw_elements_base_vertex GL_ARB_draw_instanced GL_ARB_en
hanced_layouts GL_ARB_ES2_compatibility GL_ARB_ES3_compatibility GL_ARB_ES3_1_compatibility GL_ARB_ES3_2_compatibility GL_ARB_explicit_attrib_location GL_ARB_explicit_uniform_location GL_ARB_fragment_coord_conventions GL_ARB_fragment_layer_viewport GL_ARB_fragment_program GL_ARB_fragment_program_s
hadow GL_ARB_fragment_shader GL_ARB_fragment_shader_interlock GL_ARB_framebuffer_no_attachments GL_ARB_framebuffer_object GL_ARB_framebuffer_sRGB GL_ARB_geometry_shader4 GL_ARB_get_program_binary GL_ARB_get_texture_sub_image GL_ARB_gl_spirv GL_ARB_gpu_shader5 GL_ARB_gpu_shader_fp64 GL_ARB_gpu_shad
er_int64 GL_ARB_half_float_pixel GL_ARB_half_float_vertex GL_ARB_imaging GL_ARB_indirect_parameters GL_ARB_instanced_arrays GL_ARB_internalformat_query GL_ARB_internalformat_query2 GL_ARB_invalidate_subdata GL_ARB_map_buffer_alignment GL_ARB_map_buffer_range GL_ARB_multi_bind GL_ARB_multi_draw_ind
irect GL_ARB_multisample GL_ARB_multitexture GL_ARB_occlusion_query GL_ARB_occlusion_query2 GL_ARB_parallel_shader_compile GL_ARB_pipeline_statistics_query GL_ARB_pixel_buffer_object GL_ARB_point_parameters GL_ARB_point_sprite GL_ARB_polygon_offset_clamp GL_ARB_post_depth_coverage GL_ARB_program_i
nterface_query GL_ARB_provoking_vertex GL_ARB_query_buffer_object GL_ARB_robust_buffer_access_behavior GL_ARB_robustness GL_ARB_sample_locations GL_ARB_sample_shading GL_ARB_sampler_objects GL_ARB_seamless_cube_map GL_ARB_seamless_cubemap_per_texture GL_ARB_separate_shader_objects GL_ARB_shader_at
omic_counter_ops GL_ARB_shader_atomic_counters GL_ARB_shader_ballot GL_ARB_shader_bit_encoding GL_ARB_shader_clock GL_ARB_shader_draw_parameters GL_ARB_shader_group_vote GL_ARB_shader_image_load_store GL_ARB_shader_image_size GL_ARB_shader_objects GL_ARB_shader_precision GL_ARB_shader_storage_buff
er_object GL_ARB_shader_subroutine GL_ARB_shader_texture_image_samples GL_ARB_shader_texture_lod GL_ARB_shading_language_100 GL_ARB_shader_viewport_layer_array GL_ARB_shading_language_420pack GL_ARB_shading_language_include GL_ARB_shading_language_packing GL_ARB_shadow GL_ARB_sparse_buffer GL_ARB_
sparse_texture GL_ARB_sparse_texture2 GL_ARB_sparse_texture_clamp GL_ARB_spirv_extensions GL_ARB_stencil_texturing GL_ARB_sync GL_ARB_tessellation_shader GL_ARB_texture_barrier GL_ARB_texture_border_clamp GL_ARB_texture_buffer_object GL_ARB_texture_buffer_object_rgb32 GL_ARB_texture_buffer_range G
L_ARB_texture_compression GL_ARB_texture_compression_bptc GL_ARB_texture_compression_rgtc GL_ARB_texture_cube_map GL_ARB_texture_cube_map_array GL_ARB_texture_env_add GL_ARB_texture_env_combine GL_ARB_texture_env_crossbar GL_ARB_texture_env_dot3 GL_ARB_texture_filter_anisotropic GL_ARB_texture_fil
ter_minmax GL_ARB_texture_float GL_ARB_texture_gather GL_ARB_texture_mirror_clamp_to_edge GL_ARB_texture_mirrored_repeat GL_ARB_texture_multisample GL_ARB_texture_non_power_of_two GL_ARB_texture_query_levels GL_ARB_texture_query_lod GL_ARB_texture_rectangle GL_ARB_texture_rg GL_ARB_texture_rgb10_a
2ui GL_ARB_texture_stencil8 GL_ARB_texture_storage GL_ARB_texture_storage_multisample GL_ARB_texture_swizzle GL_ARB_texture_view GL_ARB_timer_query GL_ARB_transform_feedback2 GL_ARB_transform_feedback3 GL_ARB_transform_feedback_instanced GL_ARB_transform_feedback_overflow_query GL_ARB_transpose_ma
trix GL_ARB_uniform_buffer_object GL_ARB_vertex_array_bgra GL_ARB_vertex_array_object GL_ARB_vertex_attrib_64bit GL_ARB_vertex_attrib_binding GL_ARB_vertex_buffer_object GL_ARB_vertex_program GL_ARB_vertex_shader GL_ARB_vertex_type_10f_11f_11f_rev GL_ARB_vertex_type_2_10_10_10_rev GL_ARB_viewport_
array GL_ARB_window_pos GL_ATI_draw_buffers GL_ATI_texture_float GL_ATI_texture_mirror_once GL_S3_s3tc GL_EXT_texture_env_add GL_EXT_abgr GL_EXT_bgra GL_EXT_bindable_uniform GL_EXT_blend_color GL_EXT_blend_equation_separate GL_EXT_blend_func_separate GL_EXT_blend_minmax GL_EXT_blend_subtract GL_EX
T_compiled_vertex_array GL_EXT_Cg_shader GL_EXT_depth_bounds_test GL_EXT_direct_state_access GL_EXT_draw_buffers2 GL_EXT_draw_instanced GL_EXT_draw_range_elements GL_EXT_fog_coord GL_EXT_framebuffer_blit GL_EXT_framebuffer_multisample GL_EXTX_framebuffer_mixed_formats GL_EXT_framebuffer_multisampl
e_blit_scaled GL_EXT_framebuffer_object GL_EXT_framebuffer_sRGB GL_EXT_geometry_shader4 GL_EXT_gpu_program_parameters GL_EXT_gpu_shader4 GL_EXT_multi_draw_arrays GL_EXT_multiview_texture_multisample GL_EXT_multiview_timer_query GL_EXT_packed_depth_stencil GL_EXT_packed_float GL_EXT_packed_pixels G
L_EXT_pixel_buffer_object GL_EXT_point_parameters GL_EXT_polygon_offset_clamp GL_EXT_post_depth_coverage GL_EXT_provoking_vertex GL_EXT_raster_multisample GL_EXT_rescale_normal GL_EXT_secondary_color GL_EXT_separate_shader_objects GL_EXT_separate_specular_color GL_EXT_shader_image_load_formatted G
L_EXT_shader_image_load_store GL_EXT_shader_integer_mix GL_EXT_shadow_funcs GL_EXT_sparse_texture2 GL_EXT_stencil_two_side GL_EXT_stencil_wrap GL_EXT_texture3D GL_EXT_texture_array GL_EXT_texture_buffer_object GL_EXT_texture_compression_dxt1 GL_EXT_texture_compression_latc GL_EXT_texture_compressi
on_rgtc GL_EXT_texture_compression_s3tc GL_EXT_texture_cube_map GL_EXT_texture_edge_clamp GL_EXT_texture_env_combine GL_EXT_texture_env_dot3 GL_EXT_texture_filter_anisotropic GL_EXT_texture_filter_minmax GL_EXT_texture_integer GL_EXT_texture_lod GL_EXT_texture_lod_bias GL_EXT_texture_mirror_clamp
GL_EXT_texture_object GL_EXT_texture_shadow_lod GL_EXT_texture_shared_exponent GL_EXT_texture_sRGB GL_EXT_texture_sRGB_R8 GL_EXT_texture_sRGB_decode GL_EXT_texture_storage GL_EXT_texture_swizzle GL_EXT_timer_query GL_EXT_transform_feedback2 GL_EXT_vertex_array GL_EXT_vertex_array_bgra GL_EXT_verte
x_attrib_64bit GL_EXT_window_rectangles GL_EXT_import_sync_object GL_IBM_rasterpos_clip GL_IBM_texture_mirrored_repeat GL_KHR_context_flush_control GL_KHR_debug GL_EXT_memory_object GL_EXT_memory_object_win32 GL_EXT_win32_keyed_mutex GL_KHR_parallel_shader_compile GL_KHR_no_error GL_KHR_robust_buf
fer_access_behavior GL_KHR_robustness GL_EXT_semaphore GL_EXT_semaphore_win32 GL_KHR_shader_subgroup GL_KTX_buffer_region GL_NV_alpha_to_coverage_dither_control GL_NV_bindless_multi_draw_indirect GL_NV_bindless_multi_draw_indirect_count GL_NV_bindless_texture GL_NV_blend_equation_advanced GL_NV_bl
end_equation_advanced_coherent GL_NVX_blend_equation_advanced_multi_draw_buffers GL_NV_blend_minmax_factor GL_NV_blend_square GL_NV_clip_space_w_scaling GL_NV_command_list GL_NV_compute_program5 GL_NV_compute_shader_derivatives GL_NV_conditional_render GL_NV_conservative_raster GL_NV_conservative_
raster_dilate GL_NV_conservative_raster_pre_snap GL_NV_conservative_raster_pre_snap_triangles GL_NV_conservative_raster_underestimation GL_NV_copy_depth_to_color GL_NV_copy_image GL_NV_depth_buffer_float GL_NV_depth_clamp GL_NV_draw_texture GL_NV_draw_vulkan_image GL_NV_ES1_1_compatibility GL_NV_E
S3_1_compatibility GL_NV_explicit_multisample GL_NV_feature_query GL_NV_fence GL_NV_fill_rectangle GL_NV_float_buffer GL_NV_fog_distance GL_NV_fragment_coverage_to_color GL_NV_fragment_program GL_NV_fragment_program_option GL_NV_fragment_program2 GL_NV_fragment_shader_barycentric GL_NV_fragment_sh
ader_interlock GL_NV_framebuffer_mixed_samples GL_NV_framebuffer_multisample_coverage GL_NV_geometry_shader4 GL_NV_geometry_shader_passthrough GL_NV_gpu_program4 GL_NV_internalformat_sample_query GL_NV_gpu_program4_1 GL_NV_gpu_program5 GL_NV_gpu_program5_mem_extended GL_NV_gpu_program_fp64 GL_NV_g
pu_shader5 GL_NV_half_float GL_NV_light_max_exponent GL_NV_memory_attachment GL_NV_mesh_shader GL_NV_multisample_coverage GL_NV_multisample_filter_hint GL_NV_occlusion_query GL_NV_packed_depth_stencil GL_NV_parameter_buffer_object GL_NV_parameter_buffer_object2 GL_NV_path_rendering GL_NV_path_rend
ering_shared_edge GL_NV_pixel_data_range GL_NV_point_sprite GL_NV_primitive_restart GL_NV_query_resource GL_NV_query_resource_tag GL_NV_register_combiners GL_NV_register_combiners2 GL_NV_representative_fragment_test GL_NV_sample_locations GL_NV_sample_mask_override_coverage GL_NV_scissor_exclusive
GL_NV_shader_atomic_counters GL_NV_shader_atomic_float GL_NV_shader_atomic_float64 GL_NV_shader_atomic_fp16_vector GL_NV_shader_atomic_int64 GL_NV_shader_buffer_load GL_NV_shader_storage_buffer_object GL_NV_shader_subgroup_partitioned GL_NV_shader_texture_footprint GL_NV_shading_rate_image GL_NV_
stereo_view_rendering GL_NV_texgen_reflection GL_NV_texture_barrier GL_NV_texture_compression_vtc GL_NV_texture_env_combine4 GL_NV_texture_multisample GL_NV_texture_rectangle GL_NV_texture_rectangle_compressed GL_NV_texture_shader GL_NV_texture_shader2 GL_NV_texture_shader3 GL_NV_transform_feedbac
k GL_NV_transform_feedback2 GL_NV_uniform_buffer_unified_memory GL_NV_vertex_array_range GL_NV_vertex_array_range2 GL_NV_vertex_attrib_integer_64bit GL_NV_vertex_buffer_unified_memory GL_NV_vertex_program GL_NV_vertex_program1_1 GL_NV_vertex_program2 GL_NV_vertex_program2_option GL_NV_vertex_progr
am3 GL_NV_viewport_array2 GL_NV_viewport_swizzle GL_NVX_conditional_render GL_NVX_linked_gpu_multicast GL_NV_gpu_multicast GL_NVX_gpu_multicast2 GL_NVX_progress_fence GL_NVX_gpu_memory_info GL_NVX_multigpu_info GL_NVX_nvenc_interop GL_NV_shader_thread_group GL_NV_shader_thread_shuffle GL_KHR_blend
_equation_advanced GL_KHR_blend_equation_advanced_coherent GL_OVR_multiview GL_OVR_multiview2 GL_SGIS_generate_mipmap GL_SGIS_texture_lod GL_SGIX_depth_texture GL_SGIX_shadow GL_SUN_slice_accum GL_WIN_swap_hint WGL_EXT_swap_control '
[DEBUG ] [GL ] glShaderBinary is not available
[INFO ] [GL ] Backend used <glew>
[INFO ] [GL ] OpenGL version <b'4.6.0 NVIDIA 456.71'>
[INFO ] [GL ] OpenGL vendor <b'NVIDIA Corporation'>
[INFO ] [GL ] OpenGL renderer <b'GeForce RTX 2060/PCIe/SSE2'>
[INFO ] [GL ] OpenGL parsed version: 4, 6
[INFO ] [GL ] Shading version <b'4.60 NVIDIA'>
[INFO ] [GL ] Texture max size <32768>
[INFO ] [GL ] Texture max units <32>
[DEBUG ] [Shader ] Fragment compiled successfully
[DEBUG ] [Shader ] Vertex compiled successfully
[DEBUG ] [ImageSDL2 ] Load <C:\Users\ellio\kivymd_venv\lib\site-packages\kivy\data\glsl\default.png>
[INFO ] [Window ] auto add sdl2 input provider
[INFO ] [Window ] virtual keyboard not allowed, single mode, not docked
[DEBUG ] [Camera ] Ignored <picamera> (import error)
[DEBUG ] [Camera ] Ignored <gi> (import error)
[DEBUG ] [Camera ] Ignored <opencv> (import error)
[CRITICAL] [Camera ] Unable to find any valuable Camera provider. Please enable debug logging (e.g. add -d if running from the command line, or change the log level in the config) and re-run your app to identify potential causes
picamera - ModuleNotFoundError: No module named 'picamera'
File "C:\Users\ellio\kivymd_venv\lib\site-packages\kivy\core\__init__.py", line 58, in core_select_lib
mod = __import__(name='{2}.{0}.{1}'.format(
File "C:\Users\ellio\kivymd_venv\lib\site-packages\kivy\core\camera\camera_picamera.py", line 18, in <module>
from picamera import PiCamera
gi - ModuleNotFoundError: No module named 'gi'
File "C:\Users\ellio\kivymd_venv\lib\site-packages\kivy\core\__init__.py", line 58, in core_select_lib
mod = __import__(name='{2}.{0}.{1}'.format(
File "C:\Users\ellio\kivymd_venv\lib\site-packages\kivy\core\camera\camera_gi.py", line 10, in <module>
from gi.repository import Gst
opencv - ModuleNotFoundError: No module named 'cv2'
File "C:\Users\ellio\kivymd_venv\lib\site-packages\kivy\core\__init__.py", line 58, in core_select_lib
mod = __import__(name='{2}.{0}.{1}'.format(
File "C:\Users\ellio\kivymd_venv\lib\site-packages\kivy\core\camera\camera_opencv.py", line 48, in <module>
import cv2
Traceback (most recent call last):
File "C:\Users\ellio\PycharmProjects\KivyMD200\camtest.py", line 35, in <module>
TestCamera().run()
File "C:\Users\ellio\kivymd_venv\lib\site-packages\kivy\app.py", line 949, in run
self._run_prepare()
File "C:\Users\ellio\kivymd_venv\lib\site-packages\kivy\app.py", line 919, in _run_prepare
root = self.build()
File "C:\Users\ellio\PycharmProjects\KivyMD200\camtest.py", line 32, in build
return Builder.load_string(kv)
File "C:\Users\ellio\kivymd_venv\lib\site-packages\kivy\lang\builder.py", line 408, in load_string
self._apply_rule(
File "C:\Users\ellio\kivymd_venv\lib\site-packages\kivy\lang\builder.py", line 659, in _apply_rule
child = cls(__no_builder=True)
File "C:\Users\ellio\kivymd_venv\lib\site-packages\kivy\uix\camera.py", line 91, in __init__
on_index()
File "C:\Users\ellio\kivymd_venv\lib\site-packages\kivy\uix\camera.py", line 101, in _on_index
self._camera = CoreCamera(index=self.index, stopped=True)
TypeError: 'NoneType' object is not callable
Additional context Add any other context about the problem here.
confirming getting the same traceback, if opencv-python package is not installed.
Running the same code in another venv (with opencv-python version 4.4.0.46 installed) results in a different traceback/crash on app start:
[INFO ] [Logger ] Record log in /home/andi/.kivy/logs/kivy_20-12-23_5.txt
[INFO ] [Kivy ] v2.0.0
[INFO ] [Kivy ] Installed at "/home/andi/.pyenv/versions/ae/lib/python3.6/site-packages/kivy/__init__.py"
[INFO ] [Python ] v3.6.9 (default, Aug 28 2019, 15:54:20)
[GCC 7.4.0]
[INFO ] [Python ] Interpreter at "/home/andi/.pyenv/versions/ae/bin/python"
[INFO ] [Factory ] 186 symbols loaded
[DEBUG ] [Cache ] register <kv.lang> with limit=None, timeout=None
[DEBUG ] [Cache ] register <kv.image> with limit=None, timeout=60
[DEBUG ] [Cache ] register <kv.atlas> with limit=None, timeout=None
[INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_pil (img_ffpyplayer ignored)
[DEBUG ] [Cache ] register <kv.texture> with limit=1000, timeout=60
[DEBUG ] [Cache ] register <kv.shader> with limit=1000, timeout=3600
[DEBUG ] [App ] Loading kv </home/andi/src/kivy_playground/testcamera.kv>
[DEBUG ] [App ] kv </home/andi/src/kivy_playground/testcamera.kv> not found
[INFO ] [Window ] Provider: sdl2
[INFO ] [GL ] Using the "OpenGL" graphics system
[INFO ] [GL ] Backend used <sdl2>
[INFO ] [GL ] OpenGL version <b'3.0 Mesa 20.0.8'>
[INFO ] [GL ] OpenGL vendor <b'Intel Open Source Technology Center'>
[INFO ] [GL ] OpenGL renderer <b'Mesa DRI Intel(R) HD Graphics 4000 (IVB GT2)'>
[INFO ] [GL ] OpenGL parsed version: 3, 0
[INFO ] [GL ] Shading version <b'1.30'>
[INFO ] [GL ] Texture max size <16384>
[INFO ] [GL ] Texture max units <16>
[DEBUG ] [Shader ] Fragment compiled successfully
[DEBUG ] [Shader ] Vertex compiled successfully
[DEBUG ] [ImageSDL2 ] Load </home/andi/.pyenv/versions/ae/lib/python3.6/site-packages/kivy/data/glsl/default.png>
[INFO ] [Window ] auto add sdl2 input provider
[INFO ] [Window ] virtual keyboard not allowed, single mode, not docked
[DEBUG ] [Camera ] Ignored <picamera> (import error)
[DEBUG ] [Camera ] Ignored <gi> (import error)
[INFO ] [Camera ] Provider: opencv(['camera_picamera', 'camera_gi'] ignored)
[DEBUG ] Using opencv ver.4
[INFO ] [Text ] Provider: sdl2
[DEBUG ] [Resource ] add </usr/share/fonts> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/type1> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/type1/gsfonts> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/woff> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/woff/font-awesome> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/X11> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/X11/util> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/X11/Type1> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/X11/misc> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/X11/encodings> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/X11/encodings/large> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/eot> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/eot/font-awesome> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/opentype> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/opentype/malayalam> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/opentype/font-awesome> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/opentype/noto> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/truetype> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/truetype/fonts-kalapi> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/truetype/tibetan-machine> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/truetype/abyssinica> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/truetype/openoffice> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/truetype/lohit-gujarati> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/truetype/tlwg> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/truetype/droid> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/truetype/sinhala> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/truetype/liberation2> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/truetype/fonts-deva-extra> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/truetype/lohit-malayalam> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/truetype/fonts-gujr-extra> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/truetype/open-sans> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/truetype/liberation> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/truetype/lohit-devanagari> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/truetype/Gargi> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/truetype/lohit-punjabi> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/truetype/lohit-tamil> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/truetype/lohit-bengali> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/truetype/freefont> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/truetype/lohit-oriya> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/truetype/malayalam> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/truetype/lohit-telugu> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/truetype/samyak-fonts> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/truetype/Navilu> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/truetype/font-awesome> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/truetype/roboto> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/truetype/roboto/unhinted> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/truetype/roboto/unhinted/RobotoTTF> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/truetype/ttf-khmeros-core> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/truetype/lao> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/truetype/samyak> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/truetype/Gubbi> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/truetype/Nakula> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/truetype/lohit-tamil-classical> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/truetype/pagul> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/truetype/kacst> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/truetype/ubuntu> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/truetype/noto> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/truetype/Sarai> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/truetype/lohit-assamese> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/truetype/lohit-kannada> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/truetype/fonts-beng-extra> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/truetype/padauk> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/truetype/fonts-orya-extra> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/truetype/fonts-telu-extra> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/truetype/fonts-guru-extra> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/truetype/Sahadeva> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/truetype/kacst-one> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/truetype/dejavu> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/cmap> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/svg> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/svg/font-awesome> in path list
[DEBUG ] [Resource ] add </usr/share/fonts/cMap> in path list
[DEBUG ] [Resource ] add </usr/local/share/fonts> in path list
[DEBUG ] [Resource ] add </home/andi/.pyenv/versions/ae/lib/python3.6/site-packages/kivy/data/fonts> in path list
[DEBUG ] Using opencv ver.4
[ WARN:0] global /tmp/pip-req-build-qacpj5ci/opencv/modules/videoio/src/cap_v4l.cpp (893) open VIDEOIO(V4L2:/dev/video0): can't open camera by index
Traceback (most recent call last):
File "/home/andi/.pyenv/versions/ae/lib/python3.6/site-packages/kivy/lang/builder.py", line 705, in _apply_rule
setattr(widget_set, key, value)
File "kivy/weakproxy.pyx", line 35, in kivy.weakproxy.WeakProxy.__setattr__
File "kivy/properties.pyx", line 498, in kivy.properties.Property.__set__
File "kivy/properties.pyx", line 840, in kivy.properties.ListProperty.set
File "kivy/properties.pyx", line 545, in kivy.properties.Property.set
File "kivy/properties.pyx", line 600, in kivy.properties.Property.dispatch
File "kivy/_event.pyx", line 1248, in kivy._event.EventObservers.dispatch
File "kivy/_event.pyx", line 1154, in kivy._event.EventObservers._dispatch
File "/home/andi/.pyenv/versions/ae/lib/python3.6/site-packages/kivy/uix/camera.py", line 104, in _on_index
resolution=self.resolution, stopped=True)
File "/home/andi/.pyenv/versions/ae/lib/python3.6/site-packages/kivy/core/camera/camera_opencv.py", line 70, in __init__
super(CameraOpenCV, self).__init__(**kwargs)
File "/home/andi/.pyenv/versions/ae/lib/python3.6/site-packages/kivy/core/camera/__init__.py", line 70, in __init__
self.init_camera()
File "/home/andi/.pyenv/versions/ae/lib/python3.6/site-packages/kivy/core/camera/camera_opencv.py", line 120, in init_camera
self._resolution = (int(frame.shape[1]), int(frame.shape[0]))
AttributeError: 'NoneType' object has no attribute 'shape'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/andi/src/kivy_playground/camera.py", line 35, in <module>
TestCamera().run()
File "/home/andi/.pyenv/versions/ae/lib/python3.6/site-packages/kivy/app.py", line 949, in run
self._run_prepare()
File "/home/andi/.pyenv/versions/ae/lib/python3.6/site-packages/kivy/app.py", line 919, in _run_prepare
root = self.build()
File "/home/andi/src/kivy_playground/camera.py", line 32, in build
return Builder.load_string(kv)
File "/home/andi/.pyenv/versions/ae/lib/python3.6/site-packages/kivy/lang/builder.py", line 410, in load_string
rule_children=rule_children)
File "/home/andi/.pyenv/versions/ae/lib/python3.6/site-packages/kivy/lang/builder.py", line 712, in _apply_rule
e), cause=tb)
kivy.lang.builder.BuilderException: Parser: File "<inline>", line 6:
...
4: Camera:
5: id: camera
>> 6: resolution: (640, 480)
7: play: True
8: Button:
...
AttributeError: 'NoneType' object has no attribute 'shape'
File "/home/andi/.pyenv/versions/ae/lib/python3.6/site-packages/kivy/lang/builder.py", line 705, in _apply_rule
setattr(widget_set, key, value)
File "kivy/weakproxy.pyx", line 35, in kivy.weakproxy.WeakProxy.__setattr__
File "kivy/properties.pyx", line 498, in kivy.properties.Property.__set__
File "kivy/properties.pyx", line 840, in kivy.properties.ListProperty.set
File "kivy/properties.pyx", line 545, in kivy.properties.Property.set
File "kivy/properties.pyx", line 600, in kivy.properties.Property.dispatch
File "kivy/_event.pyx", line 1248, in kivy._event.EventObservers.dispatch
File "kivy/_event.pyx", line 1154, in kivy._event.EventObservers._dispatch
File "/home/andi/.pyenv/versions/ae/lib/python3.6/site-packages/kivy/uix/camera.py", line 104, in _on_index
resolution=self.resolution, stopped=True)
File "/home/andi/.pyenv/versions/ae/lib/python3.6/site-packages/kivy/core/camera/camera_opencv.py", line 70, in __init__
super(CameraOpenCV, self).__init__(**kwargs)
File "/home/andi/.pyenv/versions/ae/lib/python3.6/site-packages/kivy/core/camera/__init__.py", line 70, in __init__
self.init_camera()
File "/home/andi/.pyenv/versions/ae/lib/python3.6/site-packages/kivy/core/camera/camera_opencv.py", line 120, in init_camera
self._resolution = (int(frame.shape[1]), int(frame.shape[0]))
Process finished with exit code 1
Import the opencv-python module I think. You need it to use kivy camera on windows.
What camera backend did you test with on 1.11.1? Maybe you already had opencv-python installed and that's why it worked?
Perhaps we need to add a camera selector so you can do pip install kivy[camera] to get the per-platform dependencies? Personally I never used the camera module so I'm not sure what you need for each platform.
opencv-python was installed on 1.11.1 and is required, but not documented, for the camera to work. I just deleted opencv-python from the venv and the camera did not work, reinstalling, the camera worked.
Installing opencv-python on my kivy 2.0.0 install did not fix the issue.
The traceback shows: opencv - ImportError: numpy.core.multiarray failed to import
I believe this is an issue on Windows related to Numpy. Tracing the code in the debugger the error is raised:
'The current Numpy installation ({!r}) fails to pass a sanity check due to a bug in the windows runtime. See this issue for more information: https://tinyurl.com/y3dm3h86'
Looking through the link. A Microsoft Windows update v2004, introduced a bug in FMOD, causing an issue with Numpy. Windows should have an update in January 2021, there are other solutions provided at the bottom of the thread at the link: https://tinyurl.com/y3dm3h86' This is the root cause of the opencv-python failure on Windows.
@matham I like your idea of a camera selector for the install.
Hi, I'm kivy beginner but,
i have same problem, i installing pip install opencv-python and seem solved problem. when i started my demo app, terminal line [DEBUG ] Using opencv ver.4 appeared and camera worked
maybe add opencv-python dependencies into kivy requirements to solved windows problem ?
my configuration :
- windows 10
- python 3.9.1
- kivy 2.1.0
- kivymd 0.104.1
@ElliotGarbus I may have found where the issue lies, but I have no clue as to why the issue persists. Can you try to remove the resolution bit from the Builder string...
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.boxlayout import BoxLayout
import time
kv = '''
CameraClick:
orientation: 'vertical'
Camera:
id: camera
#resolution: (640, 480)
play: True
Button:
text: 'Capture'
size_hint_y: None
height: '48dp'
on_release: root.capture()
'''
class CameraClick(BoxLayout):
def capture(self):
camera = self.ids.camera
time_str = time.strftime("%Y%m%d_%H%M%S")
camera.export_to_png(f'IMG_{time_str}.png')
print("Captured")
class TestCamera(App):
def build(self):
return Builder.load_string(kv)
TestCamera().run()
If this works for you as it does for me, then it will confirm my finding.
@worraps Confirmed. I commented out the resolution line, and the code runs as expected.
I ran the app with the resolution line in place, and it is currently working, but the log shows some warnings:
[INFO ] [Logger ] Record log in C:\Users\ellio.kivy\logs\kivy_21-03-03_2.txt
[INFO ] [deps ] Successfully imported "kivy_deps.gstreamer" 0.3.1
[INFO ] [deps ] Successfully imported "kivy_deps.angle" 0.3.0
[INFO ] [deps ] Successfully imported "kivy_deps.glew" 0.3.0
[INFO ] [deps ] Successfully imported "kivy_deps.sdl2" 0.3.1
[INFO ] [Kivy ] v2.0.0
[INFO ] [Kivy ] Installed at "C:\Users\ellio\kivy_venv200\lib\site-packages\kivy_init_.py"
[INFO ] [Python ] v3.9.1 (tags/v3.9.1:1e5d33e, Dec 7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)]
[INFO ] [Python ] Interpreter at "C:\Users\ellio\kivy_venv200\Scripts\python.exe"
[INFO ] [Factory ] 186 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_pil (img_ffpyplayer ignored)
[INFO ] [Window ] Provider: sdl2
[INFO ] [GL ] Using the "OpenGL" graphics system
[INFO ] [GL ] GLEW initialization succeeded
[INFO ] [GL ] Backend used anonymous-namespace'::SourceReaderCB::OnReadSample videoio(MSMF): OnReadSample() is called with error status: -1072873821 [ WARN:0] global C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-95hbg2jt\opencv\modules\videoio\src\cap_msmf.cpp (385) anonymous-namespace'::SourceReaderCB::OnReadSample videoio(MSMF): async ReadSample() call is failed with error status: -1072873821
[INFO ] [Base ] Start application main loop
[ WARN:1] global C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-95hbg2jt\opencv\modules\videoio\src\cap_msmf.cpp (435) anonymous-namespace'::SourceReaderCB::~SourceReaderCB terminating async callback [INFO ] [GL ] NPOT texture support is available [INFO ] [GL ] BGRA texture support is available [INFO ] [Base ] Leaving application in progress... [ WARN:1] global C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-95hbg2jt\opencv\modules\videoio\src\cap_msmf.cpp (435) anonymous-namespace'::SourceReaderCB::~SourceReaderCB terminating async callback
kivy[full] 2.0.0 on Manjaro with python 3.9.6 installed by pip. The official camera example got the same error
emm install openvcv-python and delete the line (resolution: (640, 480)). It finally work. Some one update that official example web
emm instale
openvcv-pythone exclua a linha (resolução: (640, 480)). Finalmente funciona. Alguém atualiza esse exemplo oficial da web
Este comentário ajudou muito, estava com o mesmo erro. Configurações: kivy 2.1.0 kivymd 0.104.1