def find_loop(self): snapshot_filename = os.path.join( tempfile.gettempdir(), "mxcube_sample_snapshot.png" ) self.camera_hwobj.take_snapshot(snapshot_filename, bw=True) info, x, y = lucid.find_loop(snapshot_filename) return x, y
def find_loop(pixels_per_mm_horizontal, show_point=True): #img_array = numpy.fromstring(camera.getChannelObject("image").getValue(), numpy.uint8) #JN,20141216,ESRF for prosilica camera #rgbImgChan = camera.addChannel({ 'type': 'tango', 'name': 'rgbimage', "read_as_str": 1 }, "RgbImage") #raw_data = rgbImgChan.getValue() #snapshot_filename = os.path.join(tempfile.gettempdir(), "mxcube_sample_snapshot.png") #Image.fromstring("RGB", (imgWidth, imgHeight), raw_data).save(snapshot_filename) #JN,20141216,maxlab version for PAL camera raw_data = str(myimage(self._drawing)) snapshot_filename = os.path.join(tempfile.gettempdir(), "mxcube_sample_snapshot.jpeg") logging.info("snapshot_filename is %s" % (snapshot_filename)) f = open(snapshot_filename, "w") f.write(raw_data) f.close() info, x, y = lucid.find_loop( snapshot_filename, pixels_per_mm_horizontal=pixels_per_mm_horizontal) self.emitProgressMessage("Loop found: %s (%d, %d)" % (info, x, y)) logging.debug("Loop found: %s (%d, %d)" % (info, x, y)) if show_point: self.emit("newAutomaticCentringPoint", (x, y)) return x, y
def find_loop(pixels_per_mm_horizontal, show_point=True): #img_array = numpy.fromstring(camera.getChannelObject("image").getValue(), numpy.uint8) #JN,20141216,ESRF for prosilica camera #rgbImgChan = camera.addChannel({ 'type': 'tango', 'name': 'rgbimage', "read_as_str": 1 }, "RgbImage") #raw_data = rgbImgChan.getValue() #snapshot_filename = os.path.join(tempfile.gettempdir(), "mxcube_sample_snapshot.png") #Image.fromstring("RGB", (imgWidth, imgHeight), raw_data).save(snapshot_filename) #JN,20141216,maxlab version for PAL camera #raw_data = str(myimage(self._drawing)) #snapshot_filename = os.path.join(tempfile.gettempdir(), "mxcube_sample_snapshot.jpeg") snapshot_filename = "/tmp/mxcube_sample_snapshot.jpeg" logging.info("snapshot_filename is %s, zoom is %s" % (snapshot_filename, str(pixels_per_mm_horizontal))) camera.takeSnapshot(snapshot_filename) info, x, y = lucid.find_loop(snapshot_filename, pixels_per_mm_horizontal=pixels_per_mm_horizontal) self.emitProgressMessage("Loop found: %s (%d, %d)" % (info, x, y)) logging.debug("Loop found: %s (%d, %d)" % (info, x, y)) if show_point: self.emit("newAutomaticCentringPoint", (x,y)) return x,y
def find_loop(self): snapshot_filename = os.path.join(tempfile.gettempdir(), "mxcube_sample_snapshot.png") HWR.beamline.sample_view.camera.take_snapshot(snapshot_filename, bw=True) info, x, y = lucid.find_loop(snapshot_filename) return x, y
def find_loop(camera, pixelsPerMm_Hor, chi_angle, msg_cb, new_point_cb): snapshot_filename = os.path.join(tempfile.gettempdir(), "mxcube_sample_snapshot.png") camera.takeSnapshot(snapshot_filename, bw=True) info, x, y = lucid.find_loop( snapshot_filename, debug=False, pixels_per_mm_horizontal=pixelsPerMm_Hor, chi_angle=chi_angle ) if callable(msg_cb): msg_cb("Loop found: %s (%d, %d)" % (info, x, y)) if callable(new_point_cb): new_point_cb((x, y)) return x, y
def find_loop(pixels_per_mm_horizontal, show_point=True): #img_array = numpy.fromstring(camera.getChannelObject("image").getValue(), numpy.uint8) rgbImgChan = camera.addChannel({ 'type': 'tango', 'name': 'rgbimage', "read_as_str": 1 }, "RgbImage") raw_data = rgbImgChan.getValue() snapshot_filename = os.path.join(tempfile.gettempdir(), "mxcube_sample_snapshot.png") Image.fromstring("RGB", (imgWidth, imgHeight), raw_data).save(snapshot_filename) info, x, y = lucid.find_loop(snapshot_filename, pixels_per_mm_horizontal=pixels_per_mm_horizontal) self.emitProgressMessage("Loop found: %s (%d, %d)" % (info, x, y)) logging.debug("Loop found: %s (%d, %d)" % (info, x, y)) if show_point: self.emit("newAutomaticCentringPoint", (x,y)) return x,y
def find_loop(camera, pixelsPerMm_Hor, chi_angle, msg_cb, new_point_cb): snapshot_filename = os.path.join(tempfile.gettempdir(), "mxcube_sample_snapshot.png") camera.takeSnapshot(snapshot_filename, bw=True) info, x, y = lucid.find_loop(snapshot_filename, debug=False, pixels_per_mm_horizontal=pixelsPerMm_Hor, chi_angle=chi_angle) if callable(msg_cb): msg_cb("Loop found: %s (%d, %d)" % (info, x, y)) if callable(new_point_cb): new_point_cb((x, y)) return x, y
def find_loop(pixels_per_mm_horizontal, show_point=True): #img_array = numpy.fromstring(camera.getChannelObject("image").getValue(), numpy.uint8) rgbImgChan = camera.addChannel( { 'type': 'tango', 'name': 'rgbimage', "read_as_str": 1 }, "RgbImage") raw_data = rgbImgChan.getValue() snapshot_filename = os.path.join(tempfile.gettempdir(), "mxcube_sample_snapshot.png") Image.fromstring("RGB", (imgWidth, imgHeight), raw_data).save(snapshot_filename) info, x, y = lucid.find_loop( snapshot_filename, pixels_per_mm_horizontal=pixels_per_mm_horizontal) self.emitProgressMessage("Loop found: %s (%d, %d)" % (info, x, y)) logging.debug("Loop found: %s (%d, %d)" % (info, x, y)) if show_point: self.emit("newAutomaticCentringPoint", (x, y)) return x, y
def test_horizontalDownLoops(self): for imgpath in self.horizontalDownLoopsGrp: res = lucid.find_loop("sample_images/"+imgpath,zoom=0,testingProc=True) self.assertTrue(((res[2][0]=='Coord') or (res[2][0]=='ApproxCoord'))) self.assertTrue((res[2][2]>((res[1]//2)+(res[1]//8))))
def test_robotArm(self): for imgpath in self.robotArmGrp: res = lucid.find_loop("sample_images/"+imgpath,zoom=0,testingProc=True) self.assertEqual(res[2][0],'ArmRobot') self.assertEqual(res[2][1],res[0])
def test_noLoops(self): for imgpath in self.noLoopsGrp: res = lucid.find_loop("sample_images/"+imgpath,zoom=0,testingProc=True) self.assertEqual(res[2],('No loop detected', -1, -1))
def test_verticalRightLoops(self): for imgpath in self.verticalRightLoopsGrp: res = lucid.find_loop("sample_images/"+imgpath,zoom=0,testingProc=True) self.assertTrue(((res[2][0]=='Coord') or (res[2][0]=='ApproxCoord'))) self.assertTrue((res[2][1]>((res[0]//2)+(res[0]//8))))
def find_loop(self): snapshot_filename = os.path.join(tempfile.gettempdir(), "mxcube_sample_snapshot.png") self.camera_hwobj.take_snapshot(snapshot_filename, bw=True) info, x, y = lucid.find_loop(snapshot_filename) return x, y
def find_loop(b64_image_array_string, shape, zoom=0): a = numpy.fromstring(base64.b64decode(b64_image_array_string), numpy.uint8).astype("float32") a.shape = shape return lucid.find_loop(a, zoom)