Evan Poliquin
Published © CC BY-NC

Raspberry Pi Quadrascopic Camera

Using a Raspberry Pi CM4 and an Arducam quad sync hat, a digital quadrascopic image can be taken, similar to the Nimslo and Nishika.

BeginnerWork in progress8 hours2,740
Raspberry Pi Quadrascopic Camera

Things used in this project

Hardware components

Compute Module 4
Raspberry Pi Compute Module 4
×1
Arducam Quad Sync Hat
×1
4.3 DSI LCD Touchscreen
×1
Waveshare Nano Base Board A
×1
Mini 10000 mah battery
×1

Software apps and online services

Pi OS
Fusion 360
Autodesk Fusion 360

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)

Story

Read more

Custom parts and enclosures

Enclosure

Schematics

Drawing

Code

Script

Python
import os
import time
from gpiozero import Button
from datetime import datetime
from signal import pause
from multiprocessing import Process, Queue
from gpiozero import CPUTemperature
from subprocess import Popen

shutterButton = Button(20)
PreviewButton = Button(26)
shutdownButton = Button(21)
cpu = CPUTemperature()
x = 0
sleepStaus = 0
k = None
startTimer = 0

def sleepFunction():
    command = "xset dpms force off"
    cmd = command
    p = Popen(cmd.split())
    print("screen off")


def run():
    print("preview is initiated")
    try:
        temperature = cpu.temperature
        command = "libcamera-hello -t 5000 --autofocus --info-text Preview_Display"
        cmd = command
        p = Popen(cmd.split())
        x = p.pid
        print("Process ID:", x)
        while True:
            if p.poll() != None:
                print("preview is closed")
                break;
            else:
                print("waiting for it to take picture")
    except:
        print("error")

def WorkerThread():
    print("capture is initiated")
    # command = "kill "+ str(x)
    # cmd = command
    # p = Popen(cmd.split())
    try:
        location = "/media/pi/SD/"
        name = datetime.now().strftime("%Y_%m_%d_%H_%M_%S")
        command = "libcamera-still -t 3000 -o "+name+".jpg --autofocus --info-text Image_Capture"
        cmd = command
        r = Popen(cmd.split())
        k = r.pid
        print(r.poll())
        while True:
            if r.poll() != None:
                print("image capture is closed")
                break;
            else:
                print("waiting for it to take picture")
    except:
        print("error")

while True:
    if (shutterButton.is_pressed == True):
        WorkerThread()
        time.sleep(1)

    elif (PreviewButton.is_pressed == True):
        run()
        time.sleep(1)

    elif (shutdownButton.is_pressed == True):
        pressed_time=time.monotonic()
        while (shutdownButton.is_pressed == True): 
            pass
        pressed_time=time.monotonic()-pressed_time
        if pressed_time<5:
            print("shutdownButton is pressed less then 5 sec")
            sleepFunction()
            time.sleep(0.05)
        elif pressed_time>=5: 
            print("shutdownButton is pressed more then 5 sec")       
            command = "sudo shutdown -h now"
            cmd = command
            p = Popen(cmd.split())
            time.sleep(0.05)

Credits

Evan Poliquin

Evan Poliquin

1 project • 0 followers

Comments