0

I have a feature map that is converted from a video frame. When I plot the feature map using OpenCV VideoWriter. It doesn't write anything to video.

out = cv2.VideoWriter('out.mp4',cv2.VideoWriter_fourcc('M','J','P','G'),30, (width,height),True) 
// width=1280,height=720

output=network.extract_output() # output from openvino inference nwtwotk of shape (1, 1, 1024, 2048)
output=cv2.resize(output[0][0], (width, height)) //output frame that I want to write to video file  
plt.imshow(output)
plt.show()

shows this image

But when I write the same frame to the video, it doesn't show anything. out.write(output)

Vardan Agarwal
  • 2,023
  • 2
  • 15
  • 27
Muhammad
  • 720
  • 6
  • 13
  • 1
    You're writing a grayscale image, but when constructing `VideoWriter` you explicitly asked for a colour video. – Dan Mašek Jan 13 '20 at 12:19
  • Thanks for the answer, can I write grayscale? – Muhammad Jan 13 '20 at 12:32
  • Yes, if you set the last parameter of `VideoWriter` constructor to `False` and the codec supports it. Otherwise, convert the image to BGR first, and then write the result. – Dan Mašek Jan 13 '20 at 12:38
  • @DanMašek I set the `color` parameter to False in the VideoWriter constructor. Now i see frames added to video in grayscale, I need them in same color as shown in the plot. Is there any way to do this ? Thanks. – Muhammad – Muhammad Jan 14 '20 at 11:45
  • 1
    https://stackoverflow.com/q/52498777/3962537 | Of course, in this case the video will no longer be grayscale. – Dan Mašek Jan 14 '20 at 12:25

0 Answers0