0

dlib をアセットを使わず unity で使用しようと思っています.

下記のコードで学習データを unityproject\Plugins (作成された dll ファイルと同じ場所) においているのですが,unity で実行しようとするとエラーが出て unity が固まってしまいます.

エラーの内容は Microsoft Visual C++ Runtime Library という名前のウィンドウが表示され,そこに

Runtime Error!!
Program:
This application has requested the Runtime to terminate it in unusualy way.
Please contact the application's support team for more information.

と書かれています.

一番下に書いた関数は同様の方法で実行してもエラーが出なかったことから,学習データを置いている場所が悪いと踏んでいます.初歩的なことかもしれませんが解決方法をわかる方がおりましたらご回答願います.

Dll.cpp

#include "stdafx.h"
#include "CV_Dll.h"
#include <opencv2/opencv.hpp>
#include<dlib\opencv.h>
#include<dlib\image_processing\frontal_face_detector.h>
#include<dlib\image_processing\render_face_detections.h>
#include<dlib\image_processing.h>
#include<dlib\gui_widgets.h>
#include<dlib\image_io.h>
extern"C"{
    void* GetPredicter() {
        dlib::shape_predictor* predicter_ptr=new dlib::shape_predictor;
        dlib::deserialize("shape_predictor_68_face_landmarks.dat") >> *predicter_ptr;
        return static_cast<void*>(predicter_ptr);
    }
}

Dll.h

#ifdef DLL_EXPORTS
#define DLL_API __declspec(dllexport)
#else
#define DLL_API __declspec(dllimport)
#endif

extern "C" {
    DLL_API void* GetPredicter();
}

Test.cs

using UnityEngine;
using System.Runtime.InteropServices;
using System;

public class Test : MonoBehaviour {
    [DllImport("DLL")] private static extern IntPtr GetPredicter();

    private IntPtr predicter_;

    void Start () {
                predicter_ = GetPredicter();
    }
}

////////////////////////////////////////////////////////////////////////////////

void* GetDetecter() {
        dlib::frontal_face_detector* detecter_ptr = new dlib::frontal_face_detector;
        *detecter_ptr = dlib::get_frontal_face_detector();
        return static_cast<void*>(detecter_ptr);
    }
2
  • 肝心のエラーが記載されていません。質問文を完成させてください。
    – sayuri
    2018年2月24日 22:14
  • ご指摘ありがとうございます.エラーの内容を追加しました.
    – onishichi
    2018年2月25日 8:57

0

この質問に回答するには、ログインする必要があります。

のタグが付いた他の質問を参照する。