samuelpowell / Spinnaker.jl

A Julia interface to the FLIR/PointGrey Spinnaker SDK
MIT License
15 stars 7 forks source link

Adding methods for avoiding waiting for images to be available in getimage(), which blocks #41

Closed IanButterworth closed 5 years ago

IanButterworth commented 5 years ago

This function implementation seems right, but reading this seems to cause it to freeze to the value that's first read (on Ubuntu 18.04 and Windows 10, with 1.20.0.14/15 spinnaker)

i.e. if you read buffertotalcount(cam) before first start!(cam) then the result will be 0 and any subsequent calls to buffertotalcount(cam) will remain at 0

After a full OS restart, if you then read buffertotalcount(cam) after start!(cam) the value will be some number between 0 and inf, and will stay there.

@samuelpowell This is most likely to be a bug with Spinnaker, right?

IanButterworth commented 5 years ago

You can see the field in action on the windows version of spinview, which seems to poll the value at ~1 FPS. The value doesn’t update in Linux spinview as I was told by support that polling is disabled.

samuelpowell commented 5 years ago

Is this useful in its current state? If so, can this be renamed totalbuffercount() to match the Spinnaker name?

Any chance of an upstream ticket?

IanButterworth commented 5 years ago

Renamed and I have a ticket open with Spinnaker tech support

IanButterworth commented 5 years ago

I've renamed this PR, as fundamentally the goal is to enable methods for avoiding waiting for images to be available in getimage(), given that getimage() blocks until images are available.

The newest addition are event selection functions, but I've not yet figured out how to actually detect event occurrences.

samuelpowell commented 5 years ago

So buffercount is windows only, and event functionality here is not yet complete, is that correct? If the former functionality is important to you feel free to split another PR (with guards for non-Windows). As for the latter, I’ll try and take a look at the implementation as soon as I can.

samuelpowell commented 5 years ago

@ianshmean aside from the fact that it doesn't currently work, you seem to be targeting the device events. If you care about images, perhaps the image event API is what you want?

In any case, the starting point should be to write a low-level API version which follows the C examples provided in the library (a number of existing translations exist in examples directory) which, once working, can then be turned into a nicer high level API. For this particular problem Spinnaker includes src/DeviceEvents_C/DeviceEvents_C.cpp and more relevantly, perhaps, src/ImageEvents_C/ImagEvents_C.cpp both of which compile without problems and thus can be directly translated.

I appreciate its an effort to go through this two stage process, but unfortunately if you get stuck with a working implementation on the Julia side its very difficult to debug it. On the other hand, one can step through a script which echos the content of one of the C examples and ensure that each step does exactly as expected.

samuelpowell commented 5 years ago

Does the updated functionality for querying the buffer count work?

IanButterworth commented 5 years ago

I don't get any errors, but the number that totalbuffercount(cam) returns freezes on the first value read (very commonly 242 for my default setup). It would be great if you could check whether this works for your camera @samuelpowell

samuelpowell commented 5 years ago

I had a go at testing but the branch doesn't seem to be working

ERROR: type CameraTLStreamNodeMap has no field hNodeMap
Stacktrace:
 [1] getproperty(::Any, ::Symbol) at ./sysimg.jl:18
 [2] totalbuffercount(::Camera) at /home/spowell/Spinnaker.jl/src/camera/stream.jl:43
 [3] top-level scope at none:0
IanButterworth commented 5 years ago

I think we can close this. The addition of getimage() timeout in #41 solves the specific issue in the title

IanButterworth commented 5 years ago

Perhaps leave the branch though, in case the totalbuffercount() method is fixed (broken in the C API) or the attempt at the event trigger implementation is helpful for future attempts

samuelpowell commented 5 years ago

Yes. I’ll xref from an issue.