Пример #1
0
def main():
    if (len(sys.argv) < 2):
        print("Give rtsp stream address, i.e. rtsp://passwd:user@ip")
        return
    else:
        address = sys.argv[1]

    livethread = LiveThread(name="live_thread", verbose=True)

    openglthread = OpenGLThread(name="mythread", n1440p=5, verbose=True)

    # now livethread and openglthread are running

    chain = BasicFilterchain(livethread=livethread,
                             openglthread=openglthread,
                             address=address,
                             slot=1)

    chain.decodingOn()  # tell the decoding thread to start its job

    # let's create some windowses
    win_id1 = openglthread.createWindow()
    win_id2 = openglthread.createWindow()
    win_id3 = openglthread.createWindow()

    # send video to x windowses
    token1 = openglthread.connect(slot=1, window_id=win_id1)
    token2 = openglthread.connect(slot=1, window_id=win_id2)
    token3 = openglthread.connect(slot=1, window_id=win_id3)

    print("sleeping for some secs")
    time.sleep(10)

    openglthread.disconnect(token1)
    openglthread.disconnect(token2)
    openglthread.disconnect(token3)
Пример #2
0
    mstimeout=
    1000,  # client timeouts if nothing has been received in 1000 milliseconds
    verbose=False)

chain.decodingOn()  # tell the decoding thread to start its job

# All the threads are running at the c-level, so there is no GIL problems here.. now, let's start doing stuff in python:
t = time.time()
while True:
    index, isize = client.pull()
    if (index == None):
        print("Client timed out..")
    else:
        print("Client index, size =", index, isize)
        data = client.shmem_list[index]
        # print(">>>",data[0:10])
        img = data.reshape((1080 // 4, 1920 // 4, 3))
        # so, here we just dump the image once more - but I guess you got the idea
        cv2.imshow("openCV_window", img)
        cv2.waitKey(1)
    if ((time.time() - t) >= 20): break  # exit after 20 secs

# that ShmemClient could be instantiated from a forked or even an independent python process, and this would still work as long as you
# use same name for ShmemClient: name and ShmemFilterchain: shmem_name.  It's named and shared posix memory and semaphores.

openglthread.disconnect(token1)
openglthread.disconnect(token2)
openglthread.disconnect(token3)

# garbage collection takes care of stopping threads etc.