You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
186 lines
4.8 KiB
186 lines
4.8 KiB
|
1 month ago
|
#include "S732.h"
|
||
|
|
#include <iostream>
|
||
|
|
#include "API_UnderStitch.h"
|
||
|
|
#include "PlatformDefine.h"
|
||
|
|
#include <string.h>
|
||
|
|
#include "opencv2/opencv.hpp"
|
||
|
|
#include <random>
|
||
|
|
#include <string>
|
||
|
|
|
||
|
|
|
||
|
|
using namespace cv;
|
||
|
|
using namespace std;
|
||
|
|
|
||
|
|
void ProcessVL(string filePath)
|
||
|
|
{
|
||
|
|
auto stitcher = API_UnderStitch::Create();
|
||
|
|
stitcher->SetOutput("BT", "google_tiles");
|
||
|
|
|
||
|
|
|
||
|
|
GD_VIDEO_FRAME_S frame = { 0 };//输入帧
|
||
|
|
GD_VIDEO_FRAME_S pan = { 0 };//输出全景
|
||
|
|
|
||
|
|
cv::Mat mat_pan;//全景显示
|
||
|
|
|
||
|
|
FILE* file = fopen(filePath.c_str(), "rb");
|
||
|
|
|
||
|
|
cv::VideoWriter output;
|
||
|
|
|
||
|
|
|
||
|
|
int i = 0;
|
||
|
|
|
||
|
|
|
||
|
|
SINT32 nVLFrameSize = 1.5 * (S732_VL_W * S732_VL_H + S732_VL_W * PARA_VL_LINE_S732);
|
||
|
|
unsigned char* pFrameVL = new unsigned char[nVLFrameSize];
|
||
|
|
|
||
|
|
while (!feof(file))
|
||
|
|
{
|
||
|
|
fread(pFrameVL, 1, nVLFrameSize, file);
|
||
|
|
|
||
|
|
STD_DTArith_Record732 Paras_VL = { 0 };
|
||
|
|
memcpy(&Paras_VL, (unsigned char*)(pFrameVL + int(1.5 * S732_VL_W * S732_VL_H)), sizeof(STD_DTArith_Record732));
|
||
|
|
|
||
|
|
FrameInfo info = { 0 };
|
||
|
|
info.nFrmID = i;
|
||
|
|
|
||
|
|
info.camInfo.fPixelSize = Paras_VL.trackInputPara.stCameraInfo.fPixelSize;
|
||
|
|
|
||
|
|
info.camInfo.nFocus = Paras_VL.trackInputPara.stCameraInfo.nFocus;
|
||
|
|
|
||
|
|
info.craft.stAtt.fYaw = Paras_VL.trackInputPara.stAirCraftInfo.stAtt.fYaw;
|
||
|
|
info.craft.stAtt.fPitch = Paras_VL.trackInputPara.stAirCraftInfo.stAtt.fPitch;
|
||
|
|
info.craft.stAtt.fRoll = Paras_VL.trackInputPara.stAirCraftInfo.stAtt.fRoll;
|
||
|
|
|
||
|
|
info.craft.stPos.B = Paras_VL.trackInputPara.stAirCraftInfo.stPos.B;
|
||
|
|
info.craft.stPos.L = Paras_VL.trackInputPara.stAirCraftInfo.stPos.L;
|
||
|
|
info.craft.stPos.H = Paras_VL.trackInputPara.stAirCraftInfo.stPos.H;
|
||
|
|
|
||
|
|
|
||
|
|
info.nEvHeight = info.craft.stPos.H - 1360;
|
||
|
|
|
||
|
|
info.servoInfo.fServoAz = Paras_VL.trackInputPara.stServoInfo.fServoAz;
|
||
|
|
info.servoInfo.fServoPt = Paras_VL.trackInputPara.stServoInfo.fServoPt;
|
||
|
|
|
||
|
|
info.nWidth = S732_VL_W;
|
||
|
|
info.nHeight = S732_VL_H;
|
||
|
|
|
||
|
|
|
||
|
|
//info.craft.stAtt.fYaw += gr.generate();
|
||
|
|
//info.craft.stAtt.fPitch += gr.generate();
|
||
|
|
//info.craft.stAtt.fRoll += gr.generate();
|
||
|
|
|
||
|
|
cv::Mat mat_src(S732_VL_H * 1.5, S732_VL_W, CV_8UC1, pFrameVL);
|
||
|
|
cv::Mat IMG;
|
||
|
|
cv::cvtColor(mat_src, IMG, cv::COLOR_YUV2BGR_NV12);
|
||
|
|
|
||
|
|
|
||
|
|
cv::Mat IMG_show;
|
||
|
|
cv::resize(IMG, IMG_show, cv::Size(IMG.cols / 4, IMG.rows / 4));
|
||
|
|
imshow("IMG_show", IMG_show);
|
||
|
|
|
||
|
|
frame.enPixelFormat = GD_PIXEL_FORMAT_NV12;
|
||
|
|
frame.u32Width = S732_VL_W;
|
||
|
|
frame.u32Height = S732_VL_H;
|
||
|
|
frame.u64VirAddr[0] = pFrameVL;
|
||
|
|
|
||
|
|
//imwrite("D:/imgVL_u.jpg", IMG);
|
||
|
|
|
||
|
|
|
||
|
|
if (i == 0 /*|| i == 200*/)
|
||
|
|
{
|
||
|
|
stitcher->Init(info);
|
||
|
|
|
||
|
|
UPanConfig cfg = { 0 };
|
||
|
|
cfg.bOutGoogleTile = 1;
|
||
|
|
cfg.bOutFrameTile = 0;
|
||
|
|
stitcher->SetConfig(cfg);
|
||
|
|
|
||
|
|
stitcher->SetOutput("baotou","E:/google_tiles");
|
||
|
|
|
||
|
|
|
||
|
|
pan = stitcher->ExportPanAddr();
|
||
|
|
|
||
|
|
mat_pan = cv::Mat(pan.u32Height, pan.u32Width, CV_8UC4, pan.u64VirAddr[0]);
|
||
|
|
|
||
|
|
output.open("E:/output.mp4", VideoWriter::fourcc('H', '2', '6', '4'), 5, Size(pan.u32Width / 8, pan.u32Height / 8), true);
|
||
|
|
if (!output.isOpened())
|
||
|
|
{
|
||
|
|
cout << "打开视频失败" << endl;
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
std::cout << info.craft.stPos.B << " " << info.craft.stPos.L << " " << info.craft.stPos.H << " "
|
||
|
|
<< info.craft.stAtt.fYaw << " " << info.craft.stAtt.fPitch << " " << info.craft.stAtt.fRoll << " "
|
||
|
|
<< info.servoInfo.fServoAz << " " << info.servoInfo.fServoPt + 90
|
||
|
|
<< std::endl;
|
||
|
|
|
||
|
|
cv::TickMeter tm;
|
||
|
|
tm.start();
|
||
|
|
// 基于外参的快拼
|
||
|
|
stitcher->Run(frame, info);
|
||
|
|
|
||
|
|
tm.stop();
|
||
|
|
|
||
|
|
cout << "time:" << tm.getTimeMilli() << endl;
|
||
|
|
}
|
||
|
|
|
||
|
|
Mat pan_rgb, pan_rgb_ds;
|
||
|
|
cv::cvtColor(mat_pan, pan_rgb, cv::COLOR_BGRA2BGR);
|
||
|
|
|
||
|
|
cv::resize(pan_rgb, pan_rgb_ds, cv::Size(pan_rgb.cols / 8, pan_rgb.rows / 8));
|
||
|
|
|
||
|
|
output.write(pan_rgb_ds);
|
||
|
|
|
||
|
|
imshow("pan_opt", pan_rgb_ds);
|
||
|
|
|
||
|
|
|
||
|
|
waitKey(1);
|
||
|
|
|
||
|
|
i = i + 1;
|
||
|
|
}
|
||
|
|
|
||
|
|
cv::TickMeter tm;
|
||
|
|
tm.start();
|
||
|
|
// 处理帧
|
||
|
|
stitcher->OptAndOutCurrPan();
|
||
|
|
|
||
|
|
tm.stop();
|
||
|
|
|
||
|
|
cout << "time opt:" << tm.getTimeMilli() << endl;
|
||
|
|
|
||
|
|
|
||
|
|
Mat pan_rgb, pan_rgb_ds;
|
||
|
|
cv::cvtColor(mat_pan, pan_rgb, cv::COLOR_BGRA2BGR);
|
||
|
|
|
||
|
|
cv::resize(pan_rgb, pan_rgb_ds, cv::Size(pan_rgb.cols / 8, pan_rgb.rows / 8));
|
||
|
|
|
||
|
|
for (int i = 0; i < 25; i++)
|
||
|
|
{
|
||
|
|
cv::putText(pan_rgb_ds, "BA opt", cv::Point(100, 40), 0, 1, cv::Scalar(255, 0, 0));
|
||
|
|
output.write(pan_rgb_ds);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
waitKey(1);
|
||
|
|
|
||
|
|
|
||
|
|
output.release();
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
int main()
|
||
|
|
{
|
||
|
|
ProcessVL("D:/S732挂飞1101/20251101_091550742_2.yuv");
|
||
|
|
return 0;
|
||
|
|
}
|