1

I am trying to find the x and y coordinates of detected fiducials from Processing BoofCV.

Code: https://github.com/lessthanoptimal/BoofProcessing/tree/master/examples/Fiducials

From the above example, i did this to get the X and Y coordinates.

for( FiducialFound f : found ) {
  detector.render(this,f);
  println(f.getFiducialToCamera().getTranslation().getX() + " " + f.getFiducialToCamera().getTranslation().getY())
}

But the returned values seem odd.

Screenshot: getX() getY() values - Processing BoofCV

Can someone point me at the right direction? Thanks in advance.

Regards S

Barett
  • 5,826
  • 6
  • 51
  • 55
werty37
  • 53
  • 11
  • What exactly do you mean when you say the values seemed odd? What exactly are the values? How exactly do they seem odd? – Kevin Workman Oct 16 '16 at 11:39
  • @KevinWorkman Please check out this image. https://i.stack.imgur.com/jledE.png – werty37 Oct 16 '16 at 13:34
  • What about these values seems odd to you? What do you expect them to be? – Kevin Workman Oct 16 '16 at 14:02
  • @KevinWorkman, I was wondering if i could get the values to be mapped directly to x and y coordinate of the screen somehow. I am creating a small game project for class where a bunch of circles/ellipse follows the fiducials. – werty37 Oct 16 '16 at 14:30
  • Can't you just multiply them by `width` and `height`? – Kevin Workman Oct 16 '16 at 15:27
  • I tried, but it sill returns odd values. – werty37 Oct 16 '16 at 16:06
  • @KevinWorkman, I tried, but it sill returns odd values. 'for ( FiducialFound f : found ) { detector.render(this, f); println(f.getFiducialToCamera().getTranslation().getX()*1280 + " " + f.getFiducialToCamera().getTranslation().getY()*720); }' I get values like: 92.11305694439972 125.257707067232 -10.820376968806611 -7.725230221282809 -10.46858093060882 -7.700975824105996 I am thinking the zero is at the center of the screen. Any idea how to translate it? – werty37 Oct 16 '16 at 16:14
  • Sure, just add `width/2` and `height/2` to the values. – Kevin Workman Oct 16 '16 at 16:17
  • @KevinWorkman, Somehow it doesnt work. Also i was checking out the docs and there seems to be a helper class which gets points from physical space and maps them on x and y coordinates. The helper class is WorldToCameraToPixel(). http://boofcv.org/javadoc/boofcv/alg/geo/WorldToCameraToPixel.html But somehow i was not able to get it working since there werent enough examples. – werty37 Oct 16 '16 at 19:33
  • You're going to have to be much more specific. What exactly did you try? Can you post a [mcve]? What exactly do you mean when you say it somehow doesn't work? What exactly did you try? – Kevin Workman Oct 16 '16 at 22:08
  • I would mention that you want image coordinates in the subject of this question. – lessthanoptimal Oct 17 '16 at 18:32
  • Please link between crossposts: https://forum.processing.org/two/discussion/18563/boofcv-detecting-x-and-y-coordinates-of-fiducials – Kevin Workman Oct 20 '16 at 15:49

2 Answers2

2

The latest github snapshot of BoofCV Processing returns the image x and y pixels. Thanks to Peter Abeles.

https://groups.google.com/forum/#!topic/boofcv/K56oTHyOVw0 https://forum.processing.org/two/discussion/comment/77018#Comment_77018

Thanks all for the help.

Cheers S

werty37
  • 53
  • 11
1

You are getting the X and Y coordinate of it's position in the world frame not the image. To find it's location in the image you need to project the 3D world point back into the camera.

The easy to use processing API is too high level, but here's how you do it in Java.

WorldToCameraToPixel worldToPixel = PerspectiveOps.createWorldToPixel(intrinsic, targetToCamera);
worldToPixel.transform(c,p);

targetToCamera is the transform that the fiducial detector returns and the point 'p' will be the fiducial's center.

lessthanoptimal
  • 2,722
  • 2
  • 23
  • 25
  • I can write a helper class or something and contribute to Boofcv processing library if you show me how. Please let me know. Thanks. – werty37 Oct 18 '16 at 15:01
  • I am trying to extract this x and y coordinates so that a vector circle follows the fiducial. I will be happy to help you in making this as a library example in processing boofcv. for ( FiducialFound f : found ) { detector.render(this, f); WorldToCameraToPixel worldToPixel = PerspectiveOps.createWorldToPixel(detector.guessCrappyIntrinsic(cam.width, cam.height), f.getFiducialToCamera().getTranslation()); worldToPixel.transform(c, p); Vec2D _target = new Vec2D(p.x, p.y); c.run(); c.chasePerson(_target); } – werty37 Oct 18 '16 at 15:30