Close

New Feature: Exposure Adjustment

A project log for 90s Raspberry Camcorder

Upgrading a 1993 RCA CC540 VHS camcorder with a Raspberry Pi, HQ Camera module, modern storage, power, and features.

DustinDustin 11/30/2020 at 04:370 Comments

In the previous log, I said I'd implement white balance next...I Lied. I ended up doing exposure adjustment instead. It was easy enough to add "auto" and "night", so I'm happy with that. Feature implementation is turning out to be one of my favorite parts. I suspect that's pretty common with most people... I do make myself go back and clean up and optimize my code after a while, but it's more of a chore. Speaking of which, I need a better system for adjusting all of these settings, as I won't have that many physical buttons on the camera. That reminds me: I need to count how many buttons I have available on the thing. I'm sure I'll add more as I go. 23 tactile buttons, and 2 sliding swithces. One switch is the power switch, two buttons are reserved for zoom, and a 1 is the record button. That leaves me a cool 20 buttons to work with right now. I counted 36 current options that require buttons, so I already far exceed what I have. Being able to scroll through functions and save commonly used as hot keys will be a requirement at this point. I need to combine the buttons to start and stop recording into a single toggle button, which will free up one button. Using a keyboard, it hardly matters how many things I tie to buttons. Maybe I'll have the option to hook up a full keyboard and unlock every single function. I giant custom control panel comes to mind, and looks glorious in my head. It makes me happy to imagine breaking out every single camera function onto a control panel, and running this like a brodcast camera. Broadcast camera is loosely what I am basing this on, so that makes perfect sense.

Anyway, back to the actual update. The following updated code is working as designed, and all is well at this point. I finally docuented all of the commands in the file, as they were starting to pile up. I feel the documentation process is one of the most important in the creation process, but it can be very time consuming and tedious up front. Worht the savings down the road, and when others wish to work with your code.

"""
Commands:
r = start recording
s = stop recording
p = take picture
0-8 = ISO modes 100-800, 0 is auto
a = auto exposure
n = night exposure


Exposure Modes:
- off
- auto
- night
- nightpreview
- backlight
- spotlight
- sports
- snow
- beach
- verylong
- fixedfps
- antishake
- fireworks

White Balance Modes:
- off
- auto
- sunlight
- cloudy
- shade
- tungsten
- flourescent
- incandescent
- flash
- horizon
"""

import keyboard
from time import sleep
from picamera import PiCamera
import numpy as np

camera = PiCamera()
camera.resolution = (1920, 1080)
camera.exposure_mode = 'auto'
camera.awb_mode = 'auto'
camera.start_preview() 

while True: 
    try:        
        if keyboard.is_pressed('r'):
            camera.resolution = (1920, 1080)
            sleep(2)
            camera.start_recording('/home/pi/Documents/test_files/button.h264')

                
        if keyboard.is_pressed('s'):    
            camera.stop_recording()         
        
        if keyboard.is_pressed('p'):
            sleep(2)
            camera.resolution = (2592, 1944)
            camera.capture('/home/pi/Documents/test_files/testpic.png')
            camera.resolution = (1920, 1080)
            camera.start_preview()
            
        if keyboard.is_pressed("n"):
            camera.exposure_mode = 'night'
            
        if keyboard.is_pressed("a"):
            camera.exposure_mode = 'auto'
            
        if keyboard.is_pressed("0"):
            camera.iso = 0    
        
        if keyboard.is_pressed("1"):
            camera.iso = 100
            
        if keyboard.is_pressed("2"):
            camera.iso = 200
        
        if keyboard.is_pressed("3"):
            camera.iso = 300
        
        if keyboard.is_pressed("4"):
            camera.iso = 400
            
        if keyboard.is_pressed("5"):
            camera.iso = 500
            
        if keyboard.is_pressed("6"):
            camera.iso = 600
            
        if keyboard.is_pressed("7"):
            camera.iso = 700
            
        if keyboard.is_pressed("8"):
            camera.iso = 800            
            
        if keyboard.is_pressed('x'):
            camera.stop_preview()
            break
            close()
        sleep(.01)
        
    except:
        pass

Discussions