Skip to content

Split camera device base class into Base and LegacyBase#590

Merged
marktsuchida merged 8 commits intomicro-manager:mainfrom
henrypinkard:split_camera_api
Sep 25, 2025
Merged

Split camera device base class into Base and LegacyBase#590
marktsuchida merged 8 commits intomicro-manager:mainfrom
henrypinkard:split_camera_api

Conversation

@henrypinkard
Copy link
Copy Markdown
Contributor

@henrypinkard henrypinkard commented Mar 5, 2025

As discussed in: #243 (comment)

This splits the camera base class that all camera adapters derive from into a legacy class (CLegacyCameraBase) which derives from a new, preferred CCameraBase class. The primary difference between theses is that the Legacy class contains a bunch of code for implementing sequence acquisitions as a series of snaps, which was originally for debugging, but ends up being inherited by all camera devices adapters.

I changed the name to LegacyBase now, rather than in the future as described in (#243 (comment)), because it seems like we would already like device adapter writers to inherit from the new base class.

See below for a few questions.

Copy link
Copy Markdown
Member

@marktsuchida marktsuchida left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this as a separate PR. I'm okay with immediately renaming to "legacy" -- makes sense if going ahead with modifying the camera adapters.

@henrypinkard
Copy link
Copy Markdown
Contributor Author

It says you requested a change, but for some reason I don's see what that is. Is there anything else needed before merging this?

@marktsuchida
Copy link
Copy Markdown
Member

It says you requested a change, but for some reason I don's see what that is.

I think you made the 'small fixes' commit at the same time I was reviewing. In it, you fixed PrepareSequenceAcqusition the way I requested.

But now that PrepareSequenceAcqusition is implemented in CCameraBase, presumably a bunch of cameras can have their change to CLegacyCameraBase undone?

Also, I commented that the Transpose_* properties should be kept in the base class because they are an entirely separate issue that needs analysis and cleanup.

(See my comments above that are marked resolved.)

@henrypinkard
Copy link
Copy Markdown
Contributor Author

But now that PrepareSequenceAcqusition is implemented in CCameraBase, presumably a bunch of cameras can have their change to CLegacyCameraBase undone?

Probably. This was a simple refactor-rename, so I think that can be done in a separate step (#598)

Also, I commented that the Transpose_* properties should be kept in the base class because they are an entirely separate issue that needs analysis and cleanup.

Fixed in previous commit

@henrypinkard
Copy link
Copy Markdown
Contributor Author

(See my comments above that are marked resolved.)

Should be all addressed now

@marktsuchida
Copy link
Copy Markdown
Member

Thanks for the fixes.

Probably. This was a simple refactor-rename, so I think that can be done in a separate step (#598)

I'd rather rebase this PR so that it never touches the cameras that it doesn't need to touch, but I can do that when merging this (which should be soon).

henrypinkard and others added 7 commits September 19, 2025 15:39
(Base class constructors are automatically invoked in C++.)
Members of the base class template need `this->` or `using` to compile.
Restore compilation of these cameras without changing behavior.

Rather than inheriting from CLegacyCameraBase, simply supply a Busy()
that returns false, which is the same behavior as with
CLegacyCameraBase::Busy(), given that no other legacy functions are used
in these cameras.

Left a comment on Multi Camera's Busy(), because theoretically it should
forward the physical cameras' Busy() results. However, it is out of
scope for this commit to change behavior (and Busy() on cameras
traditionally does not get used).
Mostly calls to the base class default constructor.

One cast to base class pointer in DECamera.
Made sure that all occurrences of CCameraBase is replaced in these
cameras, so that behavior should match previous.

Some of these cameras only make minor use of CLegacyCameraBase member
functions, and can be made to work with the new CCameraBase with little
work, but doing the simplest transformation for now.
These cameras only made simple use of the legacy functions, so switch
them back to CCameraBase with the appropriate fixes:

- Supply missing StartSequenceAcquisition(double) overload

- Supply missing Busy()

- Replace calls to OnThreadExiting() with equivalent code (but without
  the unnecessary try-catch)

- Replace calls to setStopOnOverflow()/isStopOnOverflow() with a data
  member (QCam only)
@marktsuchida
Copy link
Copy Markdown
Member

marktsuchida commented Sep 20, 2025

Force-pushed to redo the fixes to device adapters (to avoid touching the ones that don't need to be, to fix cameras that are not built on Windows, and to resolve conflicts).

This should be ready to merge now but I'll give it a once-over at a better time of the day before doing so, given that I'm making untested (albeit nearly mechanical) changes to devices :)

@marktsuchida marktsuchida linked an issue Sep 20, 2025 that may be closed by this pull request
@marktsuchida marktsuchida self-requested a review September 20, 2025 01:03
Additional member functions are needed in a mock camera now.
@marktsuchida
Copy link
Copy Markdown
Member

Here are the camera adapters that ended up having to use CLegacyCameraBase:

  • ABSCamera
  • AmScope
  • AtikCamera
  • BaumerOptronic
  • DECamera
  • FakeCamera
  • FLICamera
  • Lumenera
  • Motic_mac
  • MoticCamera
  • PICAM
  • PyDevice
  • QSI
  • SimpleCam (GPhoto)
  • TwainCamera
  • Video4Linux

(16 total)

@marktsuchida marktsuchida merged commit e1e0296 into micro-manager:main Sep 25, 2025
13 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate Cameras from CLegacyBase to CCamerBase

2 participants