ARFoundationWithOpenCVForUnityExample icon indicating copy to clipboard operation
ARFoundationWithOpenCVForUnityExample copied to clipboard

AR Foundation with OpenCV for Unity

Open Haseeb-Ali-Khan opened this issue 3 years ago • 5 comments

Hi,

I am trying to detect colors from the environment using AR Foundation in unity. I bought OpenCV for unity yesterday and used the MultiObjectTrackingBasedOnColorExample Scene. The scene is working fine and detecting colors but it is not supporting the AR. I want to place objects in the real world and also detect colors from the real environment. I also used ARFoundationWithOpenCVForUnityExample but it is giving this error ( Assets\ARFoundationWithOpenCVForUnityExample\ARFoundationCameraArUcoExample\ARFoundationCameraArUcoExample.cs(426,23): error CS1501: No overload for method 'detectMarkers' takes 8 arguments )

I am a beginner, So would you please guide me in this regard? Thank You.

Haseeb-Ali-Khan avatar Oct 19 '22 09:10 Haseeb-Ali-Khan

The latest version of OpenCV has changed the Aruco.detectMarkers method, which seems to be causing this error. I think that the problem can be solved by modifying lines 390 to 391 of ARFoundationCameraArUcoExample.cs to the following code.

// undistort image.
Calib3d.undistort(rgbMat, rgbMat, camMatrix, distCoeffs);
// detect markers.
Aruco.detectMarkers(rgbMat, dictionary, corners, ids, detectorParams, rejectedCorners);

EnoxSoftware avatar Oct 19 '22 17:10 EnoxSoftware

Its showing the same error. Assets\ARFoundationWithOpenCVForUnityExample\ARFoundationCameraArUcoExample\ARFoundationCameraArUcoExample.cs(428,23): error CS1501: No overload for method 'detectMarkers' takes 8 arguments

and will I be able to use the color detection functions of your asset with AR features at the same time?

Haseeb-Ali-Khan avatar Oct 20 '22 15:10 Haseeb-Ali-Khan

This is the same problem, so replace lines 428 through 429 with the same modified code.

I haven't tried it, but I think it is possible to integrate AR Foundation with color detection functions, although I think it would require a bit more complex calculations to convert the detection results from on 2D space to coordinates in 3D space.

EnoxSoftware avatar Oct 21 '22 13:10 EnoxSoftware

Could you please guide me more about the integration of AR Foundation with color detection? Also, When I detect a color, the shape that appears on it is very noisy and changes every millisecond. Could you please guide me on how I will make it steady, or instead, a square appears on the detected colour and its name, for example, red?

Haseeb-Ali-Khan avatar Oct 26 '22 08:10 Haseeb-Ali-Khan

Kindly help me in using the AR foundation with color detection.

Haseeb-Ali-Khan avatar Oct 27 '22 07:10 Haseeb-Ali-Khan