How to convert frame video to Image NdArray

We can convert local image to NdArray type :
with open(image_file, 'rb') as f:
....data = mx.image.imdecode(f.read(), flag=0)

but with real time, get frame from camera:
frame_resize = cv2.resize(video_frame, (200, 200))
data = mx.image.imdecode(frame_resize, flag=0)

I got message “unknown storage type: -1

I don’t want save frame to image and then load it.
How to got data with NdArray type without fail ?

Thank.

Did you try using OpenCV to decode and then convert numpy ndarray to NDArray?

No, follow this link (https://mxnet.incubator.apache.org/api/python/image/image.html#mxnet.image.imdecode).
mx.img.imdecode() function return NDArray

My problem : data = mx.image.imdecode(frame_resize, flag=0) will throw error “unknown storage type: -1”

ah, needn’t decode. Convert directly data = mx.nd.array(frame_resize)

Thank for your suggestion.

2 Likes