cozmo_taste_game.image_recognition package

cozmo_taste_game.image_recognition.response_analyzer module

Class responsible for analyzing the pictures Cozmo takes. At the moment, getFoundFood() will only return a valid value if the same Prop has been seen (streak_threshold) times in a row with a confidence > (threshold)

class cozmo_taste_game.image_recognition.response_analyzer.ResponseAnalyzer(threshold, streak_threshold, isDebugMode)[source]

Bases: object

analyze_response(file_name)[source]

Analyze a photo at location file_name. You feed this function pictures, it analyzes them with the tensorflow model. Once it analyzes the picture, it sees if it has seen the same object more than (streak_threshold) times. If it has, it sets identified_food to what it has found.

Upon entering the function, the has_been_checked flag gets flipped to False.

Parameters:file_name – location of a jpg file Cozmo has taken
Returns:None
force_input(foodItem)[source]

Force the response analyzer to see a food item

Parameters:foodItem – a string of what cozmo should see
Returns:None
get_found_food()[source]

Get what the response analyzer has decided Cozmo has seen Note: Only call this if you are sure cozmo has found something. Use has_found_food() before calling this function

Returns:A string of what Cozmo has seen
has_found_food()[source]

Check if Cozmo has found food. Call this before calling get_found_food()

Returns:True if Cozmo has found something, False otherwise

cozmo_taste_game.image_recognition.tensor_functions module

This file contains code that runs tensorflow. Most of it should only be changed if the model type is switched, or you know what you are doing.

cozmo_taste_game.image_recognition.tensor_functions.allowed_file(filename)[source]

Checks to see if the filename supplied is in ALLOWED_EXTENTIONS

Parameters:filename – a file name to be checked
Returns:True if the filename is valid, False otherwise
cozmo_taste_game.image_recognition.tensor_functions.analyze_photo(filename)[source]

Analyzes a photo, and returns a dict containing predictions and confidence

Parameters:filename – the file name of the photo to be analyzed
Returns:a dictionary with the form {‘name_of_food_1’ : confidence, …, ‘name_of_food_5 : confidence}
cozmo_taste_game.image_recognition.tensor_functions.load_graph(model_file)[source]
cozmo_taste_game.image_recognition.tensor_functions.load_labels(label_file)[source]
cozmo_taste_game.image_recognition.tensor_functions.read_tensor_from_image_file(file_name, input_height=299, input_width=299, input_mean=0, input_std=255)[source]