#include "SaveMoveImageEngine.h" using namespace ai_matrix; SaveMoveImageEngine::SaveMoveImageEngine() {} SaveMoveImageEngine::~SaveMoveImageEngine() {} APP_ERROR SaveMoveImageEngine::Init() { strPort0_ = engineName_ + "_" + std::to_string(engineId_) + "_0"; this->baseConfig_ = Config::getins()->getBaseConfig(); vecCompressionParams_.push_back(cv::IMWRITE_JPEG_QUALITY); //选择jpeg vecCompressionParams_.push_back(this->iPicQuality_); //图片质量 LogInfo << "SaveMoveImageEngine Init ok"; return APP_ERR_OK; } APP_ERROR SaveMoveImageEngine::DeInit() { LogInfo << "SaveMoveImageEngine DeInit ok"; return APP_ERR_OK; } APP_ERROR SaveMoveImageEngine::Process() { int iRet = APP_ERR_OK; while (!isStop_) { std::shared_ptr pvoidd = nullptr; inputQueMap_[strPort0_]->pop(pvoidd); if (nullptr == pvoidd) { usleep(1000); continue; } std::shared_ptr pSaveImgData = std::static_pointer_cast(pvoidd); //图片绝对路径 if (pSaveImgData->strFilePath.back() != '/') { pSaveImgData->strFilePath += "/"; } std::string strImgFilePath = pSaveImgData->strFilePath + pSaveImgData->strFileName; if (!FileUtil::getins()->createDirPath(pSaveImgData->strFilePath)) { LogError << " 创建图片存储目录失败:" << strImgFilePath; continue; } if (!pSaveImgData->cvImage.empty()) { if (cv::imwrite(strImgFilePath, pSaveImgData->cvImage, this->vecCompressionParams_)) { // std::shared_ptr pToStep1Data = std::make_shared(); // pToStep1Data->bIsEnd = pSaveImgData->bIsEnd; // pToStep1Data->strImagePath = pSaveImgData->strFilePath; // pToStep1Data->strImageName = pSaveImgData->strFileName; // // outputQueMap_[strPort0_]->push(std::static_pointer_cast(pToStep1Data), true); // LogInfo << "存储:" << strImgFilePath; } else { LogError << "图片存储失败:" << strImgFilePath; } } } return APP_ERR_OK; }