added color range

This commit is contained in:
Jared Bruni
2020-03-07 00:10:53 -08:00
parent 9fdf9a440c
commit 0bfa9d8606
7 changed files with 115 additions and 8 deletions

62
src/color_range.cpp Normal file
View File

@@ -0,0 +1,62 @@
#include"color_range.h"
ColorRangeWindow::ColorRangeWindow(QWidget *parent) : QDialog(parent) {
setFixedSize(280, 200);
color1 = new QLabel("", this);
color2 = new QLabel("", this);
color1->setGeometry(25, 25, 100, 25);
color2->setGeometry(135, 25, 100, 25);
QString color_var = "#000000";
color1->setStyleSheet("QLabel { background-color :" + color_var + " ; }");
color2->setStyleSheet("QLabel { background-color :" + color_var + " ; }");
setc1 = new QPushButton("Set", this);
setc1->setGeometry(25, 75, 100, 25);
setc2 = new QPushButton("Set", this);
setc2->setGeometry(135, 75, 100, 25);
connect(setc1, SIGNAL(clicked()), this, SLOT(selectColor1()));
connect(setc2, SIGNAL(clicked()), this, SLOT(selectColor2()));
range_set = new QPushButton("Enable", this);
range_set->setGeometry(75, 125, 100, 25);
connect(range_set, SIGNAL(clicked()), this, SLOT(setValues()));
}
void ColorRangeWindow::selectColor1() {
QColorDialog *dialog = new QColorDialog(this);
QColor color= dialog->getColor();
QVariant variant = color;
QString color_var = variant.toString();
//set_low_color = color;
color1_value[0] = color.blue();
color1_value[1] = color.green();
color2_value[2] = color.blue();
color1->setStyleSheet("QLabel { background-color :" + color_var + " ; }");
color1->setText("");
}
void ColorRangeWindow::selectColor2() {
QColorDialog *dialog = new QColorDialog(this);
QColor color= dialog->getColor();
QVariant variant = color;
QString color_var = variant.toString();
//set_low_color = color;
color2_value[0] = color.blue();
color2_value[1] = color.green();
color2_value[2] = color.blue();
color2->setStyleSheet("QLabel { background-color :" + color_var + " ; }");
color2->setText("");
}
void ColorRangeWindow::setValues() {
ac::setColorRangeLowToHigh(color1_value, color2_value);
ac::setColorRangeEnabled(true);
QMessageBox::information(this, "Color Range Enabled...", "Enabled Color Range");
}

25
src/color_range.h Normal file
View File

@@ -0,0 +1,25 @@
#ifndef __COLOR_RANGE__H_
#define __COLOR_RANGE__H_
#include"qtheaders.h"
class ColorRangeWindow : public QDialog {
Q_OBJECT
private:
QLabel *color1, *color2;
QPushButton *range_set, *setc1, *setc2;
cv::Vec3b color1_value, color2_value;
public:
ColorRangeWindow(QWidget *parent = 0);
public slots:
void selectColor1();
void selectColor2();
void setValues();
};
#endif

View File

@@ -2,7 +2,7 @@
#include"controller.h"
#include<iostream>
#ifndef _WIN32
#ifndef JOYSTICK_ENABLED
bool Controller::open(int index) {
stick = SDL_JoystickOpen(index);

View File

@@ -2,7 +2,7 @@
#ifndef __CONTROLLER_H__
#define __CONTROLLER_H__
#ifndef _WIN32
#ifndef JOYSTICK_ENABLED
#include "SDL.h"

View File

@@ -74,6 +74,11 @@ void generate_map() {
}
}
void AC_MainWindow::showRange() {
color_range_window->show();
}
void custom_filter(cv::Mat &) {
}
@@ -131,6 +136,8 @@ AC_MainWindow::AC_MainWindow(QWidget *parent) : QMainWindow(parent) {
pref_window = new OptionsWindow(this);
pref_window->setPlayback(playback);
color_range_window = new ColorRangeWindow(this);
QObject::connect(playback, SIGNAL(procImage(QImage)), this, SLOT(updateFrame(QImage)));
QObject::connect(playback, SIGNAL(stopRecording()), this, SLOT(stopRecording()));
QObject::connect(playback, SIGNAL(frameIncrement()), this, SLOT(frameInc()));
@@ -173,7 +180,7 @@ AC_MainWindow::AC_MainWindow(QWidget *parent) : QMainWindow(parent) {
}
}
*/
#ifndef _WIN32
#ifndef JOYSTICK_ENABLED
Controller::init();
joy_timer = new QTimer(this);
connect(joy_timer, SIGNAL(timeout()), this, SLOT(chk_Joystick()));
@@ -504,6 +511,8 @@ void AC_MainWindow::createMenu() {
controls_stop = new QAction(tr("Sto&p"), this);
controls_stop->setShortcut(tr("Ctrl+C"));
controls_menu->addAction(controls_stop);
controls_stop->setEnabled(false);
controls_snapshot = new QAction(tr("Take &Snapshot"), this);
controls_snapshot->setShortcut(tr("Ctrl+A"));
@@ -538,6 +547,12 @@ void AC_MainWindow::createMenu() {
connect(show_control_window, SIGNAL(triggered()), this, SLOT(controls_ShowDisp2()));
controls_menu->addAction(show_control_window);
show_range = new QAction(tr("Show Range"), this);
show_range->setShortcut(tr("Ctrl+1"));
controls_menu->addAction(show_range);
connect(show_range, SIGNAL(triggered()), this, SLOT(showRange()));
reset_filters = new QAction(tr("Reset Filters"), this);
reset_filters->setShortcut(tr("Ctrl+R"));
controls_menu->addAction(reset_filters);
@@ -1063,7 +1078,7 @@ bool AC_MainWindow::startCamera(int res, int dev, const QString &outdir, bool re
playback->Play();
disp->show();
QString out_text;
#ifndef _WIN32
#ifndef JOYSTICK_ENABLED
QTextStream stream(&out_text);
if(controller.open(0)) {
stream << "Controller: " << controller.getControllerName() << " connected...\n";
@@ -1171,7 +1186,7 @@ bool AC_MainWindow::startVideo(const QString &filename, const QString &outdir, b
playback->setVideo(capture_video,writer,recording);
playback->Play();
disp->show();
#ifndef _WIN32
#ifndef JOYSTICK_ENABLED
QString out_text;
QTextStream streamx(&out_text);
if(controller.open(0)) {
@@ -1836,7 +1851,7 @@ void AC_MainWindow::showGLDisplay() {
}
void AC_MainWindow::chk_Joystick() {
#ifndef _WIN32
#ifndef JOYSTICK_ENABLED
SDL_Event e;
while(SDL_PollEvent(&e)) {
static int speed = 0;

View File

@@ -21,6 +21,7 @@
#include "options_window.h"
#include "gl_display.h"
#include "controller.h"
#include "color_range.h"
class SearchWindow;
@@ -65,6 +66,7 @@ public:
QAction *select_next_filter, *select_prev_filter;
QAction *cycle_custom;
QAction *show_glDisplay;
QAction *show_range;
QTimer *joy_timer;
double speed_actions[7];
QRadioButton *filter_single, *filter_custom;
@@ -76,6 +78,7 @@ public:
void setOptionString(std::string op, std::string value);
void setProcMode(int index);
public slots:
void showRange();
void chk_Joystick();
void addClicked();
void rmvClicked();
@@ -152,6 +155,7 @@ private:
ImageWindow *image_window;
GotoWindow *goto_window;
OptionsWindow *pref_window;
ColorRangeWindow *color_range_window;
cv::VideoCapture capture_camera, capture_video;
cv::VideoWriter writer;
unsigned long video_frames;
@@ -167,7 +171,7 @@ private:
bool loading;
int speed_index;
cv::ocl::Context context;
#ifndef _WIN32
#ifndef JOYSTICK_ENABLED
Controller controller;
#endif

View File

@@ -6,7 +6,8 @@
#ifndef _QT_HEADERS__
#define _QT_HEADERS__
#define ac_version "v1.58.0"
#define JOYSTICK_ENABLED
#define ac_version "v1.59.0"
#include<QApplication>
#include<QMainWindow>
#include<QDialog>