Skip to content

Commit

Permalink
Merge pull request #443 from HazenBabcock/linux/spinnaker
Browse files Browse the repository at this point in the history
Linux Spinnaker device adapter.
  • Loading branch information
marktsuchida authored Feb 9, 2024
2 parents 86a5af2 + 245acef commit 85867ae
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 19 deletions.
4 changes: 4 additions & 0 deletions DeviceAdapters/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ endif
if BUILD_SIMPLECAM
SIMPLECAM = SimpleCam
endif
if BUILD_SPINNAKER
SPINNAKER = Spinnaker
endif
if BUILD_SPOT
SPOT = Spot
endif
Expand Down Expand Up @@ -94,6 +97,7 @@ SUBDIRS = \
$(SENSICAM) \
$(SEQUENCE_TESTER) \
$(SIMPLECAM) \
$(SPINNAKER) \
$(SPOT) \
$(USBMANAGER) \
$(V4L) \
Expand Down
16 changes: 16 additions & 0 deletions DeviceAdapters/Spinnaker/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

AM_CXXFLAGS=$(MMDEVAPI_CXXFLAGS)

# Linux default install location?
SPINNAKER_ROOT=/opt/spinnaker

SPINNAKERCPPFLAGS = -I$(SPINNAKER_ROOT)/include
SPINNAKERLDFLAGS = -Wl,--enable-new-dtags -Wl,-rpath,$(SPINNAKER_ROOT)/lib,-L$(SPINNAKER_ROOT)/lib
SPINNAKERLDLIBS =-lSpinnaker

deviceadapter_LTLIBRARIES=libmmgr_dal_SpinnakerCamera.la
libmmgr_dal_SpinnakerCamera_la_SOURCES=SpinnakerCamera.cpp SpinnakerCamera.h
libmmgr_dal_SpinnakerCamera_la_CPPFLAGS=$(SPINNAKERCPPFLAGS)
libmmgr_dal_SpinnakerCamera_la_LIBADD=$(MMDEVAPI_LIBADD) $(SPINNAKERLDLIBS)
libmmgr_dal_SpinnakerCamera_la_LDFLAGS=$(MMDEVAPI_LDFLAGS) $(SPINNAKERLDLIBS) $(SPINNAKERLDFLAGS)

5 changes: 5 additions & 0 deletions DeviceAdapters/Spinnaker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,8 @@ For support with installation and use of the cameras/adapters in MicroManager pl
These device adapters were initially developed by Elliot Steele as part of a final year masters project in Electrical and Electronic Engineering at Imperial College London. The project was undertaken with the Photonics Group in Imperial College's Department of Physics and in conjunction with Cairn Research Ltd. Since the completion of the project maintenance has continued and the drivers have been made freely available by Cairn Research. The code was integrated into MicroManager's source on TODO

Special acknowledgements and thanks go to Professor Paul French and the rest of the Photonics Group for hosting the project and to Cairn Research for distribution of the device adapters before their integration into the MicroManager project and their continued support in the adapters' development.


## Linux

These device adapters can also be used on a linux system. This was developed and tested with Spinnaker SDK version 3.1.0. The Spinnaker SDK should be installed in `/opt/spinnaker/`.
34 changes: 17 additions & 17 deletions DeviceAdapters/Spinnaker/SpinnakerCamera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ std::vector<CamNameAndSN> GetSpinnakeerCameraNamesAndSNs()
}

camList.Clear();
system = NULL;
system = nullptr;
return out;
}

Expand Down Expand Up @@ -124,10 +124,10 @@ MODULE_API void DeleteDevice(MM::Device* pDevice)

SpinnakerCamera::SpinnakerCamera(GENICAM::gcstring name)
: CCameraBase<SpinnakerCamera>(),
m_system(NULL),
m_cam(NULL),
m_imageBuff(NULL),
m_aqThread(NULL)
m_system(nullptr),
m_cam(nullptr),
m_imageBuff(nullptr),
m_aqThread(nullptr)
{
InitializeDefaultErrorMessages();

Expand Down Expand Up @@ -178,7 +178,7 @@ int SpinnakerCamera::Initialize()
}

m_system = SPKR::System::GetInstance();
if (m_system == NULL)
if (m_system == nullptr)
{
SetErrorText(SPKR_ERROR, "Spinnaker System Object Pointer is Null!");
return SPKR_ERROR;
Expand Down Expand Up @@ -215,7 +215,7 @@ int SpinnakerCamera::Initialize()
}
camList.Clear();

if (m_cam == NULL)
if (m_cam == nullptr)
{
this->Shutdown();
SetErrorText(SPKR_ERROR, "Could not find camera with serial number: " + m_SN);
Expand Down Expand Up @@ -489,10 +489,10 @@ int SpinnakerCamera::Shutdown()
if (m_imageBuff)
delete[] m_imageBuff;
m_imageBuff = NULL;
m_cam = NULL;
if (m_system != NULL)
m_cam = nullptr;
if (m_system != nullptr)
m_system->ReleaseInstance();
m_system = NULL;
m_system = nullptr;
}
catch (SPKR::Exception ex)
{
Expand Down Expand Up @@ -923,7 +923,7 @@ const unsigned char* SpinnakerCamera::GetImageBuffer()
LogMessage(SPKR::Image::GetImageStatusDescription(m_imagePtr->GetImageStatus()));
}

if (m_imagePtr != NULL)
if (m_imagePtr != nullptr)
m_imagePtr->Release();
}
catch (SPKR::Exception &ex)
Expand Down Expand Up @@ -1076,15 +1076,15 @@ int SpinnakerCamera::SetROI(unsigned x, unsigned y, unsigned xSize, unsigned ySi
m_cam->OffsetY.SetValue(m_cam->OffsetY.GetMin());

// Force width and height to be multiple of Width.GetInc() and Height.GetInc()
xSize = (unsigned) min(xSize - xSize % m_cam->Width.GetInc(), m_cam->Width.GetMax());
ySize = (unsigned) min(ySize - ySize % m_cam->Height.GetInc(), m_cam->Height.GetMax());
xSize = (unsigned) std::min(xSize - xSize % m_cam->Width.GetInc(), m_cam->Width.GetMax());
ySize = (unsigned) std::min(ySize - ySize % m_cam->Height.GetInc(), m_cam->Height.GetMax());

m_cam->Width.SetValue(xSize);
m_cam->Height.SetValue(ySize);

//Force offsets to be multiples of OffsetX.GetInc() and OffsetY.GetInc()
x = (unsigned) min(x - x % m_cam->OffsetX.GetInc(), m_cam->OffsetX.GetMax());
y = (unsigned) min(y - y % m_cam->OffsetY.GetInc(), m_cam->OffsetY.GetMax());
x = (unsigned) std::min(x - x % m_cam->OffsetX.GetInc(), m_cam->OffsetX.GetMax());
y = (unsigned) std::min(y - y % m_cam->OffsetY.GetInc(), m_cam->OffsetY.GetMax());

m_cam->OffsetX.SetValue(x);
m_cam->OffsetY.SetValue(y);
Expand Down Expand Up @@ -1661,7 +1661,7 @@ int SpinnakerCamera::MoveImageToCircularBuffer()
}
else
{
if (ip != NULL)
if (ip != nullptr)
ip->Release();

return ret;
Expand All @@ -1672,7 +1672,7 @@ int SpinnakerCamera::MoveImageToCircularBuffer()
LogMessage(SPKR::Image::GetImageStatusDescription(ip->GetImageStatus()));
}

if (ip != NULL)
if (ip != nullptr)
ip->Release();
}
catch (SPKR::Exception &ex)
Expand Down
4 changes: 4 additions & 0 deletions DeviceAdapters/Spinnaker/SpinnakerCamera.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
#define GENICAM Spinnaker::GenICam
#define SPKR_ERROR 10002


class SpinnakerAcquisitionThread;


class SpinnakerCamera : public CCameraBase<SpinnakerCamera>
{
public:
Expand Down
4 changes: 2 additions & 2 deletions DeviceAdapters/Spinnaker/SpinnakerCamera.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_WINDOWS;_USRDLL;SPINNAKERCAMERA_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>NOMINMAX;_DEBUG;_WINDOWS;_USRDLL;SPINNAKERCAMERA_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
Expand All @@ -73,7 +73,7 @@
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_WINDOWS;_USRDLL;SPINNAKERCAMERA_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>NOMINMAX;NDEBUG;_WINDOWS;_USRDLL;SPINNAKERCAMERA_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
Expand Down
12 changes: 12 additions & 0 deletions DeviceAdapters/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,17 @@ AS_IF([test "x$want_opencv" != xno],

AM_CONDITIONAL([BUILD_OPENCV], [test "x$use_opencv" = xyes])


# Spinnaker SDK (FLIR).
AC_MSG_CHECKING(for Spinnaker)
AM_CONDITIONAL([BUILD_SPINNAKER],[test -f "/opt/spinnaker/include/Spinnaker.h"])
if test -f "/opt/spinnaker/include/Spinnaker.h"; then
AC_MSG_RESULT([found])
else
AC_MSG_RESULT([not found])
fi


# Vimba X (Allied Vision) SDK
MM_ARG_WITH_OPTIONAL_LIB([Vimba X], [vimba-x], [VIMBA_X])
AS_IF([test "x$want_vimba_x" != xno],
Expand Down Expand Up @@ -619,6 +630,7 @@ m4_define([device_adapter_dirs], [m4_strip([
SmarActHCU-3D
SouthPort
SpectralLMM5
Spinnaker
Spot
StarlightXpress
SutterLambda
Expand Down

0 comments on commit 85867ae

Please sign in to comment.