MATLAB Answers

5

Interface and control FLIR (BlackFly S) with Matlab 64-bit platform code

Asked by Harsha K on 4 Jul 2018
Latest activity Commented on by az clearview on 29 Jan 2019
Hello Mathworks team,
This is a follow up on @Zoran Popovic's comment here: Does Image Acquisition Toolbox support FLIR (Point Grey) Blackfly S model camera?
Aim: To interface the BlackFly S camera (Model # BFS-U3-04S2M-CS) with Matlab such that I can control the camera through it.
I would like to try loading the Spinnaker drivers into Matlab and use the corresponding register read/write functions. Following are my questions:
1. I would like to know which DLL should I be adding following the procedure Loadlibrary function in Matlab
2. Once the DLL gets loaded, I would like to have the inbuilt register read/write functions list?
I am writing here as I have already tried contacting the FLIR Integrated Imaging Solutions Inc. (formerly known as Point Grey Research) technical support. The lady there informed me to contact Mathworks for further help on this issue.
I use the Spinnaker 64-bit DLL v140 (install the SDK using VS2015 setting) as recommended by the FLIR support team. In Matlab I use C++ compiler configured to:
MEX configured to use 'Microsoft Visual C++ 2015 Professional' for C++ language compilation.
The following is the code I tried:
function [rawfile] = acquireRawImg32Bit()
loadlibrary('C:\Program Files\Point Grey Research\Spinnaker\bin\vs2015\SpinnakerC_v140.dll', 'C:\Program Files\Point Grey Research\Spinnaker\include\spinc\SpinnakerC.h')
libfunctions('SpinnakerC_v140')
hCam = libpointer('hCam', 'spinCamera');
calllib('SpinnakerC_v140', 'spinCameraBeginAcquisition', hCam);
unloadlibrary('SpinnakerC_v140');
end
After which I got a huge bunch of errors:
Warning: Warnings messages were produced while parsing. Check the
functions you intend to use for correctness. Warning text can be
viewed using:
[notfound,warnings]=loadlibrary(...)
> In loadlibrary
Error loading library intermediate output follows.
The actual error is at the end of this output.
*********
Bareword found where operator expected at (eval 119) line 1, near "0xffffffffL"
(Missing operator before L?)
Type 'lconvPtr' was not found. Defaulting to type voidPtr.
Found on line 5665 of input from line 2111 of file C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\INCLUDE\\crtdefs.h
Eval of const expression 0xffffffffL failed with error syntax error at (eval 119) line 2, near "0xffffffffL
"
.
Found on line 14010 of input from line 201 of file c:\\program files\\point grey research\\spinnaker\\include\\spinc\\SpinnakerGenApiDefsC.h
Type ')' was not found. Defaulting to type error.
Found on line 18701 of input from line 2176 of file C:\\Program Files\\Point Grey Research\\Spinnaker\\include\\spinc\\SpinnakerC.h
Failed to parse type 'dllimport ) spinError spinAVIRecorderClose ( spinAVIRecorder hRecorder' original input 'dllimport ) spinError spinAVIRecorderClose ( spinAVIRecorder hRecorder '
Found on line 18701 of input from line 2176 of file C:\\Program Files\\Point Grey Research\\Spinnaker\\include\\spinc\\SpinnakerC.h
Error parsing argument for function __declspec function may be invalid.
*********
Error using loadlibrary
Building SpinnakerC_v140_thunk_pcwin64 failed. Compiler output is:
cl -I"C:\MATLAB\R2016a\extern\include" /Zp8 /W3 /nologo
-I"C:\Users\******\Documents\MATLAB" -I"C:\Program Files\Point Grey
Research\Spinnaker\include\spinc" "SpinnakerC_v140_thunk_pcwin64.c" -LD
-Fe"SpinnakerC_v140_thunk_pcwin64.dll"
SpinnakerC_v140_thunk_pcwin64.c
SpinnakerC_v140_thunk_pcwin64.c(444) : error C2059: syntax error : ')'
SpinnakerC_v140_thunk_pcwin64.c(444) : error C2061: syntax error :
identifier 'spinErrorspinAVIRecorderClose'
SpinnakerC_v140_thunk_pcwin64.c(444) : error C2059: syntax error : ';'
SpinnakerC_v140_thunk_pcwin64.c(445) : error C2143: syntax error :
missing ')' before '{'
SpinnakerC_v140_thunk_pcwin64.c(446) : error C2059: syntax error : ')'
SpinnakerC_v140_thunk_pcwin64.c(446) : error C2065: 'dllimport' :
undeclared identifier
SpinnakerC_v140_thunk_pcwin64.c(446) : error C2146: syntax error :
missing ';' before identifier 'spinError'
SpinnakerC_v140_thunk_pcwin64.c(446) : error C2275: 'spinError' :
illegal use of this type as an expression
c:\program files\point grey
research\spinnaker\include\spinc\SpinnakerDefsC.h(273) : see
declaration of 'spinError'
SpinnakerC_v140_thunk_pcwin64.c(446) : error C2146: syntax error :
missing ';' before identifier 'spinAVIRecorderClose'
SpinnakerC_v140_thunk_pcwin64.c(446) : error C2143: syntax error :
missing ')' before 'type'
SpinnakerC_v140_thunk_pcwin64.c(446) : error C2198:
'spinAVIRecorderClose' : too few arguments for call
SpinnakerC_v140_thunk_pcwin64.c(447) : error C2065: 'p0' : undeclared
identifier
SpinnakerC_v140_thunk_pcwin64.c(447) : error C2065: 'dllimport' :
undeclared identifier
SpinnakerC_v140_thunk_pcwin64.c(447) : error C2100: illegal indirection
SpinnakerC_v140_thunk_pcwin64.c(447) : error C2146: syntax error :
missing ';' before identifier 'spinError'
SpinnakerC_v140_thunk_pcwin64.c(447) : error C2275: 'spinError' :
illegal use of this type as an expression
c:\program files\point grey
research\spinnaker\include\spinc\SpinnakerDefsC.h(273) : see
declaration of 'spinError'
SpinnakerC_v140_thunk_pcwin64.c(447) : error C2146: syntax error :
missing ';' before identifier 'spinAVIRecorderClose'
SpinnakerC_v140_thunk_pcwin64.c(447) : error C2143: syntax error :
missing ')' before 'type'
SpinnakerC_v140_thunk_pcwin64.c(447) : error C2198:
'spinAVIRecorderClose' : too few arguments for call
SpinnakerC_v140_thunk_pcwin64.c(447) : error C2059: syntax error : ')'
SpinnakerC_v140_thunk_pcwin64.c(448) : error C2065: 'p0' : undeclared
identifier
SpinnakerC_v140_thunk_pcwin64.c(449) : error C2059: syntax error : ')'
end
Do not know how to resolve these errors, although I tried various recommended methods on stackoverflow as well as Mathworks forums. Please help as Mathworks team would know how to resolve this in a timely and efficient manner.

1 Answer

Answer by Andrei Ursache on 27 Nov 2018
 Accepted Answer

As of MATLAB R2018b, a custom adaptor for FLIR/PointGrey Spinnaker drivers is available for Image Acquisition Toolbox. Refer to instructions from the following File Exchange entry:

  1 Comment

My understanding is that this Answer does not address the request for camera control originally posed. It's functionality is that of the winvideo adapter, with no control of exposure, gain, etc.
Any input into how to address the compiling errors reported by original poster (@Harsha)?
Thanks! A

Sign in to comment.