User avatar
paddyg
Posts: 2541
Joined: Sat Jan 28, 2012 11:57 am
Location: UK

Re: Image viewer with transition between images

Sun Mar 13, 2016 10:55 pm

Quite hard to guess without seeing the code but I think I have generated a similar error when I tried to call the String.quick_change() method prior to an initial String.draw() call. The opengl functions are not implemented until the last minute in case textures etc are being loaded in background threads (opengl functions must be run by the main thread) And this is implemented by draw() checking if _load_opengl has been called (I suppose quick change could have this functionality added, will check). Of course it might be a completely different problem. Let me know what you find.

Paddy
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

sawitar
Posts: 9
Joined: Wed Mar 09, 2016 11:43 am

Re: Image viewer with transition between images

Sun Mar 13, 2016 11:49 pm

Silly me. Forgot to draw object first.

jodder
Posts: 5
Joined: Wed Mar 09, 2016 11:35 am

Re: Image viewer with transition between images

Mon Mar 14, 2016 4:45 pm

paddyg wrote:@jodder, I have patched the blend shaders so the line round the edges when using mipmap doesn't show. Still not sure why this happened but the fix was to discard a pixel more round the edges of the background image when blending! I have pushed the changes to github on the develop branch github.com/pi3d/pi3d_demos/archive/develop.zip
Paddyg thanks for taking a look, I missed your reply amongst the other replies until I reread them all this morning ooops! I've tried with your changes and also on a fresh install too but the problem persists :( . The lines occur when the resolution of the next image is different to the previous (or if the images change from portrait to landscape). I've been reading pi3d's documentation and tinkering with it today to see if I can solve it before asking you again... but now I'm asking you again!

My images are from a few different digital cameras, all roughly ~ 3 - 5 mb in size. Resolution varies but is always larger than 1920x1080, and orientation varies occasionally between landscape and portrait. Reading earlier posts in this thread, gkreidl mentions that all scaling is done by Pillow or PIL before getting to pi3d textures; wouldn't this therefore mean that each foreground and background resolution should be identical prior to blending and not have any pixel-wide lines around the edges? Obviously not or we wouldn't have this problem, but I'm just trying to think of a path to a solution with my limited understanding!

Another odd observation: if I use images which all have an identical resolution then the pixel line edge doesn't appear (great!), but the line does appear during the blend transition?! This becomes particularly noticeable due to the higher contrast of the line in the blend_bump transition. This is really odd and makes me wonder if it's something to do with my setup as I can't think why this would happen if the resolutions are the same.

Do you see these lines if you use different resolution/orientation images?

So, in summary, there are two niggles atm. With these fixed I think this pi3d pictureframe.py method will be the ultimate way for people to repurpose unused monitors into useful, decent-sized digital photo frames. The two niggles in bullet point form:

- 1) distracting pixel line when different resolution images are used
- 2) same line also present during transitions (even if resolutions are the same)

P.S. Thank-you so much for your time (an thanks on behalf of anyone who ever tries out this brilliant project!).

User avatar
paddyg
Posts: 2541
Joined: Sat Jan 28, 2012 11:57 am
Location: UK

Re: Image viewer with transition between images

Mon Mar 14, 2016 5:59 pm

@jodder, please don't feel that your observations are niggles - this is only way the project can continue to improve, people try things out with different parameters and find bugs or suggestions for improvement. To be honest I've only tested the PictureFrame app with the limited selection of pictures I have in the textures folder on the SD card I happened to have in my Raspberry Pi, there were some short fat and tall thin images and some 1200x800 but not higher resolution. So I need to be a bit more comprehensive with the testing.

The resizing with PIL might be significant so thanks for mentioning that, though I saw the lines on images where I know no resizing had taken place. The resizing issue is slightly more subtle in that the GPU (or firm way provided for it by Broadcom) has some 'magic' widths and when a wrong width is used the lookup function gets out of sync. I think the lines must occur somewhere in the shaders and be some kind of rounding error but I can't why at the moment. I will get back to you soon, hopefully.
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

jodder
Posts: 5
Joined: Wed Mar 09, 2016 11:35 am

Re: Image viewer with transition between images

Mon Mar 14, 2016 7:21 pm

I saw the 'magic widths' pop up a few times on my internet travels but thought that PIL would resize to 1920 immediately (i.e. a magic width) removing that as a problem.

May be of use: I noticed when using the same resolution images but with different orientations (i.e. x by y pixels and y by x pixels), the lines would appear along the bottom axis and one vertical (either right or left) for a portrait image, and then along the same bottom axis but also the opposing vertical axis on the next (landscape) image. This pattern of line position seemed consistent, but my sample size was only 4 or 5 so the could be coincidental.

Hope to hear from you soon!

J
Last edited by jodder on Tue Mar 15, 2016 10:33 am, edited 1 time in total.

User avatar
paddyg
Posts: 2541
Joined: Sat Jan 28, 2012 11:57 am
Location: UK

Re: Image viewer with transition between images

Mon Mar 14, 2016 11:53 pm

OK, this looks positive. I will do some more checking (on the Raspberry Pi) then, if ok push up to github.com.

There is a parameter that controls what happens at the edges of a texture sampler, or if the uv values go outside the range 0.0 to 1.0. This can be either clamp at the edge, start again at 0.0 or reflect, the latter giving a kind of seamless edge. It occurred to me that maybe the mipmaps were just tiling (default) and would be improved if they either clamped or reflected. However it didn't improve things so I tried everything else. Eventually I came back to look at the mipmap generation and noticed that the lines specifying the tiling are after the line to create the mipmap. By moving them before it there seems to be a significant improvement. If you look here I moved lines 271-275 up to line 263 I also had to change the Texture creation line in PictureFrame.py to

Code: Select all

  tex = pi3d.Texture(fname, blend=True, mipmap=MIPMAP, m_repeat=True)
EDIT After testing a bit on the RPi I can see that this isn't a complete fix but it does seem a bit better where the images are not being scaled down. More work required!

2nd EDIT.. I think I've found the source of this and a fix. In combination with the above mirror repeating this is quite a good solution to the black bands where the image aspect ratio doesn't match the monitor. The main thing is that the fragment shaders need to set the 'discarded' pixel values AFTER the texture lookup. This then allows a reflected, muted version of the picture to fill the space at the edge. I will do some more tests and modify the code on github.

Code: Select all

  coord = vec2(gl_FragCoord);
  coord.y = unif[15][2] - coord.y; // top left convension though means flipping image!
  coordsc = coord - unif[14].xy; // offset
  coordsc *=  pix_invf; // really dividing to scale 0-1 i.e. (x/w, y/h)
  texf = texture2D(tex0, coordsc);
  if (coord.x <= unif[14][0] || coord.x > unif[14][0]+unif[15][0] ||
      coord.y <= unif[14][1] || coord.y > unif[14][1]+unif[15][1]) texf.a *= 0.1;
  coordsc = coord - unif[16].xy; // offset
  coordsc *=  pix_invb; // really dividing to scale 0-1 i.e. (x/w, y/h)
  texb = texture2D(tex1, coordsc);
  if (coord.x <= unif[16][0] || coord.x > unif[16][0]+unif[17][0] ||
      coord.y <= unif[16][1] || coord.y > unif[16][1]+unif[17][1]) texb.a *= 0.1;
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

User avatar
paddyg
Posts: 2541
Joined: Sat Jan 28, 2012 11:57 am
Location: UK

Re: Image viewer with transition between images

Tue Mar 15, 2016 3:17 pm

That seems to work now, pushed up to github.com/pi3d/pi3d_demos develop branch. I've left it showing the edges at alpha=0.1 If you want just the background you have to edit shaders/blend_include_fs.inc

The change to pi3d/Texture.py doesn't seem to be necessary for this to work fine!
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

jodder
Posts: 5
Joined: Wed Mar 09, 2016 11:35 am

Re: Image viewer with transition between images

Wed Mar 16, 2016 7:25 pm

Brilliant! Working very nicely now. Something worryingly satisfying about not seeing pixel-wide lines at the edge!

Thank you Paddy, it is very, very gratefully appreciated!

(... P.S. I'll be sure to post any more observniggles should I come across any!)

User avatar
paddyg
Posts: 2541
Joined: Sat Jan 28, 2012 11:57 am
Location: UK

Re: Image viewer with transition between images

Wed Mar 16, 2016 7:40 pm

I also have an ulterior motive to look at this demo again. My uncle is in a nursing home now and I thought it might be nice to have a photo frame which can pick up emails with photo attachments. Amazing how easy it is to do this sort of thing with python!
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

User avatar
sapnho
Posts: 244
Joined: Sun Sep 14, 2014 3:49 pm
Location: Frankfurt am Main
Contact: Website

Re: Image viewer with transition between images

Fri Aug 24, 2018 8:55 pm

Hello Paddy, it's been some time but for four years Pi3D has performed flawlessly as a picture frame. But now, wife keeps talking about the need for an upgrade with a bigger screen. ;)

So reading about this thread that you can run a 4k (3840x2160) monitor provided you stick to 15fps (https://www.raspberrypi.org/forums/view ... 38&t=79330), I was wondering if there was any reason why Pi3D would not work in such an environment? Any thoughts?
www.TheDigitalPictureFrame.com - Build a really great digital picture frame with the Raspberry Pi.
With lots of great tips from this forum.
Please submit your digital picture frame project to the user gallery here: bit.ly/2WkyjW1

DDIT
Posts: 4
Joined: Thu Jul 25, 2019 4:27 pm

Re: Image viewer with transition between images

Thu Jul 25, 2019 4:36 pm

Hi,

I have followed this thread and the excellent guide at www.thedigitalpictureframe.com!

I'm 99% there, all is working, with the exception of the @reboot cron job and I'm stuck :cry:

My cron line looks like this

Code: Select all

@reboot /home/pi/start_slideshow.sh >> /home/pi/cron.log 2>&1
The start_slideshow.sh script looks like this

Code: Select all

echo "script started"
#!/bin/bash
cd pi3d_demos
screen -dmS PICFRAME python3 PictureFrame.py
echo "script finished"
When I reboot, I just see the Raspian wallpaper and nothing happens. When I check the cron.log file, I see

Code: Select all

script started
script finished
I followed the guide to the T, but now stuck with this last hurdle. I'm new to Pi's - having just unboxed this one today - a new Pi v4 with os-version "Buster". Can anyone suggest a solution?

User avatar
sapnho
Posts: 244
Joined: Sun Sep 14, 2014 3:49 pm
Location: Frankfurt am Main
Contact: Website

Re: Image viewer with transition between images

Thu Jul 25, 2019 5:09 pm

Hi @DDIT, does it work in the Terminal when you enter

Code: Select all

 cd pi3d_demos 
 python3 PictureFrame.py
?
www.TheDigitalPictureFrame.com - Build a really great digital picture frame with the Raspberry Pi.
With lots of great tips from this forum.
Please submit your digital picture frame project to the user gallery here: bit.ly/2WkyjW1

DDIT
Posts: 4
Joined: Thu Jul 25, 2019 4:27 pm

Re: Image viewer with transition between images

Fri Jul 26, 2019 6:56 am

@sapnho, thanks for the quick reply...

yes, it does work in terminal using the commands.

User avatar
sapnho
Posts: 244
Joined: Sun Sep 14, 2014 3:49 pm
Location: Frankfurt am Main
Contact: Website

Re: Image viewer with transition between images

Fri Jul 26, 2019 7:16 am

Ok, I am fishing for clues here...

In one script I had to add

Code: Select all

sleep 30
to have the Pi wait for another process to be ready first. Can you try inserting this before calling your startup script in crontab -e?

So like

Code: Select all

@reboot sleep 60 && /home/pi/start_slideshow.sh >> /home/pi/cron.log 2>&1
www.TheDigitalPictureFrame.com - Build a really great digital picture frame with the Raspberry Pi.
With lots of great tips from this forum.
Please submit your digital picture frame project to the user gallery here: bit.ly/2WkyjW1

DDIT
Posts: 4
Joined: Thu Jul 25, 2019 4:27 pm

Re: Image viewer with transition between images

Fri Jul 26, 2019 7:39 am

Thanks.

I inserted the "sleep 60 &&" bit, then rebooted (and waited a few minutes), but still nothing, except the new lines in the log file of course.

Is there anything else I could try? perhaps add another line to launch a text editor or something visual?

User avatar
sapnho
Posts: 244
Joined: Sun Sep 14, 2014 3:49 pm
Location: Frankfurt am Main
Contact: Website

Re: Image viewer with transition between images

Fri Jul 26, 2019 7:47 am

Hi @DDIT, please contact me directly so we can get to the bottom of this. Details are on my website.
www.TheDigitalPictureFrame.com - Build a really great digital picture frame with the Raspberry Pi.
With lots of great tips from this forum.
Please submit your digital picture frame project to the user gallery here: bit.ly/2WkyjW1

DDIT
Posts: 4
Joined: Thu Jul 25, 2019 4:27 pm

Re: Image viewer with transition between images

Fri Jul 26, 2019 7:49 am

Done! Thanks so much!

User avatar
sapnho
Posts: 244
Joined: Sun Sep 14, 2014 3:49 pm
Location: Frankfurt am Main
Contact: Website

Re: Image viewer with transition between images

Mon Jul 29, 2019 5:46 pm

Thanks to @paddyg, Pi3D now works on the Pi 4. I have updated my article to reflect the changes: https://www.thedigitalpictureframe.com/ ... sing-pi3d/
www.TheDigitalPictureFrame.com - Build a really great digital picture frame with the Raspberry Pi.
With lots of great tips from this forum.
Please submit your digital picture frame project to the user gallery here: bit.ly/2WkyjW1

matt.s
Posts: 1
Joined: Thu Aug 15, 2019 3:53 pm

Re: Image viewer with transition between images

Thu Aug 15, 2019 3:59 pm

@ Paddyg: thank you very much for providing the script!
@ sapnho: thank you very much for providing the guide on https://www.thedigitalpictureframe.com !

I've been following the guide on a Raspberry Model 1 B and I managed to get my old Rpi displaying a slideshow using PictureFrame.py.

Sadly, the images aren't rotated when shot in portrait mode. The exif info is there, as gpicview is showing the images rotated correctly. Any idea how to fix this?

User avatar
sapnho
Posts: 244
Joined: Sun Sep 14, 2014 3:49 pm
Location: Frankfurt am Main
Contact: Website

Re: Image viewer with transition between images

Wed Aug 21, 2019 9:05 am

Sadly, the images aren't rotated when shot in portrait mode. The exif info is there, as gpicview is showing the images rotated correctly. Any idea how to fix this?
As far as I understand, Pi3D does not look at the Exif data for the file orientation. But it still works fine here, so there may be another thing that causes this. @paddyg: Any thoughts?
www.TheDigitalPictureFrame.com - Build a really great digital picture frame with the Raspberry Pi.
With lots of great tips from this forum.
Please submit your digital picture frame project to the user gallery here: bit.ly/2WkyjW1

SohCahToa
Posts: 16
Joined: Fri Aug 30, 2019 3:19 am

Re: Image viewer with transition between images

Fri Aug 30, 2019 11:33 am

Thanks to Wolfgang Männel at the thedigitalpictureframe.com, I have discovered pi3d.

After days of banging my head against my desk and feeling like a bit more then I could chew, I figure out how to implement a script that would slide a series of photos from the right to the left and seamless repeat when I hit the end. However after finishing, I discovered it was actually not what I had hoped for, so I went back to the demo picture frame project.

My problem is that I do not have photos that are all the frame's resolution. I would like to get at blurred version of the image to fill the frame behind the original. I tried experimented with what was suggested earlier in this thread but it looks like it was meant for the old picture frame script not the newer one.

Any advice on how to mak pictures without the frames aspect ratio look nicer, such as getting the reflected background when edge_alpha is set to 1 to be blurred? Do I need a background slide, or do I need to learn about shaders to change the blend_new shader.

User avatar
sapnho
Posts: 244
Joined: Sun Sep 14, 2014 3:49 pm
Location: Frankfurt am Main
Contact: Website

Re: Image viewer with transition between images

Fri Aug 30, 2019 2:34 pm

Thanks @SohKahToa, glad you like Pi3D and the blog. This question should ideally be answered by @paggyg who is grail keeper of Pi3D.

If I understood you correctly, you want your images to be maximised but not cropped and the remaining screen bits filled with blurred parts of the image. That is actually the default version of the script I believe. Can you post your code around the edge_alpha settings?
www.TheDigitalPictureFrame.com - Build a really great digital picture frame with the Raspberry Pi.
With lots of great tips from this forum.
Please submit your digital picture frame project to the user gallery here: bit.ly/2WkyjW1

User avatar
paddyg
Posts: 2541
Joined: Sat Jan 28, 2012 11:57 am
Location: UK

Re: Image viewer with transition between images

Thu Sep 05, 2019 10:10 am

@SohKahToa, Blurring is possible with shaders, as used in the Blur.py demo but that's a two stage process: render the scene then use the depth info to redraw each Shape with a variable amount of blur. Also it's rather complicated for your application, so what I think I would do is use the PIL blur, The extra CPU processing can be mitigated by a) blurring a smaller version of the image b) it happens when no animation is happening so doesn't matter.
This is the kind of thing - but to use with PictureFrame.py you would need to alter the shader - let me know if you want some pointers for that.

Code: Select all

from PIL import Image, ImageFilter
import demo
import pi3d
DISPLAY = pi3d.Display.create(x=0, y=0, frames_per_second=10)
camera = pi3d.Camera(is_3d=False)
shader = pi3d.Shader("uv_flat")
##################################
im = Image.open("textures/lenna_rgb.png")
sz = (int(x * 100 / im.size[0]) for x in im.size) # new size 100 wide
im1 = im.resize(sz) # im.thumbnail() keeps aspect ratio intact but works in place
im1 = im1.filter(ImageFilter.BLUR) # checkout docs - other blurs available
tex = pi3d.Texture(im)
tex1 = pi3d.Texture(im1, m_repeat=True) # mirror tiling on
##################################
sprite = pi3d.ImageSprite(tex, shader, camera=camera, w=300.0, h=300.0, z=2.0)
sprite1 = pi3d.ImageSprite(tex1, shader, camera=camera, w=600.0, h=600.0, z=3.0)
sprite1.buf[0].unib[6:8] = [2.0, 2.0] # uniform variables passed to shader in array
sprite1.buf[0].unib[9:11] = [-0.5, -0.5] # held on Buffer object
mykeys = pi3d.Keyboard()
while DISPLAY.loop_running():
  sprite.draw()
  sprite1.draw()
  if mykeys.read() == 27:
    mykeys.close()
    DISPLAY.destroy()
    break
The pi3d.Texture doesn't attempt to use exif data but @sapnho's latest updates to PictureFrame do use the exif data, specifically the DateTimeOriginal tag. It would be possible to get the Orientation tag at the same time and include it in the list. It's not completely trivial as there are actually 8 different orientations

Code: Select all

1 = Horizontal (normal)
2 = Mirror horizontal
3 = Rotate 180
4 = Mirror vertical
5 = Mirror horizontal and rotate 270 CW
6 = Rotate 90 CW
7 = Mirror horizontal and rotate 90 CW
8 = Rotate 270 CW
but not too difficult. Let me know if you want any help with this.
PS the version of PIL in debian stretch has slightly imperfect exif decoding. If you have problems you might need to update to the latest stable version with
pip3 install Pillow (either use sudo or --user, possibly need --upgrade)
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

sunilammanabrolu
Posts: 3
Joined: Fri Sep 06, 2019 5:24 pm

Re: Image viewer with transition between images

Sat Sep 07, 2019 4:48 am

Thanks to @sapnho's website, I am able to build a decent picture frame using a Raspberry Pi Zero W.
I am using https://github.com/NautiluX/slide for my Picture frame for now. It has all I need except the transitions
I have tried pi3d's PictureFrame but not able to rotate portrait photos. Everything is great about pi3d except this and it is deal breaker for me.
I would like to solve this problem @paddyg

User avatar
paddyg
Posts: 2541
Joined: Sat Jan 28, 2012 11:57 am
Location: UK

Re: Image viewer with transition between images

Sat Sep 07, 2019 5:22 pm

OK @ sunilammanabrolu I'll have a look at it tonight if I get chance. As I say, I don't think it's too hard to do (famous last words eh!) but it should logically go into the Texture class, so maybe I'll look at doing that in the next pi3d release (and stick some of the other exif data in there as well)

The python3-pil (Pillow) library doesn't claim real exif support but I know that some of the issues in version 5.1 (which is what comes with raspbian) have been fixed in version 6.0 so it could well become 'official'.

I will let you know how I get on.

Paddy
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

Return to “General discussion”