How to convert frame video to Image NdArray

We can convert local image to NdArray type :
with open(image_file, 'rb') as f: = mx.image.imdecode(, 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 ?


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

No, follow this link (
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.