Invalid CtControl::ReadImage() data when image rotation active
The following snippet reproduces the issue:
import time
import numpy as np
from silx import sx
from Lima import Core, Simulator
cam = Simulator.Camera()
hw = Simulator.Interface(cam)
ct = Core.CtControl(hw)
ct_video = ct.video()
ct_img = ct.image()
ct_video.setActive(True)
ct_video.setVideoSource(Core.CtVideo.LAST_IMAGE)
roi = Core.Roi(100, 100, 600, 400)
ct_img.setRoi(roi)
## Reference acquisition
ct_img.setRotation(Core.Rotation_0)
ct.prepareAcq()
ct.startAcq()
while ct.getStatus().AcquisitionStatus != Core.AcqReady:
time.sleep(0.1)
img1 = ct.ReadImage()
img2 = ct_video.getLastImage()
buffer1 = img1.buffer
buffer2 = np.frombuffer(img2.buffer(), np.dtype('uint32')).reshape([img2.height(), img2.width()])
sx.imshow(buffer1, cmap="viridis", aspect=True, title="CtControl Rot0")
sx.imshow(buffer2, cmap="viridis", aspect=True, title="CtVideo Rot0")
assert(600 == buffer1.shape[1] and 400 == buffer1.shape[0])
assert(600 == buffer2.shape[1] and 400 == buffer2.shape[0])
sum1 = np.sum(buffer1)
sum2 = np.sum(buffer2)
assert(sum1 == sum2)
# Rotated acquisition
ct_img.setRotation(Core.Rotation_90)
ct.prepareAcq()
ct.startAcq()
while ct.getStatus().AcquisitionStatus != Core.AcqReady:
time.sleep(0.1)
img1 = ct.ReadImage()
img2 = ct_video.getLastImage()
buffer1 = img1.buffer
buffer2 = np.frombuffer(img2.buffer(), np.dtype('uint32')).reshape([img2.height(), img2.width()])
sx.imshow(buffer1, cmap="viridis", aspect=True, title="CtControl Rot90")
sx.imshow(buffer2, cmap="viridis", aspect=True, title="CtVideo Rot90")
assert(400 == buffer1.shape[1] and 600 == buffer1.shape[0])
assert(400 == buffer2.shape[1] and 600 == buffer2.shape[0])
sum1 = np.sum(buffer1)
sum2 = np.sum(buffer2)
assert(sum1 == sum2)
CtVideo returns a proper rotated image
while CtControl returns invalid data
Note: in this snippet, the frames are accessed after the acquisition.
Edited by Samuel Debionne