I read some files in Python as follows:
with open("C:\Users\MyUser\Downloads\testPicture.jpg", 'rb') as FID:
fileInBytes = FID.read()
This returns a bytes string in Python.
Running type(fileInBytes) returns <class 'bytes'>.
I need to call a Python function from MATLAB. The Python function expects the file instance as a bytes string, as described above. So, I would need to do the following in MATLAB:
- Read in file from
MATLABin format, which will map, when calling aPythonfunction fromMATLAB, as a bytes string.
From this document, I believe, uint8 in MATLAB converts to bytes in Python.
How can I achieve this? I'm guessing I just need to read a file in uint8 format in MATLAB and pass that into Python