TensorFlow与OpenCV,读取图片,进行简单操作并显示

TensorFlow与OpenCV,读取图片,进行简单操作并显示 难度1

http://blog.csdn.net/helei001/article/details/52400497


 

import tensorflow as tf

import cv2

 

#file_path = ‘/Users/cloveai/Desktop/’

#ilename = ‘1.jpg’

 

image = cv2.imread(‘/Users/cloveai/Desktop/1.jpg’, 1)

cv2.namedWindow(‘image’, 0)

cv2.imshow(‘image’, image)

 

# Create a TensorFlow Variable

x = tf.Variable(image, name=’x’)

 

#model = tf.initialize_all_variables()

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)

发表评论

电子邮件地址不会被公开。 必填项已用*标注