mirror of
https://github.com/lostjared/Acid.Cam.v2.Qt.git
synced 2025-12-15 19:29:58 +01:00
making progress
This commit is contained in:
@@ -12,6 +12,7 @@ public:
|
||||
bool checkEdit(QLineEdit *edit);
|
||||
void setEditFromColor(int val, QColor color);
|
||||
void enableKey(bool op);
|
||||
void showGL();
|
||||
public slots:
|
||||
void openColorSelectRange();
|
||||
void openColorSelectTolerance();
|
||||
|
||||
@@ -13,17 +13,24 @@ DisplayWindow::DisplayWindow(QWidget *parent) : QDialog(parent) {
|
||||
setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint);
|
||||
setWindowTitle(tr("Acid Cam v2 - Display Window"));
|
||||
hide();
|
||||
gl_display = new glDisplayWindow();
|
||||
gl_display->setAnimating(true);
|
||||
}
|
||||
|
||||
void DisplayWindow::showMax() {
|
||||
showFullScreen();
|
||||
}
|
||||
|
||||
void DisplayWindow::showGL() {
|
||||
gl_display->show();
|
||||
}
|
||||
|
||||
void DisplayWindow::createControls() {
|
||||
img_label = new QLabel(this);
|
||||
img_label->setGeometry(0,0,640, 480);
|
||||
}
|
||||
void DisplayWindow::displayImage(const QImage &img) {
|
||||
gl_display->setNewFrame(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());
|
||||
@@ -32,7 +39,6 @@ void DisplayWindow::displayImage(const QImage &img) {
|
||||
img_label->setPixmap(p);
|
||||
}
|
||||
|
||||
|
||||
void DisplayWindow::paintEvent(QPaintEvent *) {
|
||||
QPainter painter(this);
|
||||
painter.fillRect(QRect(QPoint(0, 0), size()), QColor(0,0,0));
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#define __DISPLAY_WINDOW_H__
|
||||
|
||||
#include"qtheaders.h"
|
||||
|
||||
#include "gl_display.h"
|
||||
|
||||
class DisplayWindow : public QDialog {
|
||||
Q_OBJECT
|
||||
@@ -21,8 +21,12 @@ public:
|
||||
void keyPressEvent(QKeyEvent *ke);
|
||||
void keyReleaseEvent(QKeyEvent *ke);
|
||||
void showMax();
|
||||
void showGL();
|
||||
|
||||
glDisplayWindow *gl_display;
|
||||
private:
|
||||
QLabel *img_label;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
#include <QtGui/QOpenGLContext>
|
||||
#include <QtGui/QOpenGLPaintDevice>
|
||||
#include <QtGui/QPainter>
|
||||
#include <iostream>
|
||||
|
||||
|
||||
|
||||
glDisplayWindow::glDisplayWindow(QWindow *parent)
|
||||
: QWindow(parent)
|
||||
@@ -24,18 +27,44 @@ void glDisplayWindow::render(QPainter *painter) {
|
||||
}
|
||||
|
||||
void glDisplayWindow::initialize() {
|
||||
resize(1280, 720);
|
||||
glClearDepth(1.0f);
|
||||
glClearColor(0, 0, 0, 0);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(0, width(), height(), 0, -1.0, 1.0);
|
||||
glEnable (GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
void glDisplayWindow::setNewFrame(const QImage &new_one) {
|
||||
frame_copy = new_one;
|
||||
}
|
||||
|
||||
unsigned int texID;
|
||||
|
||||
void glDisplayWindow::render() {
|
||||
if (!m_device)
|
||||
m_device = new QOpenGLPaintDevice;
|
||||
if(frame_copy.width()>100 && isVisible()) {
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
float aspect=(float)width()/(float)height();
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||
if(width() <= height())
|
||||
glOrtho ( -5.0, 5.0, -5.0/aspect, 5.0/aspect, -5.0, 5.0);
|
||||
else
|
||||
glOrtho (-5.0*aspect, 5.0*aspect, -5.0, 5.0, -5.0, 5.0);
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
if(frame_copy.width() > 25 && frame_copy.height() > 25) {
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glDrawPixels(frame_copy.width(), frame_copy.height(), GL_RGB,GL_UNSIGNED_BYTE,(unsigned char*)frame_copy.bits());
|
||||
glFlush();
|
||||
}
|
||||
}
|
||||
m_device->setPaintFlipped(true);
|
||||
m_device->setSize(size() * devicePixelRatio());
|
||||
m_device->setDevicePixelRatio(devicePixelRatio());
|
||||
|
||||
QPainter painter(m_device);
|
||||
render(&painter);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
|
||||
|
||||
#ifndef __GL_DISPLAY___H
|
||||
#define __GL_DISPLAY___H
|
||||
|
||||
#include <QtGui/QWindow>
|
||||
#include <QtGui/QOpenGLFunctions>
|
||||
|
||||
@@ -17,10 +21,10 @@ public:
|
||||
|
||||
virtual void render(QPainter *painter);
|
||||
virtual void render();
|
||||
|
||||
virtual void initialize();
|
||||
|
||||
void setAnimating(bool animating);
|
||||
void setNewFrame(const QImage &image);
|
||||
|
||||
public slots:
|
||||
void renderLater();
|
||||
@@ -33,8 +37,10 @@ protected:
|
||||
|
||||
private:
|
||||
bool m_animating;
|
||||
|
||||
QImage frame_copy;
|
||||
QOpenGLContext *m_context;
|
||||
QOpenGLPaintDevice *m_device;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -150,7 +150,6 @@ AC_MainWindow::AC_MainWindow(QWidget *parent) : QMainWindow(parent) {
|
||||
define_window = new DefineWindow(this);
|
||||
define_window->hide();
|
||||
define_window->main_window = this;
|
||||
gl_display = new glDisplayWindow();
|
||||
/*
|
||||
QString arg = "http://lostsidedead.com/ac/version.txt";
|
||||
QUrl url = QUrl::fromEncoded(arg.toLocal8Bit());
|
||||
@@ -1304,10 +1303,11 @@ void AC_MainWindow::setFrameIndex(int index) {
|
||||
frame_index = index;
|
||||
}
|
||||
|
||||
|
||||
void AC_MainWindow::updateFrame(QImage img) {
|
||||
if(playback->isStopped() == false) {
|
||||
disp->displayImage(img);
|
||||
disp2->displayImage(img);
|
||||
//disp2->displayImage(img);
|
||||
frame_index++;
|
||||
QString frame_string;
|
||||
QTextStream frame_stream(&frame_string);
|
||||
@@ -1764,5 +1764,5 @@ void AC_MainWindow::prev_filter() {
|
||||
}
|
||||
|
||||
void AC_MainWindow::showGLDisplay() {
|
||||
gl_display->show();
|
||||
disp->showGL();
|
||||
}
|
||||
|
||||
@@ -148,7 +148,6 @@ private:
|
||||
DefineWindow *define_window;
|
||||
ImageWindow *image_window;
|
||||
GotoWindow *goto_window;
|
||||
glDisplayWindow *gl_display;
|
||||
OptionsWindow *pref_window;
|
||||
cv::VideoCapture capture_camera, capture_video;
|
||||
cv::VideoWriter writer;
|
||||
|
||||
Reference in New Issue
Block a user