Cannot export texture as image on mobile

138 views
Skip to first unread message

jw

unread,
Jun 1, 2019, 10:19:06 PM6/1/19
to Kivy users support
I am using a Camera widget and I need to export its texture to a file, I have the Storage permission on the phone. I have tried camera.export_to_png() and camera.texture.save() with no luck.

Would love any assistance on this!

Thanks
Jaivin

Robert Flatt

unread,
Jun 1, 2019, 11:18:42 PM6/1/19
to Kivy users support
The best chance of getting help is to post a SMALL example, AND the .spec or .p4a file, AND any logfile, AND a FULL description of the test for any unexpected behavior.

Jaivin Wylde

unread,
Jun 11, 2019, 1:39:55 PM6/11/19
to kivy-...@googlegroups.com
Sorry for the late reply, I am currently working on a demo showing the problem. Before that I will explain it a bit better.

(The demo might take a few more days so use the following message as a reference)

I made an app for my android phone that uses the Camera widget to take a picture every 0.5 seconds for further calculations using the texture.save() method, I also use the opencv method opencv.imwrite() to save the final image when calculations are done. Everything works find on my Ubuntu desktop, but when compiling it into the app for android, there are no errors the images just don't save, if I try to show them using an Image widget they are just black. I have all the correct permissions to access and write to the storage, so I am perplexed to why this is happening.

Thanks for the patience
Jaivin

--
You received this message because you are subscribed to a topic in the Google Groups "Kivy users support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kivy-users/4NYorTlMHqs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kivy-users+...@googlegroups.com.
To post to this group, send email to kivy-...@googlegroups.com.
Visit this group at https://groups.google.com/group/kivy-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/30f34f37-5fad-40b7-a862-6805042efc98%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

jw

unread,
Jun 27, 2019, 9:38:24 AM6/27/19
to Kivy users support
The demo is finally ready, it consists of a Camera feed in the background, with a small Image in the bottom left. It is programmed to save a frame of the camera using the texture's save method (texture.save()). On my Ubuntu machine, the demo works fine, after one second a frame of the camera shows up in the bottom left like it should. While on my Android phone it does not work, there are no crashes, the image simply does not save, after one second nothing shows up in the bottom left corner meaning the image did not save.

This has been a big problem for me so I am happy that I know where to turn for help.

(I could not add the buildozer apk with all its files, so you will have to create an apk yourself to see the problem using "buildozer android debug deploy run")

Thanks in advance
Jaivin
camdemo.zip

Robert Flatt

unread,
Jun 27, 2019, 8:54:40 PM6/27/19
to Kivy users support
What is the video provider?
Perhaps add opencv to the requirements ?
(I didn't try it)

Or use opencv directly. Nice example (though you'll want to wrap it in Kivy)

Jaivin Wylde

unread,
Jun 27, 2019, 9:10:58 PM6/27/19
to kivy-...@googlegroups.com
On my main app where this problem is I am using opencv, and opencv's imwrite() method actually works. The only thing that does not work is kivy's texture.save() method.

--
You received this message because you are subscribed to a topic in the Google Groups "Kivy users support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kivy-users/4NYorTlMHqs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kivy-users+...@googlegroups.com.
To post to this group, send email to kivy-...@googlegroups.com.
Visit this group at https://groups.google.com/group/kivy-users.

Robert Flatt

unread,
Jun 27, 2019, 11:16:22 PM6/27/19
to Kivy users support
in the test case self.texture == None 
texture.save() is never called, best we can say is we don't know if it works.

I notice that this example does nothing on Windows as well.

And it turns out there is a bug report https://github.com/kivy/kivy/issues/6369
Perhaps you could add your experience, might get some attention.......

Then use opencv imwrite()


On Thursday, June 27, 2019 at 3:10:58 PM UTC-10, jw wrote:
On my main app where this problem is I am using opencv, and opencv's imwrite() method actually works. The only thing that does not work is kivy's texture.save() method.

On Thu, Jun 27, 2019 at 5:54 PM Robert Flatt <planckp...@gmail.com> wrote:
What is the video provider?
Perhaps add opencv to the requirements ?
(I didn't try it)

Or use opencv directly. Nice example (though you'll want to wrap it in Kivy)

On Thursday, June 27, 2019 at 3:38:24 AM UTC-10, jw wrote:
The demo is finally ready, it consists of a Camera feed in the background, with a small Image in the bottom left. It is programmed to save a frame of the camera using the texture's save method (texture.save()). On my Ubuntu machine, the demo works fine, after one second a frame of the camera shows up in the bottom left like it should. While on my Android phone it does not work, there are no crashes, the image simply does not save, after one second nothing shows up in the bottom left corner meaning the image did not save.

This has been a big problem for me so I am happy that I know where to turn for help.

(I could not add the buildozer apk with all its files, so you will have to create an apk yourself to see the problem using "buildozer android debug deploy run")

Thanks in advance
Jaivin

On Saturday, June 1, 2019 at 7:19:06 PM UTC-7, jw wrote:
I am using a Camera widget and I need to export its texture to a file, I have the Storage permission on the phone. I have tried camera.export_to_png() and camera.texture.save() with no luck.

Would love any assistance on this!

Thanks
Jaivin

--
You received this message because you are subscribed to a topic in the Google Groups "Kivy users support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kivy-users/4NYorTlMHqs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kivy-...@googlegroups.com.

Jaivin Wylde

unread,
Jun 28, 2019, 12:55:15 AM6/28/19
to kivy-...@googlegroups.com
Thanks so much for this information. Are you basically saying that you think the camera's texture on the Android app is somehow set to None and that is why it is not working?

Also what would be the best way to use opencv as a camera instead of Kivy's camera widget.

And are you saying that the demo I made does not work on windows?

To unsubscribe from this group and all its topics, send an email to kivy-users+...@googlegroups.com.

To post to this group, send email to kivy-...@googlegroups.com.
Visit this group at https://groups.google.com/group/kivy-users.

jw

unread,
Jun 29, 2019, 1:03:09 PM6/29/19
to Kivy users support
I tried a test on the app that basically showed the camera's texture is not None, I also tried to create an Image using the camera's texture and use the Image's save method, but to no avail.

I would really appreciate a push in the right direction regarding replacing Kivy's camera with opencv.

Thanks for everything so far.

On Saturday, June 1, 2019 at 7:19:06 PM UTC-7, jw wrote:

jw

unread,
Jul 9, 2019, 9:34:44 PM7/9/19
to Kivy users support
I've been testing using opencv to save camera frames on android with no success, has anyone figured out how to do this already?

I've been stuck on this for a while, so any help is very appreciated.

Thank you.

On Saturday, June 1, 2019 at 7:19:06 PM UTC-7, jw wrote:
Reply all
Reply to author
Forward
0 new messages