def createWidgets(self, x, y): self.p = params.FitParams(self.root, Gs=10 * abs(mean(diff(x))), xL=min(x), xR=max(x), row=0, column=1) self.p.bl.set(mean(y)) self.mpl = mpl.MPL(self.root, x, y, self.p, row=0, column=0, rowspan=3) self.fit = fit.Fit(self.root, self.p, self.mpl, row=1, column=1)
def pipeline(input_img): """entire image processing pipeline to go from source image to annotated output image :param input_img: :return: """ global last_fit curr_fit = fit.Fit() # undistort image undist = morph_img.undistort_image(input_img) # threshold binary binary_threshold = abs_sobel_thresh(undist) # bird's eye view birds_eye_view = morph_img.warp_to_birds_eye(binary_threshold) # fit polynomial left_fit, right_fit, left_fitx, right_fitx, ploty = fit_polynomial(birds_eye_view) curr_fit.set_fits(left_fit, right_fit) # calculate lane curvature l_curve, r_curve = measure_curvature_real(left_fit, right_fit) curr_fit.set_curves(l_curve, r_curve) # calculate position of vehicle left_peak, right_peak = get_peaks(birds_eye_view) curr_fit.set_peaks(left_peak, right_peak) vehicle_pos = position_of_vehicle(left_peak, right_peak) # TODO fix this to take most recent left/right instead o hist curr_fit.vehicle_pos = vehicle_pos # draw the detected lane on the source image lane_img = draw_lane_on_img(undist, left_fitx, right_fitx, ploty) # annotate the image final_img = add_info_to_img(lane_img, (l_curve + r_curve) / 2, vehicle_pos) # if current found fit makes sense, use it for the next prediction # if not, increase the age of the last fit, if too old, search from scratch if curr_fit.is_sane(): last_fit = curr_fit last_fit.age = 0 else: try: last_fit.age += 1 if last_fit.age >= 10: last_fit = None except AttributeError: pass return final_img
def fit_to_json(fd_in, fd_out): data_fields = [] def stash_data(name, data): data_fields.append({name: data}) f = fit.Fit(fd_in, data_field_disposition=stash_data) data = { 'data_records': data_fields, 'unknown_messages': f.unknown_messages, 'unknown_fields': f.unknown_fields } json.dump(data, fd_out, indent=4, ensure_ascii=False, sort_keys=True)
#!/usr/local/bin/python # -*- coding: utf-8 -*- # Vimのアップデートを確認するプログラム. import sys import logging import os if sys.version_info < (2, 6, 0): import fit fit.Fit(sys.argv[0].rsplit("\\", 1)[0] + "\\").fit() import pe32b as pe32 else: import pe32 from updater import OnlineUpdater def __detectArch(rootdir): arch = pe32.ARCH_UNKNOWN exe = os.path.join(rootdir, 'vim.exe') if os.path.exists(exe): arch = pe32.detectArch(exe) else: machtype = os.environ.get('PROCESSOR_ARCHITECTURE').upper() if machtype == 'X86': arch = pe32.ARCH_WIN32 elif machtype == 'AMD64': arch = pe32.ARCH_WIN64 if arch != pe32.ARCH_WIN32 and arch != pe32.ARCH_WIN64: logging.error('failed to detect CPU arch') return arch
import argparse import sys import fit import generate if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument('mode', nargs='?', default='generate') parser.add_argument('filename', nargs='?', default='test.txt') args = parser.parse_args(sys.argv[1:]) if args.mode == 'fit': curr = fit.Fit(args.filename) data = curr.action() curr.rewrite(data) elif args.mode == 'generate': curr = generate.Generate() curr.action()
DEnsem_Top_List = [] Ensemble_Tuple_list = [] AEnsemble_SpecSum_Weight = [] AEnsemble_SpecProj_Weight = [] BEnsemble_SpecSum_Weight = [] BEnsemble_SpecProj_Weight = [] DEnsemble_SpecSum_Weight = [] DEnsemble_SpecProj_Weight = [] AM_sqr = [] BM_sqr = [] DM_sqr = [] a_r0_sqr = [] Spacing = [] ChiralContFit = ft.Fit("SpecSum Global Fit") ChiralContFit_SP = ft.Fit("SpecProj Global Fit") FitA = ft.Fit("SpecSum A Ensemble") FitB = ft.Fit("SpecSum B Ensemble") FitD = ft.Fit("SpecSum D Ensemble") FitA_SP = ft.Fit("SpecProj A Ensemble") FitB_SP = ft.Fit("SpecProj B Ensemble") FitD_SP = ft.Fit("SpecProj D Ensemble") for i in range(0, len(AEnsembleList), 1): path = Full_Conf_Dir + AEnsembleList[i].EnsembleName EigProd_List = df.Data_Loader(path) AM_sqr.append( M_sqr_ev_set[0] * (pow(2 * AEnsembleList[i].Kappa * AEnsembleList[i].a / 197.32, 2)))
def setup_fit(self): if self.downloaded: self.fit = fit.Fit(self.full_path) self.fit.connect('status-changed', self.fit_status_changed_cb) self.status = Activity.Status.DOWNLOADED