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#

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);

        // -------------------------------------------------------------------------------------------------

    }
}

函數

相關文章
相關標籤/搜索