Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions MMCore/CircularBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,18 +192,12 @@ static std::string FormatLocalTime(std::chrono::time_point<std::chrono::system_c
return buf;
}

/**
* Inserts a single image in the buffer.
*/
bool CircularBuffer::InsertImage(const unsigned char* pixArray, unsigned int width, unsigned int height, unsigned int byteDepth, const Metadata* pMd) MMCORE_LEGACY_THROW(CMMError)
{
return InsertImage(pixArray, width, height, byteDepth, 1, pMd);
}

/**
* Inserts a single image, possibly with multiple components, in the buffer.
*/
bool CircularBuffer::InsertImage(const unsigned char* pixArray, unsigned int width, unsigned int height, unsigned int byteDepth, unsigned int nComponents, const Metadata* pMd) MMCORE_LEGACY_THROW(CMMError)
bool CircularBuffer::InsertImage(const unsigned char* pixArray,
unsigned int width, unsigned int height, unsigned int byteDepth, unsigned int nComponents,
const Metadata* pMd) MMCORE_LEGACY_THROW(CMMError)
{
MMThreadGuard insertGuard(g_insertLock);

Expand Down
5 changes: 3 additions & 2 deletions MMCore/CircularBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ class CircularBuffer
unsigned int Height() const {MMThreadGuard guard(g_bufferLock); return height_;}
unsigned int Depth() const {MMThreadGuard guard(g_bufferLock); return pixDepth_;}

bool InsertImage(const unsigned char* pixArray, unsigned int width, unsigned int height, unsigned int byteDepth, const Metadata* pMd) MMCORE_LEGACY_THROW(CMMError);
bool InsertImage(const unsigned char* pixArray, unsigned int width, unsigned int height, unsigned int byteDepth, unsigned int nComponents, const Metadata* pMd) MMCORE_LEGACY_THROW(CMMError);
bool InsertImage(const unsigned char* pixArray,
unsigned int width, unsigned int height, unsigned int byteDepth, unsigned int nComponents,
const Metadata* pMd) MMCORE_LEGACY_THROW(CMMError);
const unsigned char* GetTopImage() const;
const unsigned char* GetNextImage();
const ImgBuffer* GetTopImageBuffer(unsigned channel) const;
Expand Down
43 changes: 9 additions & 34 deletions MMCore/CoreCallback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,38 +218,16 @@ CoreCallback::AddCameraMetadata(const MM::Device* caller, const Metadata* pMd)
return newMD;
}

int CoreCallback::InsertImage(const MM::Device* caller, const unsigned char* buf, unsigned width, unsigned height, unsigned byteDepth, const char* serializedMetadata, const bool doProcess)
int CoreCallback::InsertImage(const MM::Device* caller, const unsigned char* buf,
unsigned width, unsigned height, unsigned bytesPerPixel,
const char* serializedMetadata)
{
Metadata origMd;
if (serializedMetadata)
{
origMd.Restore(serializedMetadata);
}

try
{
Metadata md = AddCameraMetadata(caller, &origMd);

if(doProcess)
{
MM::ImageProcessor* ip = GetImageProcessor(caller);
if( NULL != ip)
{
ip->Process(const_cast<unsigned char*>(buf), width, height, byteDepth);
}
}
if (core_->cbuf_->InsertImage(buf, width, height, byteDepth, &md))
return DEVICE_OK;
else
return DEVICE_BUFFER_OVERFLOW;
}
catch (CMMError& /*e*/)
{
return DEVICE_INCOMPATIBLE_IMAGE;
}
return InsertImage(caller, buf, width, height, bytesPerPixel, 1, serializedMetadata);
}

int CoreCallback::InsertImage(const MM::Device* caller, const unsigned char* buf, unsigned width, unsigned height, unsigned byteDepth, unsigned nComponents, const char* serializedMetadata, const bool doProcess)
int CoreCallback::InsertImage(const MM::Device* caller, const unsigned char* buf,
unsigned width, unsigned height, unsigned bytesPerPixel, unsigned nComponents,
const char* serializedMetadata)
{
Metadata origMd;
if (serializedMetadata)
Expand All @@ -261,15 +239,12 @@ int CoreCallback::InsertImage(const MM::Device* caller, const unsigned char* buf
{
Metadata md = AddCameraMetadata(caller, &origMd);

if(doProcess)
{
MM::ImageProcessor* ip = GetImageProcessor(caller);
if( NULL != ip)
{
ip->Process(const_cast<unsigned char*>(buf), width, height, byteDepth);
ip->Process(const_cast<unsigned char*>(buf), width, height, bytesPerPixel);
}
}
if (core_->cbuf_->InsertImage(buf, width, height, byteDepth, nComponents, &md))
if (core_->cbuf_->InsertImage(buf, width, height, bytesPerPixel, nComponents, &md))
return DEVICE_OK;
else
return DEVICE_BUFFER_OVERFLOW;
Expand Down
8 changes: 6 additions & 2 deletions MMCore/CoreCallback.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,12 @@ class CoreCallback : public MM::Core
void Sleep(const MM::Device* caller, double intervalMs);

// continuous acquisition support
int InsertImage(const MM::Device* caller, const unsigned char* buf, unsigned width, unsigned height, unsigned byteDepth, const char* serializedMetadata, const bool doProcess = true);
int InsertImage(const MM::Device* caller, const unsigned char* buf, unsigned width, unsigned height, unsigned byteDepth, unsigned nComponents, const char* serializedMetadata, const bool doProcess = true);
int InsertImage(const MM::Device* caller, const unsigned char* buf,
unsigned width, unsigned height, unsigned bytesPerPixel,
const char* serializedMetadata);
int InsertImage(const MM::Device* caller, const unsigned char* buf,
unsigned width, unsigned height, unsigned bytesPerPixel, unsigned nComponents,
const char* serializedMetadata);
bool InitializeImageBuffer(unsigned channels, unsigned slices, unsigned int w, unsigned int h, unsigned int pixDepth);

int AcqFinished(const MM::Device* caller, int statusCode);
Expand Down
21 changes: 13 additions & 8 deletions MMDevice/MMDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
// Header version
// If any of the class definitions changes, the interface version
// must be incremented
#define DEVICE_INTERFACE_VERSION 74
#define DEVICE_INTERFACE_VERSION 75
///////////////////////////////////////////////////////////////////////////////

// N.B.
Expand Down Expand Up @@ -1682,14 +1682,15 @@ namespace MM {
* Cameras must call this function during sequence acquisition to send
* each frame to the Core.
*
* byteDepth: 1 or 2 for grayscale images; 4 for BGR_
* bytesPerPixel: 1 or 2 for grayscale images; 4 or 8 for BGRx
*
* nComponents: 1 for grayscale; 4 for BGR_ (_: unused component)
* nComponents: 1 for grayscale; 4 for BGRx (x: an unused component)
*
* serializedMetadata: must be the result of md.serialize().c_str() (md
* being an instance of Metadata)
* (8-byte BGRx may not be supported by the Micro-Manager GUI)
*
* doProcess: must be true, except for the case mentioned below
* serializedMetadata: must be the result of md.Serialize() (md
* being an instance of MM::CameraImageMetadata)
* or nullptr (= no tags)
*
* Legacy note: Previously, cameras were required to perform special
* handling when InsertImage() returns DEVICE_BUFFER_OVERFLOW and
Expand All @@ -1698,15 +1699,19 @@ namespace MM {
* cameras should always just stop the acquisition if InsertImage()
* returns any error.
*/
virtual int InsertImage(const Device* caller, const unsigned char* buf, unsigned width, unsigned height, unsigned byteDepth, unsigned nComponents, const char* serializedMetadata, const bool doProcess = true) = 0;
virtual int InsertImage(const Device* caller, const unsigned char* buf,
unsigned width, unsigned height, unsigned bytePerPixel, unsigned nComponents,
const char* serializedMetadata = nullptr) = 0;

/**
* @brief Send a grayscale frame to the Core during sequence acquisition.
*
* Same as the overload with the added nComponents parameter.
* Assumes nComponents == 1 (grayscale).
*/
virtual int InsertImage(const Device* caller, const unsigned char* buf, unsigned width, unsigned height, unsigned byteDepth, const char* serializedMetadata = nullptr, const bool doProcess = true) = 0;
virtual int InsertImage(const Device* caller, const unsigned char* buf,
unsigned width, unsigned height, unsigned bytePerPixel,
const char* serializedMetadata = nullptr) = 0;

/**
* @brief Prepare the sequence buffer for the given image size and pixel format.
Expand Down
Loading