GithubHelp home page GithubHelp logo

billwilliams1952 / picameraapp Goto Github PK

View Code? Open in Web Editor NEW
279.0 28.0 66.0 549 KB

A graphical interface for programming the Raspberry Pi PiCamera. Written in Python using Tkinter.

Python 100.00%
raspberry-pi raspberry-pi-camera raspberry-pi-gpio python tkinter graphical-interface gui linux tkinter-graphic-interface pi-camera picamera

picameraapp's Introduction

Synopsis

PiCameraApp: A graphical user interface (GUI) for the Picamera library written in Python using Tkinter / ttk.

Motivation

While developing a camera interface to a 32x32 RGB matrix, I was constantly programming the Picamera in code to test options. I decided to develop a GUI that provides an interface to all of the Picamera's API. Since I haven't done much GUI programming in Linux, I used the Tkinter API.

Note: I am an old (old, old, old, ..., so very old) Windows programmer going back to the days of Windows 2.1 (Petzold). Both the Python language as well as Linux on the Raspberry Pi are new to me, so please forgive unintentional (or blatant) misuses of the API or Python coding 'standards'.

Version History

Version Notes
0.1
  • Initial release. Only tested under Python 2.7X
  • Tested using the RPI V1 camera module
0.2
  • Tested using Python ver 2.7.13 and Python ver 3.5.3. If there are any problems please send me new issues.
  • Awaiting a V2 camera module for test.
  • User interface update. Reorganized controls, added new icons.
  • Added tooltips. The file /Assets/Tooltips.txt can be modified by the user to add his/her own tips
  • Additional camera functionality in accordance with https://picamera.readthedocs.io/en/release-1.13/.
  • New dialogs for Preferences, Video and Image capture formats, and Annotation.
  • Support for many of the image effect parameters.
  • Code for the Camera programming tabs Basic, Exposure, and Advanced moved to separate files.
  • mainscreen0 2

    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 python PiCameraApp.py or sudo python3 PiCameraApp.py.

    Known Issues

    Issue Description / Workaround
    LED The led_pin parameter can be used to specify the GPIO pin which should be used to control the camera’s LED via the led attribute. If this is not specified, it should default to the correct value for your Pi platform. At present, the camera’s LED cannot be controlled on the Pi 3 (the GPIOs used to control the camera LED were re-routed to GPIO expander on the Pi 3). There are circumstances in which the camera firmware may override an existing LED setting. For example, in the case that the firmware resets the camera (as can happen with a CSI-2 timeout), the LED may also be reset. If you wish to guarantee that the LED remain off at all times, you may prefer to use the disable_camera_led option in config.txt (this has the added advantage that sudo privileges and GPIO access are not required, at least for LED control). Thanks https://picamera.readthedocs.io/en/release-1.13/
    Sensor Mode Use this with discretion. In any mode other than Mode 0 (Auto), I've experienced sudden 'freezes' of the application forcing a complete reboot.
    framerate_range and H264 video The App would raise an exception when attempting to cature H264 video when framerate_range was selected. The exception complained the framerate_delta could not be specified with framerate_range??? Until I resolve this bug, I don't allow capturing H264 videos with framerate_range selected.
    framerate and framerate_delta error checking There are cases where the code may not catch an exception. Avoid setting framerate and framerate_delta values that could add to numbers less than or equal to zero. A future update will fix this issue.
    JPEG image parameters The JPEG image capture parameter 'Restart' is not supported with this release.
    H264 video parameters The H264 video capture parameter 'Intra Period' is not supported with this release.
    Other video paramaters 'bitrate' and 'quality' are not supported in this release.
    Image Effects parameters The Image Effect parameters for 'colorbalance', 'film', 'solarize', and 'film' are not supported with this release.
    EXIF data display The python exif module does not support all EXIF metadata. Find a better solution.
    Image flip buttons The two image flip buttons on the bottom image pane are disabled. These are meant to 'flip' the PIL image that is displayed. To flip or rotate the camera image, use the buttons on the top preview pane.

    TODO List (future enhancements)

    TODO Description
    Save Camera State Allow the user to save and restore the current camera programming state.
    Output Samples Allow the user to generate a simple Python script that will program the camera and take a still image or video.
    INI File Have a configuration file that saves / restores Preferences
    Time Delay Support programming the camera to take still (or videos of length time), starting start time, then every time sec, delaying time sec until number or end time is reached.
    GPIO Support Better suport the LED GPIO - this is still buggy (or not fully understood). Also, allow the user to specify GPIO pin(s) that can be toggled (or held high or low) while a still image or video capture is in progress.
    Better error checking Reorgainze code

    API Reference

    PiCameraApp has been developed using Python ver 2.7.13 and Python ver 3.5.3. In addition, it uses the following additonal Python libraries. See the PiCameraApp About dialog for exact versions used.

    Library Usage
    picamera The python interface to the PiCamera hardware. See https://picamera.readthedocs.io/en/release-1.13/install.html
    RPi.GPIO Required to toggle the LED on the camera. Can get it at http://www.raspberrypi-spy.co.uk/2012/05/install-rpi-gpio-python-library/
    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.

    about

    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/.

    picameraapp's People

    Contributors

    billwilliams1952 avatar krasiu avatar

    Stargazers

     avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

    Watchers

     avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

    picameraapp's Issues

    Live full screen video - question and comment

    Hi

    I am completely new to Rasberry pi and programming in anything else than Labview. I am coordinating a microsurgery training center in Gothenburg (http://microsurgery.se/) and are looking at simple and cheap ways to monitor the work by the participants when they work.
    I have tried very expensive solutions like side tubes (5000 EUR), Leica microscope camera system for around 3500 EUR. I also used modified Logitech c920 cameras (mounted in a new house with a c-mount) in combination with Samsung tablet and the CameraFi app, that combination is around 600 EUR so cheapest so far, I can view live full screen (10" screen) sae images or video and also cast (Chrome cast) the live feed to the teaching screen in the front of the room. BUT there is an issue with simultaneous charging the tablet and viewing the camera since they use the same USB port.

    Read about the Rasberry pi system and the camera that together is very cheap, combined with a 10" touch screen it would make e even cheaper system and without the problem with simultaneous charging

    My problem is that I do not now how to create a program for this, I would like to have a program that can do all the things that your program is doing (control of the camera, save still images and live video) but also show a full screen live video feed from the microscope but I cannot see this possibility

    A comment
    My Rasberry is runnig Python 2.7.9 (pyhton --version) so I should start your program with the command sudo "python PiCameraApp.py" that does not work but "sudo python3 PiCameraApp.py" works (tried this in desperation after reading all the instruction and installing all the things needed

    Sincerely
    Michael Axelsson

    Unable to run app

    Hi there,

    Is there an updated version to work with the TKinter format changes for python3. I am also using a raspberry Pi 3 board if this makes a difference? Also it is saying that the PIL is missing even though I have installed it. Any help would be great.

    Issue in RPI4 Using full 64bits image: OSError: libmmal.so: cannot open shared object file: No such file or directory

    Hi,

    How to solve this issue(pls)?:

    ~/Desktop/PiCameraApp-master/Source $ python3 PiCameraApp.py
    Traceback (most recent call last):
    File "/home/neuberfran/Desktop/PiCameraApp-master/Source/PiCameraApp.py", line 38, in
    from AnnotationOverlay import *
    File "/home/neuberfran/Desktop/PiCameraApp-master/Source/AnnotationOverlay.py", line 61, in
    import picamera
    File "/usr/local/lib/python3.9/dist-packages/picamera/init.py", line 72, in
    from picamera.exc import (
    File "/usr/local/lib/python3.9/dist-packages/picamera/exc.py", line 41, in
    import picamera.mmal as mmal
    File "/usr/local/lib/python3.9/dist-packages/picamera/mmal.py", line 49, in
    _lib = ct.CDLL('libmmal.so')
    File "/usr/lib/python3.9/ctypes/init.py", line 374, in init
    self._handle = _dlopen(self._name, mode)
    OSError: libmmal.so: cannot open shared object file: No such file or directory

    image

    Small GUI bug

    The annotation text is default set to none, but the textbox is not disabled.

    Found no camera

    Hi,
    i want tio use the camera for a microscope and found no other application which has an gui. so i invest some time to get this one here running. So far i managed to install tkinter and get rid of that message.
    Now i am stuck at the error:

    pi@octopi:~/PiCameraApp-master/Source $ /usr/bin/python3 PiCameraApp.py
    Traceback (most recent call last):
    File "/home/pi/PiCameraApp-master/Source/AnnotationOverlay.py", line 61, in
    import picamera
    ModuleNotFoundError: No module named 'picamera'

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
    File "PiCameraApp.py", line 38, in
    from AnnotationOverlay import *
    File "/home/pi/PiCameraApp-master/Source/AnnotationOverlay.py", line 65, in
    raise ImportError("You do not seem to have picamera installed")
    ImportError: You do not seem to have picamera installed

    I try to use it with python3 on a raspi 4 with mostly new software installed. i am also running octoprint.
    i can run qtv4l2 and take videos with the cam so i can assure it is properbly connected and working. i have to stop my webcamd service to get it running and i am not sure, if picam needs webcamd running or not. But it did not make any difference regarding this stated error.
    may i be allowed one sidenote. I also investet 2hours to get a desktop icon installed (ahhrg so much time)..i don know, if this repository is still maintained, but if it is, i would like to share that with you.
    cu
    thomas

    Improvements in TimeLapse

    Such a great app, have you done any recent dev on Timelapse Code?, I was looking at the code and found the timelapse tab and the ToDo's

    Error on Startup (July 2020)

    Here is a snippit of my command line, Im not very novice on this rpi quite yet but ive done my research on other "issues" and one seemed similar but wasnt quite what im getting.
    Im running a RPI4 4gb on raspbian, with updated and upgraded packages, running Python 3.7.3

    pi@raspberrypi:~/Documents/PiCameraApp-master/Source $ sudo python3 PiCameraApp.py Traceback (most recent call last): File "PiCameraApp.py", line 38, in <module> from AnnotationOverlay import * File "/home/pi/Documents/PiCameraApp-master/Source/AnnotationOverlay.py", line 52, in <module> from Dialog import * File "/home/pi/Documents/PiCameraApp-master/Source/Dialog.py", line 43, in <module> from PIL import Image, ImageTk, ExifTags ImportError: cannot import name 'ImageTk' from 'PIL' (/usr/lib/python3/dist-packages/PIL/__init__.py)

    Thanks and stay safe!

    Framerate/Timelapse

    Hi, I was wondering how I could edit the code in order to add something that either allows me to take a 1 FPS video or a time lapse. Any recommendations are welcome!

    Change overlay view size and position

    Hi. Thanks for the code.

    We would like to change size and position of the overlay window when viewing. It is now fixed in the top left corner.

    Is it possible to do it full screen?

    Thanks in advance. Best wishes!

    HQ camera doesn't like sensor mode 0

    The HQ camera halts when taking an image in sensor mode 0 in this app, and I have to restart the program to clear it. Changed the default sensor mode to 1 on my copy to avoid the issue.

    Image not in frame

    Hi,
    Thanks for sharing. Just downloaded your code. I'm having issues with the image showing outside of the preview panel. How can I fix that?

    How can I use USB camera??

    This code is excellent.
    It is very helpful to me who is studying raspberry pi.

    How can I use a USB camera instead of a pi cam?
    I think it should not just change 'dev' because current code using PI cam lib.
    Therefore, I need your opinion as an expert.

    X11 Forwarding

    I don't know if you want to consider this issue, but X11 forwarding the preview is broken. The overlay does not display, and the non-overlay preview doesn't work either. Also the video preview doesn't work. Generally, X11 forwarding is broken.

    Cannot import ImageTk

    pi@raspberrypi:~/Desktop/PiCameraApp-master/Source $ sudo python3 PiCameraApp.py
    Traceback (most recent call last):
      File "PiCameraApp.py", line 38, in <module>
        from	AnnotationOverlay	import *
      File "/home/pi/Desktop/PiCameraApp-master/Source/AnnotationOverlay.py", line 52, in <module>
        from 	Dialog	import *
      File "/home/pi/Desktop/PiCameraApp-master/Source/Dialog.py", line 43, in <module>
        from PIL import Image, ImageTk, ExifTags
    ImportError: cannot import name 'ImageTk' from 'PIL' (/usr/lib/python3/dist-packages/PIL/__init__.py)
    

    Need Help

    Please Can u help me execute the code. each time i try to run the PiCameraApp.py file it gives me this :
    Traceback (most recent call last):
    File "PiCameraApp.py", line 38, in
    from AnnotationOverlay import *
    File "/home/pi/Downloads/PiCameraApp-master/Source/AnnotationOverlay.py", line 52, in
    from Dialog import *
    File "/home/pi/Downloads/PiCameraApp-master/Source/Dialog.py", line 43, in
    from PIL import Image, ImageTk, ExifTags
    ImportError: cannot import name ImageTk

    Whenever i try to run all the codes it gives errors like this. Please Help.

    Cannot ReSize PiCameraApp.py on GIPO 3.5" Touchscreen TFT LCD (320*480)

    We are running your code on a Raspberry Pi (Linux raspberrypi 4.14.30-v7+ #1102 SMP Mon Mar 26 16:45:49 BST 2018 armv7l GNU/Linux)

    And we are not using the HDMI output - is there a way to resize the app so that it can be used on the GIPO screen , had a look in PiCameraApp.py but could not find the option,

    Any help would be useful

    Error initializing Tkinter!

    Hello,

    I'm trying to run the application, but I'm getting the following error when running the startup command:

    running....
    No protocol specified
    No protocol specified
    Error initializing Tkinter!
    
    Shutting down
    
    Press any key
    Traceback (most recent call last):
      File "PiCameraApp.py", line 1104, in Run
        win = Tk()
      File "/usr/lib/python3.7/tkinter/__init__.py", line 2023, in __init__
        self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
    _tkinter.TclError: couldn't connect to display ":10.0"
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "PiCameraApp.py", line 1130, in <module>
        Run()
      File "PiCameraApp.py", line 1107, in Run
        raw_input()
    NameError: name 'raw_input' is not defined
    

    I'm quite new RPi and Python so still getting to grips with it all. Thanks in advance,

    Recommend Projects

    • React photo React

      A declarative, efficient, and flexible JavaScript library for building user interfaces.

    • Vue.js photo Vue.js

      🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

    • Typescript photo Typescript

      TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

    • TensorFlow photo TensorFlow

      An Open Source Machine Learning Framework for Everyone

    • Django photo Django

      The Web framework for perfectionists with deadlines.

    • D3 photo D3

      Bring data to life with SVG, Canvas and HTML. 📊📈🎉

    Recommend Topics

    • javascript

      JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

    • web

      Some thing interesting about web. New door for the world.

    • server

      A server is a program made to process requests and deliver data to clients.

    • Machine learning

      Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

    • Game

      Some thing interesting about game, make everyone happy.

    Recommend Org

    • Facebook photo Facebook

      We are working to build community through open source technology. NB: members must have two-factor auth.

    • Microsoft photo Microsoft

      Open source projects and samples from Microsoft.

    • Google photo Google

      Google ❤️ Open Source for everyone.

    • D3 photo D3

      Data-Driven Documents codes.