mirror of
https://github.com/lostjared/Acid.Cam.v2.Qt.git
synced 2025-12-16 20:00:01 +01:00
added test for characters
This commit is contained in:
@@ -10,12 +10,20 @@ ChromaWindow::ChromaWindow(QWidget *parent) : QDialog(parent) {
|
|||||||
createControls();
|
createControls();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ChromaWindow::checkEdit(QLineEdit *edit) {
|
||||||
|
QString text = edit->text();
|
||||||
|
std::string chk_value;
|
||||||
|
chk_value = text.toStdString();
|
||||||
|
for(unsigned int i = 0; i < chk_value.length(); ++i) {
|
||||||
|
if(!(chk_value[i] >= '0' && chk_value[i] <= '9'))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool ChromaWindow::checkInput(cv::Vec3b &low, cv::Vec3b &high) {
|
bool ChromaWindow::checkInput(cv::Vec3b &low, cv::Vec3b &high) {
|
||||||
double lo_b, lo_g, lo_r;
|
double lo_b, lo_g, lo_r;
|
||||||
double hi_b, hi_g, hi_r;
|
double hi_b, hi_g, hi_r;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
lo_b = atof(low_b->text().toStdString().c_str());
|
lo_b = atof(low_b->text().toStdString().c_str());
|
||||||
lo_g = atof(low_g->text().toStdString().c_str());
|
lo_g = atof(low_g->text().toStdString().c_str());
|
||||||
lo_r = atof(low_r->text().toStdString().c_str());
|
lo_r = atof(low_r->text().toStdString().c_str());
|
||||||
@@ -85,11 +93,17 @@ void ChromaWindow::openColorSelectTolerance() {
|
|||||||
|
|
||||||
void ChromaWindow::colorAdd() {
|
void ChromaWindow::colorAdd() {
|
||||||
cv::Vec3b low, high;
|
cv::Vec3b low, high;
|
||||||
|
QLineEdit *array[] = { low_r, low_g, low_b, high_r, high_g, high_b, 0 };
|
||||||
|
for(int i = 0; array[i] != 0; ++i) {
|
||||||
|
if(checkEdit(array[i])==false) {
|
||||||
|
QMessageBox::information(this, "Invalid Value", "Values must be between 0-255 no characters");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
if(checkInput(low, high)==false) {
|
if(checkInput(low, high)==false) {
|
||||||
QMessageBox::information(this,"Error ","Error Color Values must be between 0-255");
|
QMessageBox::information(this,"Error ","Error Color Values must be between 0-255");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
void ChromaWindow::colorRemove() {
|
void ChromaWindow::colorRemove() {
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ class ChromaWindow : public QDialog {
|
|||||||
public:
|
public:
|
||||||
ChromaWindow(QWidget *parent);
|
ChromaWindow(QWidget *parent);
|
||||||
bool checkInput(cv::Vec3b &low, cv::Vec3b &high);
|
bool checkInput(cv::Vec3b &low, cv::Vec3b &high);
|
||||||
|
bool checkEdit(QLineEdit *edit);
|
||||||
public slots:
|
public slots:
|
||||||
void openColorSelectRange();
|
void openColorSelectRange();
|
||||||
void openColorSelectTolerance();
|
void openColorSelectTolerance();
|
||||||
|
|||||||
Reference in New Issue
Block a user