mirror of
https://github.com/lostjared/Acid.Cam.v2.Qt.git
synced 2025-12-17 04:10:01 +01:00
split into multiple files and changed binary name
This commit is contained in:
@@ -31,7 +31,6 @@ void generate_map() {
|
||||
std::string name = "plugin " + plugins.plugin_list[j]->name();
|
||||
filter_map[name] = std::make_pair(2, j);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void custom_filter(cv::Mat &) {
|
||||
@@ -39,195 +38,11 @@ void custom_filter(cv::Mat &) {
|
||||
}
|
||||
|
||||
|
||||
Playback::Playback(QObject *parent) : QThread(parent) {
|
||||
stop = true;
|
||||
isStep = false;
|
||||
isPaused = false;
|
||||
}
|
||||
|
||||
void Playback::Play() {
|
||||
if(!isRunning()) {
|
||||
if(isStopped()) {
|
||||
stop = false;
|
||||
}
|
||||
}
|
||||
start(LowPriority);
|
||||
}
|
||||
|
||||
void Playback::setVideo(cv::VideoCapture cap, cv::VideoWriter wr, bool record) {
|
||||
mutex.lock();
|
||||
capture = cap;
|
||||
writer = wr;
|
||||
recording = record;
|
||||
if(capture.isOpened()) {
|
||||
frame_rate = (int) capture.get(CV_CAP_PROP_FPS);
|
||||
if(frame_rate <= 0) frame_rate = 24;
|
||||
}
|
||||
mutex.unlock();
|
||||
}
|
||||
|
||||
void Playback::setVector(std::vector<std::pair<int, int>> v) {
|
||||
mutex_add.lock();
|
||||
current = v;
|
||||
mutex_add.unlock();
|
||||
}
|
||||
|
||||
void Playback::setOptions(bool n, int c) {
|
||||
mutex.lock();
|
||||
ac::isNegative = n;
|
||||
negate = n;
|
||||
reverse = c;
|
||||
ac::color_order = c;
|
||||
ac::in_custom = true;
|
||||
mutex.unlock();
|
||||
}
|
||||
|
||||
void Playback::setDisplayed(bool shown) {
|
||||
mutex_shown.lock();
|
||||
video_shown = shown;
|
||||
mutex_shown.unlock();
|
||||
}
|
||||
|
||||
void Playback::run() {
|
||||
while(!stop) {
|
||||
mutex.lock();
|
||||
if(!capture.read(frame)) {
|
||||
stop = true;
|
||||
mutex.unlock();
|
||||
emit stopRecording();
|
||||
return;
|
||||
}
|
||||
|
||||
static std::vector<std::pair<int, int>> cur;
|
||||
mutex_shown.lock();
|
||||
cur = current;
|
||||
mutex_shown.unlock();
|
||||
|
||||
|
||||
ac::orig_frame = frame.clone();
|
||||
if(cur.size()>0) {
|
||||
ac::in_custom = true;
|
||||
for(unsigned int i = 0; i < cur.size(); ++i) {
|
||||
if(i == cur.size()-1)
|
||||
ac::in_custom = false;
|
||||
|
||||
if(cur[i].first == 0) {
|
||||
ac::draw_func[cur[i].second](frame);
|
||||
} else if(cur[i].first == 1) {
|
||||
current_filterx = cur[i].second;
|
||||
ac::alphaFlame(frame);
|
||||
} else if(cur[i].first == 2) {
|
||||
draw_plugin(frame, cur[i].second);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(recording && writer.isOpened()) {
|
||||
writer.write(frame);
|
||||
}
|
||||
mutex.unlock();
|
||||
bool shown_var;
|
||||
mutex_shown.lock();
|
||||
shown_var = video_shown;
|
||||
mutex_shown.unlock();
|
||||
|
||||
if(shown_var == true) {
|
||||
if(frame.channels()==3) {
|
||||
cv::cvtColor(frame, rgb_frame, CV_BGR2RGB);
|
||||
img = QImage((const unsigned char*)(rgb_frame.data), rgb_frame.cols, rgb_frame.rows, QImage::Format_RGB888);
|
||||
} else {
|
||||
img = QImage((const unsigned char*)(frame.data), frame.cols, frame.rows, QImage::Format_Indexed8);
|
||||
}
|
||||
emit procImage(img);
|
||||
if(isStep == true) {
|
||||
isStep = false;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
emit frameIncrement();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Playback::~Playback() {
|
||||
mutex.lock();
|
||||
stop = true;
|
||||
#if defined(__linux__) || defined(__APPLE__)
|
||||
condition.wakeOne();
|
||||
#endif
|
||||
mutex.unlock();
|
||||
#if defined(__linux__) || defined(__APPLE__)
|
||||
wait();
|
||||
#endif
|
||||
}
|
||||
|
||||
void Playback::Stop() {
|
||||
mutex.lock();
|
||||
stop = true;
|
||||
mutex.unlock();
|
||||
}
|
||||
|
||||
void Playback::Release() {
|
||||
mutex.lock();
|
||||
stop = true;
|
||||
if(capture.isOpened()) capture.release();
|
||||
if(writer.isOpened()) writer.release();
|
||||
mutex.unlock();
|
||||
}
|
||||
|
||||
void Playback::msleep(int ms) {
|
||||
QThread::msleep(ms);
|
||||
}
|
||||
|
||||
bool Playback::isStopped() const {
|
||||
return this->stop;
|
||||
}
|
||||
|
||||
void Playback::setStep() {
|
||||
mutex.lock();
|
||||
isStep = true;
|
||||
mutex.unlock();
|
||||
}
|
||||
|
||||
void Playback::setImage(const cv::Mat &frame) {
|
||||
mutex.lock();
|
||||
blend_set = true;
|
||||
blend_image = frame;
|
||||
mutex.unlock();
|
||||
}
|
||||
|
||||
DisplayWindow::DisplayWindow(QWidget *parent) : QDialog(parent) {
|
||||
createControls();
|
||||
setGeometry(950, 200, 640, 480);
|
||||
setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint);
|
||||
setWindowTitle(tr("Acid Cam v2 - Display Window"));
|
||||
hide();
|
||||
}
|
||||
void DisplayWindow::createControls() {
|
||||
img_label = new QLabel(this);
|
||||
img_label->setGeometry(0,0,640, 480);
|
||||
}
|
||||
void DisplayWindow::displayImage(const QImage &img) {
|
||||
QRect src(QPoint(0, 0), size());
|
||||
QPixmap p = QPixmap::fromImage(img).scaled(size(),Qt::KeepAspectRatio, Qt::FastTransformation);
|
||||
QRect dst(QPoint(0,0),p.size());
|
||||
dst.moveCenter(src.center());
|
||||
img_label->setGeometry(dst);
|
||||
img_label->setPixmap(p);
|
||||
}
|
||||
|
||||
|
||||
void DisplayWindow::paintEvent(QPaintEvent *) {
|
||||
QPainter painter(this);
|
||||
painter.fillRect(QRect(QPoint(0, 0), size()), QColor(0,0,0));
|
||||
}
|
||||
|
||||
|
||||
AC_MainWindow::~AC_MainWindow() {
|
||||
|
||||
controls_Stop();
|
||||
|
||||
delete playback;
|
||||
}
|
||||
|
||||
AC_MainWindow::AC_MainWindow(QWidget *parent) : QMainWindow(parent) {
|
||||
programMode = MODE_CAMERA;
|
||||
init_plugins();
|
||||
|
||||
Reference in New Issue
Block a user