I use the remote API to modify the output of an VisionSensor externally and pass it back to a second VisionSensor which is set to externally triggered. What I try now is to compare the blob detection rate between the original (gt) and the modified image.
The setup is like this:
-+ BlobDetectionCamera
+- BlobDetectionCamera_body
+- BlobDetectionCamera_camera (streams to external)
+- BlobDetectionCamera_camera1 (external triggered)
Both cameras show their image in a floating view. camera1 has a notable delay but also shows the blob detection frame round the parts.
I created a litle external application for testing purposes which run synchronous, fetches the image from camera, pass it back to camera1 and triggers the next step.
BlobDetectionCamera has a non-threaded child script:
Code: Select all
if (sim_call_type==sim.syscb_init) then
camera=sim.getObjectHandle('blobDetectionCamera_camera1')
cameraGT=sim.getObjectHandle('blobDetectionCamera_camera')
end
if (sim_call_type==sim.syscb_actuation) then
t=sim.getSimulationTime()
imageAnalysisFrequency=sim.getScriptSimulationParameter(sim.getScriptAssociatedWithObject(baseObject),'imageAnalysisFrequency')
if (t-lastImageAnalysisTime>1/imageAnalysisFrequency) then
lastImageAnalysisTime=t
sim.handleVisionSensor(cameraGT)
resultGT,t0GT,t1GT=sim.readVisionSensor(cameraGT)
sim.handleVisionSensor(camera)
result,t0,t1=sim.readVisionSensor(camera) --> here result is -1
if (result==-1) then
print(sim.getLastError())
end
end
end
Docs said that readVisionSensor may return -1 when handleVisionSensor is not called but it is.
So I suppose it is a timing issue? Is there a way to synchronize it?