Update send_png.py

This commit is contained in:
Naoto Kondo
2020-04-25 00:27:15 +09:00
parent 1625217d44
commit 7434789358

View File

@@ -1,43 +1,39 @@
import sys
import time
import numpy as np
import cv2
import NDIlib
import cv2 as cv
import NDIlib as ndi
def main():
if not NDIlib.initialize():
if not ndi.initialize():
return 0
img = cv2.imread('image/test2.png', cv2.IMREAD_ANYCOLOR)
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGBA)
img = cv.imread('image/test2.png', cv.IMREAD_ANYCOLOR)
img = cv.cvtColor(img, cv.COLOR_BGR2RGBA)
h, w = img.shape[:2]
send_settings = ndi.SendCreate()
send_settings.ndi_name = 'ndi-python'
send_settings = NDIlib.SendCreate()
send_settings.p_ndi_name = b'ndi-python'
ndi_send = ndi.send_create(send_settings)
ndi_send = NDIlib.send_create(send_settings)
video_frame = ndi.VideoFrameV2()
video_frame = NDIlib.VideoFrameV2()
video_frame.xres = w
video_frame.yres = h
video_frame.FourCC = NDIlib.FOURCC_TYPE_RGBA
video_frame.p_data = img.ctypes.data_as(NDIlib.POINTER(NDIlib.c_uint8))
video_frame.line_stride_in_bytes = w * 4
video_frame.data = img
video_frame.FourCC = ndi.FOURCC_VIDEO_TYPE_RGBX
start = time.time()
while time.time() - start < 60 * 5:
start_send = time.time()
for idx in reversed(range(200)):
NDIlib.send_send_video_v2(ndi_send, video_frame)
for _ in reversed(range(200)):
ndi.send_send_video_v2(ndi_send, video_frame)
print('200 frames sent, at %1.2ffps' % (200.0 / (time.time() - start_send)))
NDIlib.send_destroy(ndi_send)
ndi.send_destroy(ndi_send)
NDIlib.destroy()
ndi.destroy()
return 0