“cv2.imdecode(numpyArray, cv2.CV_LOAD_IMAGE_COLOR)” returns None
I'm trying to convert an image into Opencv (into numpy array) and use the array to publish the message over a ROS node. I tried doing the same through the following code fig.canvas.draw() nparr = np.fromstring ( fig.canvas.tostring_argb(), np.uint8 ) print nparr img_np = cv2.imdecode(nparr, cv2.CV_LOAD_IMAGE_COLOR) print img_np image_message = bridge.cv2_to_imgmsg(img_np, encoding="passthrough") pub.publish(image_message) But, when I tried doing this I get an error message AttributeError: 'NoneType' object has no attribute 'shape' So, I tried printing the values of both the numpy array whose