Example #1
0
void MainWindow::callVideoWriteDialog(bool new_session)
{
    if(new_session) {
        if(m_writeDialog.exec() == QDialog::Accepted)   {
            if(pt_videowriter->startRecordToFile(m_writeDialog.getFileName(),
                                                 m_writeDialog.getCodec(),
                                                 m_writeDialog.getFPS() > 0.0 ? m_writeDialog.getFPS() : pt_videocapture->getFPS(),
                                                 pt_videocapture->getFrameSize())) {
                pt_stasm->setCompositionMode(true);
                connect(pt_stasm, SIGNAL(imageComposed(cv::Mat,const float*,uint)), pt_videowriter, SLOT(updateFrame(cv::Mat,const float*,uint)));
                connect(pt_videocapture, SIGNAL(frameUpdated(cv::Mat)), pt_stasm, SLOT(takeWholeImage(cv::Mat)));
            } else {
                pt_writeAct->setChecked(false);
                QMessageBox msg(QMessageBox::Information, tr("Info"), tr("Can not save file"), QMessageBox::Cancel);
                msg.exec();
            }
        }
    } else {
        pt_stasm->setCompositionMode(false);
        disconnect(pt_videocapture, SIGNAL(frameUpdated(cv::Mat)), pt_stasm, SLOT(takeWholeImage(cv::Mat)));
        disconnect(pt_stasm, SIGNAL(landmarksUpdated(cv::Mat,const float*,uint)), pt_videowriter, SLOT(updateFrame(cv::Mat,const float*,uint)));
        QTimer::singleShot(0, pt_videowriter, SLOT(release()));
    }

}
Example #2
0
void MainWindow::createThreads()
{
    pt_videoThread = new QThread(this);
    pt_videocapture = new QVideoCapture();
    pt_videocapture->moveToThread(pt_videoThread);
    connect(pt_videoThread, SIGNAL(started()), pt_videocapture, SLOT(initializeTimer()));
    connect(pt_videoThread, SIGNAL(finished()), pt_videocapture, SLOT(close()));
    connect(pt_videoThread, SIGNAL(finished()), pt_videocapture, SLOT(deleteLater()));

    pt_stasmThread = new QThread(this);
    pt_stasm = new QStasm();
    pt_stasm->moveToThread(pt_stasmThread);
    connect(pt_stasmThread, SIGNAL(finished()), pt_stasm, SLOT(deleteLater()));

    pt_opencvThread = new QThread(this);
    pt_opencv = new QOpencvProcessor();
    pt_opencv->moveToThread(pt_opencvThread);
    connect(pt_opencvThread, SIGNAL(finished()), pt_opencv, SLOT(deleteLater())); 

    pt_videowriter = new QVideoWriter();
    pt_videowriter->moveToThread(pt_videoThread);
    connect(pt_videoThread, SIGNAL(finished()), pt_videowriter, SLOT(deleteLater()));

    pt_facetracker = new QFaceTracker();
    #ifdef CASCADECLASSIFIERS_PATH
        bool res = pt_facetracker->loadFaceClassifier(QString("%1%2").arg(CASCADECLASSIFIERS_PATH, "/haarcascade_frontalface_alt2.xml").toStdString());
        qWarning("Face classifier was %s", res ? "loaded": "not loaded");
        res = pt_facetracker->loadEyeClassifier(QString("%1%2").arg(CASCADECLASSIFIERS_PATH, "/haarcascade_eye.xml").toStdString());
        qWarning("Eye classifier was %s", res ? "loaded": "not loaded");
    #else
        pt_facetracker->loadFaceClassifier("data/haarcascade_frontalface_alt2.xml");
        pt_facetracker->loadEyeClassifier("data/haarcascade_eye.xml");
    #endif
    pt_facetracker->moveToThread(pt_stasmThread);
    connect(pt_stasmThread, SIGNAL(finished()), pt_facetracker, SLOT(deleteLater()));

    qRegisterMetaType<cv::Mat>("cv::Mat");
    qRegisterMetaType<cv::RotatedRect>("cv::RotatedRect");
    connect(pt_videocapture, SIGNAL(frameUpdated(cv::Mat)), pt_opencv, SLOT(custom_algorithm(cv::Mat)), Qt::BlockingQueuedConnection);
    connect(pt_videocapture, SIGNAL(frameUpdated(cv::Mat)), pt_facetracker, SLOT(updateImage(cv::Mat)), Qt::BlockingQueuedConnection);
    connect(pt_facetracker, SIGNAL(faceUpdated(cv::Mat,cv::RotatedRect)), pt_stasm, SLOT(search_points(cv::Mat, cv::RotatedRect)));
    connect(pt_stasm, SIGNAL(landmarksUpdated(cv::Mat,const float*,uint)), ui->display, SLOT(updateImage(cv::Mat,const float*,uint)));
    connect(pt_stasm, SIGNAL(displacementsUpdated(const float*,uint)), ui->waterfall, SLOT(updateNextColumn(const float*,uint)));

    qRegisterMetaType<DataSeria>("DataSeria");
    pt_seriesanalyzer = new QSeriesAnalyzer();
    pt_seriesanalyzer->moveToThread(pt_opencvThread);
    connect(pt_opencvThread, SIGNAL(finished()), pt_seriesanalyzer, SLOT(deleteLater()));

    pt_videoThread->start();   
    pt_opencvThread->start();
    pt_stasmThread->start(QThread::HighPriority);
}
Example #3
0
void PicManager::readFile(const QString &fullPath)
{
    QFileInfo fileInfo(fullPath);
    if(curPath == fileInfo.absoluteFilePath() )//! if the image needs refresh?
        return;

    curPath = fileInfo.absoluteFilePath();
    curName = fileInfo.fileName();

    curImage->recycle();
    curImage = ImageFactory::getImageWrapper(curPath);

    if(curImage->isAnimation()) {
        connect(curImage, SIGNAL(animationUpdated()), SLOT(updateAnimation()));
        curImage->startAnimation();
    } else if (curImage->frameCount() > 1){ // like ico format
        connect(curImage, SIGNAL(frameUpdated()), SLOT(updateImage()));
    }

    QImage image = curImage->currentImage();
    QString errorMsg = image.isNull() ? Global::LoadFileErrorInfo().arg(curPath)
                                 : QString::null;
    loadImage(image, errorMsg);
//     state = image.isNull() ? FileNoPicture : FilePicture;
    emit imageChanged(curName);
}
	void VideoControls::oneFrameForward(void)
	{
		if(videoStreamIsValid())
		{
			stream->readNextFrame();

			// stop if over :
			if(stream->isOver())
				stop();

			emit frameUpdated();
		}
	}
	void VideoControls::timerTick(void)
	{
		if(playing && !timeSlider.isSliderDown() && stream!=NULL)
		{
			stream->readNextFrame();
			timeSlider.setValue(stream->getCurrentTimeSec());

			int 	c = stream->getCurrentTimeSec(),
				t = stream->getVideoDurationSec();
			timeLabel.setText(tr("%1 : %2").arg(c).arg(t));

			// stop if over :
			if(stream->isOver())
				stop();

			emit frameUpdated();
		}
	}
	void VideoControls::stop(void)
	{
		if(stream!=NULL)
		{
			playing = false;
			timer.stop();

			playButton.setText("Play");
			timeSlider.setValue(0);

			int 	t = stream->getVideoDurationSec();
			timeLabel.setText(tr("0 : %1").arg(t));

			stream->seek(0.0f);
			stream->readNextFrame();

			emit frameUpdated();
		}
	}
QtkMjpgStreamer::QtkMjpgStreamer(QTcpSocket* socket, QtkVideoServer* videoServer)
{
    this->m_error = errNoError;
    this->m_socket = socket;
    if(videoServer)
    {
        this->m_videoServer = videoServer;        
    }
    else
    {
        this->m_videoServer = 0;
    }
    this->m_streamerState = 0;
    this->m_frameReady = false;
    this->m_frameDelayPreset = 0;    
    this->setStreamerState(sstStart);

	connect(videoServer, SIGNAL(frameUpdated()), this, SLOT(OnFrameUpdated()));
    QTimer::singleShot(FRAME_TIMER_PRESCALER, this, SLOT(OnStreamerRun()));
}
Example #8
0
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
 **************************************************************************/
#include "videowidget.h"

//KDE
#include <KDebug>

//SFLPhone
#include "../lib/videorenderer.h"

///Constructor
VideoWidget::VideoWidget(QWidget* parent ,* renderer) : QWidget(parent),m_Image(nullptr),m_pRenderer(renderer) {
   setMinimumSize(200,200);
   setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
   connect(m_pRenderer,SIGNAL(frameUpdated()),this,SLOT(updateFrame()));
   connect(Video::Manager::instance(),SIGNAL(videoStopped()),this,SLOT(stop()));
   connect(Video::Manager::instance(),SIGNAL(videoCallInitiated(Video::Renderer*)),this,SLOT(setRenderer(Video::Renderer*)));
}

///Set widget renderer
void VideoWidget::setRenderer(* renderer)
{
   disconnect(m_pRenderer,SIGNAL(frameUpdated()),this,SLOT(updateFrame()));
   m_pRenderer = renderer;
   connect(m_pRenderer,SIGNAL(frameUpdated()),this,SLOT(updateFrame()));
}

///Repaint the widget
void VideoWidget::update() {
   QPainter painter(this);