Why "Pages.add_matchphoto_page" ignores camera properties?


#1

I’m modifying an existing script that imports 3D camera tracking data and applies the eye, target, up values to a new camera. This works well when creating a new page object, however what I’d ideally like to use is the “Pages.add_matchphoto_page” which would not only give me a matched and locked camera, but also a corresponding background image.

The arguments allow you to specify both a camera object and image, however all camera data seems to be ignored, defaulting to a 90 degree view instead?

http://www.sketchup.com/intl/en/developer/docs/ourdoc/pages#add_matchphoto_page

Arguments:

image_name
String image name.
camera
(optional) Camera object.
page_name
(optional) String page name.
Returns:

page
the new photomatch page.


#2

Got a snippet of code we can look at?


#3

The developer of the script, TIG, has kindly allowed me to post part of his TIGimportcamera.rb script. If you’d like to view the full script, you can find it on the Sketchucation.com forums.

However, here’s the part of the code that causes issues…

cam=Sketchup::Camera.new(eye, target, up, true, fov)
view.camera=cam
if image && img=File.exist?(image)
img=image
elsif image && File.exist?(File.join(File.dirname(fname), image))
img=(File.join(File.dirname(fname), image))
else
img=nil
end
if img
new_page = pages.add_matchphoto_page(img, cam, page_name+' [PhotoMatch]')
else
new_page = pages.add(page_name)
end

The script reads the data in from a txt file, (exported from Syntheyes)

Cam2 -8,7863 -5,9812 2,1160 -8,3908 -5,6754 2,1220 0,0135 82,0251

#4

You can see from the screenshot that when using a standard Scene page, the XYZ origin lines up perfectly with the BG watermark image. However the Photomatch page just creates a default view?


#5

Here’s the result when using “add_matchphoto_page”. As you can see, the camera data is ignored.


#6

Can you provide a self-contained complete example?


#7

Sure, please find attached SU example.example1.skp (479.2 KB)


#8

Was the example file of any help? I’d really like to find a solution to this problem.


#9

Sorry, I have been away on travels. Catching up on things.
Do you have a self contained snipped that I can run on that model?


#10

Sure. Can I e-mail you the script?


#11

The camera appear to be set. I stepped through the code with the debugger and whatever camera you provide in the arguments is the camera being set.
You can even check this for yourself - inspect the values of the camera you provide and after the page is created inspect the page’s camera - you should see that the values match. Let me know if you see differently.