Package: pymembus
pymembusTable of contentsInstall from pypiLocal BuildAdministrationExamplesReferencesInstall from pypiInstall dependencies (see below) then run...

$ pip install pymembusLocal BuildWindows dependenciesInstallCMakeInstallgitInstallboostInstallVisual Studio 2017.The freeCommunity Editionis fineLinux dependencies$ sudo apt-get update
$ sudo apt-get -yq install build-essential git cmake libboost-all-dev doxygen graphviz go-md2man
$ sudo apt-get -yq install python3 python3-pip python3-python11
$ python3 -m pip install scikit-buildLocal Build / Install$ python3 -m pip install .OR$ pip3 install .Uninstall$ pip3 uninstall -y pymembusCreate wheelSoftware dist
$ python3 setup.py sdist

Binary dist
$ python3 setup.py bdist_wheelOR$ pip3 wheel . --use-feature=in-tree-buildAdministration (Linux only)Library commands, for once you have it installedDisplay help$ pymembus helpUninstall$ sudo pymembus uninstallShow installation roots$ pymembus filesGet installation information.  (Change this info inPROJECT.txt)$ pymembus info <variable>variable = One of [name, description, url, version, build, company, author, lib, include, bin, share]Examplesimportpymembus#----------------------------------------------------------------# Map shared memorysm=pymembus.memmap()assertsm.open("/myshare",1024,True)# Write stringmsg=str(time.time())assert0<sm.write(msg)# Read the stringassertsm.read(len(msg))==msgmem=numpy.array(sm,copy=False)print("MEM:%s"%str(mem))sm.close()#----------------------------------------------------------------# Shared message buffertx=pymembus.memmsg()asserttx.open("/mymsg",1024,True,True)assertnottx.existing()rx=pymembus.memmsg()assertrx.open("/mymsg",1024,False,False)assertrx.existing()foriinrange(0,10):asserttx.write("Message%s"%i)i=0max=20while10>iand0<max:max-=1msg=rx.read(0)if0<len(msg):# print("READ : %s" % msg)i+=1print("i =%s"%i)assert10<=itx.close()rx.close()#----------------------------------------------------------------# Shared imageimgs=pymembus.memvid()# Open a sharew=320h=240bpp=24fps=30bufs=10assertimgs.open("/myvideo",True,w,h,bpp,fps,bufs)# Check valuesassertimgs.getWidth()==wassertimgs.getHeight()==hassertimgs.getBpp()==bppassertimgs.getFps()==fpsassertimgs.getBufs()==bufsassertimgs.getPtr(0)==0assertimgs.next(1)==1assertimgs.next(-1)==0assertimgs.getPtrErr(3,1)==2assertlen(imgs)==bufs# Check second shareimgs2=pymembus.memvid()assertimgs2.open_existing("/myvideo")assertimgs2.getWidth()==wassertimgs2.getHeight()==hassertimgs2.getBpp()==bppassertimgs2.getFps()==fpsassertimgs2.getBufs()==bufsimgs2.close()# Write into the image bufferimg=numpy.array(imgs[0],copy=False)try:importcv2cv2.rectangle(img,(10,10),(60,60),(50,255,50),-1)cv2.rectangle(img,(50,50),(110,110),(255,50,50),-1)cv2.rectangle(img,(100,100),(150,150),(50,50,255),-1)exceptExceptionase:print(e)#----------------------------------------------------------------# Shared audioauds=pymembus.memaud()ch=2bps=16abr=48000fps=50bufs=10assertauds.open("/myaudio",True,ch,bps,abr,fps,bufs)assertauds.getChannels()==chassertauds.getBps()==bpsassertauds.getBitRate()==abrassertauds.getFps()==fpsassertauds.getBufs()==bufsassertlen(auds)==bufsprint("%s--%s"%(auds.getBufSize(),(abr/fps)))assertauds.getBufSize()==(abr/fps)auds2=pymembus.memaud()assertauds2.open_existing("/myaudio")assertauds2.getChannels()==chassertauds2.getBps()==bpsassertauds2.getBitRate()==abrassertauds2.getFps()==fpsassertauds2.getBufs()==bufsaud=numpy.array(auds[0],copy=False)aud2=numpy.array(auds2[0],copy=False)# Create numpy audio buffermsamples=int(abr/fps)nsamples=msamples*chsrc=numpy.zeros((1,nsamples),dtype='int16')src.fill(0)dch,dsz=aud.shapesch,ssz=src.shape# Ensure channel sizes matchprint("%s:%s---%s:%s"%(dch,dsz,sch,ssz))assertdch==schassertdsz==ssz# Check shareaud[0][3]=1234assertaud[0][3]==aud2[0][3]# Check the fill functionauds.fill(0,0)assertaud[0][3]==0# Copy dataaud=srcauds.close()auds2.close()ReferencesPythonhttps://www.python.org/CMakehttps://cmake.orgpiphttps://pip.pypa.io/en/stable/githttps://git-scm.com/Boosthttps://www.boost.org/Visual Studiohttps://visualstudio.microsoft.com/Doxygenhttps://github.com/doxygen/doxygenGraphvizhttps://graphviz.org/Md2manhttps://sunaku.github.io/md2man/man/man5/md2man.5.htmlhttps://github.com/sunaku/md2man