mirror of
https://github.com/lostjared/Acid.Cam.v2.Qt.git
synced 2025-12-18 21:00:13 +01:00
now supports color key images with 255,0,255 as the color key (only pixels that are 255,0,255) are drawn
This commit is contained in:
@@ -294,6 +294,14 @@ void AC_MainWindow::createMenu() {
|
|||||||
controls_setimage->setShortcut(tr("Ctrl+I"));
|
controls_setimage->setShortcut(tr("Ctrl+I"));
|
||||||
controls_menu->addAction(controls_setimage);
|
controls_menu->addAction(controls_setimage);
|
||||||
|
|
||||||
|
controls_setkey = new QAction(tr("Set Color Key Image"), this);
|
||||||
|
controls_setkey->setShortcut(tr("Ctrl+K"));
|
||||||
|
controls_menu->addAction(controls_setkey);
|
||||||
|
|
||||||
|
clear_images = new QAction(tr("Clear Images"), this);
|
||||||
|
clear_images->setShortcut(tr("Ctrl+K"));
|
||||||
|
controls_menu->addAction(clear_images);
|
||||||
|
|
||||||
controls_showvideo = new QAction(tr("Hide Display Video"), this);
|
controls_showvideo = new QAction(tr("Hide Display Video"), this);
|
||||||
controls_showvideo->setShortcut(tr("Ctrl+V"));
|
controls_showvideo->setShortcut(tr("Ctrl+V"));
|
||||||
controls_menu->addAction(controls_showvideo);
|
controls_menu->addAction(controls_showvideo);
|
||||||
@@ -306,8 +314,9 @@ void AC_MainWindow::createMenu() {
|
|||||||
connect(controls_step, SIGNAL(triggered()), this, SLOT(controls_Step()));
|
connect(controls_step, SIGNAL(triggered()), this, SLOT(controls_Step()));
|
||||||
connect(controls_stop, SIGNAL(triggered()), this, SLOT(controls_Stop()));
|
connect(controls_stop, SIGNAL(triggered()), this, SLOT(controls_Stop()));
|
||||||
connect(controls_setimage, SIGNAL(triggered()), this, SLOT(controls_SetImage()));
|
connect(controls_setimage, SIGNAL(triggered()), this, SLOT(controls_SetImage()));
|
||||||
|
connect(controls_setkey, SIGNAL(triggered()), this, SLOT(controls_SetKey()));
|
||||||
connect(controls_showvideo, SIGNAL(triggered()), this, SLOT(controls_ShowVideo()));
|
connect(controls_showvideo, SIGNAL(triggered()), this, SLOT(controls_ShowVideo()));
|
||||||
|
connect(clear_images, SIGNAL(triggered()), this, SLOT(controls_Clear()));
|
||||||
connect(combo_rgb, SIGNAL(currentIndexChanged(int)), this, SLOT(cb_SetIndex(int)));
|
connect(combo_rgb, SIGNAL(currentIndexChanged(int)), this, SLOT(cb_SetIndex(int)));
|
||||||
controls_pause->setText(tr("Pause"));
|
controls_pause->setText(tr("Pause"));
|
||||||
help_about = new QAction(tr("About"), this);
|
help_about = new QAction(tr("About"), this);
|
||||||
@@ -684,6 +693,10 @@ void AC_MainWindow::controls_Pause() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AC_MainWindow::controls_Clear() {
|
||||||
|
playback->Clear();
|
||||||
|
}
|
||||||
|
|
||||||
void AC_MainWindow::controls_SetImage() {
|
void AC_MainWindow::controls_SetImage() {
|
||||||
QString fileName = QFileDialog::getOpenFileName(this,tr("Open Image"), "/home", tr("Image Files (*.png *.jpg)"));
|
QString fileName = QFileDialog::getOpenFileName(this,tr("Open Image"), "/home", tr("Image Files (*.png *.jpg)"));
|
||||||
if(fileName != "") {
|
if(fileName != "") {
|
||||||
@@ -691,6 +704,24 @@ void AC_MainWindow::controls_SetImage() {
|
|||||||
if(!tblend_image.empty()) {
|
if(!tblend_image.empty()) {
|
||||||
playback->setImage(tblend_image);
|
playback->setImage(tblend_image);
|
||||||
QMessageBox::information(this, tr("Loaded Image"), tr("Image set"));
|
QMessageBox::information(this, tr("Loaded Image"), tr("Image set"));
|
||||||
|
} else {
|
||||||
|
QMessageBox::information(this, tr("Image Load failed"), tr("Could not load image"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AC_MainWindow::controls_SetKey() {
|
||||||
|
QString fileName = QFileDialog::getOpenFileName(this,tr("Open Color Key Image"), "/home", tr("Image Files (*.png)"));
|
||||||
|
if(fileName != "") {
|
||||||
|
cv::Mat tblend_image = cv::imread(fileName.toStdString());
|
||||||
|
if(!tblend_image.empty()) {
|
||||||
|
playback->setColorKey(tblend_image);
|
||||||
|
QString str_value;
|
||||||
|
QTextStream stream(&str_value);
|
||||||
|
stream << "ColorKey is (255,0,255)\n Image Set: " << fileName;
|
||||||
|
QMessageBox::information(this, tr("Loaded Image"), tr(str_value.toStdString().c_str()));
|
||||||
|
} else {
|
||||||
|
QMessageBox::information(this, tr("Image Load failed"), tr("Could not load ColorKey image"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,9 +31,10 @@ public:
|
|||||||
QComboBox *color_maps, *filters;
|
QComboBox *color_maps, *filters;
|
||||||
QMenu *file_menu, *controls_menu, *help_menu;
|
QMenu *file_menu, *controls_menu, *help_menu;
|
||||||
QAction *file_exit, *file_new_capture, *file_new_video;
|
QAction *file_exit, *file_new_capture, *file_new_video;
|
||||||
QAction *controls_snapshot, *controls_pause, *controls_step, *controls_stop, *controls_setimage, *controls_showvideo;
|
QAction *controls_snapshot, *controls_pause, *controls_step, *controls_stop, *controls_setimage,*controls_setkey,*controls_showvideo, *clear_images;
|
||||||
QAction *help_about;
|
QAction *help_about;
|
||||||
QRadioButton *filter_single, *filter_custom;
|
QRadioButton *filter_single, *filter_custom;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void addClicked();
|
void addClicked();
|
||||||
void rmvClicked();
|
void rmvClicked();
|
||||||
@@ -48,6 +49,8 @@ public slots:
|
|||||||
void controls_Step();
|
void controls_Step();
|
||||||
void controls_SetImage();
|
void controls_SetImage();
|
||||||
void controls_ShowVideo();
|
void controls_ShowVideo();
|
||||||
|
void controls_SetKey();
|
||||||
|
void controls_Clear();
|
||||||
void help_About();
|
void help_About();
|
||||||
void updateFrame(QImage img);
|
void updateFrame(QImage img);
|
||||||
void stopRecording();
|
void stopRecording();
|
||||||
|
|||||||
@@ -152,7 +152,11 @@ void Playback::drawEffects(cv::Mat &frame) {
|
|||||||
if(saturation_ > 0) {
|
if(saturation_ > 0) {
|
||||||
ac::setSaturation(frame, saturation_);
|
ac::setSaturation(frame, saturation_);
|
||||||
}
|
}
|
||||||
|
if(colorkey_set == true && !color_image.empty()) {
|
||||||
|
cv::Mat cframe = frame.clone();
|
||||||
|
cv::Vec3b well_color(255,0,255);
|
||||||
|
ac::filterColorKeyed(well_color, ac::orig_frame, cframe, frame);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Playback::drawFilter(cv::Mat &frame, std::pair<int, int> &filter) {
|
void Playback::drawFilter(cv::Mat &frame, std::pair<int, int> &filter) {
|
||||||
@@ -245,6 +249,15 @@ Playback::~Playback() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Playback::Clear() {
|
||||||
|
mutex.lock();
|
||||||
|
blend_set = false;
|
||||||
|
colorkey_set = false;
|
||||||
|
blend_image.release();
|
||||||
|
color_image.release();
|
||||||
|
mutex.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
void Playback::Stop() {
|
void Playback::Stop() {
|
||||||
stop = true;
|
stop = true;
|
||||||
alpha = 0;
|
alpha = 0;
|
||||||
@@ -280,6 +293,13 @@ void Playback::setImage(const cv::Mat &frame) {
|
|||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Playback::setColorKey(const cv::Mat &image) {
|
||||||
|
mutex.lock();
|
||||||
|
colorkey_set = true;
|
||||||
|
color_image = image;
|
||||||
|
mutex.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
void Playback::filterFade(cv::Mat &frame, std::pair<int, int> &filter1, std::pair<int, int> &filter2, double alpha) {
|
void Playback::filterFade(cv::Mat &frame, std::pair<int, int> &filter1, std::pair<int, int> &filter2, double alpha) {
|
||||||
unsigned int h = frame.rows; // frame height
|
unsigned int h = frame.rows; // frame height
|
||||||
unsigned int w = frame.cols;// framew idth
|
unsigned int w = frame.cols;// framew idth
|
||||||
|
|||||||
@@ -49,10 +49,12 @@ public:
|
|||||||
bool setVideoCamera(int device, int res, cv::VideoWriter writer, bool record);
|
bool setVideoCamera(int device, int res, cv::VideoWriter writer, bool record);
|
||||||
bool isStopped() const;
|
bool isStopped() const;
|
||||||
void run();
|
void run();
|
||||||
|
void Clear();
|
||||||
void msleep(int ms);
|
void msleep(int ms);
|
||||||
void setVector(std::vector<std::pair<int, int>> s);
|
void setVector(std::vector<std::pair<int, int>> s);
|
||||||
void setOptions(bool n, int c);
|
void setOptions(bool n, int c);
|
||||||
void setImage(const cv::Mat &image);
|
void setImage(const cv::Mat &image);
|
||||||
|
void setColorKey(const cv::Mat &image);
|
||||||
void setStep();
|
void setStep();
|
||||||
void setDisplayed(bool shown);
|
void setDisplayed(bool shown);
|
||||||
void setIndexChanged(std::string name);
|
void setIndexChanged(std::string name);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
#ifndef _QT_HEADERS__
|
#ifndef _QT_HEADERS__
|
||||||
#define _QT_HEADERS__
|
#define _QT_HEADERS__
|
||||||
|
|
||||||
#define ac_version "v1.04"
|
#define ac_version "v1.05"
|
||||||
|
|
||||||
#include<QApplication>
|
#include<QApplication>
|
||||||
#include<QMainWindow>
|
#include<QMainWindow>
|
||||||
|
|||||||
Reference in New Issue
Block a user