How to use set_binary_data of NxLibItem in Python API

General Information

  • Product: X36
  • Serial Number: filecam
  • Ensenso SDK Version: 3.6.1621
  • Operating System: Windows

Problem / Question

I’m trying to apply the command ReprojectPoints from the Python API. Unfortunately I’m having trouble providing the image points using set_binary_data. I tried many different paramter combinations but so far without success. The furthest I get is

with NxLibCommand(CMD_REPROJECT_POINTS) as cmd:
    cmd.parameters()[ITM_CAMERAS] = "sequence_001"
    cmd.parameters()[ITM_POINTS].set_binary_data(pos.reshape((1,1,2)))
    cmd.parameters()[ITM_RECTIFIED] = True
    cmd.parameters()[ITM_SENSOR] = "left"
    
    cmd.execute()       

which gives an NxLibExecutionFailed Exception. Here, I tried both pos.dtype=np.float32 and pos.dtype=int. Indeed, when I look at print(cmd.parameters().as_json()) it is

{
	"Cameras": "sequence_001",
	"Points": 13366972242.714200973510742188,
	"Rectified": true,
	"Sensor": "left"
}

so obviously somthing went wrong with setting the points.

Depending on how I combine the parameters of set_binary_data and the shape of pos I get various errors during the set_binary_data call.

Is there a simple example on how to use set_binary_data in python?

The set_binary* functions are used to set the data of a Binary item. The Points parameter of CmdReprojectPoints, however, expects an array of points.

cmd.parameters()[ITM_POINTS][0][0] = x
cmd.parameters()[ITM_POINTS][0][1] = y
cmd.parameters()[ITM_POINTS][0][2] = z

I hope that helps getting you further.

Ah, yes, that worked, thanks.