diff --git a/README.md b/README.md index 726baf5d..c8245178 100644 --- a/README.md +++ b/README.md @@ -58,8 +58,6 @@ https://torger.se/anders/dcamprof.html#download - Write actual tests - Histogram and analysis tools - RAW sensor capture: https://raspberrypi.stackexchange.com/questions/51191/how-can-i-stop-the-overlay-of-images-between-my-pi-camera-and-flir-camera - - ISO - - Shutter Speed - Resolution (FPS as label) - FPS option (wrt resolution) - Menus @@ -70,7 +68,6 @@ https://torger.se/anders/dcamprof.html#download - brightness - saturation - ev compression - - exposure mode - awb - auto white balance - image effect - colour effect diff --git a/src/camera_handler.py b/src/camera_handler.py index d67852b5..a45af9af 100644 --- a/src/camera_handler.py +++ b/src/camera_handler.py @@ -1,16 +1,9 @@ -import os -import shutil import time import glob -import json from io import BytesIO -from picamerax import PiCamera - -import RPi.GPIO as GPIO from pydng.core import RPICAM2DNG -from pydng.core import RAW2DNG, DNGTags, Tag # Modules import document_handler @@ -20,22 +13,12 @@ def auto_mode(camera, config): camera.iso = config["default_iso"] camera.exposure_mode = config["default_exposure_mode"] camera.shutter_speed = config["default_shutter_speed"] + camera.awb_mode = config["default_awb_mode"] overlay_handler.display_text(camera, '', config) print(f'auto mode!') def adjust_exposure_mode(camera, config): - # Fix other settings - # Now fix the values - # camera.shutter_speed = 150000 #camera.exposure_speed - # # camera.exposure_mode = 'off' - # # off, auto, night, nightpreview, backlight, spotlight, sports, snow, beach, - # # verylong, fixedfps, antishake, fireworks - # camera.exposure_mode = 'auto' - # g = camera.awb_gains - # camera.awb_mode = 'off' - # camera.awb_gains = g - idex = config["available_exposure_modes"].index(config["exposure_mode"]) + 1 if idex < len(config["available_exposure_modes"]): @@ -73,6 +56,18 @@ def adjust_shutter_speed(camera, config): overlay_handler.display_text(camera, '', config) print(f'shutter_speed: {config["shutter_speed"]}') +def adjust_awb_mode(camera, config): + idex = config["available_awb_mode"].index(config["awb_mode"]) + 1 + + if idex < len(config["available_awb_mode"]): + config["awb_mode"] = config["available_awb_mode"][idex] + else: + config["awb_mode"] = config["default_awb_mode"] + + camera.awb_mode = config["awb_mode"] + overlay_handler.display_text(camera, '', config) + print(f'awb_mode: {config["awb_mode"]}') + def set_hdr(camera, config): config["hdr"] = not config["hdr"] overlay_handler.display_text(camera, '', config) @@ -103,17 +98,16 @@ def take_hdr_shot(camera, config): width = config["width"] height = config["height"] - dcim_path = config["dcim_path"] - dcim_images_path_raw = config["dcim_images_path_raw"] - dcim_original_images_path = config["dcim_original_images_path"] + # dcim_path = config["dcim_path"] + # dcim_images_path_raw = config["dcim_images_path_raw"] + # dcim_original_images_path = config["dcim_original_images_path"] dcim_hdr_images_path = config["dcim_hdr_images_path"] - dcim_videos_path = config["dcim_videos_path"] - dcim_tmp_path = config["dcim_tmp_path"] + # dcim_videos_path = config["dcim_videos_path"] + # dcim_tmp_path = config["dcim_tmp_path"] camera.resolution = (width, height) start_time = time.time() - available_exposure_compensations = [-25, -20, -15, -10, -5, 0, 5, 10, 15, 20, 25] # TODO # SEE: https://github.com/KEClaytor/pi-hdr-timelapse nimages = 5 #10 #2160 @@ -124,8 +118,6 @@ def take_hdr_shot(camera, config): exp_step = (exposure_max - exposure_min) / (nimages - 1.0) exposure_times = range(exposure_min, exposure_max + 1, int(exp_step)) - filenames = [] - existing_files = glob.glob(f'{dcim_hdr_images_path}/*.{format}') filecount = len(existing_files) frame_count = filecount @@ -159,12 +151,12 @@ def take_single_shot(camera, config): width = config["width"] height = config["height"] - dcim_path = config["dcim_path"] + # dcim_path = config["dcim_path"] dcim_images_path_raw = config["dcim_images_path_raw"] dcim_original_images_path = config["dcim_original_images_path"] - dcim_hdr_images_path = config["dcim_hdr_images_path"] - dcim_videos_path = config["dcim_videos_path"] - dcim_tmp_path = config["dcim_tmp_path"] + # dcim_hdr_images_path = config["dcim_hdr_images_path"] + # dcim_videos_path = config["dcim_videos_path"] + # dcim_tmp_path = config["dcim_tmp_path"] format = config["format"] bayer = config["bayer"] @@ -214,12 +206,12 @@ def trigger_video(camera, config): width = config["width"] height = config["height"] - dcim_path = config["dcim_path"] - dcim_images_path_raw = config["dcim_images_path_raw"] - dcim_original_images_path = config["dcim_original_images_path"] - dcim_hdr_images_path = config["dcim_hdr_images_path"] + # dcim_path = config["dcim_path"] + # dcim_images_path_raw = config["dcim_images_path_raw"] + # dcim_original_images_path = config["dcim_original_images_path"] + # dcim_hdr_images_path = config["dcim_hdr_images_path"] dcim_videos_path = config["dcim_videos_path"] - dcim_tmp_path = config["dcim_tmp_path"] + # dcim_tmp_path = config["dcim_tmp_path"] format = config["video_format"] diff --git a/src/main.py b/src/main.py index acac9e9c..77293258 100644 --- a/src/main.py +++ b/src/main.py @@ -13,6 +13,8 @@ # 'bgra' - Write the raw image data to a file in 32-bit BGRA format # 'raw' - Deprecated option for raw captures; the format is taken from the deprecated raw_format attribute +# available_exposure_compensations = [-25, -20, -15, -10, -5, 0, 5, 10, 15, 20, 25] + # 8MP pi camera v2.1 # width = 3280 # height = 2464 @@ -21,25 +23,15 @@ # width = 4056 # height = 3040 -VERSION = "0.0.12" +VERSION = "0.0.13" -import os -import shutil import time import glob -import json -from io import BytesIO from picamerax import PiCamera import RPi.GPIO as GPIO -from pydng.core import RPICAM2DNG -from pydng.core import RAW2DNG, DNGTags, Tag - -import numpy as np -from PIL import Image, ImageDraw, ImageFont - # Modules import document_handler import overlay_handler @@ -99,7 +91,10 @@ "available_shutter_speeds": [0, 100, 500, 1000, 2000, 4000, 8000, 16667, 33333, 66667, 125000, 250000, 500000, 1000000, 2000000, 5000000, 10000000, 15000000, 20000000, 25000000, 30000000, 35000000, 40000000], "shutter_speed": 0, "default_shutter_speed": 0, - "available_menu_items": ["auto", "exposure_mode", "iso", "shutter_speed", "hdr", "video", "resolution", "encoding"], + "available_awb_mode": ['auto', 'off', 'sunlight', 'cloudy', 'shade', 'tungsten', 'fluorescent', 'incandescent', 'flash', 'horizon'], + "awb_mode": 'auto', + "default_awb_mode": 'auto', # "awb_gains": 0.0 - 8.0 (), + "available_menu_items": ["auto", "exposure_mode", "iso", "shutter_speed", "awb_mode", "hdr", "video", "resolution", "encoding"], "menu_item": "auto", "default_menu_item": "auto", "hdr": False, @@ -115,20 +110,20 @@ } } -filetype = config["filetype"] -bpp = config["bpp"] +# filetype = config["filetype"] +# bpp = config["bpp"] # format = config["format"] fps = config["fps"] screen_fps = config["screen_fps"] -dcim_images_path_raw = config["dcim_images_path_raw"] -dcim_original_images_path = config["dcim_original_images_path"] -dcim_hdr_images_path = config["dcim_hdr_images_path"] -dcim_videos_path = config["dcim_videos_path"] -dcim_tmp_path = config["dcim_tmp_path"] +# dcim_images_path_raw = config["dcim_images_path_raw"] +# dcim_original_images_path = config["dcim_original_images_path"] +# dcim_hdr_images_path = config["dcim_hdr_images_path"] +# dcim_videos_path = config["dcim_videos_path"] +# dcim_tmp_path = config["dcim_tmp_path"] -colour_profile_path = config["colour_profile_path"] +# colour_profile_path = config["colour_profile_path"] screen_w = config["screen_w"] screen_h = config["screen_h"] diff --git a/src/menu_handler.py b/src/menu_handler.py index ac7610ea..29ebdea6 100644 --- a/src/menu_handler.py +++ b/src/menu_handler.py @@ -21,6 +21,8 @@ def select_option(camera, config): camera_handler.adjust_iso(camera, config) if config["menu_item"] == "shutter_speed": camera_handler.adjust_shutter_speed(camera, config) + if config["menu_item"] == "awb_mode": + camera_handler.adjust_awb_mode(camera, config) if config["menu_item"] == "hdr": camera_handler.set_hdr(camera, config) if config["menu_item"] == "video": diff --git a/src/overlay_handler.py b/src/overlay_handler.py index 5551f0ba..1d10cbcf 100644 --- a/src/overlay_handler.py +++ b/src/overlay_handler.py @@ -1,5 +1,5 @@ import numpy as np -from PIL import Image, ImageDraw, ImageFont +from PIL import Image def compute_shutter_speed_from_us(us): if us == 0: @@ -15,9 +15,14 @@ def display_text(camera, text, config): mode = "Photo Mode" menu_item = config["menu_item"] - shutter_speed_text = compute_shutter_speed_from_us(config["shutter_speed"]) - text = f'{text}\nShutter Speed: {shutter_speed_text}, set: {camera.shutter_speed}' - camera.annotate_text = f'{mode} - exposure mode: {camera.exposure_mode}, iso: {camera.iso}, hdr: {config["hdr"]}\nSelected Menu Item: {config["menu_item"]}\n{text}' + + selected_item = f'Selected Menu Item: {config["menu_item"]}' + camera_settings = f"exposure mode: {camera.exposure_mode}, iso: {camera.iso}, awb mode: {config['awb_mode']}" + + shutter_speed = compute_shutter_speed_from_us(config["shutter_speed"]) + shutter_text = f'Shutter Speed: {shutter_speed}, set: {camera.shutter_speed}' + + camera.annotate_text = f'{mode} - {camera_settings}\nhdr: {config["hdr"]}\n{selected_item}\n{shutter_text}\n{text}' # https://picamera.readthedocs.io/en/release-1.10/recipes1.html#overlaying-images-on-the-preview def add_overlay(camera, overlay, config): diff --git a/tools/process_hdr.py b/tools/process_hdr.py index 1fe8ce63..45579fe6 100644 --- a/tools/process_hdr.py +++ b/tools/process_hdr.py @@ -2,8 +2,6 @@ sys.path.insert(1, '../src/') sys.path.insert(1, 'src/') -import os -import time import glob import cv2 diff --git a/tools/process_raw_output.py b/tools/process_raw_output.py index c5fbe3e9..1e8dfe81 100644 --- a/tools/process_raw_output.py +++ b/tools/process_raw_output.py @@ -6,7 +6,6 @@ sys.path.insert(1, '../src/') sys.path.insert(1, 'src/') -import os import time import glob import re @@ -14,7 +13,6 @@ from io import BytesIO from pydng.core import RPICAM2DNG -from pydng.core import RAW2DNG, DNGTags, Tag # Modules import document_handler