根据时间戳保存图片 20191018

根据时间戳保存图片 

//保存人脸图片并 返回图片名
QString c_thread::CameraThread::saveObjFacePicAndReturnFilePath()
{
    QString picFileDir1 = QCoreApplication::applicationDirPath();
    QDateTime qdt1 = QDateTime::currentDateTime();
    QString timeStr = qdt1.toString("yyyyMMddhhmmsszzz");
    QString picStr = timeStr.append(".jpg");

    //qDebug() << picStr;
    picFileDir1.append("/face_data/");
    picFileDir1.append(picStr).replace("/","//");;
    qDebug() << picFileDir1;

    if (photograph2_img.empty())
    {
        qDebug() << "请打开摄像头";
        return "";
    }
    else
    {
        qDebug() << "save pic";
        cv::resize(photograph2_img, photograph2_img, cv::Size(100, 100));
        cv::imwrite(picFileDir1.toStdString(), photograph2_img);
    }
    return picFileDir1;
}

//在QLabel中显示图片
void c_thread::CameraThread::showPhotographOnLabel(QLabel *qLabelParam1)
{
    if (face_img.empty())
    {
        return;
    }

    photograpg_img = face_img.clone();
    photograph2_img = face_img.clone();
    qm_img::DisplayImg(photograpg_img, qLabelParam1);
}

 

posted @ 2019-10-18 18:42  西北逍遥  阅读(836)  评论(0编辑  收藏  举报