ALP4lib
ALP4lib copied to clipboard
How to load a fixed random binary martrix
Hi,when i tried to modified the example code,i'd like to load one fixed random binary martrix,i have no idea modify my code,can you give me some advice?Thank you!
First, this is not an issue, as it is not related to a potential bug/problem with ALP4lib, this is not the place.
That being said, it is difficult to answer precisely without more detail. I would say, just load your binary matrix as a numpy array and load it to the DMD:
import numpy as np
from ALP4 import *
import time
# Load the Vialux .dll
DMD = ALP4(version = '4.3')
# Initialize the device
DMD.Initialize()
# Binary amplitude image (0 or 1)
bitDepth = 1
img = np.load(<your_file>)
imgSeq = img[None,...] # add a dimension to have a 1 image sequence of size 1 x Nx x Ny sequence
# Allocate the onboard memory for the image sequence
DMD.SeqAlloc(nbImg = 1, bitDepth = bitDepth)
# Send the image sequence as a 1D list/array/numpy array
DMD.SeqPut(imgData = imgSeq)
# Set image rate to 50 Hz
DMD.SetTiming(pictureTime = 20000)
# Run the sequence in an infinite loop
DMD.Run()
time.sleep(10)
# Stop the sequence display
DMD.Halt()
# Free the sequence from the onboard memory
DMD.FreeSeq()
# De-allocate the device
DMD.Free()