Closed mrakitin closed 6 years ago
#installing zbarlight: #had to update (sudo apt-get update) #PATH=$PATH:/sbin #sudo apt-get install libzbar0 libzbar-dev #sudo pip --proxy 10.0.137.23:8888 install zbarlight import zbarlight from PIL import Image import pandas as pd def decode_barcode(exposure_time = 0.65): old_exp = bpm_sp.cam.acquire_time.value old_mode = bpm_sp.cam.image_mode.value old_acquire = bpm_sp.cam.acquire.value bpm_sp.cam.acquire_time.put(exposure_time) bpm_sp.cam.image_mode.put(0) bpm_sp.cam.acquire.put(0) while(bpm_sp.cam.detector_state.value == 1): pass bpm_sp.cam.acquire.put(1) time.sleep(0.1) while(bpm_sp.cam.detector_state.value == 1): pass time.sleep(0.1) #fix this for GUI image = bpm_sp.image.read()['bpm_sp_image_array_data']['value'].reshape((960, 1280)) #return image bpm_sp.cam.acquire_time.put(old_exp) bpm_sp.cam.image_mode.put(old_mode) bpm_sp.cam.acquire.put(old_acquire) df = pd.DataFrame(image) mean_adjust = df.mean().mean() * 2 df[df > mean_adjust] = int(df.mean().mean()) df[df >= (df.mean().max() + df.mean().min()) / 6] = 255 df[df < (df.mean().max() + df.mean().min()) / 6] = 0 #plt.imshow(image) #image_qr = Image.fromarray(image, 'L') image_qr = Image.fromarray(np.array(df), 'L') #image_qr.show() decoded = zbarlight.scan_codes('qrcode', image_qr) if decoded is not None: return decoded[0].decode("utf-8") return ''
Links:
Resolved in https://github.com/NSLS-II-ISS/isstools/commit/3ffa05dd42dcea1c19d58671f60dce00dc4aa1b5.
Links: