This commit is contained in:
lostjared
2017-02-19 09:56:51 -08:00
parent 045239d791
commit f07be20b61
3 changed files with 30 additions and 18 deletions

View File

@@ -1,17 +1,22 @@
//#define LINUX_RELEASE
#include"qtheaders.h" #include"qtheaders.h"
#include "main_window.h" #include "main_window.h"
//#include<unistd.h> #ifdef LINUX_RELEASE
#include<unistd.h>
#endif
bool blend_set = false; bool blend_set = false;
cv::Mat blend_image; cv::Mat blend_image;
int main(int argc, char **argv) { int main(int argc, char **argv) {
/* #ifdef LINUX_RELEASE
if(chdir("/usr/share/acidcam") == 0) { if(chdir("/usr/share/acidcam") == 0) {
std::cout << "Changed directory to: /usr/share/acidcam\n"; std::cout << "Changed directory to: /usr/share/acidcam\n";
} }
*/ #endif
QApplication app(argc, argv); QApplication app(argc, argv);
AC_MainWindow window; AC_MainWindow window;

View File

@@ -67,9 +67,9 @@ void Playback::setVideo(cv::VideoCapture cap, cv::VideoWriter wr, bool record) {
} }
void Playback::setVector(std::vector<std::pair<int, int>> v) { void Playback::setVector(std::vector<std::pair<int, int>> v) {
mutex.lock(); mutex_add.lock();
current = v; current = v;
mutex.unlock(); mutex_add.unlock();
} }
void Playback::setOptions(bool n, int c) { void Playback::setOptions(bool n, int c) {
@@ -97,24 +97,30 @@ void Playback::run() {
emit stopRecording(); emit stopRecording();
return; return;
} }
static std::vector<std::pair<int, int>> cur;
mutex_shown.lock();
cur = current;
mutex_shown.unlock();
ac::orig_frame = frame.clone(); ac::orig_frame = frame.clone();
if(current.size()>0) { if(cur.size()>0) {
ac::in_custom = true; ac::in_custom = true;
for(unsigned int i = 0; i < current.size(); ++i) { for(unsigned int i = 0; i < cur.size(); ++i) {
if(i == current.size()-1) if(i == cur.size()-1)
ac::in_custom = false; ac::in_custom = false;
if(current[i].first == 0) { if(cur[i].first == 0) {
ac::draw_func[current[i].second](frame); ac::draw_func[cur[i].second](frame);
} else if(current[i].first == 1) { } else if(cur[i].first == 1) {
current_filterx = current[i].second; current_filterx = cur[i].second;
ac::alphaFlame(frame); ac::alphaFlame(frame);
} else if(current[i].first == 2) { } else if(cur[i].first == 2) {
draw_plugin(frame, current[i].second); draw_plugin(frame, cur[i].second);
} }
} }
} }
if(recording && writer.isOpened()) { if(recording && writer.isOpened()) {
writer.write(frame); writer.write(frame);
} }
@@ -161,7 +167,6 @@ void Playback::Stop() {
} }
void Playback::Release() { void Playback::Release() {
mutex.lock(); mutex.lock();
stop = true; stop = true;
if(capture.isOpened()) capture.release(); if(capture.isOpened()) capture.release();
@@ -824,8 +829,10 @@ void AC_MainWindow::frameInc() {
float index = frame_index; float index = frame_index;
float max_frames = video_frames; float max_frames = video_frames;
float value = (index/max_frames)*100; float value = (index/max_frames)*100;
unsigned int val = static_cast<unsigned int>(value);
if(frame_index <= video_frames) if(frame_index <= video_frames)
frame_stream << " - " << static_cast<unsigned int>(value) << "%"; frame_stream << " - " << val << "%";
progress_bar->setValue(val);
} }
statusBar()->showMessage(frame_string); statusBar()->showMessage(frame_string);
} }

View File

@@ -8,7 +8,7 @@ class Playback : public QThread {
Q_OBJECT Q_OBJECT
private: private:
bool stop; bool stop;
QMutex mutex,mutex_shown; QMutex mutex,mutex_shown,mutex_add;
QWaitCondition condition; QWaitCondition condition;
cv::Mat frame; cv::Mat frame;
int frame_rate; int frame_rate;