Skip to content

Commit

Permalink
Adds brightness/contrast controls via plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
domstoppable committed Sep 30, 2024
1 parent 3395ede commit a34a873
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 1 deletion.
2 changes: 2 additions & 0 deletions pupil_src/launchables/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ def player(
from surface_tracker import Surface_Tracker_Offline
from system_graphs import System_Graphs
from system_timelines import System_Timelines
from image_adjustments import Image_Adjustments

# helpers/utils
from version_utils import parse_version
Expand Down Expand Up @@ -175,6 +176,7 @@ def interrupt_handler(sig, frame):
Offline_Head_Pose_Tracker,
IMUTimeline,
EyeStateTimeline,
Image_Adjustments,
] + runtime_plugins

plugins = system_plugins + user_plugins
Expand Down
54 changes: 54 additions & 0 deletions pupil_src/shared_modules/image_adjustments.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
"""
(*)~---------------------------------------------------------------------------
Pupil - eye tracking platform
Copyright (C) Pupil Labs
Distributed under the terms of the GNU
Lesser General Public License (LGPL v3.0).
See COPYING and COPYING.LESSER for license details.
---------------------------------------------------------------------------~(*)
"""

import cv2
from plugin import Plugin
from pyglui import ui


class Image_Adjustments(Plugin):
icon_chr = chr(0xE04B)
icon_font = "pupil_icons"

def __init__(self, g_pool, brightness=0, contrast=1.0):
super().__init__(g_pool)

self.order = 0.4
self.menu = None

self.brightness = brightness
self.contrast = contrast

def recent_events(self, events):
frame = events.get("frame")
if not frame:
return

frame.img[:] = cv2.convertScaleAbs(frame.img, alpha=self.contrast, beta=self.brightness)

def init_ui(self):
self.add_menu()
self.menu.label = "Image Adjustments"
self.menu.append(
ui.Slider("brightness", self, min=0, max=100, label="Brightness")
)
self.menu.append(
ui.Slider("contrast", self, min=1.0, max=3.0, label="Contrast")
)

def deinit_ui(self):
self.remove_menu()

def get_init_dict(self):
return {
"brightness": self.brightness,
"contrast": self.contrast,
}
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ def _export_world_video(
Simulates the generation for the world video and saves a certain time range as a video.
It simulates a whole g_pool such that all plugins run as normal.
"""
from glob import glob
from time import time

import file_methods as fm
Expand All @@ -144,6 +143,7 @@ def _export_world_video(
from plugin import Plugin_List, import_runtime_plugins
from video_capture import EndofVideoError, File_Source
from video_overlay.plugins import Eye_Overlay, Video_Overlay
from image_adjustments import Image_Adjustments
from vis_circle import Vis_Circle
from vis_cross import Vis_Cross
from vis_light_points import Vis_Light_Points
Expand All @@ -167,6 +167,7 @@ def _export_world_video(
Vis_Watermark,
Eye_Overlay,
Video_Overlay,
Image_Adjustments,
],
key=lambda x: x.__name__,
)
Expand Down

0 comments on commit a34a873

Please sign in to comment.