element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Photography
  • Challenges & Projects
  • Project14
  • Photography
  • More
  • Cancel
Photography
Blog Point and Shoot Digital Camera: v2
  • Blog
  • Forum
  • Documents
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Photography to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: hugohu
  • Date Created: 10 Jul 2021 8:36 PM Date Created
  • Views 1295 views
  • Likes 8 likes
  • Comments 2 comments
  • photographych
Related
Recommended

Point and Shoot Digital Camera: v2

hugohu
hugohu
10 Jul 2021
image

Photography                                               Submit an EntrySubmit an Entry

 

Monthly Themes   | Monthly Poll   |  Back to homepage image

 

Thanks to Tariq for sending me a Raspberry Pi HQ camera kit! With the kit, I have made a completely new version of the first camera I made.

 

Notable upgrades:

- Image preview window

- much more readable and logical code

- improved camera @ 12.3MP

- integrated power supply

 

Before we begin, I would like to disclose that the power supply is a battery bank. Now that is out of the way, let's go see how the thing works.

 

This version is powered with a Pi 0W. (I do not believe I have time to do CV on a Pi 4, unfortunately, but that will certainly be done in the future.)

It is connected to an Adafruit PiTFT 2.8" Resistive touchscreen, which has 4 buttons on the outside connected to GPIO pins 17, 22, 23, and 27. Via the MIPI CSI interface, a Raspberry Pi High Quality camera is connected.

 

The lion's share of the project is done in software. The software is quite long and is in a GitHub Repository(as I do not want to play around with the e14 site markdown)

 

BOM and Software:

 

Raspberry Pi HQ Camera, with C/CS lens(and adapter if necessary)

CSI cable: standard FPC 15 pins, 1.0mm pitch contacts opposite

CSI cable: 22 pin FPC 0.5mm Pitch to 15 pin 1.0 pitch adapter

Optional: Raspberry Pi 4, 2GB or higher, for software development

Optional: Host computer, with Microsoft VSCode(must be configured on raspberry pi, but VSCode does that automatically. Install PyLance for the Raspberry Pi), Remote extension, VNC Viewer(VNC must be enabled, configured on Raspberry Pi as well)

PiTFT 2.8" Resistive for B+

Optional: single cell 18650 power bank

MicroSD Card, 16GB or higher, Class 10 or better, with Raspbian w/Desktop(preferably full version)

 

First, we will need to set up the development environment for the Raspberry Pi. While the Pi comes with Thonny, Thonny is vastly inferior to Visual Studio Code, which has a powerful PyLance extension.

 

image

 

You will need to go to VScode>Marketplace, search Python, and install the extension from Microsoft.

 

image

 

You will also need Remote - SSH, also from Microsoft.

 

Once this is done, connect to your Raspberry Pi! Make sure it's connected to your network + has SSH enabled(adafruit has a great guide on this Overview | Raspberry Pi Zero Headless Quick Start | Adafruit Learning System)

After connecting, enter your Pi's password(default username is pi, password raspberry).

 

Open a folder, in the location you would like. I have used /home/pi/Documents/ as the location for my python files.

 

Here's the GH: Hugoyhu/Raspberry-Pi-Point-and-Shoot-Camera: Python scripts for the Point and Shoot Camera, v2 (github.com)

Please copy all 4 files into VScode(sorry!)

Make sure to use pip to install PyQt5, a library for GUI development, that I used:

 

run this in the terminal

 

pip3 install PyQt5

 

Once that is done, run Main, and give it a try! Keep in mind: the app uses X11 forwarding, so you must either run directly on the pi, or VNC. You cannot forward X11(at least I haven't figured out how), over SSH(which is what ssh and VScode remote use)

 

Button 17 is to turn the preview on/off, 22 is to take an image, 23 is to take a .h264 video(press once to record, press it again to stop recording)

 

By default video is 480p and stills are 4056x3040(gotta take advantage of that extra resolution, ya know)

Like with the previous version, you'll need to increase graphics video RAM to at least 256MB. Go to sudo raspi-config -> performance options -> Video memory

 

I don't want to bore anyone with the specific details of how the code works, so I'll just give a quick overview of the structure. There are 4 python files: a main file, a file for the Camera controls, one for the window management(for image preview) and another one for the constants used in the files(such as file paths)

 

The camera control file has 3 buttons(gpiozero.Button) which creates a thread for each button with a callback assigned. The CameraController.py file has a class, CameraController that has several functions for taking images. There is an __init__ function which is an interface for the construction of a CameraController instance, and a few others such as for taking stills, videos, and turning preview on/off.

 

The CameraController is then imported into the ViewWidgets module. As CameraController is multithreaded, other than initial setup, the main thread doesn't do anything, and will require a resource exhaustive loop with sleep in order to prevent the main thread from exiting. However, the ViewWidgets module has a ViewWidgets class, which incorporates the PyQt5 library, one that is used for GUI creation. In order for the GUI to remain running, there must be a blocking function, (instance of QApplication).exec_(). However, this is troublesome as it pauses the thread that is being used. Thus, it is not feasible to have CameraController import ViewWidgets, rather, ViewWidgets importing CameraController.

 

After this is done, there is a callback from ViewWidgets that allows CameraController to "notify" ViewWidgets that a new image has been taken(so the image can be added to the list for previews)

 

The code is fully functional with my testing. However, I haven't been able to have it run from start, either with cron or rc.local. I'm not sure why, frankly.

 

Using a cardboard box, I made a larger, but more durable case. It also has room for batteries. Instead of using a Pi 0, I decided to use the Pi 4 Tariq sent me- it is just much faster. My touchscreen on the PiTFT was not working, and I do not want to transfer files/ reset configs to a new SD, so I am using VNC viewer in the video attached. Here is a demo of me using the Preview, image taking, and image gallery.

 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

I am powering externally since my internal battery is 1A, ~4000mah, and my external is 25000mah @ 2.1A. I will be trying out openvino soon!

  • Sign in to reply

Top Comments

  • robogary
    robogary over 4 years ago +1
    Excellent project. Do you have any photos of the build and photos you've taken to share ?
  • hugohu
    hugohu over 4 years ago in reply to robogary

    Unfortunately, not yet. I'm a very bad crafter and I'm still trying to figure out how to cram everything into one small box, but I'm expecting to have that done tomorrow

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • robogary
    robogary over 4 years ago

    Excellent project. Do you have any photos of the build and photos you've taken to share ? 

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube