Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/326.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/135.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在Unity/Hololens中整合黑暗尤罗?_C#_C++_Unity3d_Hololens_Yolo - Fatal编程技术网

C# 如何在Unity/Hololens中整合黑暗尤罗?

C# 如何在Unity/Hololens中整合黑暗尤罗?,c#,c++,unity3d,hololens,yolo,C#,C++,Unity3d,Hololens,Yolo,我目前正试图将Darknet YOLO()计算机视觉软件包集成到Unity中,以便为一个研究项目调查全息透镜设备中实时物体检测的速度。到目前为止,我已经能够将YOLO包导出为DLL文件,并让Unity通过函数调用与之通信。以下是我在yolo_dll.cpp文件中创建的封送函数,该文件是yolo包的一部分。以下是我从Unity端调用的函数: extern "C" _declspec(dllexport) Detector* _stdcall Init() { return new Dete

我目前正试图将Darknet YOLO()计算机视觉软件包集成到Unity中,以便为一个研究项目调查全息透镜设备中实时物体检测的速度。到目前为止,我已经能够将YOLO包导出为DLL文件,并让Unity通过函数调用与之通信。以下是我在yolo_dll.cpp文件中创建的封送函数,该文件是yolo包的一部分。以下是我从Unity端调用的函数:

extern "C" _declspec(dllexport) Detector* _stdcall Init() {
    return new Detector("yolo_write_into.txt", "yolo.weights");
}

extern "C" _declspec(dllexport) void _stdcall DeleteDetector(Detector* detector) {
    delete detector;
}

extern "C" _declspec(dllexport) int _stdcall Test(int s) {
    return s;
}

extern "C" _declspec(dllexport) int _stdcall OutsideDetect(Detector* 
mDetect, bbox_t** results, int* resultSize, int h, int w, float threshold = 
0.2f, bool use_mean = false) {
    /*image_t newImg;
    newImg.data = data;
    newImg.h = h;
    newImg.w = w;
    newImg.c = 3;*/

    std::vector<bbox_t> vec = mDetect->detect("Assets/yolo_write_image.jpg", 
    threshold, use_mean);
    //TODO: clean up boxArray
    bbox_t* boxArray = new bbox_t[vec.size()];
    for (int i = 0; i < vec.size(); i++) {
        boxArray[i] = vec[i];
    }
    *resultSize = vec.size();
    *results = boxArray;
    return 1;
}

extern "C" _declspec(dllexport) void _stdcall DeleteBArray(bbox_t** results) 
{
    delete[] results;
}
我有一个使用我的计算机网络摄像头的照片包的统一脚本,一旦它保存了内存中的PIC,它调用外部C++侦探()函数从内存中检索最近拍摄的图片,检测其中的对象,并返回一个包围框的数组,这些框可以定位对象在图片中的位置。一旦返回了边界框数组,我现在只需在Unity控制台上调试并记录所有边界框,并在信息输出到控制台后,重复拍照并在其上使用YOLO detect()的过程。我已经能够与Unity和YOLO成功沟通。但是,从一个图像的边界框显示到下一个图像的边界框显示在Unity调试控制台上,平均需要10秒。我需要YOLO软件包能够实时处理图像和输出反馈(30-60fps),它需要在全息镜头上工作,而不仅仅是在Unity上。我尝试将其导出为Hololens的一个构建,当我试图打开Hololens内部的应用程序时,它根本无法打开。因此,我有一些问题:

  • 我是否能够以某种方式将Unity的视频捕获功能集成到YOLO中,而不是不断地拍照和单独处理它们?这对全息透镜有用吗
  • 在YOLO软件包中,我必须注释掉所有带有#ifdef GPU的部分,因为如果其中任何部分处于活动状态,当我按下“播放”键时,它们只会使Unity崩溃。我是否能够使这些部分以某种方式与Unity一起工作,它们是否会加快处理时间
  • 通过DLL调用来自YOLO的封送函数是否在图像分析周期之间的巨大延迟中起作用?有没有办法弥补这一点
  • 我使用外部DLL这一事实是否是应用程序无法在全息透镜内部打开的原因
我将非常感谢在正确方向上的任何步骤,以便能够将此软件包集成到Hololens中,以便我能够实现YOLO的实时对象检测功能

您可以尝试一个带有yolo逻辑和gpu支持的nuget包,查看项目的自述文件。使用以下命令安装软件包
PM>Install package Alturos.Yolo
internal static class YoloDLL
{
    [DllImport("yolo_cpp_dll", EntryPoint = "Test")]
    public static extern int DLLTest(int s);

    [DllImport("yolo_cpp_dll", EntryPoint = "OutsideDetect")]
    public static extern int OutsideDetect(IntPtr mDetect, out IntPtr results, out int resultSize, int h, int w, float threshold, bool use_mean);

    [DllImport("yolo_cpp_dll", EntryPoint = "Init", CharSet = CharSet.Unicode)]
    public static extern IntPtr Init();

    [DllImport("yolo_cpp_dll", EntryPoint = "DeleteDetector", CharSet = CharSet.Unicode)]
    public static extern void DestroyDetector(IntPtr detector);

    [DllImport("yolo_cpp_dll", EntryPoint = "SetDebugFunction", CharSet = CharSet.Unicode)]
    public static extern void SetDebugFunction(IntPtr fp);

    [DllImport("yolo_cpp_dll", EntryPoint = "DebugLogDLL", CharSet = CharSet.Unicode)]
    public static extern void DebugLogDLL(string s);


    [DllImport("yolo_cpp_dll", EntryPoint = "DeleteBArray", CharSet = CharSet.Unicode)]
    public static extern void DeleteBArray(IntPtr results);
}