EasyAR 3.01 - Camera Error onload

0 votes
asked Jul 29 by adenio (1,000 points)
edited Jul 29 by adenio
Error in Unity (Windows-editor) when load the  Sample:HelloAR_ImageTarget

[EasyAR]Error: CameraDevice.open: cameraIndex not in range[0, 0]

In 3.0 THIS error does not occur, what's happening? How do I solve it?

Thanks for your help.

obs:

[EasyAR]Error: CameraDevice.open: cameraIndex not in range[0, 0]

UnityEngine.Debug:LogError(Object)
easyar.<>c:<GlobalInitialization>b__8_0(LogLevel, String) (at Assets/EasyAR/Scripts/EasyARBehaviour.cs:66)
easyar.Detail:FunctorOfVoidFromLogLevelAndString_func(IntPtr, LogLevel, IntPtr, IntPtr&) (at Assets/EasyAR/Scripts/csapi.cs:2991)
easyar.Detail:easyar_CameraDevice_openWithType(IntPtr, CameraDeviceType)
easyar.CameraDevice:openWithType(CameraDeviceType) (at Assets/EasyAR/Scripts/csapi.cs:5491)
easyar.ARSession:Init() (at Assets/EasyAR/Scripts/ARSession.cs:105)
easyar.ARSession:<Awake>b__24_0(PermissionStatus, String) (at Assets/EasyAR/Scripts/ARSession.cs:75)
easyar.Detail:FunctorOfVoidFromPermissionStatusAndString_func(IntPtr, PermissionStatus, IntPtr, IntPtr&) (at Assets/EasyAR/Scripts/csapi.cs:2497)
easyar.Detail:easyar_DelayedCallbackScheduler_runOne(IntPtr)
easyar.DelayedCallbackScheduler:runOne() (at Assets/EasyAR/Scripts/csapi.cs:5332)
easyar.EasyARBehaviour:Update() (at Assets/EasyAR/Scripts/EasyARBehaviour.cs:111)

1 Answer

+1 vote
answered Jul 30 by zhangpengar (2,740 points)
selected Aug 2 by adenio
 
Best answer
The log means your camera is not recognized by Windows Media Foundation.

Please check if the camera is connected to your computer and Windows has recognized your camera.

You can use the built-in camera application in Windows to check if the camera is working.
commented Jul 30 by adenio (1,000 points)
Thanks for the answer, but that's not the problem. Just to be sure, I opened the project in the Unity, using EasyAr version 3.0 and no error message occurred (how I said above, in my question). I decided to try this version (3.01) because I thought the developers had solved the problem with the camera axis ... but it seems to have complicated it even more! Come on version 4, with the problems solved, I hope ...
commented Jul 30 by zhangpengar (2,740 points)
Could you try the following diagnostic program and see what happens?
https://github.com/IanusInferus/typemake/files/3389005/MFCaptureD3D_2.zip
commented Jul 30 by adenio (1,000 points)
As soon as possible I'll take the test ... thanks for now!
commented Jul 30 by adenio (1,000 points)
Hello. Glad to say: Finally it worked.
Examining the scripts, I noticed that in this release (3.01) the developers removed a line in the script "ImageTargetController". When I put it in back (line 169 - gameObject.SetActive (false);), even with the "camera bug" (mentioned above) everything worked .
Also, by changing line 139 of the "ImageTrackerBehavior" as follows:
Old code: "pose = args.ImageRotationMatrixGlobal * pose;"
New code: "pose = args.ImageRotationMatrixGlobal * pose * Matrix4x4.Rotate (Quaternion.Euler (-90, 0, 180));"
the camera axis was positioned correctly in Unity, and work well on android device.
ps: Soon I will do the test requested above (camera)
commented Jul 30 by zhangpengar (2,740 points)
What does the "everything worked" mean? Is your camera problem on Windows disappeared?

The ImageTargetController change (line 67 and line 169) is to fix a bug that objects is visible between application start and target load finishing. What problem do you experience without gameObject.SetActive (false)?

For the Quaternion.Euler(-90, 0, 180), I don't quite understand the problem. I think there are multiple problems with it.
The first one is the coordinate system that your model editor exports: what model editor do you use? Do you export obj files? Is it Y-up or Z-up? For obj file, we usually assume it use right-handed coordinate system with X-right, Y-up and Z-out screen. You can view a obj file with MeshLab and enable "Show Axis" in "Render" menu.
The second one is Unity obj importer. It inverts x values of obj files, but Unity's camera inverts z value. This means all obj files dragged into Unity need to be rotated around y-axis for 180 degrees.
The third one is the model transform against ImageTarget. If you'd like to put the marker parallel to ground and put your model on the marker, you'll need to rotate your model in the right-hand rule direction for 90 degree. But someone may decide to use a model that is merely a planar image attached to a quad, which requires no rotation.
All these problems are from different sources and shall be handled one by one. Different editors or export options, different importers and different model transform against markers will result a different transform. I'd like to know your specific configuration to better understand the problem.
commented Jul 30 by adenio (1,000 points)
edited Jul 30 by adenio
Thanks for your replay, I will try to explain:
First of all, I think EasyAR is the best unity plugin for RA so far.

Regarding the camera error message, I still can't do the test you requested, but even appearing on the Unity console, it doesn't prevent Unity from compiling the final file - which worked correctly on the Android device.

About "gameObject.SetActive (false)" - We use this feature to evaluate which object will be displayed - or which target is identified - and then enable or disable other features of the final application.

Concerning the camera axis, note that regardless of the 3D program we use (Blender), the resulting application worked perfectly with EasyAR for Unity version 2 - After that the axes have not changed in this project, which is just an x64 update (because Google requests - with IL2CPP and ARM64).

The problems with the camera axis ocur in version 3.0, which when compiling presents the models on the wrong axis, so the option to multiply by "Quaternion.Euler (-90, 0, 180)" - I repeat: This same problem occurred in EasyAR version 1, but not in version 2.

Softwares: Windows 7 / Unity 2018.4.4f1 / Blender 2.79 / EasyAR 3.01
commented Jul 30 by adenio (1,000 points)
ps: When I put a 3dObject in Unity, I create a new empty GameObject and put my 3d inside it. For this reason, the upper axis used in Blender does not interfere with the axis used in Unity. All scripts use Gamobject's up-axis created by Unity.
commented Aug 2 by adenio (1,000 points)
Hello zhangpengar, I did the test you suggested using the app you submitted, and really the camera was not found on the windows system. So I installed the camera using the original software (not the Windows drive) and the problem described at the beginning (
[EasyAR]Error: CameraDevice.open: cameraIndex not in range[0, 0]) was fixed. Grateful for your help.
Welcome to EasyAR SDK Q&A, where you can ask questions and receive answers from other members of the community.
...