nael-lilik / droidar

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

Find the xy-coordinates of the item drawn on the screen #13

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
How can i find out the xy-coordinates of the objects currently visible on the 
screen. I am drawing my own objects using DefaultARSetup and now i want the 
coordinates of those objects on my screen at any given moment.

Original issue reported on code.google.com by funkyi...@gmail.com on 8 Sep 2011 at 6:17

GoogleCodeExporter commented 9 years ago
For further clarification the coordinates im looking for are the screen 
coordinates in 2D plane. 
Also it would be great if I can find out the current pixel size or the scale 
factor of the object compared to its original source (im drawing JPEG images on 
the screen)

Original comment by funkyi...@gmail.com on 8 Sep 2011 at 6:22

GoogleCodeExporter commented 9 years ago
can you explain what you want to do? i cant think of a usecase where this 
should be necessary.

you can take a look at GLCamera.getPickingRay() method, this is the reverse 
direction where the 2d coords are specified and the virtual pos and direction 
are calculated. i started to implement a method 
(GLCamera.getScreenCoordinatesFor()) but i dont think it will work at the 
moment.

Original comment by simon.heinen on 9 Sep 2011 at 12:25

GoogleCodeExporter commented 9 years ago
Hi,

Basically the use case is that Im trying to make a app in which i will show a 
2D image overlaying on live camera view. Now i will have a capture image button 
which when clicked will capture the image from the camera and superimpose my 2D 
image on it at the same position where it resided at the time of taking the 
picture.

How I had planned this was that I will take the current rendered coordinates of 
my 2D image on the screen and use them to map my jpeg on the captured camera 
image and then superimpose it in background.

Hope this clears the requirment.

Original comment by funkyi...@gmail.com on 9 Sep 2011 at 12:50

GoogleCodeExporter commented 9 years ago
Ok but if the canvas is places automatically after the picture ist taken, then 
you need the 2d coordinates -> 3d coords method and calculate the virtual rays 
for all for corners: (0,0) (0,max), (max,0) and (max,max) and in addition maybe 
the (middle, middle) ray to set a certain distance for the image. 

or is the canvas to place the bitmap on positioned manually? 

Original comment by simon.heinen on 9 Sep 2011 at 5:22

GoogleCodeExporter commented 9 years ago
I had planned to capture and merge the images manually. 

I already have my test.jpg image in my res folder. All I need now is the xy 
coordinates(relative to my screens xy coordinates) and the size of my rendered 
test.jpg

other then that my app is ready. Using the size and location of the rendered 
image i'll map it to the captured camera image and superimpose it manually.

FYI, im using Obj objects in my activity to create the renderable objects of my 
JPEG image.

Original comment by funkyi...@gmail.com on 9 Sep 2011 at 6:45

GoogleCodeExporter commented 9 years ago
Sorry i still dont get why you would need the virtual coords to screen coords 
mapping.
Could you provide the complete code/pseudocode you want to use in the end? 
Maybe this will help:)

Original comment by simon.heinen on 10 Sep 2011 at 8:22

GoogleCodeExporter commented 9 years ago
I dont have the code for the picture taking and merging with me (my other team 
member is working on that ) but I can try to show you how we are planning it:

ARCameraActivity{
      DefaultARSetup(){
             Obj ob = new Obj(R.drawable.ball, new Vec(5,0,1));
             }
     Button btn = new Button();
     btn.onclickListener( new OnClickListener(){
         onClick(){ captureImage()};
         }

    void  captureImage(){
     Bitmap capture = glCamera.captureImage();
     Bitmap overlay = R.drawable.ball;
     int x,y,s;

     ob.getCurrentScreenCoordinates(x,y);    [This method is what we are looking for]
     ob.getCurrentScaleFactor(s);            [This method is what we are looking for]

     mergeImage(capture.getSize(), screen.getSize(), x,y,s);

    }  

 void mergeImage(imgSize, screenSize, x,y,s)
{
   //Map the x, y, and scale of my rendered ball.jpg to the captured imgSize and screenSize
   Bitmap bmp = superimpose(capture,R.drawable.ball);;
}
}

Hope this helps. 

I also found something called gluPoject() which converts 3D coordinates to 2D, 
but didnt know how to use it.
Just so you know I have no knowlwdge of OpenGL what so ever :)
just trying to do stuff by hit and trial

Im also attaching a quick illustration of what we require.

Original comment by funkyi...@gmail.com on 10 Sep 2011 at 9:48

Attachments:

GoogleCodeExporter commented 9 years ago
Ok i will soon implement and test the requiered method but it will probably 
take till oktober before i have time for programming again. you can ask one 
stack overflow if you want, there are a lot of people with enough opengl 
knowledge. you could post the GLCamera.getPickingRay()-method there and ask for 
a reverse method. 

Original comment by simon.heinen on 11 Sep 2011 at 11:01

GoogleCodeExporter commented 9 years ago
I dont think my clients are gonna wait that long. But Thanks anyways for the 
response :)

Original comment by funkyi...@gmail.com on 12 Sep 2011 at 5:42

GoogleCodeExporter commented 9 years ago
Hello Simon,

First of all, thanks you so much for the framework, it looks very professional!

I've read this issue and found this question very interesting. I wonder whether 
you succeeded programming such a method?

Regards, Yair

Original comment by yaircle...@gmail.com on 26 Jun 2012 at 12:11

GoogleCodeExporter commented 9 years ago
Hi Simon,
       Thanks for the cool framework. Just wondering, is the method getScreenCoordinatesFor ,implemented yet. 
I would like to overlay an image (2d, or 3d) based on the user touch events and 
would be glad, if i can pass on the device x,y coordinates there, instead of 
geo locations!

Regards
Imran

Original comment by imranakt...@gmail.com on 9 Oct 2012 at 12:34