Exemplo n.º 1
0
    /* ------------------------- */



    // Use this for initialization
    void Start()
    {
        // 変数宣言
        int x_window = GlobalVar.CAMERA_WIDTH;
        int y_window = GlobalVar.CAMERA_HEIGHT;

        // カメラデバイス選択、設定
        cam1.setDevice(0);  // 水平
        cam2.setDevice(1);  // 垂直

        // HSV画像初期化
        CvSize WINDOW_SIZE = new CvSize(x_window, y_window);

        h_img1 = Cv.CreateImage(WINDOW_SIZE, BitDepth.U8, 3);
        h_img2 = Cv.CreateImage(WINDOW_SIZE, BitDepth.U8, 3);

        // データ格納用配列の初期化
        int x = x_window / GlobalVar.POINT_INTERVAL;
        int y = y_window / GlobalVar.POINT_INTERVAL;
        int z = y_window / GlobalVar.POINT_INTERVAL;

        hps_arr  = new int[y, x];
        vps_arr  = new int[z, x];
        ps_arr3D = new int[x, y, z];
        pl_arrXZ = new double[GlobalVar.VERTICE_NUM / 2, 2];
        pl_arrY  = new double[2];
        io_flag  = new int[x, y, z];    // 外部(遠):0 外部(近):1 内部:2

        // 3Dポリゴン指定
        refObj  = GameObject.Find("Object");
        polygon = refObj.GetComponent <CreatePolygonMesh>();
        polygon.Init();

        // 観測点データ初期化
        init3DArr(ps_arr3D);
        initMFlag(io_flag);

        // 図形と観測点の内部外部判定を行う
        polygon.getIODMonitoringPoint(io_flag);

        /*     デバッグ用(FPS)     */
        frameCount = 0;
        prevTime   = 0.0f;
        /* ------------------------- */
    }
Exemplo n.º 2
0
    /* ------------------------- */



    // Use this for initialization
    void Start()
    {
        // 変数宣言
        int x_window = GlobalVar.CAMERA_WIDTH;
        int y_window = GlobalVar.CAMERA_HEIGHT;

        // カメラデバイス選択、設定
        cam1.setDevice(0);  // 水平
        cam2.setDevice(1);  // 垂直

        // HSV画像初期化
        CvSize WINDOW_SIZE = new CvSize(x_window, y_window);
        h_img1 = Cv.CreateImage(WINDOW_SIZE, BitDepth.U8, 3);
        h_img2 = Cv.CreateImage(WINDOW_SIZE, BitDepth.U8, 3);

        // データ格納用配列の初期化
        int x = x_window / GlobalVar.POINT_INTERVAL;
        int y = y_window / GlobalVar.POINT_INTERVAL;
        int z = y_window / GlobalVar.POINT_INTERVAL;
        hps_arr  = new int[y, x];
        vps_arr  = new int[z, x];
        ps_arr3D = new int[x, y, z];
        pl_arrXZ = new double[GlobalVar.VERTICE_NUM / 2, 2];
        pl_arrY  = new double[2];
        io_flag  = new int[x, y, z];    // 外部(遠):0 外部(近):1 内部:2

        // 3Dポリゴン指定
        refObj = GameObject.Find("Object");
        polygon = refObj.GetComponent<CreatePolygonMesh>();
        polygon.Init();

        // 観測点データ初期化
        init3DArr(ps_arr3D);
        initMFlag(io_flag);

        // 図形と観測点の内部外部判定を行う
        polygon.getIODMonitoringPoint(io_flag);
        
        /*     デバッグ用(FPS)     */
        frameCount = 0;
        prevTime = 0.0f;
        /* ------------------------- */
    }
Exemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        /*     デバッグ用(FPS)     */
        frameCount++;
        float time = Time.realtimeSinceStartup - prevTime;

        /* ------------------------- */

        // カメラ画像の取得
        i_img1 = cam1.getCameraImage();
        i_img2 = cam2.getCameraImage();

        // カメラ画像をBGRからHSVへ変換
        g.convertBgrToHsv(i_img1, h_img1);
        g.convertBgrToHsv(i_img2, h_img2);

        // 平滑化
        g.convertSmooothing(h_img1);
        g.convertSmooothing(h_img2);

        // カメラ画像の任意の点からデータ取得
        g.getPointData(h_img1, hps_arr);
        g.getPointData(h_img2, vps_arr);

        // 縦横の点情報を結合して3次元配列に格納
        bondPosStaArr(vps_arr, hps_arr, ps_arr3D);

        // 情報が存在するレイヤー(Y軸方向)において、内部外部判定を行う
        for (int y = 0; y < GlobalVar.CAMERA_HEIGHT / GlobalVar.POINT_INTERVAL; y++)
        {
            // 情報が存在する場合
            if (isExsistInfo3DArrY(ps_arr3D, y))
            {
                // 同じ階層にポリゴンがある場合
                if (polygon.isExsistPolygon(y * GlobalVar.POINT_INTERVAL))
                {
                    Debug.Log("同じ階層にポリゴンあり");
                    if (isInsideOrOutside(io_flag, ps_arr3D, y))
                    {
                        Debug.Log("内部に手あり");
                        polygon.overrideXYData(io_flag, y);

                        // 観測点データを初期化
                        init3DArr(ps_arr3D);
                        initMFlag(io_flag);

                        // 図形と観測点の内部外部判定を行う
                        polygon.getIODMonitoringPoint(io_flag);

                        break;
                    }
                }
            }
        }

        displayIDot(io_flag);

        // 物体を3D表示
        display3Ddot(ps_arr3D);

        /*     デバッグ用(FPS)     */
        if (time >= 0.5f)
        {
            //Debug.LogFormat("{0}fps", frameCount/time);
            frameCount = 0;
            prevTime   = Time.realtimeSinceStartup;
        }
        /* ------------------------- */
    }