我在web.data()
中接收到一个二进制图像,并用cv2.imdecode
对其进行解码。结果是一幅图像。我可以成功地对它进行斑点检测没问题。然而,获得宽度和高度却成了一个问题。下面是我使用的代码(找到here和here)以及我得到的错误消息。这两种方法都不管用,为什么呢?在
imageDecoded = cv2.imdecode(np.frombuffer(web.data(), dtype='uint8'), cv2.CV_LOAD_IMAGE_GRAYSCALE)
# https://stackoverflow.com/questions/13033278/image-size-python-opencv
height, width = cv.GetSize(imageDecoded) # <class 'cv2.error'> Array should be CvMat or IplImage
# https://stackoverflow.com/questions/32971241/how-to-get-image-width-and-height-in-opencv
height, width, channels = imageDecoded.shape # <type 'exceptions.AttributeError'> 'NoneType' object has no attribute 'shape'
目前没有回答
相关问题 更多 >
编程相关推荐