complex small world

どうしようもない日々の追想

OpenCVで動画保存する際の罠

例えば以下のように宣言したwriterに、新たに生成したnumpy arrayの領域を書き込みたい

out = cv2.VideoWriter(result_path, fourcc, 10.0, (1024,640))

numpy array

img = np.zeros((patch,2*patch,3))

これをこう書きこんでも、バグのような動画しか生成されない...

out.write(img)

なぜか?8bitしかダメらしいです。なのでキャストする必要あり。

out.write(np.uint8(img))