103 lines
2.4 KiB
C++
103 lines
2.4 KiB
C++
/*
|
|
* @Date: 2024-09-04 18:58:05
|
|
* @LastEditors: Jacky
|
|
* @LastEditTime: 2024-09-13 13:38:29
|
|
* @FilePath: /GeneralTracker/Universal/CModulePostVpss.cpp
|
|
*/
|
|
#include "CModulePostVpss.h"
|
|
#include "IConfiguration.h"
|
|
#include "ImageProc.hpp"
|
|
|
|
int CModulePostVpss::create(const char* name){
|
|
m_pcName = std::string(name);
|
|
m_pSelfQueue.queueInit(m_pcName, QUEUE_SIZE);
|
|
return 0;
|
|
}
|
|
|
|
int CModulePostVpss::destroy(){
|
|
stop();
|
|
return 0;
|
|
}
|
|
|
|
int CModulePostVpss::set_data(const char* data, void* value){
|
|
return 0;
|
|
}
|
|
|
|
char* CModulePostVpss::get_data(){
|
|
return nullptr;
|
|
}
|
|
|
|
int CModulePostVpss::start(const char* data){
|
|
if(_vi_thread){
|
|
return -1;
|
|
}
|
|
|
|
_thread_flag = true;
|
|
_vi_thread = new std::thread(std::bind(&CModulePostVpss::moduleThread, std::ref(*this)));
|
|
return 0;
|
|
}
|
|
int CModulePostVpss::stop(){
|
|
if(_vi_thread){
|
|
_thread_flag = false;
|
|
_vi_thread->join();
|
|
delete _vi_thread;
|
|
_vi_thread = nullptr;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
void CModulePostVpss::push_data(DataProcessBase *src, pool::IMemoryBlock* block){
|
|
if(static_cast<IConfiguration::MODULE_TYPE_E>(src->getType()) == IConfiguration::MODULE_OSD){
|
|
//主通道数据
|
|
m_pSelfQueue.sendFrame(block);
|
|
}else{
|
|
/**
|
|
* 叠加通道数据,只保留一帧
|
|
* 只保留数据指针,需要加锁(看是否需要进行数据拷贝)
|
|
*/
|
|
_pip_block = block;
|
|
}
|
|
}
|
|
|
|
int CModulePostVpss::zoom(GD_VIDEO_FRAME_S *frame){
|
|
if(_zoom_value == _zoom_current_value){
|
|
return 0;
|
|
}
|
|
|
|
//保存变倍系数
|
|
_zoom_current_value = _zoom_value;
|
|
GD_SIZE size = {frame->u32Width, frame->u32Height};
|
|
GD_RECT rect = code::getZoomArea(_zoom_current_value, &size, 2);
|
|
code::imageCropScale(frame, frame->u32Width, frame->u32Height, &rect);
|
|
return 0;
|
|
}
|
|
|
|
int CModulePostVpss::pip(GD_VIDEO_FRAME_S *frame){
|
|
if(_pip_block == nullptr || !_pip_enable){
|
|
return 0;
|
|
}
|
|
|
|
|
|
return 0;
|
|
}
|
|
|
|
int CModulePostVpss::moduleThread(){
|
|
int timeout = 100;
|
|
while(_thread_flag){
|
|
pool::IMemoryBlock* mb = m_pSelfQueue.getFrame(timeout);
|
|
if(mb){
|
|
AdditionalImp* imp = mb->data();
|
|
GD_VIDEO_FRAME_S *frame = mb->yuv();
|
|
|
|
//电子变倍
|
|
zoom(frame);
|
|
//画中画
|
|
pip(frame);
|
|
|
|
push_input_pipe(mb);
|
|
m_pSelfQueue.releaseFrame(mb);
|
|
}
|
|
}
|
|
return 0;
|
|
}
|