Python-VLC set a file as Media content, not file name

Viewed 67

My project is Structured light 3D scanner.

I generate binary image(pattern) and projector have to show it but I only find how to set Media content by file name. I don't want to save every pattern.

Function that create pattern:

def getPattern():
    width, height = (640,480)
    imgMatr = 255*np.ones((height, width), np.uint8) #white
    return imgMatr

My current code with reading file name:

# importing vlc module
import vlc
# importing time module
import time
import cv2

def showPattern():
    pattern = getPattern()
    patternFileName = "image0.jpg"
    # write image to file system because vlc.Media get filename
    cv2.imwrite(patternFileName, pattern)
    
    media_player = vlc.MediaPlayer()
    media_player.toggle_fullscreen()
    media = vlc.Media(patternFileName) # --> @@@ I want to pass pattern, not patternFileName 
    # seting media to the media player
    this.media_player.set_media(media)
    # start playing media
    this.media_player.play()
    time.sleep(15)
    this.media_player.stop()
0 Answers
Related