def setup(): maybe_image = take_picture(config.video_device) maybe_current_posture = determine_posture(maybe_image) if maybe_current_posture.success: distance_reference = str(maybe_current_posture.result.get('distance')) config.config_file['MAIN']['distance_reference'] = distance_reference print("Reference value detected as:", maybe_current_posture.result) else: print("Error:", maybe_current_posture.result) return maybe_current_posture config.config_file.write()
def setup(): config = ConfigObj('slouchy.ini') maybe_image = take_picture(video_device) maybe_face = detect_face(maybe_image) maybe_current_posture = calculate_current_posture(maybe_face) if maybe_current_posture.success: config['MAIN']['posture_reference'] = str(maybe_current_posture.result) print("Reference value detected as:", maybe_current_posture.result) else: print("Error:", maybe_current_posture.result) return maybe_current_posture config.write()
def setup(): config = ConfigObj('slouchy.ini') # #video_device can be an int or a string, so try int, and if not assume string # try: # video_device = int(config['MAIN']['video_device']) # except ValueError: # video_device = str(config['MAIN']['video_device']) maybe_image = take_picture(video_device) maybe_face = detect_face(maybe_image) maybe_c_squared = calculate_c_squared(maybe_face) if maybe_c_squared.success: config['MAIN']['c_squared_reference'] = str(maybe_c_squared.result) print("Reference value detected as:", maybe_c_squared.result) else: print("Error:", maybe_c_squared.result) return maybe_c_squared config.write()
def test_take_picture(self): filename = random_string() take_picture(filename) assert os.path.isfile(filename + '.png') os.remove(filename + '.png')