senderj
Posts: 14
Joined: Mon Jan 19, 2015 9:54 am

rotate images on screen

Mon Jan 19, 2015 10:21 am

I am new to Pi (not own one yet), have brief experience on Linux, Python and C, and much on Java with NetBeans and Eclipse. I am thinking of an application that use Pi to display images on a screen and rotate them after an interval. I can use a Windows PC for development so the Pi is only used when testing or in production. I don't have preference on programing language, instead, I prefer a simpler and cleaner implementation. Other than those that come with the Pi, I don't know what other software components I need and other skills I have to learn to implement such application. Also, how is the embedded Python differ from the one on PC? Please point me to the right direction.

User avatar
rpdom
Posts: 15180
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: rotate images on screen

Mon Jan 19, 2015 10:43 am

You can use Python on your PC and copy the files over to the Pi. If you use C you will either need to use a cross-compiler or compile the final code on the Pi.

I don't understand your comment about "embedded Python"? What is that? The Python on the Pi is exactly the same as on the PC. So is the Linux. It just runs on different hardware. The Pi can be used as an embedded system, but it is actually a fully capable (if a bit slow) Linux system.

senderj
Posts: 14
Joined: Mon Jan 19, 2015 9:54 am

Re: rotate images on screen

Tue Jan 20, 2015 3:42 am

Thanks for the reply rpdom. Sorry for using the incorrect term "embedded Python". What I wanted to know is in fact answered by you: "Python on the Pi is exactly the same as on the PC". My question seems open because I may then have chance to get some info that is outside my search scope.

I wanted to develop my app on a Windows PC and port to Pi for production use. I imagine that this means all software components used in production have to work on both Windows and Pi. Python is fine then. How about other components?

Mine is a graphic app so graphic library is a must (Pi didn't come with any ??). Reading through posts here I think I have these options but I don't know if they work on both Windows (at development stage) and Pi (production). Please help :
PIL - looks like strong for image display and processing, but mine is just simple single color shape images, overkill?
Pygame - more for games.
OpenVG - for 2D vector graphic, looks like the way to go.
Pi3D - for 3D rendering, overkill for me.
Info-beamer Pi - uses Lua, though doesn't look difficult, but other options seems don't need to learn other language, correct?

From Pi spec, the GPU support OpenGL ES, I don't know does it means there is an Open GL ES library that comes with the Pi. If so than why many people develop and use the libraries about? Can Python issue Open GL ES instructions/api/commands for simple shape image display and rotate?

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

Re: rotate images on screen

Thu Jan 22, 2015 10:04 pm

Not sure what 'production' involves. But I would suggest you set up your computer dual boot linux/Windows. Especially if it's a debian flavour like ubuntu you will find things map across more easily than from Windows - but python is pretty much python so it's not the end of the world. pi3d doesn't work on windows yet but you could use it in linux.

To do image rotation nicely I think you need to use EGL and GLES functionality, I don't think you can do that with pygame without venturing into its OpenGL functionality. (You can get this from python very easily using ctypes.CDLL() but stringing together all the function calls and matrix multiplications is far from trivial so better to use something ready-made)
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

senderj
Posts: 14
Joined: Mon Jan 19, 2015 9:54 am

Re: rotate images on screen

Wed Feb 04, 2015 8:52 am

After further research, the simplest API I found is ajstarks's openvg layer. Run the Shapedemo here
https://github.com/ajstarks/openvg
successfully in my B+. Starting to give a try with my own code. But before that, I have some questions hoping others can help:

1. Other than jpeg, what image format is supported? I need to display image with transparent holes to let images under it to be seen.
2. Don't totally understand the Translate() and Rotate() functions. Tried them on images but not work. Looks like they are for Text() only. How can I rotate an image?

Please help.

User avatar
Fidelius
Posts: 447
Joined: Wed Jan 01, 2014 8:40 pm
Location: Germany

Re: rotate images on screen

Wed Feb 04, 2015 2:59 pm

senderj wrote:I am new to Pi (not own one yet), have brief experience on Linux, Python and C, and much on Java with NetBeans and Eclipse. I am thinking of an application that use Pi to display images on a screen and rotate them after an interval.
[..]
Mine is a graphic app so graphic library is a must (Pi didn't come with any ??).
[..]
From Pi spec, the GPU support OpenGL ES, I don't know does it means there is an Open GL ES library that comes with the Pi.
Since you know Java much, why not use Java8's nice new JavaFX API to do your 2D graphics? On desktop PCs the JavaFX API uses OpenGL to render 2D and 3D graphics, and on the smaller devices like the PI it uses OpenGL-ES to render them, so indeed even hardware accleration on our little Pi1 with its Videocore GPU.
The JavaFX graphics API is very similar to Java2D API, so in case you know your Graphics2D etc you would see results in no time. No need to use the low-level OpenGL API at all; it's all wrapped with the high-level FX API. (I'm not saying OpenGL bare metal isn't fun, it is, but for faster results use a high-level API.)

Raspbian comes with Java8 which includes JavaFX. Only if you would manually download newer JDKs for the ARM the FX libs are missing, but you could either stay with the current Raspbian's JDK (1.8.0 or 1.8.0_06) and bundle it or its JRE with your application, or add OpenJFX to JDK1.8.0_33+ like Ltorok mentions in the other thread.

Here's the JavaFX API tutorial, and good luck with your project:
http://docs.oracle.com/javase/8/javase- ... logies.htm

P.S. For smaller projects you can even develop on the Pi1 with a lightweight Java IDE like BlueJ. If you need a full blown IDE like Eclipse or Netbeans, you would probably need a Pi2 (haven't tested it yet) or use a desktop PC and remote-run and -debug on the Pi, like it's built-in in Netbeans 8.

User avatar
ajstarks
Posts: 129
Joined: Fri Jun 22, 2012 2:14 am

Re: rotate images on screen

Mon Feb 09, 2015 12:08 pm

senderj wrote:After further research, the simplest API I found is ajstarks's openvg layer. Run the Shapedemo here
https://github.com/ajstarks/openvg
successfully in my B+. Starting to give a try with my own code. But before that, I have some questions hoping others can help:

1. Other than jpeg, what image format is supported? I need to display image with transparent holes to let images under it to be seen.
2. Don't totally understand the Translate() and Rotate() functions. Tried them on images but not work. Looks like they are for Text() only. How can I rotate an image?

Please help.

Note that currently only JPEG is supported with the C API, but other formats are supported in Go.
The translation and rotation functions do not apply to images, but I think that other forks have corrected this.

Return to “Graphics programming”