zoukankan      html  css  js  c++  java
  • Qt5和opencv常用函数

    convert Mat to QImage
    1 void MainWindow::nextFrame()
    2 {
    3     camera>>frame;//已在头文件里声明camera和frame
    4     if(!frame.empty())
    5     {
    6         image=Mat2QImage(frame);
    7         ui->label->setPixmap(QPixmap::fromImage(image));
    8     }
    9 }
    取一帧,并把其展示到label
     1 void MainWindow::on_pushButton_2_clicked()
     2 {
     3     if (capture.isOpened())
     4            capture.release();     //decide if capture is already opened; if so,close it
     5        capture.open(0);           //open the default camera
     6        if (capture.isOpened())
     7        {
     8            rate= capture.get(CV_CAP_PROP_FPS);
     9            capture >> frame;
    10            if (!frame.empty())
    11            {
    12 
    13                image = Mat2QImage(frame);
    14                ui->label->setPixmap(QPixmap::fromImage(image));
    15                QTimer *timer = new QTimer(this);
    16                timer->setInterval(1000/rate);   //set timer match with FPS
    17                connect(timer, SIGNAL(timeout()), this, SLOT(nextFrame()));
    18                timer->start();
    19            }
    20        }
    21 }
    摄像头预览函数
  • 相关阅读:
    PHP 单态设计模式
    五中常见的PHP设计模式
    PHP如何定义类及其成员属性与操作
    thinkphp 中MVC思想
    1.4 算法
    1.3 迭代器
    1.2 容器-container
    1.1 STL 概述
    2.3顺序容器-deque
    2.2 顺序容器-list
  • 原文地址:https://www.cnblogs.com/Songhe/p/10050874.html
Copyright © 2011-2022 走看看