Hello,
I have a python script successfully running
In the script I receive image data via mqtt. I capture the data and convert it using numpy
import numpy as np
# convert string of image data to uint8
nparr = np.fromstring(msg.payload, np.uint8)
This gives an array typically like this: [255 216 255 …, 127 255 217]
It allows me then to manipulate the image using functions in cv2 (OpenCV) so that I have an image in memory.
image = cv2.imdecode(nparr, cv2.IMREAD_COLOR)
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
Now to make inference, I use the following code, first saving to file system, then reading again
# save the image to disk
cv2.imwrite(cnbr+'.jpg', image)
# load the image (into shared CPU/GPU memory)
img, width, height = jetson.utils.loadImageRGBA(cnbr+'.jpg')
detections = net.Detect(img, width, height, "box,labels,conf")
It works fine but I would really like to skip the saving to file and instead use the image directly but I think the format is wrong. Does anybody know how I could do it instead?
Very grateful to any help and suggestions,
Kind regards, Walter