MotionAwayPlugin::MotionAwayPlugin( QObject *parent, const char *name, const QStringList & /* args */ ) : Kopete::Plugin( MotionAwayPluginFactory::instance(), parent, name ) { kdDebug(14305) << k_funcinfo << "Called." << endl; /* This should be read from config someday may be */ m_width = DEF_WIDTH; m_height = DEF_HEIGHT; m_quality = DEF_QUALITY; m_maxChanges = DEF_CHANGES; m_gap = DEF_GAP; /* We haven't took the first picture yet */ m_tookFirst = false; m_captureTimer = new QTimer(this); m_awayTimer = new QTimer(this); connect( m_captureTimer, SIGNAL(timeout()), this, SLOT(slotCapture()) ); connect( m_awayTimer, SIGNAL(timeout()), this, SLOT(slotTimeout()) ); signal(SIGCHLD, SIG_IGN); m_imageRef.resize( m_width * m_height * 3); m_imageNew.resize( m_width * m_height * 3); m_imageOld.resize( m_width * m_height * 3); m_imageOut.resize( m_width * m_height * 3); kdDebug(14305) << k_funcinfo << "Opening Video4Linux Device" << endl; m_deviceHandler = open( videoDevice.latin1() , O_RDWR); if (m_deviceHandler < 0) { kdDebug(14305) << k_funcinfo << "Can't open Video4Linux Device" << endl; } else { kdDebug(14305) << k_funcinfo << "Worked! Setting Capture timers!" << endl; /* Capture first image, or we will get a alarm on start */ getImage (m_deviceHandler, m_imageRef, DEF_WIDTH, DEF_HEIGHT, IN_DEFAULT, NORM_DEFAULT, VIDEO_PALETTE_RGB24); /* We have the first image now */ m_tookFirst = true; m_wentAway = false; m_captureTimer->start( DEF_POLL_INTERVAL ); m_awayTimer->start( awayTimeout * 60 * 1000 ); } loadSettings(); connect(this, SIGNAL(settingsChanged()), this, SLOT( loadSettings() ) ); }
CaptureWgt::CaptureWgt( QWidget * parent ) : QMainWindow( parent ) { pd = new PD(); pd->ui.setupUi( this ); pd->video = 0; pd->imgScale = 1.0; pd->flipX = false; pd->flipY = false; pd->fps = 2.0; pd->imgSize = QSize( 80, 60 ); pd->ui.brightnessDw->setVisible( false ); pd->brightness = new BrightnessWgt( this ); pd->ui.brightnessDw->setWidget( pd->brightness ); connect( pd->brightness, SIGNAL(rangeChanged(const QPointF &)), this, SLOT(slotBrightnessChanged(const QPointF &)) ); connect( pd->ui.brightnessRange, SIGNAL(triggered()), this, SLOT(slotBrightness()) ); connect( pd->ui.resolution, SIGNAL(triggered()), this, SLOT(slotResolution()) ); connect( pd->ui.settings, SIGNAL(triggered()), this, SLOT(slotSettings()) ); Ui_CaptureWgt & ui = pd->ui; connect( ui.capture, SIGNAL(triggered()), this, SLOT(slotCapture()) ); pd->scene = new QGraphicsScene( pd->ui.view ); pd->scene->setBackgroundBrush( QBrush( Qt::gray ) ); pd->ui.view->setScene( pd->scene ); pd->image = new QGraphicsPixmapItem( 0, pd->scene ); pd->image->setPos( 0.0, 0.0 ); pd->lineX1 = new QGraphicsLineItem( pd->image, pd->scene ); pd->lineY1 = new QGraphicsLineItem( pd->image, pd->scene ); pd->lineX2 = new QGraphicsLineItem( pd->image, pd->scene ); pd->lineY2 = new QGraphicsLineItem( pd->image, pd->scene ); //pd->image->setPixmap( QPixmap( ":/images/camera.png" ) ); connect( pd->ui.flipX, SIGNAL(triggered()), this, SLOT(slotFlipX()) ); connect( pd->ui.flipY, SIGNAL(triggered()), this, SLOT(slotFlipY()) ); ui.view->installEventFilter( this ); connect( ui.pixmap, SIGNAL(triggered()), this, SLOT(slotSavePixmap()) ); }
CaptureWgt::CaptureWgt( QWidget * parent ) : QMainWindow( parent ) { pd = new PD(); pd->ui.setupUi( this ); pd->crossFname = "./video.ini"; pd->modifyLaserPos = false; pd->devMenu = 0; pd->resMenu = 0; pd->imgScale = 1.0; pd->drawArrow = false; pd->flipX = false; pd->flipY = false; pd->resolutionAcquired = false; pd->cap = new Capture( this ); pd->ui.brightnessDw->setVisible( false ); pd->brightness = new BrightnessWgt( this ); pd->ui.brightnessDw->setWidget( pd->brightness ); pd->cap->setBrightnessRange( pd->brightness->range() ); connect( pd->brightness, SIGNAL(rangeChanged(const QPointF &)), this, SLOT(slotBrightnessChanged(const QPointF &)) ); connect( pd->ui.brightnessRange, SIGNAL(triggered()), this, SLOT(slotBrightness()) ); Ui_CaptureWgt & ui = pd->ui; connect( ui.capture, SIGNAL(triggered()), this, SLOT(slotCapture()) ); connect( ui.settings, SIGNAL(triggered()), this, SLOT(slotSettings()) ); connect( ui.cross, SIGNAL(triggered()), this, SLOT(slotCrossEmphasis()) ); pd->scene = new QGraphicsScene( pd->ui.view ); pd->scene->setBackgroundBrush( QBrush( Qt::gray ) ); pd->ui.view->setScene( pd->scene ); pd->image = new QGraphicsPixmapItem( 0, pd->scene ); pd->image->setPos( 0.0, 0.0 ); pd->lineX1 = new QGraphicsLineItem( pd->image, pd->scene ); pd->lineY1 = new QGraphicsLineItem( pd->image, pd->scene ); pd->lineX2 = new QGraphicsLineItem( pd->image, pd->scene ); pd->lineY2 = new QGraphicsLineItem( pd->image, pd->scene ); pd->arrow = new QGraphicsPolygonItem( pd->image, pd->scene ); // This is for laser spot position. pd->laserPosImage = new QGraphicsPixmapItem( 0, pd->scene ); pd->laserPosImage->setPixmap( QPixmap( ":/images/laser.png" ) ); pd->laserPosImage->setPos( -pd->laserPosImage->pixmap().width()/2, -pd->laserPosImage->pixmap().height()/2 ); pd->laserPosImage->setVisible( false ); connect( pd->ui.flipX, SIGNAL(triggered()), this, SLOT(slotFlipX()) ); connect( pd->ui.flipY, SIGNAL(triggered()), this, SLOT(slotFlipY()) ); pd->cap = new Capture( this ); listDevices(); connect( pd->cap, SIGNAL(frame(const QImage &)), this, SLOT(slotFrame(const QImage &)) ); ui.view->installEventFilter( this ); pd->inMenu = new QMenu( this ); ui.input->setMenu( pd->inMenu ); QAction * a = new QAction( "Default", this ); a->setCheckable( true ); a->setChecked( true ); pd->inMenu->addAction( a ); pd->inList << a; a = new QAction( "Usb", this ); a->setCheckable( true ); pd->inMenu->addAction( a ); pd->inList << a; a = new QAction( "S-Video", this ); a->setCheckable( true ); pd->inMenu->addAction( a ); pd->inList << a; a = new QAction( "Composite", this ); a->setCheckable( true ); pd->inMenu->addAction( a ); pd->inList << a; for ( int i=0; i<pd->inList.size(); i++ ) { QAction * a = pd->inList[i]; connect( a, SIGNAL(triggered()), this, SLOT(slotInput()) ); } // ƒействи¤ соответствующие фильтрам. pd->filterList << ui.equalizeHist; pd->filterList << ui.fullContrast; pd->filterList << ui.sobel; pd->filterList << ui.median; pd->filterList << ui.timeSmooth; pd->filterList << ui.highPass; pd->filterList << ui.surface; pd->filterList << ui.brightnessRange; for ( int i=0; i<pd->filterList.size(); i++ ) { QAction * a = pd->filterList[i]; connect( a, SIGNAL(triggered()), this, SLOT(slotFilter()) ); } connect( ui.pixmap, SIGNAL(triggered()), this, SLOT(slotPixmap()) ); QToolButton * btn = qobject_cast<QToolButton *>(ui.toolBar->widgetForAction(ui.input)); if ( btn ) btn->setPopupMode(QToolButton::InstantPopup); btn = qobject_cast<QToolButton *>(ui.toolBar->widgetForAction(ui.device)); if ( btn ) btn->setPopupMode(QToolButton::InstantPopup); btn = qobject_cast<QToolButton *>(ui.toolBar->widgetForAction(ui.resolution)); if ( btn ) btn->setPopupMode(QToolButton::InstantPopup); //pd->usbLight = new LightIcon( this ); //ui.toolBar->addWidget( pd->usbLight ); // Laser spot handling. QMenu * m = new QMenu( this ); a = m->addAction( "Set laser spot position" ); connect( a, SIGNAL(triggered()), this, SLOT(slotSetLaserSpot()) ); btn = qobject_cast<QToolButton *>(ui.toolBar->widgetForAction(ui.laser)); btn->setPopupMode( QToolButton::MenuButtonPopup ); ui.laser->setMenu( m ); updateCrossPos(); }