## # create folder for measurements todaystr = datetime.datetime.now().strftime('%Y-%m-%d_%H-%M-%S') myfolder = './ptycho_'+todaystr os.mkdir(myfolder) # Initilizae the Camera #cap = cv2.VideoCapture('/dev/video0', cv2.CAP_V4L2) #cap = cv2.VideoCapture('gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw, format=BGRx ! ximagesink') cap = cv2.VideoCapture('v4l2src device=/dev/video0 ! video/x-raw, format=BGRx ! videoconvert ! appsink', cv2.CAP_GSTREAMER) #cap = cv2.VideoCapture(0) # Initialize position of the XY-stages myxStepper = xy.xyStepper(myserial=serial, mycurrentposition=0, mystepper='x') myyStepper = xy.xyStepper(myserial=serial, mycurrentposition=0, mystepper='y') # Make sure we are at the edge of the stage mycmd = myxStepper.reset_pos() mycmd = myyStepper.reset_pos() # read in the file with all positions with open(mycsvfile, 'r') as f: data = list(csv.reader(f, delimiter=";")) myscanpoints = np.array(data[1:-1], dtype=np.float) maxpos = np.max(myscanpoints,axis=0)*2 myscanpoints/=maxpos minpos = np.min(myscanpoints,axis=0) myscanpoints-=minpos
mycsvfile = './DATA/Fermat_FOV1200um_step72um_202points.csv' # Initialize the USB-Serial connection serial = serial.Serial("/dev/ttyUSB0", 9600) time.sleep(1) # connect to ARduino # camera paramters # parameters for the x/y stage stepsize = 17.27 # One STEPSIZE in X/Y of the cheap-stage is 17.27 µm myoffsetx = 10 # offset steps for the x dirrection myoffsety = 20 # offset steps for the y dirrection mybacklashx = 10 mybacklashy = 50 # this is required to offset the stage from the non-moving rim # Initialize position of the XY-stages myxStepper = xy.xyStepper(myserial=serial, mycurrentposition=0, mystepper='x', backlash=mybacklashx) myyStepper = xy.xyStepper(myserial=serial, mycurrentposition=0, mystepper='y', backlash=mybacklashy) # Make sure we are at the edge of the stage #myyStepper.reset_pos() #myxStepper.reset_pos() # read in the file with all positions with open(mycsvfile, 'r') as f: data = list(csv.reader(f, delimiter=";")) myscanpoints = np.array(data[1:-1], dtype=np.float) maxpos = np.max(myscanpoints, axis=0)
Ny = 10 StepsizeX = 10 StepsizeY = 10 # create folder for measurements try: os.mkdir(mydatafolder) except: print('Folder already exists') todaystr = datetime.datetime.now().strftime('%Y-%m-%d_%H-%M-%S') myfolder = mydatafolder + 'ptycho_' + todaystr os.mkdir(myfolder) # Initialize position of the XY-stages Stepper_XY = xy.xyStepper(myserial=serial, mycurrentposition=(0, 0), mystepper='xy', backlash=mybacklashx) if (0): # Make sure we are at the edge of the stage mycmd = Stepper_X.reset_pos() mycmd = Stepper_Y.reset_pos() print('Start programm') # Flush anything which is on the pipe.. serial.flushInput() # move stepper forward/backward in X for ix in range(Nx): for iy in range(Ny):