def calibrate(): """ Calibrate radar. """ radar.StartCalibration() app_status, calibration_process = radar.GetStatus() while app_status == radar.STATUS_CALIBRATING: radar.Trigger() app_status, calibration_process = radar.GetStatus() return
def startAndCalibrateWalabot(): """ Start the Walabot and calibrate it. """ wlbt.StartCalibration() print('- Calibrating...') while wlbt.GetStatus()[0] == wlbt.STATUS_CALIBRATING: wlbt.Trigger() wlbt.Start() print('- Calibration ended.\n- Ready!')
def start(self): # begin calibration and prepare for scanning bot.SetProfile(bot.PROF_SENSOR) # set Walabot properties bot.SetArenaR(minDistance, maxDistance, 5) bot.SetArenaTheta(-1, 1, 1) bot.SetArenaPhi(minAngle, maxAngle, 5) bot.SetThreshold(60) bot.SetDynamicImageFilter(bot.FILTER_TYPE_NONE) bot.Start() # start calibration bot.StartCalibration() print("Calibrating") while bot.GetStatus( )[0] == bot.STATUS_CALIBRATING: # wait for calibration to end bot.Trigger() # calibration process Walabot print(".", end="") print(CLEARSCREEN + moveCursor(0, 1) + "Calibrated: " + Fore.CYAN + Style.BRIGHT + "True") # done calibrating print(Style.RESET_ALL + "Player: " + Fore.YELLOW + Style.BRIGHT + str(player))
try: wala.ConnectAny() except WalabotError as err: if err.message == wala.WALABOT_INSTRUMENT_NOT_FOUND: print('Please connect your Walabot') else: print(err.message) wala.SetProfile(wala.PROF_SENSOR) wala.SetDynamicImageFilter(wala.FILTER_TYPE_MTI) wala.Start() while True: wala.Trigger() targets = wala.GetSensorTargets() if targets: appStatus, calibrationProcess = wala.GetStatus() if debug: print(appStatus) if debug: print(calibrationProcess) TargetsToAzure(targets, sbs) else: print('No Target Detected') wala.Stop() wala.Disconnect()
bot.SetProfile(bot.PROF_TRACKER) bot.SetArenaR(5, 20, 0.2) bot.SetArenaTheta(-1, 1, 1) bot.SetArenaPhi(-10, 10, 10) bot.SetThreshold(30) bot.SetDynamicImageFilter(bot.FILTER_TYPE_NONE) bot.Start() # calibrate the Walabot to the background noise # after calibration, it will only sense the distance your foot is from it. print("[calibrate]") bot.StartCalibration() try: while bot.GetStatus()[0] == bot.STATUS_CALIBRATING: bot.Trigger() # start scanning the distance from your foot using the image data from the Walabot print("[scan]") while True: bot.Trigger() img, _, _, _, _ = bot.GetRawImageSlice() # use the raw image data of the scan # each row corrosponds to distance from the sensor # we just need to find which row is the first one that contains your foot minRow = 0
resIndegrees = 2 ## Walabot_SetArenaPhi - input parameters minPhiInDegrees = -4 maxPhiInDegrees = 4 resPhiInDegrees = 2 ##JC: here below modified from C++ breathing code, before use variables needs to be defined, parameters accoarding to http://api.walabot.com/_features.html and http://api.walabot.com/_sample.html C++ breathing code ## Setup arena - specify it by Cartesian coordinates(ranges and resolution on the x, y, z axes); ## In Sensor mode there is need to specify Spherical coordinates(ranges and resolution along radial distance and Theta and Phi angles). wlbt.SetArenaR(minInCm, maxInCm, resICm) ## Sets polar range and resolution of arena (parameters in degrees). wlbt.SetArenaTheta(minIndegrees, maxIndegrees, resIndegrees) ## Sets azimuth range and resolution of arena.(parameters in degrees). wlbt.SetArenaPhi(minPhiInDegrees, maxPhiInDegrees, resPhiInDegrees) wlbt.Start() # starts Walabot in preparation for scanning print('hello') while True: ##JC: add calibrates based from C++ code ##// calibrates scanning to ignore or reduce the signals wlbt.StartCalibration() while wlbt.GetStatus()[0] == wlbt.STATUS_CALIBRATING: wlbt.Trigger() Energy_current = wlbt.GetImageEnergy() #JC: replace GetSensorTargets to GetImageEnergy system('cls' if platform == 'win32' else 'clear') # clear the terminal print('Energy_Current = ', Energy_current, '/n') wlbt.Stop() # stops Walabot when finished scanning wlbt.Disconnect() # stops communication with Walabot
## Sets polar range and resolution of arena (parameters in degrees). wlbt.SetArenaTheta(minIndegrees, maxIndegrees, resIndegrees) ## Sets azimuth range and resolution of arena.(parameters in degrees). wlbt.SetArenaPhi(minPhiInDegrees, maxPhiInDegrees, resPhiInDegrees) wlbt.Start() # starts Walabot in preparation for scanning print('hello') while True: ##JC: add calibrates based from C++ code ##// calibrates scanning to ignore or reduce the signals Energy = [] #array which save each energy get from wlbt start = time.time() #timer control how long each circle while (time.time() - start) < 10: #each 10s wlbt.StartCalibration() #start calibration while wlbt.GetStatus( )[0] == wlbt.STATUS_CALIBRATING: #when calibraion done wlbt.Trigger() #trigger walabot Energy.append(wlbt.GetImageEnergy()) # get Energy #Energy_current = wlbt.GetImageEnergy() ##JC: replace GetSensorTargets to GetImageEnergy #system('cls' if platform == 'win32' else 'clear') # clear the terminal #print('Energy_Current = ', Energy_current, '/n') #after each 10s do following print('Energy mean in 10s = ', sum(Energy) / len(Energy), '/n') print('Energy max in 10s = ', max(Energy), '/n') print('Energy min in 10s = ', min(Energy), '/n') print('time elapsed', time.time() - start, '/n') wlbt.Stop() # stops Walabot when finished scanning wlbt.Disconnect() # stops communication with Walabot
min_R, max_R, res_R = 216, 457, 5 wala.SetArenaR(min_R, max_R, res_R) min_Theta, max_Theta, res_Theta = -19, 19, 5 wala.SetArenaTheta(min_Theta, max_Theta, res_Theta) min_Phi, max_Phi, res_Phi = -43, 43, 5 wala.SetArenaPhi(min_Phi, max_Phi, res_Phi) # Start Walabot and perform calibration wala.Start() wala.StartCalibration() calibration_status, calibration_progress = wala.GetStatus() wala.Trigger() while calibration_status == wala.STATUS_CALIBRATING and calibration_progress < 100: wala.Trigger() print("Calibrating " + str(calibration_progress) + '%') calibration_status, calibration_progress = wala.GetStatus() # Initialize video camera. Wait 1 second for 'warmup' cap = cv.VideoCapture(1) time.sleep(1) # WebCam capture dimensions, a cv2 method cap.set(3, 640)
wb.SetProfile(wb.PROF_TRACKER) # Set scan arena wb.SetArenaR(*ARENA[0]) wb.SetArenaPhi(*ARENA[1]) wb.SetArenaTheta(*ARENA[2]) print("Arena set") # Set image filter wb.SetDynamicImageFilter(wb.FILTER_TYPE_MTI) # Start scan wb.Start() wb.StartCalibration() stat, prog = wb.GetStatus() while stat == wb.STATUS_CALIBRATING and prog < 100: print("Calibrating " + str(prog) + "%") stat, prog = wb.GetStatus() posmap = GenPosMap() print("Setting plot") if os.name == 'nt': prep_plot(None, posmap) else: curses.wrapper(prep_plot, posmap) wb.Stop() wb.Disconnect()
def run(): cap = VideoCapture(0) # Select scan arena # R Phi Theta ARENA = [(40, 500, 4), (-60, 60, 5), (-15, 15, 5)] # Init of Dataframe dataset = pd.DataFrame() # Star Walabot capture process print("Initialize API") wb.Init() wb.Initialize() # Check if a Walabot is connected try: wb.ConnectAny() except wb.WalabotError as err: print("Failed to connect to Walabot.\nerror code: " + str(err.code)) print(wb.GetExtendedError()) print(wb.GetErrorString()) sys.exit(1) ver = wb.GetVersion() print("Walabot API version: {}".format(ver)) print("Connected to Walabot") wb.SetProfile(wb.PROF_SENSOR) # Set scan arena wb.SetArenaR(*ARENA[0]) wb.SetArenaPhi(*ARENA[1]) wb.SetArenaTheta(*ARENA[2]) print("Arena set") # Set image filter wb.SetDynamicImageFilter(wb.FILTER_TYPE_NONE) # Start calibration wb.Start() wb.StartCalibration() while wb.GetStatus()[0] == wb.STATUS_CALIBRATING: wb.Trigger() print("Calibration done!") namevar = time.strftime("%Y_%m_%d_%H_%M_%S") dim1, dim2 = wb.GetRawImageSlice()[1:3] try: pairs = wb.GetAntennaPairs() j = 1 # print(len(wb.GetAntennaPairs())) # fig = plt.figure() # ax = fig.add_subplot(111, projection='3d') while True: # One iteration takes around 0.1 seconds wb.Trigger() ret, frame = cap.read() try: raw_image, size_X, size_Y, size_Z, power = wb.GetRawImage() raw_imageSlice, size_phi, size_r, slice_depth, powerSlice = wb.GetRawImageSlice( ) sample_dict = { 'timestamp': time.time_ns(), # 'raw_signals': raw_signals, 'wlb/img': raw_image, 'wlb/slice': raw_imageSlice, 'wlb/X': size_X, 'wlb/Y': size_Y, 'wlb/Z': size_Z, 'wlb/power': power, 'wlb/Sphi': size_phi, 'wlb/Sr': size_r, 'wlb/Sdepth': slice_depth, 'wlb/Spower': powerSlice, 'cam/img': frame } # plotpointcloud(raw_image, ax) # if j%10 == 0: # plt.show() cv2.imshow('frame', frame) if cv2.waitKey(1) & 0xFF == ord('q'): break dataset = dataset.append(sample_dict, ignore_index=True) # print(sample_dict["timestamp"]) except: print(sys.exc_info()) j = j + 1 if j % 1000 == 0: print("Saving at j=" + str(j)) dataset.to_pickle("walabot_{}_{}.pkl.zip".format( namevar, int(j / 1000)), compression='zip') print("Saved!") dataset = pd.DataFrame() except KeyboardInterrupt: print('interrupted!') finally: dataset.iloc[-1000:].to_pickle("walabot_{}_{}.pkl.zip".format( namevar, int(j / 1000) + 1), compression='zip') cap.release() destroyAllWindows() wb.Stop() wb.Disconnect() print("Done!") sys.exit(0)
wlbt.PROF_SHORT_RANGE_IMAGING) # set scan profile out of the possibilities wlbt.SetDynamicImageFilter(wlbt.FILTER_TYPE_NONE) # specify filter to use wlbt.SetThreshold(thresh) wlbt.SetAdvancedParameter(wlbt.PARAM_DIELECTRIC_CONSTANT, 4) wlbt.SetArenaX(xArenaMin, xArenaMax, xArenaRes) #Set Arena Size wlbt.SetArenaY(yArenaMin, yArenaMax, yArenaRes) wlbt.SetArenaZ(zArenaMin, zArenaMax, zArenaRes) cali = 'N' print("Please enter C to calibrate") cali = input() wlbt.Start() # starts Walabot in preparation for scanning wlbt.StartCalibration() #Walabot Calibration while wlbt.GetStatus()[0] == wlbt.STATUS_CALIBRATING: wlbt.Trigger() while sc == "N": print("Please enter S to start a scan") sc = input() if sc == "S": #print(wlbt.GetAdvancedParameter(wlbt.PARAM_DIELECTRIC_CONSTANT)) q = 1 while (q == 1): appStatus, calibrationProcess = wlbt.GetStatus() wlbt.Trigger() # initiates a scan and records signals listpairs = wlbt.GetAntennaPairs() q = len(listpairs) f1 = open("AntennaPairs.txt", "w+") for i in listpairs: