Skip to content

Commit

Permalink
Added power line frequency setting to Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
trcwm committed Jan 7, 2018
1 parent 2246c3e commit 2f32bc7
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 40 deletions.
34 changes: 17 additions & 17 deletions QtCaptureTest/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ MainWindow::MainWindow(QWidget *parent) :
connect(ui->hueSlider, SIGNAL(valueChanged(int)), this, SLOT(onHueSlider(int)));
connect(ui->backlightSlider, SIGNAL(valueChanged(int)), this, SLOT(onBacklightSlider(int)));
connect(ui->sharpnessSlider, SIGNAL(valueChanged(int)), this, SLOT(onSharpnessSlider(int)));
connect(ui->colorEnableSlider, SIGNAL(valueChanged(int)), this, SLOT(onColorEnableSlider(int)));
connect(ui->powerlineFreqSlider, SIGNAL(valueChanged(int)), this, SLOT(onColorEnableSlider(int)));

// add timer to refresh the frame display
m_refreshTimer = new QTimer(this);
Expand Down Expand Up @@ -692,32 +692,32 @@ void MainWindow::readCameraSettings()
// COLOR ENABLE
// ********************************************************************************

if (Cap_getPropertyLimits(m_ctx, m_streamID, CAPPROPID_COLORENABLE, &emin, &emax, &edefault)==CAPRESULT_OK)
if (Cap_getPropertyLimits(m_ctx, m_streamID, CAPPROPID_POWERLINEFREQ, &emin, &emax, &edefault)==CAPRESULT_OK)
{
qDebug() << "color enable min: " << emin;
qDebug() << "backlightcomp max: " << emax;
qDebug() << "backlightcomp default: " << edefault;
ui->colorEnableSlider->setEnabled(true);
ui->colorEnableSlider->setRange(emin, emax);
qDebug() << "power line freq min: " << emin;
qDebug() << "power line freq max: " << emax;
qDebug() << "power line freq default: " << edefault;
ui->powerlineFreqSlider->setEnabled(true);
ui->powerlineFreqSlider->setRange(emin, emax);
m_hasBacklightcomp = true;
}
else
{
ui->colorEnableSlider->setRange(0, 0);
ui->colorEnableSlider->setEnabled(false);
ui->powerlineFreqSlider->setRange(0, 0);
ui->powerlineFreqSlider->setEnabled(false);
}

int32_t colorEnable;
if (Cap_getProperty(m_ctx, m_streamID, CAPPROPID_COLORENABLE, &colorEnable)==CAPRESULT_OK)
int32_t powerline;
if (Cap_getProperty(m_ctx, m_streamID, CAPPROPID_POWERLINEFREQ, &powerline)==CAPRESULT_OK)
{
qDebug() << "color enable: " << backlight;
ui->colorEnableSlider->setEnabled(true);
ui->colorEnableSlider->setValue(backlight);
qDebug() << "power line : " << powerline;
ui->powerlineFreqSlider->setEnabled(true);
ui->powerlineFreqSlider->setValue(powerline);
}
else
{
qDebug() << "Failed to get color enable value";
ui->colorEnableSlider->setEnabled(false);
qDebug() << "Failed to get power line frequency value";
ui->powerlineFreqSlider->setEnabled(false);
}

}
Expand Down Expand Up @@ -787,5 +787,5 @@ void MainWindow::onSharpnessSlider(int value)

void MainWindow::onColorEnableSlider(int value)
{
Cap_setProperty(m_ctx, m_streamID, CAPPROPID_COLORENABLE, value);
Cap_setProperty(m_ctx, m_streamID, CAPPROPID_POWERLINEFREQ, value);
}
42 changes: 21 additions & 21 deletions QtCaptureTest/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,27 @@
<string>Camera Settings</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="13" column="1">
<widget class="QSlider" name="sharpnessSlider">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="15" column="1">
<widget class="QSlider" name="powerlineFreqSlider">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="15" column="0">
<widget class="QLabel" name="label_13">
<property name="text">
<string>Power line freq</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QSlider" name="gainSlider">
<property name="orientation">
Expand Down Expand Up @@ -243,27 +264,6 @@
</property>
</widget>
</item>
<item row="13" column="1">
<widget class="QSlider" name="sharpnessSlider">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="15" column="0">
<widget class="QLabel" name="label_13">
<property name="text">
<string>Color enable</string>
</property>
</widget>
</item>
<item row="15" column="1">
<widget class="QSlider" name="colorEnableSlider">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down
13 changes: 11 additions & 2 deletions linux/platformstream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,10 @@ bool PlatformStream::setProperty(uint32_t propID, int32_t value)
case CAPPROPID_BACKLIGHTCOMP:
ctrl.id = V4L2_CID_BACKLIGHT_COMPENSATION;
break;
default:
case CAPPROPID_POWERLINEFREQ:
ctrl.id = V4L2_CID_POWER_LINE_FREQUENCY;
break;
default:
return false;
}

Expand Down Expand Up @@ -750,6 +753,9 @@ bool PlatformStream::getPropertyLimits(uint32_t propID, int32_t *emin, int32_t *
case CAPPROPID_BACKLIGHTCOMP:
ctrl.id = V4L2_CID_BACKLIGHT_COMPENSATION;
break;
case CAPPROPID_POWERLINEFREQ:
ctrl.id = V4L2_CID_POWER_LINE_FREQUENCY;
break;
default:
return false;
}
Expand Down Expand Up @@ -804,7 +810,10 @@ bool PlatformStream::getProperty(uint32_t propID, int32_t &value)
break;
case CAPPROPID_BACKLIGHTCOMP:
ctrl.id = V4L2_CID_BACKLIGHT_COMPENSATION;
break;
break;
case CAPPROPID_POWERLINEFREQ:
ctrl.id = V4L2_CID_POWER_LINE_FREQUENCY;
break;
default:
return false;
}
Expand Down

0 comments on commit 2f32bc7

Please sign in to comment.