NormandErwan / ArucoUnity

Bring augmented reality to Unity by tracking Aruco markers in real time.
https://normanderwan.github.io/ArucoUnity/
BSD 3-Clause "New" or "Revised" License
205 stars 38 forks source link

Where to find ArucoUnity/Calibrations/USB Camera - 2017-10-27_19-20-12.xml #3

Closed snowymo closed 6 years ago

snowymo commented 6 years ago

In calibration scene, unity project cannot find the xml file to open camera. And it is not optional. I checked all the commits in 2017-10-27 and failed to find the xml file. Can you commit it again or give an example? Thanks

snowymo commented 6 years ago

Here is the detail about the error:

FileNotFoundException: Could not find file "D:\Projects\aruco-unity\src\aruco_unity_package\Assets\ArucoUnity\Calibrations\USB Camera - 2017-10-27_19-20-12.xml". ArucoUnity.Cameras.ArucoCameraWebcam.Configure () (at Assets/ArucoUnity/Scripts/Cameras/ArucoCameraWebcam.cs:147) ArucoUnity.Cameras.ArucoCamera.Start () (at Assets/ArucoUnity/Scripts/Cameras/ArucoCamera.cs:203)

Although you mentioned the file is optional and will be filled automatically, the project does need that file to config the camera.

NormandErwan commented 6 years ago

Hi,

I didn't commit this calibration file, it is particular to the webcam I use to work on this project. Each camera needs to be calibrated before used for marker tracking. I can't provide a calibration file for you camera. But I forgot to remove the file reference in the Calibration and Tracking scenes.

So, you first need to calibrate your camera with the Calibration scene: it will generate a calibration file (by default on the ArucoUnity/Calibrations/ folder if ArucoCameraWebcam.CameraParameterFilePath property is empty). Then use this file in the Tracking scene in the ArucoCameraWebcam.CameraParameterFilePath property.

I've updated the README.md file to make the marker creation, camera calibration and marker tracking easier to understand.

Can you tell me if you succeed to calibrate your camera?

Thanks

snowymo commented 6 years ago

Thanks for the reply. Actually I already have some configuration file generated by opencv. However, they are all in opencv-matrix format rather than normal xml. I don't know how to adapt them. That is why I want an example so that I can manually type my camera parameter to use your tracking scene.

My question is, what do you use for calibration, normally I used chessboard. But I guess you are using some marker to do the calibration here? Correct me if I am wrong.

(1) Then I tried your creation scene. when I checked GridBoard_Dict4x4_50_X_7_Y_5_MarkerSize_160 and ChArUcoBoard_Dict4x4_50_X_7_Y_5_SquareSize_200_MarkerSize_120 for creation scene. There will be errors too. I strongly suggest you try that again.

(2) And then I use your calibration scene and leave the parameterFilePath empty. Turns out I still met errors like:

NullReferenceException: Object reference not set to an instance of an object
ArucoUnity.Plugin.Aruco.RefineDetectedMarkers (ArucoUnity.Plugin.Mat image, ArucoUnity.Plugin.Board board, ArucoUnity.Plugin.VectorVectorPoint2f detectedCorners, ArucoUnity.Plugin.VectorInt detectedIds, ArucoUnity.Plugin.VectorVectorPoint2f rejectedCorners, ArucoUnity.Plugin.Mat cameraMatrix, ArucoUnity.Plugin.Mat distCoeffs, Single minRepDistance, Single errorCorrectionRate, Boolean checkAllOrders, ArucoUnity.Plugin.VectorInt recoveredIdxs, ArucoUnity.Plugin.DetectorParameters parameters) (at Assets/ArucoUnity/Scripts/Plugin/Aruco/ArucoUnity.cs:436)
ArucoUnity.Plugin.Aruco.RefineDetectedMarkers (ArucoUnity.Plugin.Mat image, ArucoUnity.Plugin.Board board, ArucoUnity.Plugin.VectorVectorPoint2f detectedCorners, ArucoUnity.Plugin.VectorInt detectedIds, ArucoUnity.Plugin.VectorVectorPoint2f rejectedCorners, ArucoUnity.Plugin.Mat cameraMatrix, ArucoUnity.Plugin.Mat distCoeffs, Single minRepDistance, Single errorCorrectionRate, Boolean checkAllOrders, ArucoUnity.Plugin.VectorInt recoveredIdxs) (at Assets/ArucoUnity/Scripts/Plugin/Aruco/ArucoUnity.cs:446)
ArucoUnity.Plugin.Aruco.RefineDetectedMarkers (ArucoUnity.Plugin.Mat image, ArucoUnity.Plugin.Board board, ArucoUnity.Plugin.VectorVectorPoint2f detectedCorners, ArucoUnity.Plugin.VectorInt detectedIds, ArucoUnity.Plugin.VectorVectorPoint2f rejectedCorners, ArucoUnity.Plugin.Mat cameraMatrix, ArucoUnity.Plugin.Mat distCoeffs, Single minRepDistance, Single errorCorrectionRate, Boolean checkAllOrders) (at Assets/ArucoUnity/Scripts/Plugin/Aruco/ArucoUnity.cs:455)
ArucoUnity.Plugin.Aruco.RefineDetectedMarkers (ArucoUnity.Plugin.Mat image, ArucoUnity.Plugin.Board board, ArucoUnity.Plugin.VectorVectorPoint2f detectedCorners, ArucoUnity.Plugin.VectorInt detectedIds, ArucoUnity.Plugin.VectorVectorPoint2f rejectedCorners, ArucoUnity.Plugin.Mat cameraMatrix) (at Assets/ArucoUnity/Scripts/Plugin/Aruco/ArucoUnity.cs:463)
ArucoUnity.Plugin.Aruco.RefineDetectedMarkers (ArucoUnity.Plugin.Mat image, ArucoUnity.Plugin.Board board, ArucoUnity.Plugin.VectorVectorPoint2f detectedCorners, ArucoUnity.Plugin.VectorInt detectedIds, ArucoUnity.Plugin.VectorVectorPoint2f rejectedCorners) (at Assets/ArucoUnity/Scripts/Plugin/Aruco/ArucoUnity.cs:470)
ArucoUnity.Controllers.ArucoCalibrator.Detect () (at Assets/ArucoUnity/Scripts/Controllers/ArucoCalibrator.cs:246)
ArucoUnity.Controllers.ArucoCalibrator.ArucoCamera_ImagesUpdated () (at Assets/ArucoUnity/Scripts/Controllers/ArucoCalibrator.cs:191)
ArucoUnity.Cameras.ArucoCamera.OnImagesUpdated () (at Assets/ArucoUnity/Scripts/Cameras/ArucoCamera.cs:409)
ArucoUnity.Cameras.ArucoCameraWebcam.UpdateCameraImages () (at Assets/ArucoUnity/Scripts/Cameras/ArucoCameraWebcam.cs:188)
ArucoUnity.Cameras.ArucoCamera.Update () (at Assets/ArucoUnity/Scripts/Cameras/ArucoCamera.cs:215)
ArucoUnity.Cameras.ArucoCameraWebcam.Update () (at Assets/ArucoUnity/Scripts/Cameras/ArucoCameraWebcam.cs:114)

Hope you can help me. Thanks.

NormandErwan commented 6 years ago

Sorry for the late reply, I'm currently working on a v2 of the project. It will be released this week.

Since the API are going to change, you could retry with this new version. I've created better prefabs and made the scenes simpler to use. The xml configure file are going to change too. I'll ship an example on the release.

What are the detail of the errors of (1) ?

Concerning (2) that should not be normal, the calibration script should generate automatically a parameters filename. Could you retry when the v2 will be released? For the calibration, you need to use an Aruco chessboard, like in this tutorial : https://docs.opencv.org/3.3.0/da/d13/tutorial_aruco_calibration.html The Calibration should contains everything ready you need to calibrate your usb camera.

nickos64252 commented 6 years ago

Hello,

I have the same problem.

You say the program should generate the xml file, but if I don't give it one, errors occus.

What should I put in the "Camera Parameters File Path" field if I don't have yet one?

Thank you

FreakTheMighty commented 6 years ago

@NormandErwan I think the confusion comes from a circular requirement. The docs indicate that you need to use the calibration sceneto generate the calibration file, however the calibration scene requires a calibration file.

When I set the camera calibration file path to an empty string I get this error when I hit play

I'm using release 1.2, which I just noticed looks pretty different from master.

NullReferenceException: Object reference not set to an instance of an object
ArucoUnity.Cameras.ArucoCameraWebcam.ConfigureCameraAndBackground () (at Assets/ArucoUnity/Scripts/Cameras/ArucoCameraWebcam.cs:194)
ArucoUnity.Cameras.ArucoCameraWebcam.Update () (at Assets/ArucoUnity/Scripts/Cameras/ArucoCameraWebcam.cs:96)

image

artcitizen commented 6 years ago

Hi!

I have same problem. When I start I not have calibration xml, and if I clear "CameraParametersFilePath" field in inspector then i get NullReferenceException.

will-molloy commented 6 years ago

Same issue as @FreakTheMighty. Please reply and fix it.

will-molloy commented 6 years ago

I got it to work by cloning the master (he fixed the problem there).

~However you need to fix compile errors by copying plugins/x64 folder and renamed ArucoUnity dll to ArucoUnityPlugin and in Plugin/Cv/Size.cs rename au_cv_Size_new1 to au_cv_Size_new.~

Ok gives other errors (when tracking markers) I guess you need to rebuild whole thing following https://normanderwan.github.io/ArucoUnity/manual/build-from-sources.html).

NormandErwan commented 6 years ago

Hi everyone,

Very sorry for the late reply.

Before doing any tracking, you need to calibrate your camera. It's required by the aruco module of OpenCV. This process measures some parameters of the camera (essentially the focal length, the optical center point and the image distortions). It allows aruco to determines precisely the position and rotation of the markers. You can read the doc for more details: https://normanderwan.github.io/ArucoUnity/manual/build-from-sources.html.

However, I think it could be possible to add a dummy calibration just to test the tracking but with less accurate detected positions...

You all right, it's better to use the master branch actually. You can get the updated ArucoUnityPlugin here. I moved the plugin to a dedicated repository and added continuous integration build. So the plugin in the release is up to date!

@FreakTheMighty the calibration file is optional during the calibration process. The field is visible because OpenCV allows to refine a calibration. I'll update the documentation to make this point clearer. Thank you for your comment!

I close the issue. I think the documentation is explicit. But feel free to open any issue if some points on the docs can be improved! Finally, I need to release the v2 as soon as possible...

NormandErwan commented 6 years ago

I've added a pre-release version of the package, with up to date plugin: https://github.com/NormandErwan/ArucoUnity/releases/tag/v2.0-alpha