tommytracx / andar

Automatically exported from code.google.com/p/andar
0 stars 0 forks source link

Get 2D position of marker on screen #75

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
We're developing an application in which we use the pattern recognition of 
AndAR and showing a small View object (probably WebView) over the marker when 
it is detected. 

Is there any way to retrieve the x,y coordinates of the marker relative to the 
device's screen, or relative to the original camera image used to test for the 
marker? Since the marker was originally detected from a 2D image, it seems 
there would perhaps be a reference to the area of the 2D image that matched the 
marker. A corner of the marker, the center point, any (x,y) point would be 
helpful.

Note: we obviously don't need the View to be transformed onto the 3D plane of 
the marker. Just display as a normal view, positioned to cover the marker as 
best as possible.

Original issue reported on code.google.com by j...@phonogram.co.jp on 8 Aug 2011 at 8:37

GoogleCodeExporter commented 9 years ago
Hi,
even i am trying the same to find the coordinates of the screen for a 
particular marker detected.

did u find anything, any progress would help me a lot.

- shashank

Original comment by shashank...@gmail.com on 23 Aug 2011 at 6:25

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
if you don't mind delving into the C code using JNI, I found the coordinates 
inside arDetectMarker.c

look for this line of code:
__android_log_print(ANDROID_LOG_INFO,"AR","cf[%d] = %g 
id[%d]=%d",i,wmarker_info[i].cf,i,wmarker_info[i].id);

and add this one after it, recompile the code, and run the code:

__android_log_print(ANDROID_LOG_INFO,"POSITION","wmarker_info[%d].POSITION: Y = 
%f; X = %f",i,wmarker_info[i].pos[0], wmarker_info[i].pos[1]);
           __android_log_print(ANDROID_LOG_INFO,"POSITION","wmarker_info[%d].RELATIVE_POSITION: Y = %f; X = %f",i,wmarker_info[i].pos[0]/480.0, wmarker_info[i].pos[1]/320.0);

(where 480 and 320 are the screen dimensions)

To support logging, make sure you add #include <android/log.h> to the top of 
the c file.

P.S if when building the code with ndk-builder you get some errors related to a 
missing GLES/gl.h, make sure you add 'APP_PLATFORM := android-8' to 
jni/Application.mk

good luck

Original comment by tomtema...@gmail.com on 6 Apr 2012 at 9:02

GoogleCodeExporter commented 9 years ago
I'm now developing this, and I can get 2D position of marker on screen.

If you were interested, please see "arToolkit.c" and "arToolkit.java" in below 
repository:
https://github.com/nmatsui/AR_Speeker

Original comment by nobuyuki...@gmail.com on 5 Jul 2012 at 9:53