HoloLensWithOpenCVForUnityExample icon indicating copy to clipboard operation
HoloLensWithOpenCVForUnityExample copied to clipboard

Problem with CameraIntrinsics

Open Patsufr opened this issue 3 years ago • 15 comments

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

Patsufr avatar Feb 10 '21 17:02 Patsufr

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.

EnoxSoftware avatar Feb 12 '21 07:02 EnoxSoftware

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 ?

Patsufr avatar Feb 12 '21 18:02 Patsufr

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.

EnoxSoftware avatar Feb 13 '21 10:02 EnoxSoftware

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 ...

Patsufr avatar Feb 13 '21 14:02 Patsufr

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

EnoxSoftware avatar Feb 13 '21 17:02 EnoxSoftware

My HoloLensCameraStream.dll = 27,000 bytes

i don't have cameraIntrinsics image

Patsufr avatar Feb 13 '21 18:02 Patsufr

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

EnoxSoftware avatar Feb 13 '21 19:02 EnoxSoftware

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

Patsufr avatar Feb 13 '21 20:02 Patsufr

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.

EnoxSoftware avatar Feb 14 '21 08:02 EnoxSoftware

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.

momo5ms1 avatar Jul 03 '23 19:07 momo5ms1

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

Patsufr avatar Jul 03 '23 19:07 Patsufr

@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.

momo5ms1 avatar Jul 03 '23 19:07 momo5ms1

@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 !

Patsufr avatar Jul 03 '23 19:07 Patsufr

Okay Thanks. @EnoxSoftware Could you suggest any solutions?

momo5ms1 avatar Jul 03 '23 19:07 momo5ms1

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

EnoxSoftware avatar Jul 05 '23 07:07 EnoxSoftware