PIL rendering on raspberry pi different than custom OS - python

I am having an issue with PIL (python image library). Same code running on standard raspbian and the same on custom Yocto OS don't have the same output. The yocto one is deformed, especially the 0 character
I am using python 2.7 and PIL 1.1.7.
I tested increasing gpu_mem to 128Mb on the yocto, use vc4graphics but this is not changing anything. I guess there's something I don't think about as I'm inexperienced with image rendering.
I would like to understand how to debug this.
Raspbian:
Custom Yocto:
Thanks

Well, there are too many assumptions to say anything definitely.
Are both systems using same graphical backend?
If not, you should probably match them.
It's not "Yocto OS", it's usual Linux, Yocto is just a tool to improve work-flow of building Linux.
What LCD are you using?
Usually when you are developing for board, with some new model of lcd, you also get a datasheet from vendor to tweak different parameters. I had the same problem with display not being crisp, look for lcd display section of .dts file. There should be parameters like "bits-per-pixel", which you should match to what is advised in a data-sheet.
In your case since you have 2 systems with one having a clear image and one having a fuzzy one, I can advice to look for .dts file on both systems and match lcd sections for them. Just an example of a path to .dts file in Yocto
build/tmp/work-shared/imx6ulevk/kernel-source/arch/arm/boot/dts/imx6ul-14x14-evk.dts
Find .dts files for both systems, look for what's different in lcd display section and copy raspbian lcd parameters to your Yocto .dts file.

Related

How to compile python, QT5 app and create single app custom raspberry ISO

I have written a small program in python and QT5. I want it on raspberry PI as a single application. I have checked out buildroot and yocto but can't seems to find a single tutorial which can explain the steps from compiling the python code and make it part of buildroot/yocto. Can anyone please guide me or point me to a tutorial.
Regards,
In Buildroot, there are two ways that you can add your own Python code to the build.
Using a root filesystem overlay to add you python files in the appropriate place in the root filesystem. This has a lot of limitations though: it doesn't get byte-compiled, you have to make sure yourself that it gets installed in some location in PYTHONPATH, and generally it's a bit more difficult to maintain. However, it's a very simple approach for a first try.
Creating a custom python package. It's also not really complicated to do that, but you really do have to read the documentation.

How to capture screen on Wayland(Gnome) in Python code?

I'm trying to capture my screen using Python because I'll use it on OpenCV, but I couldn't find a way to make it work on Gnome, since Gnome uses Wayland and all libraries that I've found only work with X11.
For now I'm not considering change my interface. I'm searching a solution to this problem.
Does someone know a solution?
To be more specific, I'll use the images to train an AI and so I need they continuously.
EDIT:
I've found this but how can I pass frames to OpenCV in Python instead of save a video file?
The proper way to do screencasting these days is by using the Screencast portal, which is part of XDG desktop portals and is already supported by GNOME, KDE, wlroots (and more). As an added advantage, this will also work in containerized formats like Flatpaks.
You can find an example on how to do screencasting in Pyhon using this snippet, created by one of the Mutter maintainers. If you look for parse_launch(), you will see a GStreamer pipeline which you can modify to include the GStreamer OpenCV elements that can do the processing for you.
Note: in your edit, you link to a predecessor of that portal, which is GNOME-specifc, internal API, so I wouldn't rely on it ;-)

Place an image in a specific locaton on a windows desktop using python

I wish to use python to place an image (say jpg or bmp) at a specific location on my Windows 7 desktop. I would also like the ability to drag it around using the mouse and for the python code to store it's final locations coordinates. So when Windows restarts (with the python code configured to run at startup), it reads the stored location and places the image back at its previous location.
Is this possible to do?
If it is, could someone please provide some suggestions on how to do it, as my python experience is pretty limited?
Thanks.
You need to use LVM_SETITEMPOSITION for arranging icons on the desktop.
There are a similar questions:
How can I programmatically manipulate Windows desktop icon
locations?
win32 programming
Python is not the best choice for this job, but if it's required try to look in to - commctrl, win32gui, and pywin32 libraries

Tablet Pressure with Python on Linux

Is there a simple way to get the pen pressure data from a usb tablet using python on Linux?
You can do it by reading input events on the input device node. I wrote some modules to do this. you can find it in the Pycopia project.
The disadvantage of this is that your program must run as root.
The powerdroid project also uses this, but that's old code now. You can see another example of synthesizing touch input in the devices module. It probably won't work anymore, but you might start with that.
Try using PySide, it's a QT Wrapper here: QTabletEvent.
Or you can use Python and PyGame: Here.

How I can develop a screen-capture tool in Python

I'm learning Python now and I want to develop a screen capture tool in Python.How I can do this work?
If you're on windows, use ImageGrab module along with Imaging library.
Something like:
from PIL import ImageGrab
ImageGrab.grab().save("screenshot.jpg", "JPEG")
I think the best way to do this would be create a higher level interface to ffmpeg. Unless you want to write the code to deal with X11 and record the screen, then it would be the best option.
If you test it on various platforms, then give useful error messages on things like incompatible sound systems, where to get certain video drivers, etc then this could be a pretty useful program.

Categories