PDA

View Full Version : Convert null world location to screen space (pixel) coordinates ?



adk
02-20-2018, 03:05 PM
Heya folks,

I have a scene where I have a number of nulls in the camera viewport for which I'm trying to get the respective screen space / pixel locations.
If I get the vector between camera and null locations then all I need is the intersection between that and the camera frustrum / image plane ... theoretically that should do it.
I'm wondering if anyone has done anything like this or has any ideas of how I can achieve that ?


Cheers

Sensei
02-21-2018, 02:50 AM
Convert null world location to screen space (pixel) coordinates ?

But item can have any pixel location, depending on camera rotation and position...

Where would be used pixel x,y later?

Item Info > World Position - Camera Item Info > World Position is one vector,
Camera Item Info > World Forward is direction in which camera is looking.

02-21-2018, 07:26 AM
Look at Relativity. I want to say I remember something in there for doing this kind of thing.

adk
02-22-2018, 06:08 AM
Perhaps I didn't explain this properly.
This is essentially what I'm after.
Camera has a resolution of 16x16 pixels

140242

I want the pixel location of that blue null inside the camera frustrum.
If the camera rotates / moves like you say Sensei then the vector between camera and null changes. Then where it intersects the frustrum plane also changes.
I just need to pluck out the intersection coordinates in pixel/screen space as per the image... x=5 y=3

gar26lw
02-22-2018, 07:18 AM
simple way - stick a semi transparent image with your 16x16 grid as the foreground image in compositing section of bgd.

render and look at coordinates.

adk
02-24-2018, 10:06 PM
simple way - stick a semi transparent image with your 16x16 grid as the foreground image in compositing section of bgd.

render and look at coordinates.

Yeah you're right ... but nahh, cause that's exactly the way I m doing it now :D and I want to get away from manually reading 20 + null coordinate locations from a 4k image, for multiple images.

It's actually to streamline Worley's camera match plugin, which is the only one I know of that does it via trying to match points in screen space to points in 3d space.
Especially handy where you have existing geo-located mesh to work with and can only move the camera to the correct location.
If anyone here has experience in matching aerial views (some of which have very little y axis - height geometry to play with) then I'm all ears :)

gar26lw
02-25-2018, 01:46 AM
are you on 2018 or 2015?

adk
02-25-2018, 04:51 AM
both :D including 11.1 which is the last version that runs cam match as far as I know

MonroePoteet
02-25-2018, 02:10 PM
I'm not sure what you're really trying to do, but SynthEyes (https://www.ssontech.com) can export tracker data as 2-dimensional offsets from the center of the "screen" (i.e. image) with the dimensions of the screen being scaled to the range -1.0 to 1.0 left-to-right in the X dimension, and -1,0 to 1.0 top-to-bottom in the Y dimension. So, if a tracker is at the center of the image, it's 2D data will be (0.000,0.000), center bottom will be (0.000,1.000), upper-left corner is (-1.000,-1.000), etc.

For example, grabbing this arbitrary image from the web:


http://www.messiter.com/BMHC/Images/bigfield.jpg

bringing it into SynthEyes, I set up twelve manual trackers (Trackers tab, add, then click to place, using the close-up thumbnail to the left to fine-tune) as shown:

140314

Fine tuning Tracker 5 using the closeup thumbnail to the left:

140315

I selected all the trackers to turn them red for visibility. Then, choosing File=>Export=>Trackers 2D Path, I get a text file containing:


Tracker1 0 -0.164593 0.627867 15
Tracker2 0 -0.066397 0.392125 15
Tracker3 0 0.136768 0.415466 15
Tracker4 0 0.075819 0.672214 15
Tracker5 0 0.739492 0.219403 15
Tracker6 0 0.673463 -0.051350 15
Tracker7 0 -0.117188 -0.252080 15
Tracker8 0 -0.992492 0.982647 15
Tracker9 0 0.008097 -0.991983 15
Tracker10 0 -0.994185 0.970976 15
Tracker12 0 0.035186 -0.039679 15

The trackers I placed at the center top and lower left were just to demonstrate the normalized value range upon the image.

SynthEyes is a fantastic match-mover, which will very capably "reverse engineer" LW camera motion from a live-action shot in most cases. You might download the Demo version, load in one of your images (or a flyover) and give it a try.

mTp

adk
02-25-2018, 03:48 PM
Thanks a lot for that explanation MonroePoteet. Much appreciated.
I have used SynthEyes eons ago (pretty sure it was the trial) so might revisit it again and see if it does what I need. I was very impressed with it's tracking but didn't realise I could use it for stills.
Essentially I have a geo-located massing model along with some cadastral information.
When I drop all that into Google Earth you get a pretty spot match when you do some aerial / oblique views. Everything just falls into place.

I then take a screen grab of one of those aerials and try to do a cam match inside LW.
The method being to use that cadastral information (which is in 3D) to match up with the same cadastral info from the Google Earth screen grab.
When the two match up you know you have your camera in the correct location.... and Worley's Cam Match is the only way I know that achieves this.

I'll do a little gif explanation when I get home as it's easier explained via images rather than words. Plus I need to knock something up that isn't under NDA

MonroePoteet
02-26-2018, 09:59 AM
OK, thanks for the explanation of the end goal. SynthEyes has a number of manual methods of helping the analysis of images for camera placement. For example, you can draw an axis on the still of something you know is vertical or horizontal, or identify the corners of known real-world rectangles and it uses those "hints" to fine-tune it's calculated camera position and focal length. As you know, the focal length of the camer will also change the screen coordinates of a 3D position, so not only the camera position but focal length must match.

I'd definitely recommend giving SynthEyes a try. A truly remarkable tool, IMO. There's a website FULL of tutorials that Russ Anderson (the creator and support of SynthEyes) has done detailing lots of tricks, hints, etc.

mTp

adk
02-26-2018, 03:38 PM
... As you know, the focal length of the camer will also change the screen coordinates of a 3D position, so not only the camera position but focal length must match.

Yep fully realise that as I used to send aerial photographers up in choppers/planes to do specific angles for our projects and I always needed the full lens / camera info to get the proper location.

I had a look at some of those SynthEyes tutes and it just might do the trick, tho pretty pricey for just matching stills. If I had video work it would be a no brainer I guess. I'll see what I can cobble together and get back to you.