def record_form(survey, img_id, noact=False, paperinfo=None): survey_id = survey['id'] rmarks = rm.extract_data(survey['paperinfo']) # # Right now we just pass the whole form image to the barcode reader, so we # don't need the barcode bounding box #barcode_bbox = survey['paperinfo']['barcode']['bbox']; # Get the image info img_info_url = '%s/surveys/%s/scans/%s' % (API_BASE, survey_id, img_id) print 'Getting image info from %s' % img_info_url try: img_info = api_get(img_info_url) except APIError, e: return 2
# Set up API access api = survey_api.API(os.getenv('SURVEY_API_BASE', 'http://localhost:3000')) # Load data input_file = file(input_filename, "r") data = json.load(input_file) # survey_id = data['template']['survey'] parcelsets = data['parcelsets'] # Get the global survey information survey = api.get_survey(survey_id) # Interpret the registration mark information paperinfo = survey['paperinfo'] rmarks = rm.extract_data(paperinfo) # Load the skeletal form skeleton_img = Image.open(skeleton_file) # Interpret the bubble information form_bubble_sets = [] for parcel_info in data['template']['parcels']: form_bubble_sets.append(Bubble.extract_data(parcel_info)) # Draw the bubbles for parcel_bubble_set in form_bubble_sets: for bs in parcel_bubble_set.sets: bs.draw(skeleton_img) # Draw the registration marks
print 'Bad input arguments' return 2 # Set up API access api = survey_api.API(os.getenv('SURVEY_API_BASE', 'http://localhost:3000')) # Load data input_file = file(input_filename, "r") data = json.load(input_file) # survey_id = data['survey'] parcels = data['parcels'] formsets = Bubble.extract_data(data) # survey = api.get_survey(survey_id) rmarks = rm.extract_data(survey['paperinfo']) # # Load the skeletal form skeleton_img = Image.open(skeleton_file) # Draw the bubbles for bs in formsets.sets: bs.draw(skeleton_img) # Draw the registration marks for mark in rmarks: mark.draw(skeleton_img) # Iterate over parcels and create forms form_data = {"forms" : [{"parcels" : [], "type" : "paper", "mapping" : {}, "survey" : survey_id}]} for parcel in parcels: