Method: ColorRoi#retrieve

Defined in:
lib/roi/color/color_roi.rb

#retrieve(args = {}) ⇒ Object

Public: Gets the color of the region defined in the Roi.

Corresponds to: api_read_color_from_screen

Returns the color as a Hash with keys :red, :green, :blue, each being an Integer value (0 - 255).



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/roi/color/color_roi.rb', line 110

def retrieve(args={})
  logger.info('Retrieving color')
  frame = args[:frame]
  value(args) do
    if frame.nil?
      # Get the color from the screen
      json = get_json_for_get
      color = test_case.send(:tmc_post, "/api/roi/color/actions/#{dut.slot}", json: json)['value']
    else
      # Get the color from the frame
      json = get_json_for_get(frame: frame)
      color = test_case.send(:tmc_post, '/api/roi/color/actions', json: json)['value']
    end
    color = {red: color['red'], green: color['green'], blue: color['blue']}
    logger.roi(self, args.merge(message: "Retrieved color #{color.inspect}", use_last_image: frame.nil?,
                                screenshot: frame.nil?))
    color
  end
end