1. 程式人生 > >jupyter notebook oepncv 顯示一張影象

jupyter notebook oepncv 顯示一張影象

感想

我們在用jupyter notebook的時候,經常需要視覺化一些東西,尤其是一些影象,我這裡給個sample code

環境

opencv-python

matplotlib

numpy

sample

import os
import numpy as np
from matplotlib import pyplot as plt
%matplotlib inline
img_dir='/Users/eric/Documents/data/wheel_train_val/train/non_defect/'
filename='00005.BMP_block_8.jpg'
img = cv2.imread(img_dir +os.sep+ filename)
plt.imshow(img)
plt.show()

參考文獻

[1]. opencv.imshow will cause jupyter notebook crash.  https://stackoverflow.com/questions/46236180/opencv-imshow-will-cause-jupyter-notebook-crash