一、安裝Python環境,推薦使用Anaconda,過程再也不贅述。python
二、下載opencv_python3.3.0cp35cp35mwin_amd64.whl或...win32.whl,session
opencv_python下載地址,下載好後把文件複製到Anaconda3\Lib\site-packages文件夾下 。ide
三、安裝2的文件。測試
鍵入:spa
cd 文件路徑 pip install 文件名.whl
四、Successful!blog
注:若是在測試的時候出錯,ImportError: numpy.core.multiarray failed to import,ip
那麼就安裝(更新)numpy。 cmd.exe裏鍵入: ci
pip install -U numpy
五、測試get
import tensorflow as tf import cv2 p_w_picpath = cv2.imread("F:/p_w_picpath.jpg") cv2.namedWindow('p_w_picpath', 0) cv2.imshow('p_w_picpath', p_w_picpath) # Create a TensorFlow Variable x = tf.Variable(p_w_picpath, name='x') model = tf.global_variables_initializer() with tf.Session() as session: x = tf.transpose(x, perm=[1,0 , 2]) #將圖像數據轉置 session.run(model) result = session.run(x) cv2.namedWindow('result', 0) cv2.imshow('result', result) cv2.waitKey(0)
效果:cmd