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?
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)
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?
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.