def cv2_imshow(image, name='name'):
"""Display an OpenCV image (2D NumPy array) through the Udacity IDE."""
global max_images, num_images
if num_images >= max_images:
print("WARNING: Exceeded max no. of imshow() calls ({}), no more images will be shown.".format(max_images))
return
num_images += 1
ext = 'png'
# encodedImage = cv2.cv.EncodeImage('.' + ext, cv2.cv.fromarray(image)) # OpenCV 2.3.x
# bytes = encodedImage.tostring()
retval, bytes = cv2.imencode('.' + ext, image) # OpenCV 2.4.x
output_image(name, ext, bytes)
评论列表
文章目录