def test1(): st=""" Test single live stream """ pre=pre_mod+"test1 :" print(pre,st) livethread=LiveThread( name ="live_thread", verbose=True ) openglthread=OpenGLThread( name ="mythread", n_1440p =5, verbose =True ) # now livethread and openglthread are running .. chain=BasicFilterchain1( openglthread=openglthread, slot=1 ) chain.setLiveContext("rtsp://*****:*****@192.168.1.41") livethread.registerStream (chain.live_ctx) livethread.playStream (chain.live_ctx) print("sleeping for some secs") time.sleep(5) livethread.stopStream (chain.live_ctx) livethread.deregisterStream (chain.live_ctx) print("bye!")
def test3(): st = """ Test ShmemFilterchain """ pre = pre_mod + "test3 :" print(pre, st) livethread = LiveThread(name="live_thread", verbose=True) openglthread = OpenGLThread(name="mythread", n_1440p=5, verbose=True) # now livethread and openglthread are running .. chain = ShmemFilterchain1( openglthread=openglthread, slot=1, shmem_image_dimensions=( 1920 // 4, 1080 // 4), # images passed over shmem are full-hd/4 reso shmem_image_interval=1000, # .. passed every 1000 milliseconds shmem_ringbuffer_size=10 # size of the ringbuffer ) chain.setLiveContext("rtsp://*****:*****@192.168.1.41") livethread.registerStream(chain.live_ctx) livethread.playStream(chain.live_ctx) print("sleeping for some secs") time.sleep(5) livethread.stopStream(chain.live_ctx) livethread.deregisterStream(chain.live_ctx) print("bye!")
def createTestThreads(): """ valkkafsmanager = ValkkaFSManager( valkkafs, # read = False, # debugging # cache = False, # debugging # write = False # debugging ) """ livethread = LiveThread( # starts live stream services (using live555) name="live_thread", # verbose=True, verbose=False) usbdevicethread = USBDeviceThread( name="usb_thread", #verbose=True, verbose=False) openglthread = OpenGLThread( # starts frame presenting services name="opengl_thread", # reserve stacks of YUV video frames for various resolutions n_720p=20, n_1080p=20, n_1440p=20, n_4K=0, verbose=True, # verbose=False, msbuftime=300) return livethread, usbdevicethread, openglthread
def test2(): st = """ Test ShmemFilterchain """ pre = pre_mod + "test2 :" print(pre, st) livethread = LiveThread(name="live_thread", verbose=True) openglthread = OpenGLThread(name="mythread", n_1440p=5, verbose=True) # now livethread and openglthread are running .. chain = ShmemFilterchain( livethread=livethread, openglthread=openglthread, address="rtsp://*****:*****@192.168.1.10", slot=1, # images passed over shmem are full-hd/4 reso shmem_image_dimensions=(1920 // 4, 1080 // 4), shmem_image_interval=1000, # .. passed every 1000 milliseconds shmem_ringbuffer_size=10 # size of the ringbuffer ) print("sleeping for some secs") time.sleep(3) print("bye!")
def test1(): st = """ Test single stream """ pre = pre_mod + "test1 :" print(pre, st) livethread = LiveThread( name="live_thread", verbose=True ) openglthread = OpenGLThread( name="mythread", n_1440p=5, verbose=True ) # now livethread and openglthread are running .. chain = BasicFilterchain( livethread=livethread, openglthread=openglthread, address="rtsp://*****:*****@192.168.1.10", slot=1 ) print("sleeping for some secs") time.sleep(3) print("bye!")
def test1(): st = """Empty test """ pre = pre_mod + "test1 :" print(pre, st) livethread = LiveThread(name="live_thread") openglthread = OpenGLThread(name="mythread", n1440p=5, verbose=True)
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)
def test1(): dm = DataModel() dm.clearAll() dm.saveAll() collection = dm.camera_collection collection.new( RTSPCameraRow, { "slot": 1, "address": "192.168.1.41", "username": "******", "password": "******", "tail": "" }) collection.new( RTSPCameraRow, { "slot": 2, "address": "192.168.1.42", "username": "******", "password": "******", "tail": "" }) for element in collection.get(): print("test1 : 1", element) gpu_handler = GPUHandler(n_720p=5, n_1080p=5, n_1440p=0, n_4K=0, msbuftime=300, verbose=False) livethread = LiveThread( name="live_thread", # verbose = True, verbose=False, # affinity = self.pardic["live affinity"] ) filterchain_group = FilterChainGroup(datamodel=dm, livethread=livethread, gpu_handler=gpu_handler, verbose=True) filterchain_group.update() print("\n ADDING ONE \n") collection.new( RTSPCameraRow, { "slot": 3, "address": "192.168.1.43", "username": "******", "password": "******", "tail": "" }) filterchain_group.update() print("\n REMOVING ONE \n") entry = next(collection.get({"address": "192.168.1.41"})) collection.delete(entry["_id"]) filterchain_group.update() print("\n BYE \n") filterchain_group.close()
* Decode the stream once, and only once from H264 into YUV * Redirect the YUV stream into two branches: * Branch 1 goes into GPU, where YUV => RGB interpolation is done 25-30 fps. The final bitmap is shown in multiple windows * Branch 2 is interpolated from YUV => RGB once in a second on the CPU and into a small size. This small sized image is then passed over shared memory to opencv running in python. """ import sys import time import cv2 from valkka.api2.threads import LiveThread, OpenGLThread, ShmemClient from valkka.api2.chains import BasicFilterchain, ShmemFilterchain address = "rtsp://*****:*****@192.168.0.157" livethread = LiveThread( # starts live stream services (using live555) name="live_thread", verbose=False) openglthread = OpenGLThread( # starts frame presenting services name="mythread", n720p=10, # reserve stacks of YUV video frames for various resolutions n1080p=10, n1440p=0, n4K=0, naudio=10, verbose=False) # now livethread and openglthread are running chain = ShmemFilterchain( # decoding and branching the stream happens here livethread=livethread,