EnoxSoftware / HoloLensWithOpenCVForUnityExample

HoloLens With OpenCVforUnity Example (Support for Hololens1 and Hololens2)
MIT License
262 stars 50 forks source link

Problem with CameraIntrinsics #30

Open Patsufr opened 3 years ago

Patsufr commented 3 years ago

Hi, I am starting on unity and openCV. When I import your project and import the other unitypackage needed I get this error. Do you have an idea how to solve it? image image Paul

EnoxSoftware commented 3 years ago

Based on the error message you sent me about CameraIntrinsics not be found, I'm guessing that the error is due to HoloLensCameraStream (https://github.com/camnewnham/HoloLensCameraStream) not importing it.

Patsufr commented 3 years ago

Thanks for your answer! I tried to import HoloLensCameraStream by following the tutotrial on the github of camnewnham. I did it but i still have the same error :/ Do you have an another idea ?

EnoxSoftware commented 3 years ago

I tested it again in my environment and the project setup was successful.

My environment : Windows 10 Unity 2018.4.28f1

I found that the order in which the assets are imported is important during the project setup process. I also found out that enabling the "Enable MSBuild for Unity" option in the "MRTK Project Configurator" window in step 5 will break the project. MRTKProjectConfigurator window Please be aware that this condition cannot be fixed later. When redoing the setup process, start with a clean slate.

Detailed Instructions:

  1. Download the latest release unitypackage. HoloLensWithOpenCVForUnityExample.unitypackage
  2. Create a new project. (HoloLensWithOpenCVForUnityExample) Change the platform to UWP in the "Build Settings" window.
  3. Import the OpenCVForUnity. Setup the OpenCVForUnity. (Tools > OpenCV for Unity > Set Plugin Import Settings) Move the "OpenCVForUnity/StreamingAssets/haarcascade_frontalface_alt.xml" and "OpenCVForUnity/StreamingAssets/lbpcascade_frontalface.xml" to the "Assets/StreamingAssets/" folder.
  4. Clone HoloLensCameraStream repository. Copy the "HoloLensCameraStream/HoloLensVideoCaptureExample/Assets/CamStream/" folder to the "Assets/" folder. Set the scripting backend of the plugin inspector to "Any Script Backend". (IL2CPP support)
  5. Import the Microsoft.MixedReality.Toolkit.Unity.Foundation.2.2.0.unitypackage. Setup the MRTKv2. (Mixed Reality ToolKit > Utilities > Configure Unity Project) Do not enable the "Enable MSBuild for Unity" option in the "MRTK Project Configurator > Modify Configurations" tab.
  6. Import the HoloLensWithOpenCVForUnityExample.unitypackage.
  7. Add the "Assets/HoloLensWithOpenCVForUnityExample/*.unity" files to the "Scenes In Build" list in the "Build Settings" window.
Patsufr commented 3 years ago

It didn't work i don't know why :( My environment: Windows 10 Unity 2018.4.31 MRTK 2.2.0 The last version of OpenCV for Unity

I followed your instruction even MSbuild. I tried 5 times. I have more errors :( image Maybe i don't use the good unitypackage or files are missing for hololens ...

EnoxSoftware commented 3 years ago

project file structure:

HoloLensWithOpenCVForUnityExample_issue30

The errors up to the fourth one are caused by the fact that the CametaStream example code contains an old Unity API, so you can either let UnityEditor fix it automatically or delete the "CamStream/Examples" folder.

The CameraIntrinsics definition is contained in "CamStream/Plugins/WSA/HoloLensCameraStream.dll". Could you make sure that the file size of "HoloLensCameraStream.dll" is correct? HoloLensCameraStream.dll = 30,720 bytes

In addition, Could you use VisualStudio's Object Browser to make sure that the namespace of HoloLensCameraStream contains CameraIntrinsics?

HoloLensWithOpenCVForUnityExample_issue30_2
Patsufr commented 3 years ago

My HoloLensCameraStream.dll = 27,000 bytes

i don't have cameraIntrinsics image

EnoxSoftware commented 3 years ago

I think you apparently downloaded the "CameraStream" asset file from a different repository than my development environment. The "HoloLensCameraStream.dll" file looks obviously wrong. It appears to be from the VulcanTechnologies repository, as there is no CameraIntrinsics definition.

Could you try to get it from camnewnham's fork repository again? https://github.com/camnewnham/HoloLensCameraStream/archive/master.zip

Patsufr commented 3 years ago

It's a stupid mistake :( It's working now. Thank you for your help ! :)

I have another question if i want to detect two differents markers at the same time i juste have to duplicate this part ? image

EnoxSoftware commented 3 years ago

Multiple markers can be detected at the same time if they belong to the same dictionary ID. However, the HoloLensArUcoExample limits the number of AR objects that can be displayed to one. In order to display AR objects corresponding to multiple detected markers, you will need to modify the code.

momo5ms1 commented 1 year ago

Hello @Patsufr, I know this is an old thread but i'm encoutering the same issue. You mentioned that it was a stupid mistake. What was wrong ? and how did you solve it.

Best Regards.

Patsufr commented 1 year ago

If m’y memoris are good you need to download the right CameraStream from here https://github.com/camnewnham/HoloLensCameraStream/archive/master.zip

momo5ms1 commented 1 year ago

@Patsufr I need the dll to run this Project : https://github.com/EnoxSoftware/HoloLensWithOpenCVForUnityExample due to several problems in importing the project, I used the dll from HoloLensVideoCaptureExample, and I put it under Assets/OpenCVForUnity/Plugins/WSA in the project in the link above. PS: I'm using OpenCVForUnity v 2.4.7.

Patsufr commented 1 year ago

@Patsufr I need the dll to run this Project : https://github.com/EnoxSoftware/HoloLensWithOpenCVForUnityExample due to several problems in importing the project, I used the dll from HoloLensVideoCaptureExample, and I put it under Assets/OpenCVForUnity/Plugins/WSA in the project in the link above. PS: I'm using OpenCVForUnity v 2.4.7.

Sorry i didn’t touch This library since a moment! I Know i it was difficult to import correctly all package ! Try again to import the correct package lt’s the only issue i think !

momo5ms1 commented 1 year ago

Okay Thanks. @EnoxSoftware Could you suggest any solutions?

EnoxSoftware commented 1 year ago

I recently set up this example from scratch for another matter and it worked fine. I think Patsufr's advice is valid.