Friday, August 23, 2019

implementing opencv project with Spinnaker SDK for Point Grey FLIR cameras

This post documents my learning curve with migrating code written for the SDK for QHY cameras to the Spinnaker SDK for Point Grey FLIR cameras.

  1. On both Windows and Linux, I had to make changes to my build platform. On Linux, Ubuntu 18.04 was a supported platform, so I installed 18.04 onto a spare partition. On Windows, I was using Visual Studio 2017, and had to install the VS2015 toolset. 
  2. On Linux, even though the spinnaker examples had large and complex makefiles, the sdk had put the include and lib files in the default locations, so I just had to modify my CMakeLists.txt file minimally -


  3. On Windows, there was a much more elaborate series of steps, which I will put in a separate post.
  4. The simpler parts of implementation, like changing exposure time, gain etc could be done in a fairly straight-forward way. Unfortunately, there was no example for continuous capture with live display. ptgrey.com being redirected to flir.com, the examples obtained on googling couldn't be directly found. Finally, found this, which indicated that StreamBuffer handling had to be changed. Looking for this specific information, found the documentation at this page, which mentions its potential use in live view scenarios. Putting that in place, then Begin Acquisition and End Acquisition could be implemented outside the capture loop, and the frame rate improved.  
Edit: Here is a dump of the nodes I changed, full code is at https://github.com/hn-88/FDOCT/blob/master/BscanFFTspin.cpp (spinnaker documentation talks about the details of the nodes, and the example code helps).

(Gain is in dB)

In terms of nodes,
AcquisitionControl -> AcquisitionMode -> Continuous
AcquisitionControl -> ExposureAuto -> Off
AcquisitionControl -> ExposureTime -> 1000
AnalogControl -> GainAuto -> Off
AnalogControl -> Gain -> 0.0
AnalogControl -> Gamma -> 1.0
ImageFormatControl -> Width -> 1280
ImageFormatControl -> Height -> 960
ImageFormatControl -> OffsetX -> 0
ImageFormatControl -> OffsetY -> 0
ImageFormatControl -> PixelFormat -> Mono8
ImageFormatControl -> PixelFormat -> Mono16
ImageFormatControl -> AdcBitDepth -> Bit12
ImageFormatControl -> AdcBitDepth -> Bit10
BufferHandlingControl -> StreamBufferHandlingMode -> NewestOnly

Using Displayspin, on my machine, I got
71 fps for Bit12 Mono8
34 fps for Bit12 Mono16 (converted to Mono8 to display on screen)
71 fps for Bit10 Mono8

So, probably we can always use Bit12, since it does not seem to have much of a speed penalty.

And a small note on a mistake I made - initially I got the error  
Spinnaker: Can't clear a camera because something still holds a reference to the camera [-1004].
Putting pCam = nullptr; before camList.Clear(); removes this error.




2 comments: