Quantcast
Channel: OpenCV Q&A Forum - Latest question feed
Viewing all articles
Browse latest Browse all 19555

Simple example of writing color imagery using VideoWriter in python

$
0
0
I want to be able to write out a color raster for each video from in python. However, when I pass a 3d array to video writer, it generates a bad output. What am I doing wrong? Sampled code below.... h,w = raster.shape cmap = hot() writer = cv2.VideoWriter('output.avi', cv2.VideoWriter_fourcc('P','I','M','1'), 25, (h,w), True) for i in range(len(images)): x = np.transpose((dsp.normalize(images[i]**(0.5))*255).astype('uint8')) x = (cmap(x)*255).astype('uint8') for k in range(25): writer.write(x) del writer **EDIT 1:** Here is a simplier, stand alone version of the problem. This hangs VLC. import cv2 import numpy as np x = np.random.randint(0,255,(100,100,3)).astype('uint8') writer = cv2.VideoWriter('output.avi', cv2.VideoWriter_fourcc('P','I','M','1'), 25, (100,100), True) for k in range(100): writer.write(x) del writer

Viewing all articles
Browse latest Browse all 19555

Latest Images

Trending Articles



Latest Images