Skip to content

Added exposure controls for UVC video cameras - #392

Merged
gr5 merged 4 commits into
blinkratefrom
blinkrate_exposure
Oct 20, 2026
Merged

gr5 merged 4 commits into
blinkratefrom
blinkrate_exposure

Conversation

@gr5

@gr5 gr5 commented Oct 18, 2026

Copy link
Copy Markdown
Collaborator

Tested against 3 different USB cameras. Can control exposure and gain on all 3 just fine. Wasn't able to test autoExposure feature as none of my 3 cameras seem to allow that through UVC/DirectShow. That code is simpler so hopefully no bugs.

gr5 added 2 commits October 18, 2026 13:05
"auto" checkbox for auto exposure. camera itself remembers
settings so didn't use QSettings

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cpp-linter Review

Used clang-tidy v21.1.8

Have any feedback or feature suggestions? Share it here.

Comment thread videostreamworker.cpp Outdated
// Special formatting for FOURCC to make it readable
if (prop.id == cv::CAP_PROP_FOURCC && value > 0) {
int fourcc = static_cast<int>(value);
char fcc[] = {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

clang-tidy diagnostic

videostreamworker.cpp:327:30: warning: [clang-analyzer-deadcode.DeadStores]

Value stored to 'fcc' during its initialization is never read

  327 |                         char fcc[] = {
      |                              ^~~     ~
  328 |                             static_cast<char>(fourcc & 0XFF),
      |                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  329 |                             static_cast<char>((fourcc >> 8) & 0XFF),
      |                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  330 |                             static_cast<char>((fourcc >> 16) & 0XFF),
      |                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  331 |                             static_cast<char>((fourcc >> 24) & 0XFF),
      |                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  332 |                             0
      |                             ~
  333 |                         };
      |                         ~
videostreamworker.cpp:327:30: note: Value stored to 'fcc' during its initialization is never read
  327 |                         char fcc[] = {
      |                              ^~~     ~
  328 |                             static_cast<char>(fourcc & 0XFF),
      |                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  329 |                             static_cast<char>((fourcc >> 8) & 0XFF),
      |                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  330 |                             static_cast<char>((fourcc >> 16) & 0XFF),
      |                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  331 |                             static_cast<char>((fourcc >> 24) & 0XFF),
      |                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  332 |                             0
      |                             ~
  333 |                         };
      |                         ~

@github-actions

Copy link
Copy Markdown

🚀 New build available for commit 0f74d0b
Download installer here

Comment thread dftarea.cpp

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Line 1089 emit updateFilterSize(Rad) is old code and overwrote the new code. So this file is not correct.

@gr5

gr5 commented Oct 19, 2026

Copy link
Copy Markdown
Collaborator Author

I see now. I removed a line of code that wasn't being used because clang complained. Original code 9/30/2026:

void DFTArea::mouseMovedExternal(int rad){
   double frequencyBin = rad / (static_cast<double>(m_dftsize)/(m_outside.m_radius * 2 * m_scaleFactor));
    qDebug() << "DFT Received rad bin" << rad << frequencyBin << zoom;
    emit updateFilterSize(rad);
}

Then on 10/1 you removed the qDebug line. Then yesterday I deleted the line that creates frequencyBin. Which is no longer needed as the qDebug is gone.

So I think it's probably okay now? I didn't test it but I probably tested some time after 9/30.

I'm going to fix that clang error above now. I just have to delete some code in dumpAll() that isn't needed.

@githubdoe

githubdoe commented Oct 19, 2026 via email

Copy link
Copy Markdown
Owner

@github-actions

Copy link
Copy Markdown

🚀 New build available for commit 342d33d
Download installer here

@gr5

gr5 commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator Author

I fixed that one clang complaint above. Please look this PR over, Dale. Thanks.

Next I'm going to look into why the camera frames switch to black after about 30 seconds even though communication with the camera still works.

Before I added the cv::mean() function it was happening every 10-30 seconds.
Now about once per minute so that alone made it better, lol.  The restart
takes about 3 seconds versus having to reclick the "0" in settings which then takes
about 7 seconds.  So this is a big improvement.
@gr5

gr5 commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator Author

@githubdoe I wrote a little patch of code which reconnects the camera when I start getting blank frames (all values zero).

This makes life so much better with the camera on my desktop. I hope you don't mind that I added it to this PR. As usual, to see the commit changes individually, click on "commits" tab below the PR tab and next to the "discussion" tab. Or use the "files changed" tab to see all the changes in this PR at once.

@github-actions

Copy link
Copy Markdown

🚀 New build available for commit cfae213
Download installer here

@gr5
gr5 merged commit 73c098c into blinkrate Oct 20, 2026
17 checks passed
@gr5

gr5 commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator Author

@githubdoe Okay. I merged. I think we should merge this into master. I didn't look carefully at the code but... I did look at quite a few small sections as was needed. I'll start a PR but we can cancel it if you don't like the idea.

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.

2 participants