|
|
|
@ -51,7 +51,7 @@ UnderStitch::UnderStitch(std::string cachedir)
|
|
|
|
_cacheDir = cachedir;
|
|
|
|
_cacheDir = cachedir;
|
|
|
|
|
|
|
|
|
|
|
|
// 创建缓存对象
|
|
|
|
// 创建缓存对象
|
|
|
|
_cache = new FileCache<FrameCache>(100, cachedir);
|
|
|
|
_cache = new FileCache<FrameCache>(500, cachedir);
|
|
|
|
|
|
|
|
|
|
|
|
_GeoSolver = new GeoSolver();
|
|
|
|
_GeoSolver = new GeoSolver();
|
|
|
|
|
|
|
|
|
|
|
|
@ -237,8 +237,8 @@ UPanInfo UnderStitch::InitMap_SCAN(FrameInfo para, float ptRange)
|
|
|
|
float min_y = min(min(ct_geo_left.y, ct_geo_right.y), min(ct_geo_left_fly.y, ct_geo_right_fly.y));
|
|
|
|
float min_y = min(min(ct_geo_left.y, ct_geo_right.y), min(ct_geo_left_fly.y, ct_geo_right_fly.y));
|
|
|
|
float max_y = max(max(ct_geo_left.y, ct_geo_right.y), max(ct_geo_left_fly.y, ct_geo_right_fly.y));
|
|
|
|
float max_y = max(max(ct_geo_left.y, ct_geo_right.y), max(ct_geo_left_fly.y, ct_geo_right_fly.y));
|
|
|
|
|
|
|
|
|
|
|
|
float E_range = (max_x - min_x) * 1.2;
|
|
|
|
float E_range = (max_x - min_x) * 1.3;
|
|
|
|
float N_range = (max_y - min_y) * 1.2;
|
|
|
|
float N_range = (max_y - min_y) * 1.3;
|
|
|
|
|
|
|
|
|
|
|
|
// 不损失分辨率的全景图尺寸
|
|
|
|
// 不损失分辨率的全景图尺寸
|
|
|
|
panPara.m_pan_width = E_range / scale_max;
|
|
|
|
panPara.m_pan_width = E_range / scale_max;
|
|
|
|
@ -381,7 +381,7 @@ UPanInfo UnderStitch::Init(FrameInfo info)
|
|
|
|
|
|
|
|
|
|
|
|
// 摆扫45度初始化地图尺寸
|
|
|
|
// 摆扫45度初始化地图尺寸
|
|
|
|
#ifdef SCAN_MODE
|
|
|
|
#ifdef SCAN_MODE
|
|
|
|
_panPara = InitMap_SCAN(info,45);
|
|
|
|
_panPara = InitMap_SCAN(info,42);
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
// 常规初始化全景图(基于内存限制)
|
|
|
|
// 常规初始化全景图(基于内存限制)
|
|
|
|
_panPara = InitMap(info);
|
|
|
|
_panPara = InitMap(info);
|
|
|
|
@ -399,6 +399,9 @@ UPanInfo UnderStitch::Init(FrameInfo info)
|
|
|
|
_config.bUseBA = false;
|
|
|
|
_config.bUseBA = false;
|
|
|
|
_config.bOutFrameTile = false;
|
|
|
|
_config.bOutFrameTile = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
infoLast = info;
|
|
|
|
|
|
|
|
|
|
|
|
LOG_INFO("Init success");
|
|
|
|
LOG_INFO("Init success");
|
|
|
|
return _panPara;
|
|
|
|
return _panPara;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -443,12 +446,43 @@ bool UnderStitch::isFrameInPanView(const cv::Size& frameSize, const cv::Mat& H,
|
|
|
|
return false; // 需要触发处理
|
|
|
|
return false; // 需要触发处理
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cv::Mat gammaCorrect(const cv::Mat& src, double gamma)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
cv::Mat lut(1, 256, CV_8U);
|
|
|
|
|
|
|
|
for (int i = 0; i < 256; i++)
|
|
|
|
|
|
|
|
lut.at<uchar>(i) = pow(i / 255.0, gamma) * 255.0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
cv::LUT(src, lut, dst);
|
|
|
|
|
|
|
|
return dst.clone();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SINT32 UnderStitch::Run(GD_VIDEO_FRAME_S frame, FrameInfo para)
|
|
|
|
SINT32 UnderStitch::Run(GD_VIDEO_FRAME_S frame, FrameInfo para)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
stopWatch sw;
|
|
|
|
LOG_INFO("Run Frame {}", para.nFrmID);
|
|
|
|
LOG_INFO("Run Frame {}", para.nFrmID);
|
|
|
|
TransPitch(para);
|
|
|
|
TransPitch(para);
|
|
|
|
|
|
|
|
|
|
|
|
run_test(para);
|
|
|
|
|
|
|
|
|
|
|
|
LOG_INFO("B:{} L:{} H:{} Yaw:{} Pitch:{} Roll:{},fAz:{} fPt:{},camf:{},camPixel:{}",
|
|
|
|
|
|
|
|
para.craft.stPos.B, para.craft.stPos.L, para.craft.stPos.H, para.craft.stAtt.fYaw, para.craft.stAtt.fPitch, para.craft.stAtt.fRoll,
|
|
|
|
|
|
|
|
para.servoInfo.fServoAz, para.servoInfo.fServoPt,para.camInfo.nFocus,para.camInfo.fPixelSize);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//run_test(para);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 统计扫描方向
|
|
|
|
|
|
|
|
int dir = StatScanDir(para);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (dir == 1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("++++++++++++++++++++\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("--------------------\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//// 视频帧筛选
|
|
|
|
//// 视频帧筛选
|
|
|
|
if (!FilterFrame(para))
|
|
|
|
if (!FilterFrame(para))
|
|
|
|
@ -473,6 +507,20 @@ SINT32 UnderStitch::Run(GD_VIDEO_FRAME_S frame, FrameInfo para)
|
|
|
|
cv::Size(_panPara.m_pan_width, _panPara.m_pan_height)))
|
|
|
|
cv::Size(_panPara.m_pan_width, _panPara.m_pan_height)))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//cv::Mat pan_ds;
|
|
|
|
|
|
|
|
// Mat pan_rgb_ds(cv::Size(panImage.cols / 2, panImage.rows / 2),CV_8UC3);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// cv::resize(panImage, pan_ds, cv::Size(panImage.cols / 2, panImage.rows / 2));
|
|
|
|
|
|
|
|
// cv::cvtColor(pan_ds, pan_rgb_ds, cv::COLOR_BGRA2BGR);
|
|
|
|
|
|
|
|
// imwrite(_outDir + "/" + _filename + std::to_string(_lastFrameKey) + "_z" + "_pan.png", pan_rgb_ds);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//OptAndOutCurrPan(_baCurrViewKey);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// cv::resize(panImage, pan_ds, cv::Size(panImage.cols / 2, panImage.rows / 2));
|
|
|
|
|
|
|
|
//cv::cvtColor(pan_ds, pan_rgb_ds, cv::COLOR_BGRA2BGR);
|
|
|
|
|
|
|
|
// imwrite(_outDir + "/" + _filename + std::to_string(_lastFrameKey) + "_z" + "_pan_AFTER.png", pan_rgb_ds);
|
|
|
|
|
|
|
|
|
|
|
|
LOG_INFO("Frame {} is out of pan view, reinitializing projection parameters", para.nFrmID);
|
|
|
|
LOG_INFO("Frame {} is out of pan view, reinitializing projection parameters", para.nFrmID);
|
|
|
|
|
|
|
|
|
|
|
|
// 输出当前所有瓦片,再不输出就会丢失当前全景中的瓦片
|
|
|
|
// 输出当前所有瓦片,再不输出就会丢失当前全景中的瓦片
|
|
|
|
@ -486,6 +534,8 @@ SINT32 UnderStitch::Run(GD_VIDEO_FRAME_S frame, FrameInfo para)
|
|
|
|
_googleProduct.ExportTileSet(mat_pan, mat_mask, tilesvec, outdirpath, filename);
|
|
|
|
_googleProduct.ExportTileSet(mat_pan, mat_mask, tilesvec, outdirpath, filename);
|
|
|
|
}, "ExportTileSet");
|
|
|
|
}, "ExportTileSet");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// _googleProduct.ExportTileSet(panImage, panMask, _taskTilesVec, _outDir, _filename + std::to_string(_lastFrameKey));
|
|
|
|
// _googleProduct.ExportTileSet(panImage, panMask, _taskTilesVec, _outDir, _filename + std::to_string(_lastFrameKey));
|
|
|
|
|
|
|
|
|
|
|
|
// 重新初始化投影参数
|
|
|
|
// 重新初始化投影参数
|
|
|
|
@ -514,9 +564,24 @@ SINT32 UnderStitch::Run(GD_VIDEO_FRAME_S frame, FrameInfo para)
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//if (dir == -1)
|
|
|
|
|
|
|
|
//{
|
|
|
|
|
|
|
|
// cv::Mat src1(frame.u32Height, frame.u32Width, CV_8UC3, (void*)frame.u64VirAddr[0]);
|
|
|
|
|
|
|
|
// src1 = src1 + cv::Scalar(30, 30, 30);
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
//if (dir == 1 && para.servoInfo.fServoPt < 0)
|
|
|
|
|
|
|
|
//{
|
|
|
|
|
|
|
|
// int delta = ABS(para.servoInfo.fServoPt);
|
|
|
|
|
|
|
|
// cv::Mat src1(frame.u32Height, frame.u32Width, CV_8UC3, (void*)frame.u64VirAddr[0]);
|
|
|
|
|
|
|
|
// src1 = src1 + cv::Scalar(delta, delta, delta);
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取RGBA图像
|
|
|
|
// 获取RGBA图像
|
|
|
|
cv::Mat src = getRGBAMatFromGDFrame(frame, frame.u64VirAddr[0]);
|
|
|
|
cv::Mat src = getRGBAMatFromGDFrame(frame, frame.u64VirAddr[0]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 输出单帧谷歌瓦片
|
|
|
|
// 输出单帧谷歌瓦片
|
|
|
|
if (_config.bOutFrameTile)
|
|
|
|
if (_config.bOutFrameTile)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@ -544,6 +609,9 @@ SINT32 UnderStitch::Run(GD_VIDEO_FRAME_S frame, FrameInfo para)
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LOG_INFO("stitch total times:{}", sw.elapsed_ms());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -580,7 +648,7 @@ SINT32 UnderStitch::OptAndOutCurrPan(vector<KeyType> workFrame)
|
|
|
|
// 输出当前所有瓦片
|
|
|
|
// 输出当前所有瓦片
|
|
|
|
LOG_INFO("ExportTileSet");
|
|
|
|
LOG_INFO("ExportTileSet");
|
|
|
|
_googleProduct.ExportTileSet(_MapBlender->getPanImageMat(), _MapBlender->getPanMaskMat(),
|
|
|
|
_googleProduct.ExportTileSet(_MapBlender->getPanImageMat(), _MapBlender->getPanMaskMat(),
|
|
|
|
_taskTilesVec, _outDir, _filename + std::to_string(_lastFrameKey));
|
|
|
|
_taskTilesVec, _outDir, _filename + std::to_string(_lastFrameKey),false);
|
|
|
|
|
|
|
|
|
|
|
|
return workFrame.size();
|
|
|
|
return workFrame.size();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -608,7 +676,13 @@ bool UnderStitch::FilterFrame(FrameInfo para)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 扫描角过大,跳过
|
|
|
|
// 扫描角过大,跳过
|
|
|
|
if (ABS(para.servoInfo.fServoPt) > 45)
|
|
|
|
if (ABS(para.servoInfo.fServoPt) > 37)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 姿态不稳定,跳过
|
|
|
|
|
|
|
|
if(ABS(para.craft.stAtt.fRoll) > 5)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -1030,6 +1104,24 @@ void UnderStitch::TransPitch(FrameInfo& info)
|
|
|
|
info.servoInfo.fServoPt += 90;
|
|
|
|
info.servoInfo.fServoPt += 90;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int UnderStitch::StatScanDir(FrameInfo& para)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
double d = para.servoInfo.fServoPt - infoLast.servoInfo.fServoPt;
|
|
|
|
|
|
|
|
infoLast = para;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 指数平滑趋势
|
|
|
|
|
|
|
|
ScanTrend = 0.2 * ScanTrend + 0.8 * d;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int dir = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ScanTrend > 0.2)
|
|
|
|
|
|
|
|
dir = 1;
|
|
|
|
|
|
|
|
else if (ScanTrend < -0.2)
|
|
|
|
|
|
|
|
dir = -1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return dir;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cv::Mat UnderStitch::getAffineFromGeo2Pan(UPanInfo _pan)
|
|
|
|
cv::Mat UnderStitch::getAffineFromGeo2Pan(UPanInfo _pan)
|
|
|
|
|