PiCamera graphical user interface for the Raspberry PI - optimized for touchscreen. Written in Python using Tkinter.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Assets
.gitignore
AllDialogs.py
Buttons.py
ConfigFile.py
Dialog.py
Globals.py
LICENSE
Languages.py
README.md
WebStream.py
microVIEW.language
microVIEW.py

README.md

microVIEW

PiCamera user interface optimized for a touchscreen display.

Motivation

This work is a result of a collaboration between myself and Michael Axelsson, Professor, University of Gothenburg, Department of Biological and Environmental Sciences (http://www.bioenv.gu.se/personal/Axelsson_Michael/). Professor Axelsson has been investigating using inexpensive hardware and 3-D printed parts in order to capture video/photos from various types of microscopes. The final hardware/software solution would be primarily targeted to a teaching environment. After research, Professor Axelsson had selected the Raspberry PI (RPI) Model 3 as the computer system. Coupled with an RPI camera (V2 model) with flex cable, an SD card (for the OS), a power cable, a touchscreen display (Sundfounder 10” screen (https://www.sunfounder.com/10-1-touch-screen.html) with a 3D printed enclosure, and 3-D printed parts used to mount the RPI camera to each microscope; he had an inexpensive system that offered high resolution video and photo capture capabilities. What was needed was software. Professor Axelsson contacted me about using my PiCamera software (https://github.com/Billwilliams1952/PiCameraApp) to control the system. However, after further discussions, I decided to develop a user interface from scratch targeting a touchscreen display.

Professor Axelsson has documented the R&D effort - see http://microsurgery.se/ under the R/D tab.

Design

This version of microVIEW is optimized for a 1280x800 touchscreen display running in fullscreen mode. Where possible, all controls are simple pushbuttons or sliders that are created specifically for microVIEW. There are no text fields in the option panels. The buttons and sliders have been enlarged to minimize 'touch' errors. In general during normal opeation, a keyboard should not be needed.

When microVIEW is first started, it creates a default microVIEW.INI file if one does not already exist. The default values may be edited to change many aspects of the program interface, file storage locations, and default camera programming values. Key microVIEW.INI data that the user may want to initially edit include:

Under [Preferences]

INI Field Default Value Notes
defaultphotodir /home/pi/Pictures Default location for photos captured by user. May also be selected under Preferences | Files. This is also true for the remaining photo and video directories.
defaultvideodir /home/pi/Videos Default location for videos captured by user
defaulttimelapsephotodir /home/pi/Pictures Default location for photos captured by timelapse
defaulttimelapsevideodir /home/pi/Videos Default location for videos captured by timelapse
defaultfilesdir /home/pi/Documents Default location for any text data created by microVIEW

Under [Network]

INI Field Default Value Notes
headinglevel1 microVIEW The first line (larger font) displayed on the streaming website. Both headingLevel1 and headingLevel2 are available for annotations too.
headinglevel2 Streaming Live Video from Station 1 The second line (smaller font) displayed on the streaming website. headingLevel2 may be used to identify the station (or computer system) that is streaming. Both headingLevel1 and headingLevel2 are available for annotations too.

User Interface

Main Screen

When started, microVIEW displays a fullscreen preview of the video. Along the bottom are four buttons:

Image1 Image2 Image3 Image4

  • The first button closes microVIEW.
  • The second button displays the options screen - see discussion below.
  • The third button takes a picture and saves the photo under the directory specified by defaultphotodir.
  • The fourth button starts video capture. While video capture is in progress, the video button will flash red. To stop the video capture, press the video capture button again. The video will be saved under the directory specified by defaultvideodir.

Options Screen

image

Basic Tab

Basic camera programming functions are provided.

Advanced Tab
  • Camera Tab: Contains additional camera programming. In order to simplify the user interface, many of the advanced options for programming the camera are not provided. However, should the need arise, additional functionality can be readily added.
  • Annotation Tab: Contains options for displaying a timestamp, frame number and/or the headingLevel1 or headingLevel2 text. The text color and background color can be adjusted.
Time lapse Tab

Both Video and Photo timelapse capture are provided under Timelapse | Photos and Timelapse | Videos.

  • Photos Tab: Set the rate of photo capture (e.g. every 10 seconds), and either the stop count (e.g. stop after 10 pictures) or delta time (e.g. stop after 2 hours). Photo timelapse may occur even during a video capture or video timelapse.
  • Videos Tab: Set the rate of video capture (e.g. capture every 30 seconds), the video length (e.g. 10 seconds) and either the stop count (e.g. stop after 10 videos) or delta time (e.g. stop after 2 hours). During Video Timelapse, the Video capture button on the main screen is disabled.
Preferences Tab
  • Files Tab: Set the default directories for saving photos and videos.
  • Network Tab: A simple HTTP web server is provided, allowing the user to stream the video over a local network. Both Ethernet and WiFi are supported. The controls are located under Preferences | Network. Once the HTTP Server is turned ON, it cannot be turned OFF. To enable / disable video streaming, toggle the Video Stream ON or OFF.
  • Interface Tab: Multiple languages are supported via the microVIEW.language file. This file contains many (not all - yet) of the labels, button/control text and messages used by microVIEW interface, ordered by [Language] sections. Currently there are entries for English, Svenska (Swedish), Deutsche (German), Italiano (Italian), Español (Spanish), Nederlands (Dutch), and Français (French). Please note that many translations may not be accurate usage (since I was just using Google Translate). Also note that not all text has translations (yet). Please feel free to update the file and send me the updates as they are completed. If the microVIEW.language file is missing at startup, a default microVIEW.language file is created with just English translations. When editing the microVIEW.language file, the user may insert a newline character (\n) to force a line break in the text. This is useful when trying to fit text within a control or label. For example:
    dynamicrangecompression = Dynamisk\nOmfångskompression:
  • About Tab: Contains microVIEW version information, license information, and credits.

Version History

Refer to Preferences | About | About for the version number of microVIEW.

Version Notes
0.1
  • Initial release. Tested under Python 3.5.3. Note Python 3.X is required
  • Tested using the RPI V2 camera module

Known Issues

Issue Description / Workaround
Language Support The language support is not complete for all controls and text messages throughout microVIEW. Also, I have not verified the accuracy/suitability of the translations. I have just used Google translate. I really need the translations reviewed by native speakers.

TODO List (future enhancements)

TODO Description
Language Support Continue to update translations as reviews are completed and suggestions are offered.
Screen Size microVIEW has been designed assuming a 1280 x 800 touch screen tablet. Provide support for other touchscreen sizes.
Web Server microVIEW uses a very simple web server to stream the video. Only Python 3.x is supported. Provide support for Python 2.x. Provide the ability to start / stop the web server.

API Reference

microVIEW has been developed using Python ver 3.5.3. In addition, it uses the following additonal Python libraries. Refer to Preferences | About | About for the exact versions used.

Library Usage
picamera The python interface to the PiCamera hardware. See https://picamera.readthedocs.io/en/release-1.13/install.html
PIL / Pillow The Pillow fork of the Python Image Library. One issue is with PIL ImageTk under Python 3.x. It was not installed on my RPI. If you have similar PIL Import Errors use: sudo apt-get install python3-pil.imagetk.
netifaces Library to help discover IP addresses. Install using sudo pip3 install netifaces

Installation

Download the zip file and extract to a directory of your choosing. To run, open a terminal, change to the directory containing the source files, and enter sudo python3 microVIEW.py.

Installation on a Fresh Image

On a fresh install of Raspbian

(1) Update software sources. Open the terminal and enter:

sudo apt-get update

(2) Once the update is complete, update everything to the latest version by entering:

sudo apt-get upgrade

(3) Then install ImageTk for python3 by entering:

sudo apt-get install python3-pil.imagetk

(4) Finally, install netifaces by entering:

sudo pip3 install netifaces

(5) If there is a black border of unused pixels around the screen display, you’ll need to disable overscan, otherwise the button overlays won’t line up with the actual buttons underneath the preview. Edit the /boot/config.txt file by opening up a terminal and entering the following command:

sudo nano /boot/config.txt

(5.1) Find and uncomment the disable_overscan=1 line by deleting the ‘#’ character:

disable_overscan=1

(5.2) Save then exit by entering Ctrl+X and then pressing Y to save the file.

(6) Make sure you enable the camera. On the main menu, select Preferences, then ‘Raspberry Pi Configuration’. Once the configuration screen is up, select Interfaces, and Enable the Camera.

(7) Reboot your RPI. The black border should be gone, the Camera should work. After changing to the directory containing microVIEW, it should start up using the command:

sudo python3 microVIEW.py

License

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.