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 Raspberry Pi Point and Shoot Camera
  • 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: 31 May 2021 3:22 AM Date Created
  • Views 5397 views
  • Likes 12 likes
  • Comments 10 comments
  • photographych
Related
Recommended

Raspberry Pi Point and Shoot Camera

hugohu
hugohu
31 May 2021

Digital cameras are fun. They're smaller than a DSLR, and while not usually offering that great cameras, they're significantly cheaper and have good image quality compared to majority mainstream smartphones.

 

What if you didn't want to buy one, but you just happened to have a small PiTFT, a camera module, and a Raspberry Pi?

 

You can consider making a Digital Camera. Especially if there just happens to be a Photography Project14 image

 

Currently, my prototype does not have charging, power, or anything else. The screen is touchscreen but for controls you will use the 4 buttons connected via the PiTFT.

 

Here is a quick, (and ugly) demo.

 

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

BOM:

Raspberry Pi, Any Model with 2x20 pin header(preferably with WiFi, if Pi 0, camera adapter required)

Raspberry Pi Camera, any model(Preferably HQ camera, using 8mp)

Adafruit PiTFT 2.8" - No touch, Resistive, or Capacitive(using resistive)

SD Card, Power, CSI 15 pin cable

 

Useful knowledge for the project:

Basic Linux terminal commands

Basic Python Experience

 

First, we will make a Python script that will be run to make a simple button-based controller for the Camera. The PiTFT has 4 tactile switches, wired to GPIO 17, 22, 23, and 27.

 

This is the Python Script I wrote. It is simple and has only basic functions, and that is for camera preview, 2800x2100 still images(interestingly enough, the software wouldn't allow full resolution images at the full 8MP), and 1280x720@15fps.

 

from gpiozero import Button
from picamera import PiCamera
from time import sleep
from time import strftime
import datetime

camera = PiCamera()

camera.framerate = 15


softwareOn = Button(17)
softwareOff = Button(22)
takeImage = Button(23)
takeVideo = Button(27)


software = False
video = False


def capture_photo(file_capture):
print("\r\nImage Capturing\r\n")
sleep(2)
camera.capture(file_capture)
print("\r\nImage Captured! \r\n")

while True:
     if softwareOn.is_pressed:
          software = True
          camera.start_preview()
     if softwareOff.is_pressed:
          software = False
          camera.stop_preview()
     if takeImage.is_pressed:
          camera.resolution = (2800, 2100)
          date = datetime.datetime.now().strftime('%m-%d-%Y_%H.%M.%S')
          capture_img = '/home/pi/Photos/' + date + '.jpg'
          capture_photo(capture_img)
     if takeVideo.is_pressed:
          camera.resolution = (1280, 720)
          if video == False:
               video = True
               print("video recording")
               date = datetime.datetime.now().strftime('%m-%d-%Y_%H.%M.%S')
               camera.start_recording('/home/pi/Photos/' + date + '.h264')
               while video == True:
                    sleep(0.25)            
                    if takeVideo.is_pressed:
                         video = False
                         print("Video Recorded")
                         camera.stop_recording()
                         sleep(3)

 

I have tried to format this to the best of my ability. However, the built-in syntax highlighting feature is quite buggy and slow to use. If you are copy-pasting the code, you may need to format the indents and stuff yourself.

 

A quick explanation of the code:

 

We first import our necessary libraries. gpiozero Button is our library for interfacing with the GPIO buttons(in this case, 17, 22, 23, and 27). We have PiCamera, for camera interface, time, for delays, strftime and datetime to determine the time you are taking the photo/video. By default, preview and video recording is off. There is a while loop(While True, so it runs infinitely), which tries to detect your button presses. If you press GPIO 17, the software will begin to start preview and show a fullscreen real-time view of your camera feed. When 22 is pressed, this is turned off. When 23 is pressed it sets resolution to 2800x2100(PiCamera defaults to your screen size, so we don't want a 320x240 image, do we?)

 

Lastly, there when GPIO 27 is pressed it will set video recording to True. This will set resolution to 1280x720, and start recording. The minimum record time is 1/4 second, but this is mainly to work out any longer presses. In addition, when you press the button again, it will stop recording and sleep for 3 seconds(so you do not accidentally trigger another recording).

Lastly, datetime and strftime will check the exact time on-demand to add to the end of your file names. No more pesky IMG_4280582085280450240 filenames.

 

We will probably want the program to run upon boot.

One such way is rc.local.

 

First, we save the file(I saved as camera.py in ~/Home/Pi/)

 

Open up a terminal, type in

 

sudo nano /etc/rc.local

 

image

 

Now, we type in, just before "exit 0",

 

sudo python /home/pi/camera.py

 

Of course, this is assuming if you are using Python and your path to your file is /home/pi/camera.py. It may be different for you.

 

Now, we restart, and the program is working perfectly on boot!

 

Thanks to Tariq for sending me a Raspberry Pi 4, a HQ Camera and a 16mm lens!

 

Initially, I was able to software render 320x240 video at 30FPS. While this was a low resolution, it was quite smooth. However, this lead to increased power draw and the CPU temperatures increased to 75 degrees C, as I was unable to implement active cooling. Due to this, the camera's preview will likely be set to 10FPS for lower power consumption and heat.

 

I am currently designing a flexible case design that can incorporate either a Raspberry Pi 4, or a Raspberry Pi 0. I will hopefully be making two versions of the camera: one that has a built in battery, powered with a Raspberry Pi Z, and passive cooling. It will have a render of 10fps for the preview, and will take 1080P still images, and record 720 video at 15FPS. I have already ordered a raspberry Pi 0 for this purpose.

 

The second design will use a Raspberry Pi 4, 8GB. There will be active cooling, as the Pi 4 generally emits greater heat, and external power, as it has a massive energy draw. 30FPS, or possibly even higher, will be attempted thanks to the lack of restraint on power and heat. I will also attempt to run OpenVino along with an Intel Neural Compute Stick 2 to run some basic machine learning on the camera.

 

One issue I have faced with the 8MP camera(on my POC) and my experiments with the HQ camera, was that I was unable to take still images at or even close to the maximum resolution of the camera modules. After some investigation, I realized that the GPU of the Raspberry Pi shared the RAM with the CPU. However, that set RAM rate must be increased to increase the still resolution.

 

By default on my Raspberry Pi, the memory was set to 128MB. The maximum for the Pi 4 is 256MB shared RAM. After bumping it up to 256MB(thanks to 8GB ram on the Pi, 256MB is no big deal.) After this, the Raspberry Pi worked perfectly and was able to capture images at the HQ camera's maximum resolution(somewhere around 4000x3000.) However, while 256MB may be insignificant for a Raspberry Pi 4B, this is certainly an issue for a Raspberry Pi 0. Both the Raspberry Pi 3A+ and 0 were considered, and the 0 was more economic and had the least energy draw. One tradeoff for it's small size and cost was the RAM. The Raspberry Pi 0 only has an integrated 512MB of RAM. Due to this, it will be likely only possible to take images at a maximum of 2K. This is assuming you set 128MB as the GPU memory allocation. It is possible to run with Swap memory but that will decrease performance, possibly.

  • Sign in to reply

Top Comments

  • colporteur
    colporteur over 4 years ago +4
    As a production model it would need some refinements but as a proof of concept prototype I think it is exceptional. It demonstrates the functionality and capabilities for evaluation. I especially like…
  • cbohra00627
    cbohra00627 over 4 years ago +3
    This is not ugly... in fact, this is very clean and tidied up.
  • hugohu
    hugohu over 4 years ago in reply to colporteur +2
    Yeah, I originally wanted a touch screen one, but I have resistive and resistive isn't the best for touch, and you don't want a stylus for a camera, would you I don't have access to a 3D printer but I…
Parents
  • hugohu
    hugohu over 4 years ago

    I found a soap box that fits the dimensions nearly perfectly. I will use it as a temporary solution. I'll also begin to use openvino hopefully.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • hugohu
    hugohu over 4 years ago

    I found a soap box that fits the dimensions nearly perfectly. I will use it as a temporary solution. I'll also begin to use openvino hopefully.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
No Data
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