I use this function to display one frame image. But when I try to getMat or getPos, the card return
as if it is on (0,0,0)
def create_image(self, frame, s_to_t=None):
if s_to_t is None:
s_to_t = np.eye(4)
height, width = frame.shape[:2]
cm = CardMaker('card')
p1 = LVector3(*np.matmul(s_to_t, np.array([-width / 2, height, 0, 1]))[:3]) #
p2 = LVector3(*np.matmul(s_to_t, np.array([width / 2, height, 0, 1]))[:3])
p3 = LVector3(*np.matmul(s_to_t, np.array([width / 2, 0, 0, 1]))[:3])
p4 = LVector3(*np.matmul(s_to_t, np.array([-width / 2, 0, 0, 1]))[:3])
cm.setFrame(p4, p3, p2, p1) # ll, lr, ur, ul # vertical flip
card = self.render.attachNewNode(cm.generate())
tex = Texture()
tex.setup2dTexture(width, height, Texture.T_unsigned_byte, Texture.F_rgba8)
frame=rgb2rgba(frame)
buf = frame.tobytes()
tex.setRamImage(buf)
card.setTexture(tex)
card.hide()
card.setTransparency(TransparencyAttrib.M_alpha)
# card.setMat(self.np4ToM4(s_to_t)) # if I set the mat, I can get the Mat, but the frame display at another position
return card