From 242e6b5d93c4c1a59eb0616da09a6f02ec711877 Mon Sep 17 00:00:00 2001 From: "Mark A. Tsuchida" Date: Fri, 20 Feb 2026 15:59:39 -0600 Subject: [PATCH 1/2] Remove the doProcess flag from InsertImage() --- MMCore/CircularBuffer.cpp | 12 +++-------- MMCore/CircularBuffer.h | 5 +++-- MMCore/CoreCallback.cpp | 43 ++++++++------------------------------- MMCore/CoreCallback.h | 8 ++++++-- MMDevice/MMDevice.h | 21 +++++++++++-------- 5 files changed, 34 insertions(+), 55 deletions(-) diff --git a/MMCore/CircularBuffer.cpp b/MMCore/CircularBuffer.cpp index 448e6f9a0..9db6b396e 100644 --- a/MMCore/CircularBuffer.cpp +++ b/MMCore/CircularBuffer.cpp @@ -192,18 +192,12 @@ static std::string FormatLocalTime(std::chrono::time_pointProcess(const_cast(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) @@ -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(buf), width, height, byteDepth); + ip->Process(const_cast(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; diff --git a/MMCore/CoreCallback.h b/MMCore/CoreCallback.h index e31e8966d..74bb1f10b 100644 --- a/MMCore/CoreCallback.h +++ b/MMCore/CoreCallback.h @@ -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); diff --git a/MMDevice/MMDevice.h b/MMDevice/MMDevice.h index f7ab56a18..cb76c2c36 100644 --- a/MMDevice/MMDevice.h +++ b/MMDevice/MMDevice.h @@ -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. @@ -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 @@ -1698,7 +1699,9 @@ 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) = 0; /** * @brief Send a grayscale frame to the Core during sequence acquisition. @@ -1706,7 +1709,9 @@ namespace MM { * 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. From e93660371050dd57ff50bed22a04d6afb557500d Mon Sep 17 00:00:00 2001 From: "Mark A. Tsuchida" Date: Fri, 20 Feb 2026 16:56:02 -0600 Subject: [PATCH 2/2] Add default arg for InsertImage serializedMetadata This change is safe, in the sense that it won't cause any silent change in overload resolution. In the unlikely event that a camera adapter (that we don't control) calls InsertImage(c, b, w, h, bpp, 0), which previously resolved to the single-component overload (0 being null serializedMetadata), it would now get a compiler error ("call is ambiguous"). Such calls would need to remove the 0 or replace it with `nullptr`. --- MMDevice/MMDevice.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MMDevice/MMDevice.h b/MMDevice/MMDevice.h index cb76c2c36..84a4a661c 100644 --- a/MMDevice/MMDevice.h +++ b/MMDevice/MMDevice.h @@ -1701,7 +1701,7 @@ namespace MM { */ virtual int InsertImage(const Device* caller, const unsigned char* buf, unsigned width, unsigned height, unsigned bytePerPixel, unsigned nComponents, - const char* serializedMetadata) = 0; + const char* serializedMetadata = nullptr) = 0; /** * @brief Send a grayscale frame to the Core during sequence acquisition.