1

The on-line document on hitTest says:

public List<HitResult> hitTest (float xPx, float yPx)
..............................
Parameters
xPx x coordinate in pixels
yPx y coordinate in pixels
.................................

However, I do not know in which coordinate system these pixel value are in regards.

Background: we obtained a 2D point using computer vision algorithm based on the arcore computervision_java sample. The image obtained is 1280x720 in resolution and is from GPU. We need to find the intersection 3D coordinate of the 2D_point with the plane from Frame. however the result of hitTest is not we expected.

I am guessing that maybe the hitTest need to use an image from Frame (640x480 in resolution). We have also tried to scale the pixel coordinate from 1280x720 down to 640x480, but the result is still not make any sense to us.

Thank you. Peter Yin

Dee_wab
  • 1,171
  • 1
  • 10
  • 23
Peter Yin
  • 51
  • 1
  • 4

1 Answers1

0

I fully agree that the documentation of

public List<HitResult> hitTest (float xPx, float yPx)

is vague. But the documentation of the overloaded method

public List<HitResult> hitTest (float[] origin3, int originOffset, float[] direction3, int directionOffset)

says

Similar to hitTest(float, float), but takes an arbitrary ray in world space coordinates instead of a screen-space point.

Hence, the parameters of the method hitTest (float xPx, float yPx) ought to be in screen space. Changing the method signature to hitTest (float screenSpaceX, float screenSpaceY) would be a lot more informative and readable.

Along with

Rect displaySize = new Rect();
((WindowManager)getContext().getSystemService(Context.WINDOW_SERVICE))
  .getDefaultDisplay().getRectSize(displaySize);

giving you the screen size, you should be able to perform correct hitTest(float, float) invocations.

ManuelTS
  • 316
  • 4
  • 14