Kivy Question: Dynamic Image Updating

Before I try to post something on stackexchange (where I would have to do a bunch of work to produce abridged code for people to review), I thought I’d ask here to see if anyone knows the answer.

I’m working on an image-based calibration and I have two box layouts on the screen, one displays a live feed from the webcam and the second displays a snapshot of an image from the webcam that is used for calibration. I have a series of buttons that I press to make the measurements happen. The first is “calibrate” and when I press that, the kivy widget calls a specific routine that takes the current frame from the live feed, performs calculations, and then shows that image in the second box layout. This works fine. When I press a button to move the sled to a particular spot (say +2 inch, +2 inch) and take the same measurement, the resulting image on the second box layout is all black. I know the image is good (i.e., not a black image) because I save it to the disk in the very routine that updates the image… the image is fine.

The difference between the pressing “calibrate” and pressing “move to +2, +2” is that the function to calibrate is called directly from the kivy button widget. However, when I press the “move to +2, +2” button, it calls a function that sends a command to the firmware to move the sled to that position. It also sets the logger to callback to the measurement function once the logger sees that the sled is done moving. The callback is to the same function that the calibrate widget calls. This all works, but the image that gets displayed is all black and not the image that is in memory. I can update text on the screen with no problem (I report the measurement error on a part of the screen) but all image updates done this way are all black. If I hit the “calibrate” button again, it works. So the issue seems to be related to the fact that the function is called from a callback and not directly from the widget… why this matters is beyond me.

1 Like

The only thing I can think is that it could be a paths issue?

I believe that python can change where the current directory is in different scopes so ./image.png might be right in one place but wrong somewhere else?

That’s all I can think of, it sounds like you are doing everything right.

Well, I tried two ways. The first is to do everything in memory (texture update) and when that didn’t work, I tried saving the file, updating the widget source and reloading it and that didn’t work. I assume paths are right for that since I’m using the same path. It’s like it’s a bug.

I’ve found that the kivy google group is more responsive to questions than Stack Exchange…you are beyond my experience with images here. I agree that it should work.