How to get byte data from Code Composer Studio showed here (10.). Now we have a frame.bin, containg picture bytes.
1. Setup python 3, pip and matplotlib in windows:
1) download python3 from here, install
2) download get-pip.py from here to some local dir (in my case, ctrl-c in chrome and make a new text file get-pip.py in C:\Distrib\Python), install pip (type in cmd):
cd C:\Distrib\Python
python get-pip.py
3) to install matplotlib you need to open cmd and type:
python -m pip install -U matplotlib
2. Read frame.bin file with numpy.fromfile.
NumPy doc:
Stackoverflow:
Do in cmd:
python
>>> import numpy as np
>>> img = np.fromfile("frame.bin",dtype='uint8')>>> re_img = np.reshape(img[:388800],(540,720))
3. Draw RGB-bitstream from file in matplotlib:
1) How to Display a Matplotlib RGB Image https://www.pyimagesearch.com/2014/11/03/display-matplotlib-rgb-image/
Matplotlib doc:
1) imread - reads png-file:
2) imshow - show numpy array:
Error showing grayscale image as colored:
Do in cmd:
python
>>> import matplotlib.pyplot as plt
>>> plt.imshow(re_img, cmap='gray')>>> plt.show()
Result script:
python
>>> import numpy as np
>>> img = np.fromfile("frame.bin",dtype='uint8')>>> re_img = np.reshape(img[:388800],(540,720))
>>> import matplotlib.pyplot as plt
>>> plt.imshow(re_img, cmap='gray')>>> plt.show()
Комментариев нет:
Отправить комментарий