|
/*=========================================================================
|
|
* 图像pj演示:2022-08-09
|
|
*=========================================================================
|
|
*/
|
|
#include <opencv2/highgui.hpp>
|
|
#include <iostream>
|
|
#include <cstring>
|
|
//ubuntu必须必须头文件
|
|
#include <unistd.h>
|
|
|
|
#include <opencv/cv.h>
|
|
#include <opencv/highgui.h>
|
|
#include <opencv2/opencv.hpp>
|
|
#include <opencv2/core/core.hpp>
|
|
#include <opencv2/highgui/highgui.hpp>
|
|
#include <opencv2/imgproc/imgproc.hpp>
|
|
#include <opencv2/ml/ml.hpp>
|
|
#include <string>
|
|
#include <string.h>
|
|
#include <iostream>
|
|
#include <cstring>
|
|
#include <time.h>
|
|
//#include <CSTRING>
|
|
|
|
using namespace std;
|
|
using namespace cv;
|
|
|
|
//表头文件 :
|
|
#include<sys/types.h>
|
|
#include<sys/stat.h>
|
|
#include<fcntl.h>
|
|
#include<stdio.h>
|
|
|
|
|
|
|
|
//=========================================================
|
|
|
|
//=======================================================================================================
|
|
//c++ 矩形数据结构定义
|
|
typedef struct MPOSITION {
|
|
int left; //目标左上角x坐标
|
|
int top; //目标左上角y坐标
|
|
int right; //目标相对于左上角x坐标水平宽度
|
|
int bottom; //目标相对于左上角y坐标垂直高度
|
|
int width; //目标相对于左上角x坐标水平宽度
|
|
int height; //目标相对于左上角y坐标垂直高度
|
|
}MIMGPOS;
|
|
// 视频源数据结构头文件
|
|
typedef struct MIMGMAP1
|
|
{
|
|
int total;//视频源总数;例如:MAX_IMGGROUP_NUM =64;
|
|
int h; //视频源行数;例如:row=8;
|
|
int w; //视频源列数;例如:col=6;
|
|
int idxw;//视频源缩引图像列数;
|
|
int idxh;//视频源缩引图像行数;
|
|
int num; //视频源编号;例如:MAX_IMGGROUP_NUM =64,num:0~63;
|
|
MIMGPOS rr; //视频源图像在屏幕上的位置;例如:rr.left=1;rr.top=1,rr.right=420,rr.bottom=475
|
|
//CRect rr;
|
|
char ipstr[20];//IP地址
|
|
char usensme[20];//用户名称
|
|
char passwd[20];//用户口令
|
|
int channel;//通道编号
|
|
int nport; //视频源端口:该编号一般不能重复
|
|
int kh; //1:可见光 ,2:红外
|
|
int dtype; //驱动类型,本系统可以分成N类:1:海康 ,2:集光,3:丰泰达;4:圣格尔
|
|
int logflag; //已登录成功为1;否则为0
|
|
int selflag; //已选中作做入侵检测处理:1;否则为0
|
|
long lUserID; //海康登录句柄
|
|
long m_lPlayHandle; //海康登录播放句柄
|
|
long hPlayWnd;//播放窗口的句柄,为NULL表示不播放图象
|
|
unsigned char mbufo[1920 * 1080 * 3];//拼接显示用
|
|
unsigned char mbufe[1920 * 1080 * 3];//鱼眼校正用
|
|
unsigned char mbufi[1920 * 1080 * 3];//拼接用
|
|
//unsigned char mbufo[1 * 1* 3];
|
|
}IMGMAP1;
|
|
|
|
//设置窗口数
|
|
//多画面列数;例如8列。代表一行排列8视频源
|
|
int IMGCOLS = 1;
|
|
//多画面行数;例如8行。代表屏幕共排列8行视频源
|
|
int IMGROWS = 1;
|
|
// 多画面行数;视频源数据结构
|
|
//多画面总共变量
|
|
int MAX_IMGGROUP_NUM = 1;
|
|
#define MAX_IMGS_NUM 15
|
|
IMGMAP1 imgs[MAX_IMGS_NUM];
|
|
//IMGMAP2 imgs2[MAX_IMGS_NUM];
|
|
//IMGMAP3 imgs3[MAX_IMGS_NUM];
|
|
int multimg_w = 0;
|
|
int multimg_h = 0;
|
|
//CRect rr;
|
|
//MIMGPOS rr;
|
|
Mat timg, himg;
|
|
//多视频源启动显示标识
|
|
int mmultimg_flag = 0; //0:未启动;1:已启动
|
|
//双击放大显示单个特殊图像
|
|
int mmultimg_dispsingles = 0; //0:未启动;1:已启动
|
|
//========================================================
|
|
//14路拼接数据结构定义
|
|
typedef struct MPINDATAN {
|
|
int cnt;//结构内数据个数
|
|
int bh;
|
|
int xz;
|
|
int yz;
|
|
int width;
|
|
int height;
|
|
}PINDATAN;
|
|
//14路拼接数据结构定义
|
|
typedef struct MPINDATA {
|
|
int cnt;//结构内数据个数
|
|
int bh;
|
|
int xz;
|
|
int yz;
|
|
int width;
|
|
int height;
|
|
}PINDATA;
|
|
PINDATA pindatan[20];
|
|
int GetpinjeConfig(void);
|
|
//// 用于拼接图像
|
|
//#define FCNT 2
|
|
//#define XDIM 960 //1500//图像宽度
|
|
//#define YDIM 1080//图像高度
|
|
//int m_Width = 960;
|
|
//int m_Height = 1080;
|
|
//int znum = 0;
|
|
#define FCNT 2 //水平向拼接帧数
|
|
//#define VCNT 7 //垂直向拼接帧数
|
|
#define VCNT 7 //垂直向拼接帧数
|
|
#define XDIM 1920 //拼接图像水平向基本像元阵列个数定义
|
|
#define YDIM 1080 //拼接图像垂直向基本像元阵列个数定义
|
|
int m_Width = 1920;//拼接图像水平向基本像元阵列个数变量
|
|
int m_Height = 1080;//拼接图像垂直向基本像元阵列个数定义变量
|
|
int znum = 0;//图像拼接垂直与水平向拼接个数变量
|
|
|
|
//拼接图像
|
|
unsigned char pinbufo[XDIM*YDIM*FCNT*3]; //横向图像拼接缓存设置
|
|
//XDIM*YDIM*3为横向拼接单帧图像缓存定义尺寸
|
|
//FCNT为横向拼接图像缓存定义尺寸,
|
|
//例如:横向2帧图像相拼,则FCNT定义为2;
|
|
//横向10帧图像相拼,则FCNT定义为10;
|
|
//横向N(N为大于1的正整数)帧图像相拼,则FCNT定义为N;
|
|
unsigned char mpinbufo[XDIM*YDIM*FCNT*VCNT*3];//垂直拼接缓存设置
|
|
//XDIM*YDIM*3为垂直向拼接单帧图像缓存定义尺寸
|
|
//FCNT为横向拼接图像缓存定义尺寸,
|
|
//VCNT为垂直向拼接图像条数缓存定义尺寸,
|
|
//垂直向拼接的基本思想为:
|
|
//第一步首先进行横向拼接,拼接完成后的拼接图像定义为一条横向图像
|
|
//(例如:横向2帧拼接后的图像定义为一条横向图像)
|
|
//第二步是在第一步的基础上,进而对横向拼接完成后的数条横向图像进行垂直向再拼接,
|
|
unsigned char bufo00[XDIM*YDIM * 3];//图像显示
|
|
unsigned char bufo01[XDIM*YDIM * 3];//图像显示
|
|
unsigned char bufi[XDIM*YDIM * 3]; //单帧图像中间缓存变量定义
|
|
unsigned char bufi1[XDIM*YDIM * 3]; //单帧图像中间缓存变量定义
|
|
|
|
//=================================================================
|
|
//鱼眼校正函数
|
|
//X光应用部分
|
|
//鱼眼校正全局变量
|
|
char modname[60] = "amParam.dat";
|
|
int imgsize = 0;
|
|
// x映像结构
|
|
Mat mapx;
|
|
// y映像结构
|
|
Mat mapy;
|
|
|
|
int initFisheye()
|
|
{
|
|
char imgname[60];
|
|
//char modname[60];
|
|
//char outname[60];
|
|
//固有矩阵
|
|
cv::Matx33d intrinsic_matrix;
|
|
//畸变系数
|
|
cv::Vec4d distortion_coeffs;
|
|
Size image_size;
|
|
//string datFileName = "C:\\pic1\\gen\\amParam.dat";
|
|
//sprintf_s(modname, "C:\\pic1\\gen\\amParam.dat");
|
|
//printf("\n modname=%s \n ", modname);
|
|
FILE *camParam;
|
|
camParam=fopen(modname, "rb");
|
|
if (camParam == NULL) {
|
|
//std::cout << "can not create data file: " << modname << " !!!" << std::endl;
|
|
printf("\n can not create data file:%s \n ", modname);
|
|
//CString str;
|
|
//str.Format(_T("鱼眼校正模型打开失败,请检查模型路径"), modname);
|
|
//AfxMessageBox(str);
|
|
getchar();
|
|
return false;
|
|
}
|
|
fread(&intrinsic_matrix, sizeof(cv::Matx33d), 1, camParam);
|
|
fread(&distortion_coeffs, sizeof(cv::Vec4d), 1, camParam);
|
|
fread(&image_size, sizeof(Size), 1, camParam);
|
|
fclose(camParam);
|
|
// x映像结构
|
|
mapx = Mat(image_size, CV_32FC1);
|
|
// y映像结构
|
|
mapy = Mat(image_size, CV_32FC1);
|
|
//旋转映像结构
|
|
Mat R = Mat::eye(3, 3, CV_32F);
|
|
//鱼眼校正初始化
|
|
//initUndistortRectifyMap(intrinsic_matrix, distortion_coeffs, R, intrinsic_matrix, image_size, CV_32FC1, mapx, mapy);
|
|
fisheye::initUndistortRectifyMap(intrinsic_matrix, distortion_coeffs, R, intrinsic_matrix, image_size, CV_32FC1, mapx, mapy);
|
|
//准备鱼眼校正后的图像结构 Mat t
|
|
////Mat t = testImage.clone();
|
|
////cv::remap(testImage, t, mapx, mapy, INTER_LINEAR);
|
|
////进行鱼眼校正处理,
|
|
////testImage需要校正带图像,他、t校正后的图像
|
|
//remap(testImage, t, mapx, mapy, INTER_LINEAR);
|
|
//imshow("testImage", testImage);
|
|
//imshow("t", t);
|
|
//printf("\n outname=%s \n ", outname);
|
|
//imwrite(outname, t);
|
|
//cout << "保存结束" << endl;
|
|
//AfxMessageBox(_T("fisheye init successfully !!!"));
|
|
return 1;
|
|
}
|
|
|
|
//鱼眼校正函数
|
|
int fisheyehandle(Mat &s, Mat &d)
|
|
{
|
|
Mat m;
|
|
m = s.clone();
|
|
//imshow("testImage", s);
|
|
remap(s,m,mapx,mapy,INTER_LINEAR);
|
|
d = m.clone();
|
|
//imshow("dddd", d);
|
|
//imshow("dddddt", d);
|
|
//waitKey(0);
|
|
m.release();
|
|
return 1;
|
|
}
|
|
|
|
int GetpinjeConfig(void)
|
|
{
|
|
FILE *fp;
|
|
int bhn;
|
|
int xz, yz, width, height;
|
|
//errno_t err;
|
|
//char fisheyeconfig[160];
|
|
fp=fopen("fisheyecfg.txt", "r");///home/li/lix/
|
|
//printf("\nfp=%d",fp);
|
|
|
|
if (fp == NULL) {
|
|
printf("\n畸变校正参数文件 打开失败 !!!,请检查参数文件路径\n");
|
|
//AfxMessageBox(_T("畸变校正参数文件 打开失败 !!!,请检查参数文件路径"));
|
|
return 0;
|
|
}
|
|
for (int i = 1; i<17; i++) {
|
|
int ret = fscanf(fp, "%d %d %d %d %d", &bhn, &xz, &yz, &width, &height);
|
|
if (ret < 0)
|
|
break;
|
|
pindatan[i].xz = xz;
|
|
pindatan[i].yz = yz;
|
|
pindatan[i].width = width;
|
|
pindatan[i].height = height;
|
|
pindatan[i].bh = bhn;
|
|
pindatan[0].cnt++;
|
|
|
|
//printf("\n i=%d lx=%d ly=%d width=%d height=%d cnt=%d"
|
|
// , i, pindatan[i].xz, pindatan[i].yz, pindatan[i].width, pindatan[i].height, pindatan[0].cnt);
|
|
////FILE *fpp;
|
|
//char rett[200];
|
|
//fopen_s(&fpp, "c:\\GetpinjeConfig-log.txt", "a");
|
|
////sprintf_s(rett, "\n j=%d i=%d 识别该帧图像所用的时间为:%0.3fms", j, i, time0*1000.0);
|
|
//sprintf_s(rett, "\n i=%d lx=%d ly=%d width=%d height=%d cnt=%d"
|
|
// , i, pindatan[i].xz, pindatan[i].yz, pindatan[i].width, pindatan[i].height, pindatan[0].cnt);
|
|
//fwrite(rett, strlen(rett), 1, fpp);
|
|
//fclose(fpp);
|
|
}
|
|
//getchar();
|
|
return 1;
|
|
}
|
|
|
|
//图像插入另一幅图像中心
|
|
void center_insert1(Mat &s, Mat &d,int h,int w)
|
|
{
|
|
int i, j;
|
|
//CString str;
|
|
//str.Format(_T(" h=%d w=%d"), h, w);
|
|
//AfxMessageBox(str);
|
|
int xx = (1920 - w) / 2;
|
|
int yy = (1080 - h) / 2;
|
|
for (i = 0; i < h; i++) {
|
|
for (j = 0; j < w*3; j++) {
|
|
d.at<uchar>(i+(yy), j+(xx)*3) = s.at<uchar>(i, j);
|
|
|
|
}
|
|
}
|
|
//////FILE *fpp;
|
|
//////char rett[200];
|
|
//////fopen_s(&fpp, "c:\\Fun2Proc-time-log.txt", "a");
|
|
////////sprintf_s(rett, "\n j=%d i=%d 识别该帧图像所用的时间为:%0.3fms", j, i, time0*1000.0);
|
|
//////sprintf_s(rett, "\n i=%d 所用的时间为:%0.3fms h_width=%d h_height=%d", i, time0*1000.0, h_width, h_height);
|
|
//////fwrite(rett, strlen(rett), 1, fpp);
|
|
//////fclose(fpp);
|
|
//memcpy(&d.data[0], &dd[0], h*2*w *2*3);
|
|
////imshow("center_inser", d);
|
|
//imwrite("c:\\avi\\center_insertd.bmp", d);
|
|
//imwrite("c:\\avi\\center_inserts.bmp", s);
|
|
//imshow("center_inser11", d);
|
|
//waitKey(1000);
|
|
|
|
}
|
|
|
|
|
|
//=================================================================
|
|
//pinjie funtion
|
|
unsigned char mrpp[1920 * 1080 * 3];
|
|
int imgpinh(int znum, unsigned char *buf)
|
|
{
|
|
for (int hi = 0, j = 0; hi<m_Height; hi++, j++) {
|
|
//生成拼图
|
|
memcpy(&pinbufo[j*m_Width*FCNT * 3 + (znum)*m_Width * 3], &buf[j*m_Width * 3], m_Width * 3);
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
int mimgpinh(int znum, unsigned char *buf,int ww,int hh)
|
|
{
|
|
int mh = hh;
|
|
int mw = ww;
|
|
for (int hi = 0, j = 0; hi<mh; hi++, j++) {
|
|
//生成拼图
|
|
memcpy(&mpinbufo[znum*mw*mh*3+j*ww*3], &buf[j*ww * 3] , mw * 3);
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
//=================================================================
|
|
|
|
//=================================================================
|
|
#define DWIDTH 1920
|
|
#define DHEIGHT 1080
|
|
int main()
|
|
{
|
|
|
|
Mat frame1;
|
|
int i,j,k;
|
|
char fname[40];
|
|
char fname1[40];
|
|
double ttime;
|
|
namedWindow("mimgpin",WINDOW_NORMAL);
|
|
resizeWindow("mimgpin", 600, 700) ;
|
|
printf("\n ===================");
|
|
int x_Height = 1080;
|
|
int x_Width = 1920;
|
|
//===================================================================
|
|
Mat dImg31(1080, 1920, CV_8UC3, cv::Scalar(0, 0, 0));
|
|
Mat dImg32(1080, 1920, CV_8UC3, cv::Scalar(0, 0, 0));
|
|
Mat m_roi14(1080, 1920, CV_8UC3, cv::Scalar(0, 0, 0));
|
|
Mat src1(DHEIGHT,DWIDTH,CV_8UC3); Mat d1(DHEIGHT, DWIDTH, CV_8UC3); Mat m_roi1(DHEIGHT, DWIDTH, CV_8UC3);
|
|
//Mat src14(DHEIGHT, DWIDTH, CV_8UC3); Mat d14(DHEIGHT, DWIDTH, CV_8UC3); Mat m_roi14(DHEIGHT, DWIDTH, CV_8UC3);
|
|
Mat oimg=imread("/home/li/lix/avi-10-2/oimg1.bmp",1);
|
|
int m_Width = 1920;
|
|
int m_Height = 1080;
|
|
//fishyey correct
|
|
//鱼眼校正初始化,加载校正模型
|
|
initFisheye();
|
|
//加载鱼眼校正定位参数
|
|
GetpinjeConfig();
|
|
memcpy(&imgs[1].mbufe[0],&oimg.data[0], m_Width*m_Height * 3);
|
|
double time10;
|
|
double ttime10=0.0;
|
|
//鱼眼校正处理
|
|
for(int jj=0;jj<5;jj++)
|
|
{
|
|
//记录起始时间
|
|
//double time0 = static_cast<double>(getTickCount());
|
|
// pDlg->hmylock.lock();
|
|
|
|
time10 = static_cast<double>(getTickCount());
|
|
int h_width = m_Width;
|
|
int h_height = m_Height;
|
|
int multimg_w, multimg_h, w, h;
|
|
multimg_w = imgs[1].idxw=m_Width;
|
|
multimg_h = imgs[1].idxh= m_Height;
|
|
w = imgs[1].w = m_Width;
|
|
h = imgs[1].h = m_Height;
|
|
|
|
////================================================
|
|
memcpy(&d1.data[0], &imgs[1].mbufe[0], m_Width*m_Height * 3);
|
|
|
|
//鱼眼校正
|
|
resize(d1, src1, Size(1524, 800), 0, 0, INTER_LINEAR);
|
|
center_insert1(src1, d1, 800, 1524);
|
|
//dImg31 = dImg32.clone();
|
|
remap(d1, src1, mapx, mapy, INTER_LINEAR);
|
|
m_roi1 = src1(cv::Rect(pindatan[1].xz, pindatan[1].yz, pindatan[1].width, pindatan[1].height));
|
|
resize(m_roi1, d1, Size(1920, 1080), 0, 0, INTER_LINEAR);
|
|
//imshow("mimgpin-1",d1);
|
|
|
|
memcpy(&imgs[1].mbufi[0], &d1.data[0], m_Width*m_Height * 3);
|
|
|
|
|
|
/*resize(d1, dImg31, Size(1524, 800), 0, 0, INTER_LINEAR);
|
|
center_insert1(dImg31, dImg32, 800, 1524);
|
|
dImg31 = dImg32.clone();
|
|
remap(dImg32, dImg31, mapx, mapy, INTER_LINEAR);
|
|
|
|
m_roi1 = dImg31(cv::Rect(pindatan[1].xz, pindatan[1].yz, pindatan[1].width, pindatan[1].height));
|
|
resize(m_roi1, d1, Size(1920, 1080), 0, 0, INTER_LINEAR);
|
|
//imshow("mimgpin-1",d1);
|
|
memcpy(&imgs[1].mbufi[0], &d1.data[0], m_Width*m_Height * 3);
|
|
*/
|
|
//dImg31.release();
|
|
//dImg32.release();
|
|
time10 = ((double)getTickCount() - time10) / getTickFrequency();
|
|
ttime10=ttime10+time10;
|
|
printf("\n jj=%d fisheye correct所用的时间为:%0.3fms total=%0.3fms averge=%0.3fms\n",jj, time10*1000.00,ttime10*1000.00,ttime10*1000.0/5);
|
|
|
|
//================================================
|
|
//resize(d1, src1, Size(multimg_w, multimg_h), 0, 0, INTER_LINEAR);
|
|
|
|
|
|
//for (int ii = multimg_h, k = 0; ii >= 1; ii--, k++) {
|
|
// memcpy(&imgs[1].mbufo[k*multimg_w * 3], &src1.data[(ii - 1)*multimg_w * 3], multimg_w * 3);
|
|
//}
|
|
|
|
//memcpy(imgs[1].mbufo, src.data, multimg_w*multimg_h * 3);
|
|
//pDlg->hmylock.lock();
|
|
//sleep(1);
|
|
//启动拼接线程
|
|
//SetEvent(pDlg->hx_hVideoEvent);
|
|
//释放DecCBfun
|
|
//ResetEvent(pDlg->x_14videoEvent);
|
|
//time0 = ((double)getTickCount() - time0) / getTickFrequency();
|
|
////FILE *fpp;
|
|
//char rett[200];
|
|
//fopen_s(&fpp, "c:\\fyfunProc2-log.txt", "a");
|
|
//sprintf_s(rett, "\n 鱼眼校正1帧 所用的时间为:%0.3fms ",time0*1000.0);
|
|
//fwrite(rett, strlen(rett), 1, fpp);
|
|
//fclose(fpp);
|
|
}
|
|
imshow("mimgpin", d1);
|
|
printf("\n multimg_w=%d multimg_=%d ",multimg_w, multimg_h);
|
|
waitKey(10000);
|
|
getchar();
|
|
return 0;
|
|
//===================================================================
|
|
|
|
Rect rt;
|
|
rt.x = 0;
|
|
rt.y = 0;
|
|
rt.height = x_Height - 2;// 1079;
|
|
rt.width = x_Width - 2;// 1919;
|
|
Mat src, dst,dd;
|
|
Mat src11, dst11, dd1;
|
|
Mat imgpin(1080, 1920*FCNT, CV_8UC3);
|
|
Mat mimgpin(1080* VCNT, 1920* FCNT, CV_8UC3);
|
|
printf("\n 1");
|
|
//memcpy(mrpp, imgrp.data, SRPH*SRPW * 3);
|
|
|
|
//printf("\n 1imgrp,rows=%d cols=%d", imgrp.rows, imgrp.cols);
|
|
printf("\n 3");
|
|
int h = 0;
|
|
//记录起始时间
|
|
ttime=0.0;
|
|
double time0;
|
|
double time1;
|
|
time0 = static_cast<double>(getTickCount());
|
|
|
|
|
|
for(int hh=0;hh<5;hh++){
|
|
//记录起始时间
|
|
time1 = static_cast<double>(getTickCount());
|
|
//printf("\n 拼接开始时间为:%0.3fms ms", time1*1000.0);
|
|
//for (i = 1, j = 0; i < 15; i = i + 2, j++) {
|
|
for (i = 1,j=0,h=0; i < 15; i=i+2,j++,h++) {
|
|
sprintf(fname, "/home/li/lix/avi-10-2/himg%d.bmp",i+1);
|
|
src = imread(fname, 1);
|
|
if (i == 1 || i == 5 || i == 9 || i == 13) {
|
|
rectangle(src, rt, Scalar(0, 0, 255), 8, LINE_8, 0);
|
|
}
|
|
else {
|
|
rectangle(src, rt, Scalar(0, 255, 255),8, LINE_8, 0);
|
|
}
|
|
sprintf(fname1, "/home/li/lix/avi-10-2/himg%d.bmp", i+0);
|
|
src1 = imread(fname1, 1);
|
|
|
|
|
|
|
|
if (i == 1 || i == 5 || i == 9 || i == 13) {
|
|
rectangle(src11, rt, Scalar(0, 255, 255), 8, LINE_8, 0);
|
|
}
|
|
else {
|
|
rectangle(src11, rt, Scalar(0, 0, 255), 8, LINE_8, 0);
|
|
}
|
|
|
|
memcpy(bufi, src.data, src.rows*src.cols * 3);
|
|
memcpy(bufi1,src11.data, src11.rows*src1.cols * 3);
|
|
znum = 0;
|
|
imgpinh(znum, &bufi[0]);
|
|
znum = 1;
|
|
imgpinh(znum, &bufi1[0]);
|
|
memcpy(imgpin.data, pinbufo, 1920 * FCNT * 3 * 1080);
|
|
//imshow("imgpin", imgpin);
|
|
//imwrite("H:\\pic\\avi-10\\m.bmp", imgpin);
|
|
//waitKey(1);
|
|
mimgpinh(j, &pinbufo[0], 1920*FCNT, 1080);
|
|
printf("\n hh=%d i=%d j=%d",hh,i,j);
|
|
}
|
|
|
|
memcpy(mimgpin.data, mpinbufo, 1080* VCNT * 1920*FCNT * 3);
|
|
////
|
|
//for (int hi = 0, j = 0; hi<m_Height; hi++, j++) {
|
|
// //生成拼图
|
|
// //memcpy(&pinbufo[j*m_Width*FCNT+(i)*m_Width],&bufi1[j*m_Width*FCNT],m_Width);
|
|
// printf("\n pinbufoj*m_Width*FCNT*3 + (znum)*m_Width * 3=%d j*m_Width * 3=%d ", j*m_Width*FCNT * 3 + (znum)*m_Width * 3, j*m_Width * 3);
|
|
//
|
|
// FILE *fpp;
|
|
// char rett[200];
|
|
// fopen_s(&fpp, "c:\\pin-log.txt", "a");
|
|
// sprintf_s(rett, "\n hi=%d j=%d pinbufoj*m_Width*FCNT*3 + (znum)*m_Width * 3=%d j*m_Width * 3=%d ",hi,j, j*m_Width*FCNT * 3 + (znum)*m_Width * 3, j*m_Width * 3);
|
|
// fwrite(rett, strlen(rett), 1, fpp);
|
|
// fclose(fpp);
|
|
// memcpy(&pinbufo[j*m_Width*FCNT*3 + (znum)*m_Width * 3], &bufi[j*m_Width * 3], m_Width * 3);
|
|
//}
|
|
memcpy(imgpin.data, pinbufo, 1080 * 1920 * 3);
|
|
//memcpy(rp.data, rpp, SRPH*SRPW * 3);
|
|
// angle = 90.0 * 2;//角度
|
|
//Rotate(dst, d, angle);
|
|
//imshow("mimgpin", mimgpin);
|
|
//imshow("dst1", imgpin);
|
|
//imwrite("c:\\avi\\dst.bmp", dst);
|
|
//imwrite("c:\\avi\\dst1.bmp",dst1);
|
|
//imwrite("c:\\avi\\imgpin.bmp", imgpin);
|
|
//获取当地时间字符串
|
|
time1 = ((double)getTickCount() - time1) / getTickFrequency();
|
|
ttime=ttime+time1;
|
|
|
|
printf("\n 拼接1x14帧所用的时间为:%0.3fms total=%0.3fms \n", time1*1000.00,ttime*1000.00);
|
|
// imshow("mimgpin", mimgpin);
|
|
//waitKey(1);
|
|
|
|
}
|
|
|
|
//获取当地时间字符串
|
|
time0 = ((double)getTickCount() - time0) / getTickFrequency();
|
|
imshow("mimgpin", mimgpin);
|
|
waitKey(10000);
|
|
|
|
//printf("\n The time taken to splice 1 frame is:% 0.3fms, and the average time is:% 0.3fms", time0*1000.0,time0*1000.0/5);
|
|
printf("\n 拼接5X14帧所用的时间为:%0.3fms 平均时间为:%0.3fms", time0*1000.0,ttime*1000.0/5);
|
|
imwrite("/home/li/lix/avi-10-2/auotmimgpin2.bmp", mimgpin);
|
|
|
|
|
|
//FILE *fp;
|
|
//char rett[200];
|
|
//fopen_s(&fp, "D:\\dnn-jslulanqi\\dnn-ssd-result7-log.txt", "a");
|
|
//sprintf_s(rett, " \n i=%d detectionMat %0.4f %0.4f %0.4f %0.4f %0.4f %0.4f %0.4f\n "
|
|
// , i, detectionMat.at<float>(i, 0), detectionMat.at<float>(i, 1), detectionMat.at<float>(i, 2), detectionMat.at<float>(i, 3)
|
|
// , detectionMat.at<float>(i, 4), detectionMat.at<float>(i, 5), detectionMat.at<float>(i, 6));
|
|
// fwrite(rett, strlen(rett), 1, fp);
|
|
//fclose(fp);
|
|
|
|
//FILE *fpp;
|
|
//char rett[200];
|
|
//fopen_s(&fpp, "pinjietime14-log.txt", "a");
|
|
//sprintf(rett, "\n新算法拼接1帧所用的时间为:%0.3fms",time0*1000.0);
|
|
//fwrite(rett, strlen(rett), 1, fpp);
|
|
//fclose(fpp);
|
|
|
|
printf("\n拼接结束!!!");
|
|
getchar();
|
|
|
|
|
|
return 0;
|
|
}
|
|
//======================================================================================
|
|
|
|
|