A Raspberry Pi Camera Controller
Pi Vision is a Graphical User Interface for the recently introduced Raspberry Pi Camera.
Pi Vision allows you to control the camera functions through the camera’s native camera apps. The incentive here is to allow for easy use of the Raspberry Pi camera. In addition, Pi Vision also serves as an instructional tool. For instance, employed commands are relayed to the user. This assists novice users in understanding the command structure. The project was developed using Lazarus FPC and has been released as open source.
In subsequent sections of this article you will find more details about the Pi Vision open source project. For now, assuming that you already have your Raspberry Pi camera setup and running, you can download Pi Vision and start using it directly on your Raspberry Pi.
Download Pi Vision for the Raspberry Pi File Size: 4.6 MB Downloads: 6,093
Run Pi Vision on the Raspberry
Start the Raspberry’s LXDE and create a new directory. Unpack the contents of the download. Place this in the newly created directory.
In order to run the Pi Vision app you need to first set permissions. Right-click the app, select Properties and from the Properties menu select the Permissions tab. There is a small check-box which needs to be checked called “Make this file executable”.
Then click on the Pi Vision app to run. The start-up page of Pi Vision includes a button called “Test Camera Preview”. This will start a 5 second 640 x 480 camera preview in the upper left corner of your screen. Assuming that your camera is set up correctly and the preview is successful then you are now ready to start using your camera with Pi Vision.
Like any camera the Raspberry Pi camera has a wide spectrum of uses. It also allows many parameters to be set. But it is important to mention that the Raspberry Pi camera is not like your contemporary webcam. What’s the difference? Well, at this point, the incentive appears to be that the camera, like the Raspberry, is an educational tool. The idea is to familiarize oneself with the workings and functions of an on board digital camera. One of the most apparent aspects is that the camera does not seem to infinitely stream its video like a common webcam. There is no Video On or OFF setting. Instead, you need to set a duration time. Only during that time will the camera stream its video.
Note 1: The camera may still be consuming power although not streaming its video.
Review Pi Vision on your OS
Pi Vision is specifically built for the ARM based Raspberry Pi to control its camera. However, binaries have also been provided for Windows, OSX and Debian Linux. These are only intended to review the application and/or if you don’t (yet) have a Raspberry Pi.
Download Pi Vision for Linux Debian 64-bit File Size: 2.0 MB Downloads:507Download
Download Pi Vision for Win 64-bit File Size: 1.0 MB Downloads: 853Download
Download Pi Vision for OSX intel File Size: 6.1 MB Downloads: 337Download
Pi Vision was developed using the Lazarus IDE and FPC (Free Pascal Compiler) running Linux Mint 14. If you want the project sources as well as more detailed information you can find the project here on GitHub. It is what you make of it…
Pi Vision, Raspberry Pi Camera and Lazarus Pascal
An introductory overview
Raspberry Pi, the Altair 8800 of Subspace
Personally…if I had to name one of the most interesting and inspiring gadgets to come out in recent years it would probably be the little Raspberry Pi. Introduced as an educational device it’s an ARM based board level computer with a foot print the size of a large box of matches. It runs under Linux and the basic board unit sells for only $35.
The Bare Minimum
Running about as fast as your old P2 the Raspberry Pi (RPi) does not mean much in terms of computational power. At least when it comes to its ARM based CPU ( Broadcom chip aside). It´s not meant to be. It’s just enough to bring the bare basics to a working level at the bare minimum. And, if you don’t use it for development you can always fall-back and use it as a media player.
But that is not the true essence about what this device is all about. The Raspberry Pi is not just a gadget. It’s a building block. A prelude to something bigger, or actually smaller and more integrated. In a way it is the next phase in computational integration. Sure, others have set milestones here. But the Raspberry Pi symbolizes something a bit more tangible to a larger audience. All that “minimal” has been enough to light a fire among hundreds of thousands of developers. Setting things ablaze.
Depending on how old you are you’ll probably remember when computers took up “floor space”. That migrated later to “desktop space” and, now, “mobile space”. What’s next? Well, for lack of a better word I’ll call it “subspace”. The internet of things.
Myspace, Yourspace, and Subspace
Subspace is a space where computational power has integrated, networked and submerged itself into our environment. It’s in our house, our refrigerator, our car and maybe even our walls, tables and coffee mugs. Sensing, calculating and connecting. It is all around us, fully interfaced. Yet not as tangible as we remembered it to be.
This progression has already started. But it’s devices such as the Raspberry Pi that bring this technology closer to us. Something like the Altair 8800 did for the desktop computing era. Yes, the Altair was in a different price range. Its computational footprint was very small. But like the Raspberry it symbolized something bigger in the years to come.
Accessible Board Level Development Space
The Raspberry Pi (RPi) has sparked as well as re-kindled the production of other boards as well. These typically offer more power, are bigger (larger foot-print) and are more (sometimes much more) costly. Yet, most seem to kinda miss the point. At the other end of the spectrum there are the bare chips which cost pennies. But the complexities involved make these less accessible for the average developer.
Accessibility is a big word. Lets break it down and try to define what makes the Raspberry Pi so interesting, successful and accessible. To me, there are 5 main attributes which make the Raspberry Pi successful. The sum of these parts prove to be an obvious winning combination. The first 3 are; ultra-low cost, very small and the bare minimum. The last 2 are the ability to connect (network, USB, HDMI, audio, video and GPIO) and that it runs Linux (an official distro as well as several others, with more on the way), making it fully accessible and modifiable. Important? Yes. After all, it is still developers that get things done. Not just machines.
RPi Application Development
The script/language of choice for this little device is Python. And, with good reason. Python offers simplicity, it’s easy to understand and very easy to use. It subscribes to the novice developer, in particular, very well. Other ways to create programs/applications are also available. But when it comes to rapid application development you will need something more advanced. To me the choice was Pascal. More specially, FPC using the Lazarus IDE.
Pascal is not the best language. There is no such thing. The question is actually; what does it take to get the job done. And, how to do it in a good, easy and effective way. Pascal is a strongly typed language and offers structure. But more importantly it is accessible and intuitive. In addition, the Lazarus IDE and the FPC runs on most systems; Win, OSX, Linux and Raspbian.
Sure, if you want to get down with lean and mean low-level programming you´ll probably choose for C++ or C. But these are less intuitive. More importantly, most of time I don´t need that type of low-level power. I build high-level interfaces and applications, not low-level broadcom chip firmware development. In addition, when I do need to go low-level, Pascal will typically still allow me to dig in pretty deep.
RPi Quick Start
Again, this is an introductory overview. It is certainly not exhaustive nor is the code supplied as production code. The incentive here is getting started with FPC, Lazarus, RPi and its camera. The information is largely built upon the work of others. It consolidates these. In addition, I am only going to highlight certain things. If you run into a problem you will find ample info on the Internet.
The official package for the RPi is Rasbian Wheezy which is a special Debian distro. After your first start-up you will be presented with a start-up screen/menu that allows you to select certain commands. One of these is to use the entire SD card space. I highly recommend that you do this otherwise you will end up with not enough space to install FPC/Lazarus.
In case you missed the startup menu type in the following at the command prompt (omit the Dollar sign):
$ sudo raspi-config
The ¨sudo¨ means Super User Do. It is one step below root privileges and relates to a user who is permitted to make changes to the system. Select the ¨Expand root partition to fill SD card in the start menu. After that select finish and reboot.
Just a note: To shutdown RPi from the command prompt use:
$ sudo poweroff
I mention this as it was initially unclear how to shut down the RPi properly. Rebooting is:
$ sudo reboot
To update and upgrade your RPi type in:
$ sudo apt-get update
Let it do its thing and then type in:
$ sudo apt-get upgrade
The first time you do this it can take some time to complete. In any case when you install new stuff it is recommended that you use update and upgrade things before installing.
Raspbian Wheezy includes the LXDE desktop which is a lightweight desktop environment. At the command prompt you can start it by typing in:
Another handy note is that you can repeat commands in the terminal by selecting Ctrl-R and then type the first word of what you want repeated.
RPi Installing FPC/Lazarus
Assuming that you were able to expand your root partition to fill the SD card and have rebooted, we can now start to install FPC/Lazarus. The package is already part of the Raspbian repository. So installation is easy. If you have not already done so from the previous section update and upgrade your Raspbian. To install FPC and Lazarus:
$ sudo apt-get install fpc
$ sudo apt-get install lazarus
This can take some time to download and install. After it has completed you will find Lazarus in the ¨Programming¨ menu section of your LXDE start menu.
You may notice that this version of Lazarus is not the most recent. More recent version can be compiled to run on Raspbian Weezy. But that is beyond this article. In any case, this version of Lazarus will do fine in compiling and running Pi Vision.
Having the Lazarus IDE running on the RPi is really great. But you will also notice that it is kinda…slow. The current desktop environment for the Raspberry Pi is LXDE, which is a lightweight desktop. Unfortunately it runs from the ARM processor and does not take advantage of the Broadcom chip’s hardware acceleration at this time. However this may change soon.
The result is that, apart from some simple coding, you won´t really be able to do any serious work on it such as building application interfaces. The idea instead would be to build your Lazarus applications on a more powerful machine and then open and recompile these projects in Lazarus on the RPi for ARM. Setting up a cross compile configuration would be best. But for now you can simply build your projects on your main Linux, OSX or Win machine and then recompile on the Raspberry Pi using Lazarus.
Another important thing to mention is that the RPi includes a GPIO which Lazarus can use! You can find sample code and setup here.
Pi Vision Open Source Project
Start LXDE on the Raspberry.
Create a directory in a desired location on your Raspberry. Place all source files and directories in this directory that you downloaded from the Github Pi Vision repository. Pi Vision’s Lazarus project file is called:
Double click this file. Lazarus is typically already associated with its native files and will open automatically. It may take a moment or two to start Lazarus on the RPi. If Lazarus does not start automatically go to the Programming section, start Lazarus and open the .lpr file from the Lazarus IDE.
With the project opened go to “Run” in the main menu and select “Build”. Then select Run once this completes or the F9 key. It may take up to two minutes for Pi Vision to build and run.
If you have set up your camera correctly you will be able to directly use Pi Vision to control it.
One of the great things about the Raspberry Pi is that it uses Linux. Sky is the limit. It’s also become a great way to become more familiar with Linux.
For many I’d expect that their first real Linux experience was probably through the Raspberry. And, since the Raspberry is also used in schools and by so many young students it means that their first experience with computing was with Linux as well. Sure, they probably used Windows before or picked up an iPad. But the serious computing started with the Raspberry and Linux.
Pi Vision was developed on a machine running Linux Mint 14. But what about Fedora or how about just Ubuntu? And, what about the DE? GNome, KDE, LXDE. Well…it really does not matter. Linux is Linux. Discussing which DE or even distro is better or worse is kinda ridiculous. What matters is what you need, want to do and what your taste is.
If the various DE’s were ice cream flavors then you may want Pralines & Cream while someone else may be satisfied with plain Vanilla. Either way, it’s still ice cream from the same store. Linux simply provides choice.
But what is most apparent about Linux in comparison to other OS is the way it has been put together. Linux is a community effort of thousands of developers world-wide. Although non-profit comes to mind there are serious commercial aspects to it.
While most commercial development has an obvious commercial incentive, open source development, like Linux, forms a more natural evolution towards surviving in a digital ecosystem.
Remember those wooden (or plastic) building blocks you used to play with as a kid. You probably built a tower as high as you could go. You would plan out how to build the best base for the highest possible tower. Either intentionally or by accident it would fall/crash down at some point. In either case you knew that it would happen. And, then you would start over again. Make and then break. Start over. Make better. Do it again. Linux involves something similar in its development progression.
Recently, clones have appeared of the native RPi camera. These clones include a different board and lens. They seem to work fine using the RPi’s native camera apps and Pi Vision. The lenses (M12 and CS-Mount) are, typically, removable, allowing greater capture possibilities than the pinhole type lens found on the native RPi camera. The M12 and the CS-Mount allow focusing. But it should not be difficult to find lenses with zoom and iris control as well.
However, when choosing a different lens it is important that the lens is compatible with the imaging sensor. There are 2 things to keep in mind; the imaging sensor size and the distance between the imaging sensor and lens. The imaging array size looks to be about 1/4 Inch. While a lens may fit it must also create the right sized image on the imaging array. Spacers may be needed to make sure the distance between the lens and sensor are correct.
Raspberry Pi Projects? A library of great info can be found at:
Lazarus, Free Pascal and Delphi can be found at the Blaise Pascal Magazine website
Find the article about Pi Vision in MagPi November 2013 issue page 24
MagPi Nov 2013 issue page 24