Skip to main content

Rendering Pi Camera pictures into Minecraft Pi world

With my new Pi Camera I improved the Minecraft JPG renderer script allowing to take pictures in real time using the Pi Camera and render it into Minecraft world.

Currently the script is divided in two parts to improve the usability, the first part is the Pi Camera script section:

UPDATE: here is the full joined code of the two scripts:

This script takes a picture from Pi Camera and resizes it to a Minecraft scale. There are some considerations with this script, because the libjpeg support is not enabled by default by the PIL Python module, so you must do:

sudo apt-get install python-dev
sudo apt-get install libjpeg8-dev
sudo ln -s /usr/lib/arm-linux-gnueabihf/libjpeg.so /usr/lib/
sudo pip install PIL

The second part of the script is the old Minecraft JPG renderer script, that uses as input the output file from capturepicamera.py script, so its trivial to join the two scripts in one if you want. You also can add at the end of the first script something like this to call second script from the first one.

subprocess.call([‘./minecraftpicture.py’])

All scripts are on github: https://github.com/ferriman/SSandSP

Here is the result, my Minecrafted face on real time:

Me rendered on Minecraft pi using Pi Camera
Me rendered on Minecraft pi using Pi Camera

21 thoughts on “Rendering Pi Camera pictures into Minecraft Pi world

    1. There are different ways to do it, I like PIP utility, btw i’m not sure if python-imaging package has the libjpeg support enabled by default.

    1. The Camera captures only static images, you cannot see real time video rendering because of the CPU limitations of Rpi and Minecraft pi.

      1. Hi,

        I´m a teacher from germany and I work with the Raspberry Pi in my classroom. I`d love to use your program, but ufortunately I couldn´t get it running. If you have some spare time, could you please write down all the necassary steps for using the program with the new Version of Raspbian. It has minecraft already installed, but I think you now have to use “from mcpi import minecraft” in order to import the minecraft library. I already changed that, but I couldn`t get it working. I guess there`s a problem while importing the picture. Maybe you could just tell me where exactly the picture has to be stored in order to use it with your script. I can run the Pi Camera script and it saves a file in my /home/pi folder. But when I open the JPG renderer script, it can`t find the picture. I guess I`m making some basic mistake, but I can´t figure it out and my pupils would really like to use your program. Thanks & greetings from germany!

  1. Hi,

    I bought a Raspberry PI 3 to my 11 years old boy, addict to MineCraft, because he wants to learn to program. He was really interested by your post. He would like to try the same kind of things but with an existing picture (not taken by the camera).
    I guess it’s possible but i’m not really sure how….

    Is it correct if i just modify the following piece of code ?

    # FETCH FILE FROM THE CAMERA
    savefile=”/home/pi/tmp_image.jpg” # Need to update file name
    size= 200,200 # Need to update picture size
    # camera=picamera.PiCamera()
    # camera.start_preview()
    # i=raw_input() # PRESS ANY KEY TO FETCH THE PICTURE
    camera.capture(savefile)
    camera.stop_preview()
    im=Image.open(savefile)
    im.thumbnail(size,Image.ANTIALIAS)

    Thanks for your help!

  2. Hi,

    I bought a Raspberry PI 3 to my 11 years old boy, addict to MineCraft, because he wants to learn to program. He was really interested by your post. He would like to try the same kind of things but with an existing picture (not taken by the camera).
    I guess it’s possible but i’m not really sure how….

    Is it correct if i just modify the following piece of code ?

    # FETCH FILE FROM THE CAMERA
    savefile=”/home/pi/tmp_image.jpg” # Need to update file name
    size= 200,200 # Need to update picture size
    # camera=picamera.PiCamera()
    # camera.start_preview()
    # i=raw_input() # PRESS ANY KEY TO FETCH THE PICTURE
    camera.capture(savefile)
    camera.stop_preview()
    im=Image.open(savefile)
    im.thumbnail(size,Image.ANTIALIAS)

    Thanks for your help!

      1. Hi,

        So we tried.
        We had a small issue installing PIL but now it’s fixed.
        My actual problem is “Minecraft no such module”.
        Which is surprising me as Minecraft PI is installed on my Raspberry.
        Am i missing something ?

        Thanks for your help !

        Regards,

Leave a Reply

%d bloggers like this: