criteo / je-code-crazy-filters

Apache License 2.0
6 stars 1 forks source link

ValueError: cannot reshape array of size 1228800 into shape (921600,) #2

Open arthurzenika opened 6 years ago

arthurzenika commented 6 years ago
$ python crazy-filters/main.py 
[INFO   ] [Logger      ] Record log in /home/arthur/.kivy/logs/kivy_18-11-20_1.txt
[INFO   ] [Kivy        ] v1.10.1
[INFO   ] [Python      ] v3.6.6 (default, Sep 12 2018, 18:26:19) 
[GCC 8.0.1 20180414 (experimental) [trunk revision 259383]]
[INFO   ] [Factory     ] 194 symbols loaded
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2, img_pil, img_gif (img_ffpyplayer ignored)
[INFO   ] [Text        ] Provider: sdl2
[INFO   ] [Window      ] Provider: sdl2(['window_egl_rpi'] ignored)
[INFO   ] [GL          ] Using the "OpenGL" graphics system
[INFO   ] [GL          ] Backend used <gl>
[INFO   ] [GL          ] OpenGL version <b'3.0 Mesa 18.0.5'>
[INFO   ] [GL          ] OpenGL vendor <b'Intel Open Source Technology Center'>
[INFO   ] [GL          ] OpenGL renderer <b'Mesa DRI Intel(R) HD Graphics 620 (Kaby Lake 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 <32>
[INFO   ] [Window      ] auto add sdl2 input provider
[INFO   ] [Window      ] virtual keyboard not allowed, single mode, not docked
 /home/arthur/.virtualenvs/crazy-filters/lib/python3.6/site-packages/kivy/core/camera/camera_gi.py:10: PyGIWarning: Gst was imported without specifying a version first. Use gi.require_version('Gst', '1.0') before import to ensure that the right version gets loaded.
   from gi.repository import Gst
[INFO   ] [CameraGi    ] Using Gstreamer 1.14.1.0
[INFO   ] [Camera      ] Provider: gi(['camera_picamera'] ignored)
[INFO   ] [GL          ] NPOT texture support is available
[INFO   ] [ProbeSysfs  ] device match: /dev/input/event17
[INFO   ] [MTD         ] Read event from </dev/input/event17>
[INFO   ] [ProbeSysfs  ] device match: /dev/input/event18
[INFO   ] [MTD         ] Read event from </dev/input/event18>
[INFO   ] [Base        ] Start application main loop
[WARNING] [MTD         ] Unable to open device "/dev/input/event17". Please ensure you have the appropriate permissions.
[WARNING] [MTD         ] Unable to open device "/dev/input/event18". Please ensure you have the appropriate permissions.
[INFO   ] [Base        ] Leaving application in progress...
 Traceback (most recent call last):
   File "crazy-filters/main.py", line 8, in <module>
     CrazyFiltersApp().run()
   File "/home/arthur/.virtualenvs/crazy-filters/lib/python3.6/site-packages/kivy/app.py", line 826, in run
     runTouchApp()
   File "/home/arthur/.virtualenvs/crazy-filters/lib/python3.6/site-packages/kivy/base.py", line 502, in runTouchApp
     EventLoop.window.mainloop()
   File "/home/arthur/.virtualenvs/crazy-filters/lib/python3.6/site-packages/kivy/core/window/window_sdl2.py", line 727, in mainloop
     self._mainloop()
   File "/home/arthur/.virtualenvs/crazy-filters/lib/python3.6/site-packages/kivy/core/window/window_sdl2.py", line 460, in _mainloop
     EventLoop.idle()
   File "/home/arthur/.virtualenvs/crazy-filters/lib/python3.6/site-packages/kivy/base.py", line 337, in idle
     Clock.tick()
   File "/home/arthur/.virtualenvs/crazy-filters/lib/python3.6/site-packages/kivy/clock.py", line 581, in tick
     self._process_events()
   File "kivy/_clock.pyx", line 384, in kivy._clock.CyClockBase._process_events
   File "kivy/_clock.pyx", line 414, in kivy._clock.CyClockBase._process_events
   File "kivy/_clock.pyx", line 412, in kivy._clock.CyClockBase._process_events
   File "kivy/_clock.pyx", line 167, in kivy._clock.ClockEvent.tick
   File "/home/arthur/.virtualenvs/crazy-filters/lib/python3.6/site-packages/kivy/core/camera/camera_gi.py", line 155, in _update
     self._copy_to_gpu()
   File "/home/arthur/.virtualenvs/crazy-filters/lib/python3.6/site-packages/kivy/core/camera/__init__.py", line 127, in _copy_to_gpu
     self.dispatch('on_texture')
   File "kivy/_event.pyx", line 703, in kivy._event.EventDispatcher.dispatch
   File "kivy/_event.pyx", line 1214, in kivy._event.EventObservers.dispatch
   File "kivy/_event.pyx", line 1138, in kivy._event.EventObservers._dispatch
   File "/home/arthur/local/je-code-crazy-filters/crazy-filters/ui/image_transform.py", line 152, in on_tex
     self.apply_all_transforms()
   File "/home/arthur/local/je-code-crazy-filters/crazy-filters/ui/image_transform.py", line 123, in apply_all_transforms
     self.set_frame(buf)
   File "/home/arthur/local/je-code-crazy-filters/crazy-filters/ui/image_transform.py", line 99, in set_frame
     data=buf.reshape(self.texheight * self.texwidth * len(self.texfmt)),
 ValueError: cannot reshape array of size 1228800 into shape (921600,)
annemariet commented 6 years ago

Hi Arthur. At first sight, it looks like your camera resolution is bigger than what I tested. I cannot check right now, but if you find some hardcoded width=640/height=480 somewhere in my code, that's a likely cause for error.

annemariet commented 6 years ago

Hi @arthurlogilab, I checked the code, and it should work with bigger resolutions. Your issue might come from which provider is used for the camera. Check this line in your log: [INFO ] [Camera ] Provider: gi(['camera_picamera'] ignored) Where you have gi, ... ignored, I have opencv.

You can check with the more basic Kivy camera example here: https://kivy.org/doc/stable/examples/gen__camera__main__py.html

And you can check that your OpenCV install allows using the camera correctly using a code snippet from here: https://docs.opencv.org/3.0-beta/doc/py_tutorials/py_gui/py_video_display/py_video_display.html.

Please tell me how it goes so I can update the documentation accordingly! And thanks for reporting your bug.