Fixed qt application, now working as a general webcam

This commit is contained in:
Harald Hvaal 2007-02-23 20:37:11 +00:00
parent 1228a70cb5
commit 7cb6c5f44f
6 changed files with 288 additions and 12 deletions

View File

@ -8,6 +8,6 @@ set(libtest_DIR libtest)
get_filename_component(libtest_ABSOLUTE ${libtest_DIR} ABSOLUTE)
add_subdirectory(${libtest_ABSOLUTE})
#set(qt_DIR qt)
#get_filename_component(qt_ABSOLUTE ${qt_DIR} ABSOLUTE)
#add_subdirectory(${qt_ABSOLUTE})
set(qt_DIR qt)
get_filename_component(qt_ABSOLUTE ${qt_DIR} ABSOLUTE)
add_subdirectory(${qt_ABSOLUTE})

View File

@ -11,37 +11,35 @@ include_directories( ${SDL_INCLUDE_DIR} ${SDLIMAGE_INCLUDE_DIR} )
# the next line sets up include and link directories and defines some variables that we will use.
# you can modify the behavior by setting some variables, e.g.
set(QT_USE_QTOPENGL TRUE)
#set(QT_USE_QTOPENGL TRUE)
# -> this will cause cmake to include and link against the OpenGL module
include(${QT_USE_FILE})
# the variable "qtproject_SRCS" contains all .cpp files of this project
set(aigoqt_SRCS
aigoqt.cpp
main.cpp
)
#ui
set(aigoqt_UIS
main.ui
)
qt4_wrap_ui(aigoqt_UIS_H ${aigoqt_UIS})
set(CMAKE_INCLUDE_CURRENT_DIR ON)
#moc
qt4_automoc(${aigoqt_SRCS})
#resources
qt4_add_resources(aigoqt_RESOURCES resources)
#qt4_add_resources(aigoqt_RESOURCES resources)
link_directories(${effector_ABSOLUTE})
include_directories(
${QT_INCLUDE_DIR}
${QT_QTOPENGL_INCLUDE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
#${dgl_ABSOLUTE}
${current_demo_dir}
../lib/
)
add_executable(aigoqt ${aigoqt_SRCS} ${aigoqt_UIS_H} ${aigoqt_RESOURCES})
add_executable(aigoqt ${aigoqt_SRCS} ${aigoqt_UIS_H})
target_link_libraries(aigoqt ${QT_LIBRARIES} aigolib)

38
qt/aigoqt.cpp Normal file
View File

@ -0,0 +1,38 @@
#include "aigoqt.h"
#include <QtDebug>
AigoQt::AigoQt(QWidget *parent)
: QMainWindow(parent)
{
setupUi(this);
cam = new Quickcam("/dev/video0");
timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(updateImage()));
timer->start(200);
}
AigoQt::~AigoQt( void )
{
delete cam;
}
void AigoQt::updateImage( void )
{
cam->update();
SDL_Surface *s = cam->getSurface();
image->setPixmap(QPixmap::fromImage(QImage((uchar*)s->pixels, s->w, s->h, QImage::Format_RGB32)));
}
void AigoQt::on_buttonSetCorners_clicked( void )
{
}
void AigoQt::on_slider_valueChanged( int value)
{
timer->stop();
timer->start(value);
}
#include "aigoqt.moc"

30
qt/aigoqt.h Normal file
View File

@ -0,0 +1,30 @@
#ifndef _AIGOQT_H_
#define _AIGOQT_H_
#include <QMainWindow>
#include <ui_main.h>
#include <quickcam.h>
#include <QTimer>
class AigoQt : public QMainWindow, public Ui::AigoQt
{
Q_OBJECT
public:
AigoQt(QWidget *parent = NULL);
virtual ~AigoQt( void );
private slots:
void on_buttonSetCorners_clicked( void );
void on_slider_valueChanged(int value);
void updateImage();
private:
Quickcam *cam;
QTimer *timer;
};
#endif /* ifndef _AIGOQT_H_ */

20
qt/main.cpp Normal file
View File

@ -0,0 +1,20 @@
#include <QApplication>
//#include <QGLFormat>
#include "aigoqt.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
/*
QGLFormat f;
f.setDoubleBuffer(true);
f.setRgba(true);
f.setDepth(true);
QGLFormat::setDefaultFormat(f);
*/
AigoQt vindu;
vindu.show();
return app.exec();
}

190
qt/main.ui Normal file
View File

@ -0,0 +1,190 @@
<ui version="4.0" >
<class>AigoQt</class>
<widget class="QMainWindow" name="AigoQt" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>849</width>
<height>644</height>
</rect>
</property>
<property name="windowTitle" >
<string>AigoQT</string>
</property>
<widget class="QWidget" name="centralwidget" >
<layout class="QGridLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="1" column="1" >
<widget class="QLCDNumber" name="lcdNumber" />
</item>
<item row="1" column="0" >
<widget class="QSlider" name="slider" >
<property name="minimum" >
<number>10</number>
</property>
<property name="maximum" >
<number>400</number>
</property>
<property name="singleStep" >
<number>10</number>
</property>
<property name="pageStep" >
<number>50</number>
</property>
<property name="value" >
<number>200</number>
</property>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QGroupBox" name="groupBox_2" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>4</hsizetype>
<vsizetype>5</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title" >
<string>Controls</string>
</property>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QPushButton" name="buttonSetCorners" >
<property name="text" >
<string>Set corners</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="0" column="0" >
<widget class="QGroupBox" name="groupBox" >
<property name="minimumSize" >
<size>
<width>700</width>
<height>550</height>
</size>
</property>
<property name="title" >
<string>Preview</string>
</property>
<widget class="QLabel" name="image" >
<property name="geometry" >
<rect>
<x>40</x>
<y>40</y>
<width>640</width>
<height>480</height>
</rect>
</property>
<property name="minimumSize" >
<size>
<width>640</width>
<height>480</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>640</width>
<height>480</height>
</size>
</property>
<property name="text" >
<string/>
</property>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>849</width>
<height>25</height>
</rect>
</property>
<widget class="QMenu" name="menu_File" >
<property name="title" >
<string>&amp;File</string>
</property>
<addaction name="action_Quit" />
</widget>
<addaction name="menu_File" />
</widget>
<widget class="QStatusBar" name="statusbar" />
<action name="action_Quit" >
<property name="text" >
<string>&amp;Quit</string>
</property>
</action>
</widget>
<resources/>
<connections>
<connection>
<sender>slider</sender>
<signal>valueChanged(int)</signal>
<receiver>lcdNumber</receiver>
<slot>display(int)</slot>
<hints>
<hint type="sourcelabel" >
<x>702</x>
<y>618</y>
</hint>
<hint type="destinationlabel" >
<x>727</x>
<y>618</y>
</hint>
</hints>
</connection>
<connection>
<sender>slider</sender>
<signal>sliderMoved(int)</signal>
<receiver>lcdNumber</receiver>
<slot>display(int)</slot>
<hints>
<hint type="sourcelabel" >
<x>542</x>
<y>621</y>
</hint>
<hint type="destinationlabel" >
<x>829</x>
<y>628</y>
</hint>
</hints>
</connection>
</connections>
</ui>