Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Problems using OpenCV on Windows with .dll files

Discussion in 'General Discussion' started by hyperion2020, Jun 13, 2023.

  1. hyperion2020

    hyperion2020

    Joined:
    Apr 9, 2020
    Posts:
    8
    I have had multiple issues trying to get this to work, I am basically evolving a C++ project to go from face detection using circles to also detecting a depth value only using the webcam feed and machine learning (face lbp cascade + onnx depthsense file).
    Before, I had Unity crash on me at every game launch.
    Now, I put all the old dll files aside and redid my tutorial to copy the C++ file dll and OpenCV dll's in the Asset/Plugins folder and recopied the .xml and .onnx file at the root.
    So now, every time I launch it, I get the following error:

    DllNotFoundException: UnityOpenCVSample assembly:<unknown assembly> type:<unknown type> member:(null)
    OpenCVFaceDetection.Start () (at Assets/Scripts/OpenCVFaceDetection.cs:24)

    I don't know what could be wrong since I basically just copied all the required dll files. Any ideas on what I could do?
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    3,899
    Did you check the Inspector for the DLL? Maybe it doesn't have the platform checked that you want to run it on, or maybe it's a 32-bit only DLL but you're building for x64.

    More info would help, folder structure, code, inspector settings.
     
  3. hyperion2020

    hyperion2020

    Joined:
    Apr 9, 2020
    Posts:
    8
    Is there an inspector? I think all DLL's have been compiled for x64, I am basically using the third person template and I added the xml and onnx files to the root of the Unity project and the dll's to the Asset/Plugins folder. This can't be an issue related to code since the error states there's a missing dll so I don't know what to say...
     
  4. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    3,899
    Click on the DLL file in the Asset/Plugins folder and you'll see Inspector settings for it, as well as some info which platform it supports and all that. If you don't see that, then it's not a (valid) DLL file.
     
  5. hyperion2020

    hyperion2020

    Joined:
    Apr 9, 2020
    Posts:
    8
    They are all made for Windows and recognized for both x86 and x64. Capture.JPG
     
  6. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    3,899
    Perhaps OpenCVFaceDetection has a dependency on yet another DLL file that isn't included. To me it feels like the most likely cause.
     
  7. hyperion2020

    hyperion2020

    Joined:
    Apr 9, 2020
    Posts:
    8
    This is it, but I don't know what dependency that is anymore, I copied all the .dll's I had in the OpenCV installation folder. And it works, since my OpenCV C++ project compiles normally.