def _generate_block_ensemble(self, network_name, emotion, valence, arousal, face_image=None, x=0, y=0): block = self._get_container(x, y, self._output_block_height_ensemble, self._output_block_width) # Image if not (face_image is None): uimage.draw_image( block, face_image, FERDemo._BLOCK_INIT_POS_IMAGE_ENSEMBLE[self._screen_size]) # Text: Ensemble uimage.draw_text( block, network_name, FERDemo._BLOCK_INIT_POS_TEXT_NETWORK_ENSEMBLE[self._screen_size], FERDemo._COLOUR_BGR_BLACK, FERDemo._TEXT_PARAM_SCALE[self._screen_size], FERDemo._TEXT_PARAM_THICKNESS[self._screen_size]) # Text: Emotion uimage.draw_text( block, emotion, FERDemo._BLOCK_INIT_POS_TEXT_EMOTION_ENSEMBLE[self._screen_size], FERDemo._COLOUR_BGR_BLACK, FERDemo._TEXT_PARAM_SCALE[self._screen_size], FERDemo._TEXT_PARAM_THICKNESS[self._screen_size]) # Text: Activation uimage.draw_text( block, FERDemo._TEXT_ACTIVATION + " {:.2f}".format(arousal), FERDemo._BLOCK_INIT_POS_TEXT_ACTIVATION[self._screen_size], FERDemo._COLOUR_BGR_BLACK, FERDemo._TEXT_PARAM_SCALE[self._screen_size], FERDemo._TEXT_PARAM_THICKNESS[self._screen_size]) # Text: Pleasant uimage.draw_text( block, FERDemo._TEXT_PLEASANT + (" 0.00" if valence < 0 else " {:.2f}".format(valence)), FERDemo._BLOCK_INIT_POS_TEXT_PLEASANT[self._screen_size], FERDemo._COLOUR_BGR_BLACK, FERDemo._TEXT_PARAM_SCALE[self._screen_size], FERDemo._TEXT_PARAM_THICKNESS[self._screen_size]) # Text: Unpleasant uimage.draw_text( block, FERDemo._TEXT_UNPLEASANT + (" {:.2f}".format(valence) if valence < 0 else " 0.00"), FERDemo._BLOCK_INIT_POS_TEXT_UNPLEASANT[self._screen_size], FERDemo._COLOUR_BGR_BLACK, FERDemo._TEXT_PARAM_SCALE[self._screen_size], FERDemo._TEXT_PARAM_THICKNESS[self._screen_size]) # Bar: Activation uimage.draw_horizontal_bar( block, arousal, FERDemo._MAX_AROUSAL, FERDemo._BLOCK_INIT_POS_BAR_ACTIVATION[self._screen_size], FERDemo._BLOCK_FINAL_POS_BAR_ACTIVATION[self._screen_size], FERDemo._TEXT_PARAM_THICKNESS[self._screen_size], FERDemo._COLOUR_BGR_DARK_BLUE) # Bar: Pleasant uimage.draw_horizontal_bar( block, 0.0 if valence < 0.0 else valence, FERDemo._MAX_VALENCE, FERDemo._BLOCK_INIT_POS_BAR_PLEASANT[self._screen_size], FERDemo._BLOCK_FINAL_POS_BAR_PLEASANT[self._screen_size], FERDemo._TEXT_PARAM_THICKNESS[self._screen_size], FERDemo._COLOUR_BGR_DARK_GREEN) # Bar: Unpleasant uimage.draw_horizontal_bar( block, np.abs(valence) if valence < 0.0 else 0.0, FERDemo._MAX_VALENCE, FERDemo._BLOCK_INIT_POS_BAR_UNPLEASANT[self._screen_size], FERDemo._BLOCK_FINAL_POS_BAR_UNPLEASANT[self._screen_size], FERDemo._TEXT_PARAM_THICKNESS[self._screen_size], FERDemo._COLOUR_BGR_DARK_RED) # Plot: Arousal and Valence if self._display_graph_ensemble: self._plot_arousal.append(arousal) self._plot_valence.append(valence) uimage.draw_graph( block, self._plot_arousal, self._plot_valence, FERDemo._BLOCK_INIT_POS_GRAPH[self._screen_size], FERDemo._BLOCK_SAMPLE_GRAPH, FERDemo._TEXT_ACTIVATION_WITHOUT_TWO_DOTS, FERDemo._TEXT_PLEASANT_UNPLEASANT, FERDemo._COLOUR_BGR_BLUE, FERDemo._COLOUR_BGR_ORANGE, FERDemo._BLOCK_THICKNESS_GRAPH[self._screen_size], FERDemo._BLOCK_OFFSET_GRAPH[self._screen_size], FERDemo._BLOCK_FONT_SIZE_GRAPH[self._screen_size], FERDemo._COLOUR_BGR_DARK_GREY, FERDemo._BLOCK_SIZE_GRAPH[self._screen_size]) return block
def _generate_block(self, network_name, emotion, valence, arousal, face_image=None, x=0, y=0): block = self._get_container(x, y, self._output_block_height, self._output_block_width) # Image if not (face_image is None): uimage.draw_image(block, face_image, FERDemo._BLOCK_INIT_POS_IMAGE[self._screen_size]) # Text: Ensemble uimage.draw_text( block, network_name, FERDemo._BLOCK_INIT_POS_TEXT_NETWORK[self._screen_size], FERDemo._COLOUR_BGR_BLACK, FERDemo._TEXT_PARAM_SCALE[self._screen_size], FERDemo._TEXT_PARAM_THICKNESS[self._screen_size]) # Text: Emotion uimage.draw_text( block, emotion, FERDemo._BLOCK_INIT_POS_TEXT_EMOTION[self._screen_size], FERDemo._COLOUR_BGR_BLACK, FERDemo._TEXT_PARAM_SCALE[self._screen_size], FERDemo._TEXT_PARAM_THICKNESS[self._screen_size]) # Text: Arousal uimage.draw_text( block, FERDemo._TEXT_AROUSAL, FERDemo._BLOCK_INIT_POS_TEXT_AROUSAL[self._screen_size], FERDemo._COLOUR_BGR_BLACK, FERDemo._TEXT_PARAM_SCALE[self._screen_size], FERDemo._TEXT_PARAM_THICKNESS[self._screen_size]) # Text: Valence uimage.draw_text( block, FERDemo._TEXT_VALENCE, FERDemo._BLOCK_INIT_POS_TEXT_VALENCE[self._screen_size], FERDemo._COLOUR_BGR_BLACK, FERDemo._TEXT_PARAM_SCALE[self._screen_size], FERDemo._TEXT_PARAM_THICKNESS[self._screen_size]) # Bar: Arousal uimage.draw_horizontal_bar( block, arousal, FERDemo._MAX_AROUSAL, FERDemo._BLOCK_INIT_POS_BAR_AROUSAL[self._screen_size], FERDemo._BLOCK_FINAL_POS_BAR_AROUSAL[self._screen_size], FERDemo._TEXT_PARAM_THICKNESS[self._screen_size], FERDemo._COLOUR_BGR_DARK_BLUE) # Bar: Valence uimage.draw_horizontal_bar( block, np.abs(valence), FERDemo._MAX_VALENCE, FERDemo._BLOCK_INIT_POS_BAR_VALENCE[self._screen_size], FERDemo._BLOCK_FINAL_POS_BAR_VALENCE[self._screen_size], FERDemo._TEXT_PARAM_THICKNESS[self._screen_size], FERDemo._COLOUR_BGR_DARK_RED if valence < 0.0 else FERDemo._COLOUR_BGR_DARK_GREEN) return block