c# C++接口封装 汽车模拟仿真
struct PinCamParIn//用户输入的针孔相机参数结构体
{
char CameraName[512];
float Offset[3];
float Angle[3];
float FocalLen;
float PixsSize;
int Resolution[2];
}
struct PinCamParOut//用于给南老师渲染图像的相机参数结构体
{
char CameraName[512];
float Offset[3];
float Angle[3];
float VerFOV;
float Aspect;
int Resolution[2];
}
struct FishCamPar//用户输入的鱼眼相机参数结构体
{
char CameraName[512];
float Offset[3];
float Angle[3];
float FocalLen;
float PixsSize;
int Resolution[2];
float MaxFOV;
}
struct ImagePar//输出图像性质结构体
{
unsigned char* ImagePtr;//图像数组指针
int Resolution[2];
}
struct EnvCamPar//用户输入包络线相机参数结构体
{
char CameraName[512];
int Flag;//用于储存切割集合体形状
float NearDist;
float FarDist;
float FOV[2];
}
struct EnvImPar//用户输入包络线图像参数结构体
{
float SecHeight;
float mPerBlock;
int MaxXBlockNum;
int MaxYBlockNum;
}
/*
用于将用户输入的针孔相机参数结构体转换为南老师渲染需要的针孔相机结构体。
函数参数说明:
struct PinCamParIn InputPinPar 用户输入的针孔相机参数
返回值说明:
struct PinCamParOut类型,用于给南老师渲染
*/
struct PinCamParOut CameraIOTransfer(struct PinCamParIn InputPinPar)
/*
用于根据用户输入的鱼眼相机参数计算得到合成图片用的5个针孔相机参数。
函数参数说明:
struct FishCamPar InputFishPar 用户输入的鱼眼相机参数
返回值说明:
struct PinCamParOut*类型指针,存储着5个鱼眼相机的渲染参数
*/
struct PinCamParOut* FisheyeParCal(struct FishCamPar InputFishPar)
/*
用于合成鱼眼镜头图像
函数参数说明:
struct FishCamPar InputFishPar 用户输入的鱼眼相机参数
ImagePar* FishPinImList 存储5张针孔图片内存的指针
返回值说明:
struct ImagePar 类型的结构体,存储鱼眼图像的指针和横纵像素数
*/
struct ImagePar FisheyeSyn(struct FishCamPar InputFishPar, struct ImagePar* FishPinImList)
/*
用于计算界面上包络线相机的缺省值参数
函数参数说明:
struct PinCamParIn InputPinPar 用户输入的针孔相机参数
返回值说明:
struct EnvCamPar 类型的结构体,存储界面上包络线相机参数的结构体
*/
struct EnvCamPar EnvCamParCal(struct PinCamParIn InputPinPar)
/*
用于生成包络线图片
函数参数说明:
int PinCamNum 针孔相机数量
float ShaftHeight 车辆前轴高度
struct PinCamParIn* InputPinParList 指向所有针孔相机参数结构体数组的指针
struct EnvCamPar* EnvParList 指向所有包络线相机参数结构体的指针
struct EnvImPar EnvImSet 存储用户设置的包络线图形参数的结构体
返回值说明:
struct ImagePar 类型的结构体,存储包络线图像的指针和横纵像素数
*/
struct ImagePar Envelope(int PinCamNum, float ShaftHeight, struct PinCamParIn* InputPinParList, struct EnvCamPar* EnvParList , struct EnvImPar EnvImSet)
// 给北京外包公司接口及结构体定义
struct PinCamParIn//用户输入的针孔相机参数结构体
{
char CameraName[512];
float Offset[3];
float Angle[3];
float FocalLen;
float PixsSize;
int Resolution[2];
}
struct PinCamParOut//用于给南老师渲染图像的相机参数结构体
{
char CameraName[512];
float Offset[3];
float Angle[3];
float VerFOV;
float Aspect;
int Resolution[2];
}
struct FishCamPar//用户输入的鱼眼相机参数结构体
{
char CameraName[512];
float Offset[3];
float Angle[3];
float FocalLen;
float PixsSize;
int Resolution[2];
float MaxFOV;
}
struct ImagePar//输出图像性质结构体
{
unsigned char* ImagePtr;//三维数组指针
int Resolution[2];
}
struct EnvCamPar//用户输入包络线相机参数结构体
{
char CameraName[512];
int Flag;//用于储存切割集合体形状
float NearDist;
float FarDist;
float FOV[2];
}
struct EnvImPar//用户输入包络线图像参数结构体
{
float SecHeight;
float mPerBlock;
int MaxXBlockNum;
int MaxYBlockNum;
}
// ------------------------------------------------------------------------------------------------
/*!
*
* 界面针孔相机参数转换为3D渲染相机参数的接口
*
* @param[in] PinCamParIn 用户输入界面相机参数
* return PinCamParOut 输出3D渲染相机参数
*/
struct PinCamParOut CameraIOTransfer(struct PinCamParIn InputPinPar)
// ------------------------------------------------------------------------------------------------
/*!
*
* 生成鱼眼图像接口
*
* @param[in] InputFishPar 用户输入鱼眼相机参数
* return PinCamParOut 输出3D渲染相机参数
*/
struct ImagePar FisheyeSyn(struct FishCamPar InputFishPar)
// ------------------------------------------------------------------------------------------------
/*!
*
* 包络线生成接口
*
* @param[in] PinCamNum 用户输入相机数量
* @param[in] EnvParList 用户输入包络线相机参数结构体指针
* @param[in] EnvImSet 用户输入包络线图像参数结构体
* return ImagePar 输出图像数据
*/
struct ImagePar Envelope(int PinCamNum, struct EnvCamPar* EnvParList, struct EnvImPar EnvImSet)
// -------------------------------------------------------------------------------------------------
c# 封装后-------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
namespace PanoCam.Interface
{
/// <summary>
/// 相机接口
/// </summary>
public static class IPanoCamera
{
/// <summary>
/// 用户输入的针孔相机参数结构体
/// </summary>
public struct PinCamParIn
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 512)]
public string CameraName;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
public float[] Offset;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
public float[] Angle;
public float FocalLen;
public float PixsSize;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
public int[] Resolution;
}
/// <summary>
/// 用于给南老师渲染图像的相机参数结构体
/// </summary>
public struct PinCamParOut
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 512)]
public string CameraName;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
public float[] Offset;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
public float[] Angle;
public float VerFOV;
public float Aspect;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
public int[] Resolution;
}
/// <summary>
/// 用户输入的鱼眼相机参数结构体
/// </summary>
public struct FishCamPar
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 512)]
public string CameraName;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
public float[] Offset;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
public float[] Angle;
public float FocalLen;
public float PixsSize;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
public int[] Resolution;
public float MaxFOV;
}
/// <summary>
/// 输出图像性质结构体
/// </summary>
public struct ImagePar
{
public IntPtr ImagePtr;//三维数组指针unsigned char*
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
public int[] Resolution;
}
/// <summary>
/// 用户输入包络线相机参数结构体
/// </summary>
public struct EnvCamPar//
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 512)]
public string CameraName;
public int Flag;//用于储存切割集合体形状
public float NearDist;
public float FarDist;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
public float[] FOV;
}
/// <summary>
/// 用户输入包络线图像参数结构体
/// </summary>
public struct EnvImPar//
{
public float SecHeight;
public float mPerBlock;
public int MaxXBlockNum;
public int MaxYBlockNum;
}
// ------------------------------------------------------------------------------------------------
/*!
*
* 界面针孔相机参数转换为3D渲染相机参数的接口
*
* @param[in] PinCamParIn 用户输入界面相机参数
* return PinCamParOut 输出3D渲染相机参数
*/
[DllImport("dllPort.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "CameraIOTransfer")]
public static extern IntPtr CameraIOTransfer(IntPtr InputPinPar);
// ------------------------------------------------------------------------------------------------
/*!
*
* 生成鱼眼图像接口
*
* @param[in] InputFishPar 用户输入鱼眼相机参数
* return ImagePar 输出图像数据
*/
[DllImport("dllPort.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "FisheyeSyn")]
public static extern IntPtr FisheyeSyn(IntPtr InputFishPar);
// ------------------------------------------------------------------------------------------------
/*!
*
* 包络线生成接口
*
* @param[in] PinCamNum 用户输入相机数量
* @param[in] EnvParList 用户输入包络线相机参数结构体指针
* @param[in] EnvImSet 用户输入包络线图像参数结构体
* return ImagePar 输出图像数据
*/
[DllImport("dllPort.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Envelope")]
public static extern IntPtr Envelope(int PinCamNum, IntPtr EnvParList, IntPtr EnvImSet);
// -------------------------------------------------------------------------------------------------
}
}