- Notifications
You must be signed in to change notification settings - Fork748
Type conversion problem#2375
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
I am trying to interface with a .NET dll to read stuff from a camera and i have trouble figuring out the types for a function call. Admittedly i have just started using pythonnet so my problem might be trivial. Here is the truncated version of my program: importclrfromSystemimport*clr.AddReference('PylonC.NET')fromPylonC.NETimportPylonfromPylonC.NETimportPylonBufferfromPylonC.NETimportPylonGrabResult_thDev=Pylon.CreateDeviceByIndex(0)imgBuf=PylonBuffer[Byte](None)#PylonBuffer<Byte> imgBuf = null; Is None correct here ?grabResult=PylonGrabResult_t()ret=Pylon.DeviceGrabSingleFrame(hDev,Int32(0),imgBuf,grabResult,UInt32(500))# the above raises an exception:# System.ArgumentException: PylonC.NET.PylonBuffer`1[System.Byte] value cannot be converted to PylonC.NET.PylonBuffer`1[T] in method# Boolean DeviceGrabSingleFrame[T](PylonC.NET.PYLON_DEVICE_HANDLE, Int32, PylonC.NET.PylonBuffer`1[T] ByRef, PylonC.NET.PylonGrabResult_t ByRef, UInt32) I have doubts if the imgBuf = PylonBufferByte is equivalent to the original c: PylonBuffer imgBuf = null; Also im not sure how to deal with the ref and out keywords. Any help is welcomed, |
BetaWas this translation helpful?Give feedback.
All reactions
Replies: 2 comments 1 reply
-
Hi I got the same question. Did you figure it out? Like how to convert imgBuf into the ref type needed in C# function? Thank you! |
BetaWas this translation helpful?Give feedback.
All reactions
-
Hi, unfortunately no, i stopped trying. |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
I spent time on this and managed to figure it out, sort of... # System.ArgumentException: PylonC.NET.PylonBuffer`1[System.Byte] value cannot be converted to PylonC.NET.PylonBuffer`1[T] in method ..... Apparently, you can construct a specific type of the function like: grabFrame=Pylon.DeviceGrabSingleFrame[Byte]ret=grabFrame(hDev,Int32(0),imgBuf,grabResult,UInt32(500)) In most cases i think this would work, but in my case i need to pass imgBuf and grabResult by reference that cannot be done in pythonnet. |
BetaWas this translation helpful?Give feedback.