def testChain(): sd = ScaleDetection() im = sd.openImage(FILENAME) sd.calibrate(im, IMG_DIM[0], IMG_DIM[1], UNIT) im = sd.openImage(FILENAMES[-1]) w, h, unit = sd.getSize(im, show_conts=SAVE_IMG) print "Width: {}".format(round(w,1)) print "Height: {}".format(round(h,1)) assert round(w, 1) == round(DIMS[-1][0], 1) assert round(h, 1) == round(DIMS[-1][1], 1)
def testCalibration(): sd = ScaleDetection() im = sd.openImage(FILENAME) sd.calibrate(im, IMG_DIM[0], IMG_DIM[1], UNIT) w,h = IMG_PIX assert round(sd.x_scale * Decimal(w), 0) == IMG_DIM[0] assert round(sd.y_scale * Decimal(h), 0) == IMG_DIM[1]
def testScales(): for i in range(0, len(FILENAMES)): sd = ScaleDetection() sd.x_scale = SCALE[0] sd.y_scale = SCALE[1] sd.units = UNIT im = sd.openImage(FILENAMES[i]) w,h,unit = sd.getSize(im, show_conts=SAVE_IMG) print "Width: {}".format(round(w,1)) print "Height: {}".format(round(h,1)) assert round(w, 1) == round(DIMS[i][0], 1) assert round(h, 1) == round(DIMS[i][1], 1)
def testCalibrationFail(): sd = ScaleDetection() im = sd.openImage(FILENAME) f = sd.calibrate(im, IMG_DIM[0], "a", UNIT) assert f == False
def testDimensions(): sd = ScaleDetection() im = sd.openImage(FILENAME) w, h = sd.getDimensions(im) assert w == IMG_PIX[0] assert h == IMG_PIX[1]