Ejemplo n.º 1
0
def get_viewer_CLargs(parser: argparse.ArgumentParser):
    """Add viewer related CL arguments to given parser

    Added Arguments
    ---------------
    play: optional
        int specifying frame delay in ms to play the video using OpenCV.
    save: optional
        int specifying the framerate to save the video in using OpenCV.
    frame: optional
        int specifying a frame to save in 16 bit color using matplotlib.
    contour: optional
        int specifying the threshold to use if drawing a contour.
    follow: optional
        str specifying what to focus the frame on.
        follow = 'max' centers the frame on the max temperature.
        follow = 'contour' centers the frame on the center of gravity of the contour (if present).
    fsize: optional
        int specifying the size of the window when following max temp or contour.
    info: optional
        'mp' or 'contour' to display an info pane with relevant info above video.
    """
    descriptions = get_description_dict()
    parser.add_argument('-play',
                        type=int,
                        help=descriptions['play_frame_delay'],
                        default=None)
    parser.add_argument('-save',
                        type=int,
                        help=descriptions['save_framerate'],
                        default=None)
    parser.add_argument('-frame',
                        default=None,
                        type=int,
                        help=descriptions['save_frame_CLarg'])
    parser.add_argument('-contour',
                        type=int,
                        default=None,
                        help=descriptions['contour_threshold'])
    parser.add_argument('-follow',
                        type=str,
                        default=None,
                        help=descriptions['follow_CLarg'])
    parser.add_argument('-fsize',
                        type=int,
                        default=20,
                        help=descriptions['follow_size'])
    parser.add_argument('-info',
                        type=str,
                        default=None,
                        help=descriptions['infopane_CLarg'])
Ejemplo n.º 2
0
def get_composite_CLargs(parser: argparse.ArgumentParser):
    """Add composite related CL arguments to given parser.

    Added Arguments
    ---------------
    threshold: optional
        int specifying the threshold to be used for the composite image.
    dst_folder: optional
        str specifying where to save the composite image. Defaults to build folder.
    cap: optional
        int specifying the max number of frames to use for composite.
    max: optional
        0 or 1 specifying whether or not to generate a max temperature composite image.
    avg: optional
        0 or 1 specifying whether or not to generate an average temperature composite image.
    int: optional
        int specifying threshold to be used to generate a temperature integration composite image.
    hotspot: optional
        0 or 1 specifying whether or not to generate a hotspot composite image.
    """
    desc_dict = get_description_dict()
    parser.add_argument('-threshold',
                        type=int,
                        help=desc_dict['threshold'],
                        default=None)
    parser.add_argument('-dst_folder',
                        type=str,
                        default=None,
                        help=desc_dict['thresh_dst_folder'])
    parser.add_argument('-cap', type=int, help=desc_dict['thresh_cap'])
    parser.add_argument('-max',
                        type=int,
                        help=desc_dict['max_temp_composite_CLarg'],
                        default=0)
    parser.add_argument('-avg',
                        type=int,
                        help=desc_dict['avg_composite_CLarg'],
                        default=0)
    parser.add_argument('-int',
                        type=int,
                        help=desc_dict['int_composite'],
                        default=None)
    parser.add_argument('-hotspot',
                        type=int,
                        help=desc_dict['hotspot_CLarg'],
                        default=None)
Ejemplo n.º 3
0
    def __init__(self,
                 dataset: DataSet,
                 contour_threshold: int = None,
                 follow: str = None,
                 follow_size: int = 20,
                 info_pane=None):
        self.dataset = dataset
        self.quit = False
        self.cur_frame = None
        self.pause = False
        self.update_frame = True
        self.framerate = 0
        self.contour_threshold = contour_threshold
        self.follow = follow
        self.follow_size = follow_size
        self.info_pane = info_pane
        self.descriptions = get_description_dict()

        # Keycodes stored as list so multiple keys can be assigned to a function w/o other changes
        # Could be made simpler using ASCII lookup and keycodes, but apparently keycodes are
        # different depending on platform
        self.keys = {
            'Play/Pause': ['P', 'Space', 'K'],
            'Quit': ['Q', 'Esc'],
            'Save': ['S'],
            'Adv 1 Frame': ['M'],
            'Adv 10 Frame': ['L'],
            'Adv 100 Frame': ['O'],
            'Rew 1 Frame': ['N'],
            'Rew 10 Frame': ['J'],
            'Rew 100 Frame': ['I'],
        }

        self.keycodes = {
            'Play/Pause': [ord('p'), 32, ord('k')],
            'Quit': [ord('q'), 27],
            'Save': [ord('s')],
            'Adv 1 Frame': [ord('m')],
            'Adv 10 Frame': [ord('l')],
            'Adv 100 Frame': [ord('o')],
            'Rew 1 Frame': [ord('n')],
            'Rew 10 Frame': [ord('j')],
            'Rew 100 Frame': [ord('i')]
        }
Ejemplo n.º 4
0
def get_dataset_CLargs(parser: argparse.ArgumentParser):
    """Add dataset related CL arguments to given parser.

    Added Arguments
    ---------------
    temp_data: required
        filename (and location) of thermal cam temps file.
    mp_data: optional
        filename (and location) of merged data file.
    top: optional
        0 or 1 specifying whether or not to remove top reflections.
    bot: optional
        0 or 1 specifying whether or not to remove bottom reflections.
    scale: optional
        int specifying the factor to scale frames by.
    range: optional
        start,end specifying frame range to use in dataset.
    """
    desc_dict = get_description_dict()
    parser.add_argument('temp_data', type=str, help=desc_dict['temp_data'])
    parser.add_argument('-top',
                        type=int,
                        default=False,
                        help=desc_dict['remove_top_CLarg'])
    parser.add_argument('-bot',
                        type=int,
                        default=False,
                        help=desc_dict['remove_bot_CLarg'])
    parser.add_argument('-scale',
                        type=int,
                        default=1,
                        help=desc_dict['scale_factor'])
    parser.add_argument('-mp_data',
                        type=str,
                        default=None,
                        help=desc_dict['mp_data'])
    parser.add_argument('-range',
                        default=None,
                        type=str,
                        help=desc_dict['range_CLarg'])
Ejemplo n.º 5
0
    def __init__(self):
        self.ACTIVEBACKGROUND = consts.ACTIVEBACKGROUND
        self.ACTIVEBUTTONBACKGROUND = consts.ACTIVEBUTTONBACKGROUND
        self.ACTIVEFIELDBACKGROUND = consts.ACTIVEFIELDBACKGROUND
        self.ACTIVEFRAMEBORDER = consts.ACTIVEFRAMEBORDER
        self.TEXTCOLOR = consts.TEXTCOLOR

        self.INACTIVEBACKGROUND = consts.INACTIVEBACKGROUND
        self.INACTIVEBUTTONBACKGROUND = consts.INACTIVEBUTTONBACKGROUND
        self.INACTIVEFIELDBACKGROUND = consts.INACTIVEFIELDBACKGROUND
        self.INACTIVEFRAMEBORDER = consts.INACTIVEFRAMEBORDER

        self.root = Tk()
        self.root.title("YSU Thermography")
        self.root['bg'] = self.ACTIVEBACKGROUND
        # root.iconbitmap("images/YSU_Logo")

        self.progressbar = None

        # Get description dictionary
        self.descriptions = get_description_dict()

        # Creating variables for checkboxes to change
        self.dataset = None
        self.viewer = None

        # Dataset related variables
        self.remove_top = BooleanVar(False)
        self.remove_bot = BooleanVar(False)
        self.scale_factor = IntVar(value=1)
        self.start_frame = IntVar(value=-1)
        self.end_frame = IntVar(value=-1)

        # Viewer related variables
        self.contour_threshold = IntVar(value=None)
        self.follow = StringVar(value=None)
        self.follow_size = IntVar(value=20)
        self.info_pane = StringVar(value=None)
        self.frame_delay = IntVar(value=1)
        self.framerate = IntVar(value=60)

        # Composite related variables
        self.composite_threshold = IntVar(value=None)

        self.generate_img = BooleanVar(False)
        self.save_frame = BooleanVar()
        self.play_video = BooleanVar(False)
        self.save_video = BooleanVar(False)
        self.gen_threshold_img = BooleanVar(False)
        self.data_set = BooleanVar()
        self.gradient_plots = BooleanVar()
        self.pixel_temp_range = BooleanVar()

        self.tempData = StringVar()

        self.genthreshold_threshold = StringVar()

        self.save_FrameNumber = StringVar()
        self.save_ImageNumber = StringVar()

        self.play_scaleFactor = StringVar()
        self.play_frameDelay = StringVar()
        self.play_pixelAroundMax = StringVar()
        self.play_contourTempThresh = StringVar()
        self.play_contourPixelRange = StringVar()
        self.play_frameRate = StringVar()
        self.play_removeTopReflection = BooleanVar()
        self.play_removeBottomReflection = BooleanVar()
        self.play_displayMeltPool = BooleanVar()
        self.play_saveStartFrame = StringVar()
        self.play_saveEndFrame = StringVar()
        self.play_displayContour = BooleanVar()

        self.plot_PixelLocX = StringVar()
        self.plot_PixelLocY = StringVar()
        self.plot_TempThresh = StringVar()
        self.plot_StartFrame = StringVar()
        self.plot_EndFrame = StringVar()
        self.grad_mag = BooleanVar()
        self.grad_angle = BooleanVar()
        self.grad_2dHist = BooleanVar()
        self.grad_scatter = BooleanVar()
        self.grad_hexBin = BooleanVar()
        self.grad_3D = BooleanVar()
        self.plot_line = BooleanVar()
        self.grad_all = BooleanVar()

        # Creating Frame Sections
        self.filePanel = Frame(self.root, bg=self.ACTIVEBACKGROUND)
        self.filePanel.pack(side=TOP, fill=BOTH, pady=10)

        self.dataset_panel = Frame(self.root, bg=self.ACTIVEBACKGROUND)
        self.dataset_panel.pack(side=TOP, fill=BOTH, pady=10)

        self.viewer_panel = Frame(self.root, bg=self.ACTIVEBACKGROUND)
        self.viewer_panel.pack(side=TOP, fill=BOTH, pady=10)

        self.optionsPanel = Frame(self.root,
                                  bg=self.ACTIVEBACKGROUND,
                                  bd=1,
                                  highlightthickness=1,
                                  highlightcolor=self.ACTIVEFRAMEBORDER,
                                  highlightbackground=self.ACTIVEFRAMEBORDER,
                                  padx=5,
                                  relief=FLAT)
        self.optionsPanel.pack(fill=BOTH)

        self.optionsPanel.columnconfigure(0, weight=1)
        self.optionsPanel.columnconfigure(1, weight=1)
        self.optionsPanel.rowconfigure(0, weight=1)
        self.optionsPanel.rowconfigure(1, weight=1)
        self.optionsPanel.rowconfigure(2, weight=1)
        self.optionsPanel.rowconfigure(3, weight=1)

        # Building  all frames
        self.buildFileFrame()
        self.build_dataset_frame()
        self.build_viewer_frame()
        self.build_composite_frame()
        self.buildPlotOptionsFrame()
        self.buildGradOptionsFrame()

        # Main GUI loop
        self.root.mainloop()
Ejemplo n.º 6
0
                        help=descriptions['infopane_CLarg'])


def colormap_frame(frame):
    frame = cv2.normalize(frame,
                          frame,
                          0,
                          255,
                          cv2.NORM_MINMAX,
                          dtype=cv2.CV_8UC1)
    frame = cv2.applyColorMap(frame, cv2.COLORMAP_INFERNO)
    return frame


if __name__ == '__main__':
    description_dict = get_description_dict()
    argument_parser = argparse.ArgumentParser(
        description=description_dict['viewer_main'])

    get_viewer_CLargs(argument_parser)
    get_dataset_CLargs(argument_parser)

    args = argument_parser.parse_args()

    play = args.play
    temp_data = str(args.temp_data)
    top = bool(args.top)
    bot = bool(args.bot)
    scale = args.scale
    save_frame = args.frame
    framerange = args.range