Install Rosetta 2
$ softwareupdate --install-rosetta
Set Up Python Environment
$ CONDA_SUBDIR=osx-64 conda create -n rosetta python
$ conda activate rosetta
$ python -c "import platform;print(platform.machine())" # should output x86_64
$ conda env config vars set CONDA_SUBDIR=osx-64
$ conda deactivate
$ conda activate rosetta
Install ddddocr
$ pip install ddddocr
An Example Program
from PIL import Image
if not hasattr(Image, 'ANTIALIAS'):
setattr(Image, 'ANTIALIAS', Image.LANCZOS)
import ddddocr
ocr = ddddocr.DdddOcr()
image = open(validate_code_image_path, "rb").read()
result = ocr.classification(image)
References
- https://www.yuque.com/wangpengfei4113/messy/cc8222